This is the ICMP echo (ping) request implementation.
This implementation is designed to be similar to Unix ping, but differs from it in some respects.
The behavior of this ping implementation is as follows:
- A ping request will be sent. The time for the next ping request is calculated as the current time plus the given ping interval.
- If the ping response is not received within the ping retry timeout (see below for details) then it the ping request will be retransmitted. This will be repeated up to
MMPING_MAX_RETRIES times.
- If
MMPING_MAX_RETRIES is exceeded or a valid ping reply is received then ping will wait until the next ping request time calculated above before proceeding to send the next ping request. If this time has already elapsed then the next ping request will be sent immediately.
The ping retry timeout is calculated as the 2 times average RTT if one or more ping responses have been received, otherwise it will be MMPING_INITIAL_RETRY_INTERVAL_MS.
◆ MMPING_ARGS_DEFAULT
| #define MMPING_ARGS_DEFAULT |
Value: { \
}
#define MMPING_DEFAULT_DATA_SIZE
Default ping data packet size in bytes, excluding ICMP header.
#define MMPING_DEFAULT_PING_INTERVAL_MS
Default time interval in milliseconds between ping requests.
Initializer for mmping_args.
Definition at line 95 of file mmping.h.
◆ MMPING_DEFAULT_DATA_SIZE
| #define MMPING_DEFAULT_DATA_SIZE (56) |
Default ping data packet size in bytes, excluding ICMP header.
Definition at line 48 of file mmping.h.
◆ MMPING_DEFAULT_PING_COUNT
| #define MMPING_DEFAULT_PING_COUNT (0) |
Default max count for ping request to run forever.
Definition at line 46 of file mmping.h.
◆ MMPING_DEFAULT_PING_INTERVAL_MS
| #define MMPING_DEFAULT_PING_INTERVAL_MS (1000) |
Default time interval in milliseconds between ping requests.
Definition at line 44 of file mmping.h.
◆ MMPING_ICMP_ECHO_HDR_LEN
| #define MMPING_ICMP_ECHO_HDR_LEN (8) |
Length of the ICMP echo header in octets.
Definition at line 64 of file mmping.h.
◆ MMPING_INITIAL_RETRY_INTERVAL_MS
| #define MMPING_INITIAL_RETRY_INTERVAL_MS (1000) |
Rate at which to retry unacknowledged ping requests when the RTT is not known.
``
Definition at line 58 of file mmping.h.
◆ MMPING_IPADDR_MAXLEN
| #define MMPING_IPADDR_MAXLEN (48) |
Maximum length of an IP address string including null-terminator.
Definition at line 61 of file mmping.h.
◆ MMPING_MAX_COUNT
| #define MMPING_MAX_COUNT (0xffff) |
Maximum number of pings before terminating.
Definition at line 54 of file mmping.h.
◆ MMPING_MAX_DATA_SIZE
| #define MMPING_MAX_DATA_SIZE (1500) |
Maximum data size of ping request packet excluding ICMP header.
Definition at line 52 of file mmping.h.
◆ MMPING_MAX_RETRIES
| #define MMPING_MAX_RETRIES (2) |
Maximum number of times to retransmit a ping request before giving up and moving on.
Definition at line 56 of file mmping.h.
◆ MMPING_MIN_DATA_SIZE
| #define MMPING_MIN_DATA_SIZE (8) |
Minimum data size of ping request packet excluding ICMP header.
Definition at line 50 of file mmping.h.
◆ mmping_start()
| uint16_t mmping_start |
( |
const struct mmping_args * |
args | ) |
|
Initialize ping parameters and start ping.
- Parameters
-
| args | Ping request arguments |
- Returns
- the ID for this ping on success, on failure returns 0.
◆ mmping_stats()
Get Ping Statistics.
- Parameters
-
| stats | Instance to receive ping statistics |
- Note
- Calling
mmping_start() will reset the ping statistics