LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 08-15-2009, 02:21 AM   #1
grob115
Member
 
Registered: Oct 2005
Posts: 528

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


Hello,

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
replies.
 
Old 08-15-2009, 02:23 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,275

Rep: Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028Reputation: 1028
"ping -c ?"
 
Old 08-15-2009, 09:24 PM   #3
grob115
Member
 
Registered: Oct 2005
Posts: 528

Original Poster
Rep: Reputation: 32
Hello,

Quote:
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
bash-3.00$


But what does it mean when the "man" page says:
Quote:
If you specify the optional npackets, ping sends ping requests until it
either sends npackets requests or receives npackets replies
 
Old 08-15-2009, 09:35 PM   #4
micxz
Senior Member
 
Registered: Sep 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, 09:52 PM   #5
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
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:

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

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


Reply


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 01:04 AM
Restrict access times for specific IP addresses? gjhicks Linux - Networking 11 11-02-2006 10:42 PM
Running a program at specific times only i666an Suse/Novell 4 04-02-2006 07:49 AM
router dropping connection at specific times cs-cam Linux - Networking 0 02-12-2006 09:17 PM
System hangs; Atheros Madwifi-ping times out every 15/16 times james 456 Linux - Networking 0 01-12-2006 06:55 PM


All times are GMT -5. The time now is 05:09 AM.

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