@@ -33,15 +33,13 @@ int print_usage() {
3333 fprintf (stderr , " Connect to echo server at CID:port. Pipe STDIN to server,\n" );
3434 fprintf (stderr , " server response to STDOUT.\n" );
3535 fprintf (stderr , "\n" );
36- fprintf (stderr , " ping <cid> <port> <count> <delay> \n" );
36+ fprintf (stderr , " ping <cid> <port> <count>\n" );
3737 fprintf (stderr , " Send <count> ping messages to echo server at CID:port.\n" );
38- fprintf (stderr , " <delay> is the delay in seconds between pings (float).\n" );
3938 fprintf (stderr , " Prints RTT for each ping in microseconds.\n" );
4039 fprintf (stderr , "\n" );
41- fprintf (stderr , " ping-uds <uds_path> <port> <count> <delay> \n" );
40+ fprintf (stderr , " ping-uds <uds_path> <port> <count>\n" );
4241 fprintf (stderr , " Send <count> ping messages to echo server at <uds_path>:port.\n" );
4342 fprintf (stderr , " Uses Unix Domain Socket with Firecracker CONNECT protocol.\n" );
44- fprintf (stderr , " <delay> is the delay in seconds between pings (float).\n" );
4543 fprintf (stderr , " Prints RTT for each ping in microseconds.\n" );
4644 fprintf (stderr , "\n" );
4745 return -1 ;
@@ -101,7 +99,7 @@ int run_echo(uint32_t cid, uint32_t port) {
10199}
102100
103101
104- int run_ping (uint32_t cid , uint32_t port , int count , double delay_sec ) {
102+ int run_ping (uint32_t cid , uint32_t port , int count ) {
105103
106104 int sock = socket (AF_VSOCK , SOCK_STREAM , 0 );
107105 if (sock < 0 ) {
@@ -123,10 +121,6 @@ int run_ping(uint32_t cid, uint32_t port, int count, double delay_sec) {
123121 char ping_msg [64 ];
124122 memset (ping_msg , 'A' , sizeof (ping_msg ));
125123
126- struct timespec delay_ts ;
127- delay_ts .tv_sec = (time_t )delay_sec ;
128- delay_ts .tv_nsec = (long )((delay_sec - (time_t )delay_sec ) * 1000000000 );
129-
130124 for (int seq = 1 ; seq <= count ; seq ++ ) {
131125 struct timespec start , end ;
132126
@@ -168,18 +162,14 @@ int run_ping(uint32_t cid, uint32_t port, int count, double delay_sec) {
168162
169163 printf ("rtt=%.3f us seq=%d\n" , (double )rtt_us , seq );
170164 fflush (stdout );
171-
172- if (seq < count && delay_sec > 0 ) {
173- nanosleep (& delay_ts , NULL );
174- }
175165 }
176166
177167 close (sock );
178168 return 0 ;
179169}
180170
181171
182- int run_ping_uds (const char * uds_path , uint32_t port , int count , double delay_sec ) {
172+ int run_ping_uds (const char * uds_path , uint32_t port , int count ) {
183173
184174 int sock = socket (AF_UNIX , SOCK_STREAM , 0 );
185175 if (sock < 0 ) {
@@ -231,10 +221,6 @@ int run_ping_uds(const char *uds_path, uint32_t port, int count, double delay_se
231221 char ping_msg [64 ];
232222 memset (ping_msg , 'A' , sizeof (ping_msg ));
233223
234- struct timespec delay_ts ;
235- delay_ts .tv_sec = (time_t )delay_sec ;
236- delay_ts .tv_nsec = (long )((delay_sec - (time_t )delay_sec ) * 1000000000 );
237-
238224 for (int seq = 1 ; seq <= count ; seq ++ ) {
239225 struct timespec start , end ;
240226
@@ -276,10 +262,6 @@ int run_ping_uds(const char *uds_path, uint32_t port, int count, double delay_se
276262
277263 printf ("rtt=%.3f us seq=%d\n" , (double )rtt_us , seq );
278264 fflush (stdout );
279-
280- if (seq < count && delay_sec > 0 ) {
281- nanosleep (& delay_ts , NULL );
282- }
283265 }
284266
285267 close (sock );
@@ -306,33 +288,31 @@ int main(int argc, char **argv) {
306288 }
307289
308290 if (strcmp (argv [1 ], "ping" ) == 0 ) {
309- if (argc != 6 ) {
291+ if (argc != 5 ) {
310292 return print_usage ();
311293 }
312294 uint32_t cid = atoi (argv [2 ]);
313295 uint32_t port = atoi (argv [3 ]);
314296 int count = atoi (argv [4 ]);
315- double delay = atof (argv [5 ]);
316297
317- if (!cid || !port || count <= 0 || delay < 0 ) {
298+ if (!cid || !port || count <= 0 ) {
318299 return print_usage ();
319300 }
320- return run_ping (cid , port , count , delay );
301+ return run_ping (cid , port , count );
321302 }
322303
323304 if (strcmp (argv [1 ], "ping-uds" ) == 0 ) {
324- if (argc != 6 ) {
305+ if (argc != 5 ) {
325306 return print_usage ();
326307 }
327308 const char * uds_path = argv [2 ];
328309 uint32_t port = atoi (argv [3 ]);
329310 int count = atoi (argv [4 ]);
330- double delay = atof (argv [5 ]);
331311
332- if (!port || count <= 0 || delay < 0 ) {
312+ if (!port || count <= 0 ) {
333313 return print_usage ();
334314 }
335- return run_ping_uds (uds_path , port , count , delay );
315+ return run_ping_uds (uds_path , port , count );
336316 }
337317
338318 return print_usage ();
0 commit comments