Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-15-2009, 03:21 AM   #1
Registered: Oct 2005
Posts: 540

Rep: Reputation: 32
Ping for a specific number of times


Question on the ping test. How can I ping on UNIX to display round trip delay a specific number of times. The "man" page mentions about the -s flag and the npackets option. However, I can't find any example using the npackets option.

When you specify the s flag, sends one datagram per second
(adjust with -I) and prints one line of output for every
ECHO_RESPONSE that it receives. ping produces no output if
there is no response. In this second form, ping computes
round trip times and packet loss statistics; it displays a
summary of this information upon termination or timeout. The
default data_size is 56 bytes, or you can specify a size
with the data_size command-line argument. If you specify
the optional npackets, ping sends ping requests until it
either sends npackets requests or receives npackets
Old 08-15-2009, 03:23 AM   #2
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,997

Rep: Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219
"ping -c ?"
Old 08-15-2009, 10:24 PM   #3
Registered: Oct 2005
Posts: 540

Original Poster
Rep: Reputation: 32

Originally Posted by syg00 View Post
"ping -c ?"
I think "ping -c 1 localhost" doesn't quite work on UNIX because no matter what number I specified, it only ping once. In addition, it only states it's alive without the latency info.
bash-3.00$ ping -c 1 localhost
localhost is alive
bash-3.00$ ping -c 2 localhost
localhost is alive

But what does it mean when the "man" page says:
If you specify the optional npackets, ping sends ping requests until it
either sends npackets requests or receives npackets replies
Old 08-15-2009, 10:35 PM   #4
Senior Member
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
What OS are you using? ping -c is the correct command from what I can tell.
Old 08-15-2009, 10:52 PM   #5
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Stretch (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
The Unix version of 'ping' takes the packet count as an option argument (and the '-c' flag has a different purpose).

I suspect you have to specify the packet size too. I reckon it will be something like this:

ping -s 56 10
In this example, the packet size is 56 and the count is 10.

Last edited by neonsignal; 08-15-2009 at 10:55 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-login at specific times Vorik Linux - Software 6 12-11-2007 02:04 AM
Restrict access times for specific IP addresses? gjhicks Linux - Networking 11 11-02-2006 11:42 PM
Running a program at specific times only i666an SUSE / openSUSE 4 04-02-2006 08:49 AM
router dropping connection at specific times cs-cam Linux - Networking 0 02-12-2006 10:17 PM
System hangs; Atheros Madwifi-ping times out every 15/16 times james 456 Linux - Networking 0 01-12-2006 07:55 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:01 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration