General Description
192
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Ping
12.1 General Description
Ping is a network utility, part of the device internal network utilities, which verifies if a particular IP address
exists. This utility is based on the ICMP (control message protocol), and sends an echo request to a
specified entity in the network and waits for a reply. Ping supports IPv4 and IPv6 standards. This utility
can be used to test connectivity and determine the round trip time.
12.2 Start and Stop Ping
The same API starts and stops the ping process. To stop the ping process, apply value 0 in the IP field.
The following parameters can be configured in the ping start command:
•
Ping parameters – holds configuration regarding the ping command:
–
Ping interval time: interval between ping packets, in ms
–
Ping size: ping packet size
–
Ping request time-out: time-out time for every ping, in ms
–
Total number of attempts: number of ping requests. 0 indicates infinite.
–
Flags: flag options are as follows:
•
0 – send ping report only when finishing transmitting all the requests
•
1 – send ping report for every ping request
•
2 – stop ping after one successful ping request (received reply)
•
4 – Do not fragment the ping packet. This flag can be set with other flags.
–
IP: destination IPv4\IPv6 address. In case of IPv4, use this field only.
–
Ip1OrPadding: destination IPv6 address
–
Ip2OrPadding: destination IPv6 address
–
Ip3OrPadding: destination IPv6 address
•
Family – specifies the protocol family IPv4 or IPv6
•
Report – Return value. If callback is not set, the API is blocked until the ping report is received. Hold
information regarding the results of the ping request and include the following parameters:
–
Packets sent – number of sent ping requests
–
Packets received – number of received ping replied
–
Min round time – shortest round time, in ms
–
Max round time – longest round time, in ms
–
Average round time – average round time, in ms
–
Test time – total time the test took, in ms
•
Ping callback – optional parameter. If the callback is provided, the API does not block, and immediately
returns. When results are available, the callback is called. If it is not implemented, NULL should be
placed and API blocks, until the results are ready.
Example of sending an IPV4 ping request with a report for every successful ping:
_i16 Status;
SlNetAppPingReport_t report;
SlNetAppPingCommand_t pingCommand;
pingCommand.Ip = SL_IPV4_VAL(10,1,1,200);
/* destination IP address is 10.1.1.200 */
pingCommand.PingSize = 150;
/* size of ping, in bytes */
pingCommand.PingIntervalTime = 100;
/* delay between pings, in milliseconds */
pingCommand.PingRequestTimeout = 1000;
/* timeout for every ping in milliseconds */
pingCommand.TotalNumberOfAttempts = 20;
/* number of ping requests */
pingCommand.Flags = 0;
/* report only when finished */
Status = sl_NetAppPing( &pingCommand, SL_AF_INET, &report, NULL );
if
(Status)
{
/* error */
}