1

I want to ping 500 times three different ip address SIMULTANEOUSLY. If these pings are not the same time that will be an easy question. Somebody may say about open three cmd and start to ping your ip in each one.... ummm thats work But I'am finding to smarter way? I searched and I found one way in Linux, I'm working on Win7.

  • 2
    Create 500 threads (or 3, it's not clear what parallelisation you want here), and have each one do a separate ping. (Of course, they still won't be literally simultaneous, because that's impossible.) – Oliver Charlesworth Sep 04 '13 at 20:03
  • 1
    Can you post what you found for Linux? The same method, with some special sauce, might work for Windows also. – Mark Lakata Sep 04 '13 at 20:03
  • http://stackoverflow.com/questions/4708631/modify-shell-script-to-monitor-ping-multiple-ip-addresses. Is there easier way or this question is dublicated? – Mohammad Reza Rezwani Sep 04 '13 at 20:06
  • 'Simultaneously' has no meaning here. The packets will get sequentialized on the network anyway. – user207421 Sep 05 '13 at 03:13
  • @EJP Not complete simultaneously! – Mohammad Reza Rezwani Sep 05 '13 at 05:14
  • @EJP Running `ping -n 500` 3 times will take ~1500 second to complete when run sequentially, but only ~500 seconds when run in parallel. You'd be correct if each process consumed the entire available bandwidth, but that's not the case here. – Ansgar Wiechers Sep 05 '13 at 10:56
  • @alex Do you just want to run `ping -n 500` 3 times or do you need to do something with the results? What do you actually want to achieve by doing this? – Ansgar Wiechers Sep 05 '13 at 10:59
  • @AnsgarWiechers , I tell you may scenario my be help you to help me! My computer is in local network and also there are three computers in this local network. Think I connect them by wireless I want to 500 times ping each of them and calculate an average delay by ICMP reply time.What is so important is ping all of them Simultaneously because I want to compare their delay inorder to investigate my goal – Mohammad Reza Rezwani Sep 05 '13 at 12:02
  • Are the bellow answers are simultaneous? with respect to thier idea I think a better a way is writing a bash file which include a for loop with 500 repetition and there is three line in the loop each line ping one address. I am not familiar with bash could you please write this bash script. – Mohammad Reza Rezwani Sep 05 '13 at 20:30
  • Why would you want to ping 500 times? I was assuming the more rational strategy pinging once, of course. – user207421 Sep 05 '13 at 21:33
  • @EJP,500 is not important by itself sir I did not want to say X times. – Mohammad Reza Rezwani Sep 06 '13 at 04:43
  • @EJP Also piginig one time is not enough we ping them for EXAMPLE 1000 times divide them to 100 part and we average every 10 times we can call it dellay on the moment but another approach is calculating average delay JUST for 1000 packet not for all packet. – Mohammad Reza Rezwani Sep 06 '13 at 04:53
  • @EJP A familiar approach is calculating delay on based on time.In ns2 tools they generate TCP or UDP packets for 60 secondes(FOR EXAMPLE) and after that they calculate throughput and delay.But I my scenario is different – Mohammad Reza Rezwani Sep 06 '13 at 04:58
  • Related: [Arrange the pinging of multiple website in order with batch?](https://stackoverflow.com/q/50826932) – aschipfl Mar 10 '21 at 11:20

6 Answers6

3

You can install a utility fping which works in a round-robin way to ping each ip address. You can install it by:

sudo apt install fping

Then you can ping multiple addresses using one-liner:

fping <ip1> <ip2> <ip3>

It can also be used to run multiple ip addresses written down in a file.

subtleseeker
  • 4,415
  • 5
  • 29
  • 41
1
@echo off
for %%a in (1.1.1.1 2.2.2.2 3.3.3.3) do (
start ping -n 500 %%a
)
foxidrive
  • 40,353
  • 10
  • 53
  • 68
1

If you want to compare delays afterwards you could so something like this:

@echo off

setlocal

start "" "%COMSPEC%" /c ping -n 500 192.168.1.23 ^>log1.txt
start "" "%COMSPEC%" /c ping -n 500 192.168.1.42 ^>log2.txt
start "" "%COMSPEC%" /c ping -n 500 192.168.1.113 ^>log3.txt

The 3 log files contain the output of each ping command.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
1

You can try script (I am the author) below to run command(s) against multiple targets (IP/Names). Commands are not limited to Ping only but can be any command like tracert/traceroute, ncat, whatever you can run from terminal. Tested on Linux and windows - for windows script packed in .exe file for the ease of use.

For Windows: ccmd.exe -c 500 -ts 8.8.8.8,bbc.com,8.8.4.4/31 -D -b 20

For Linux: ccmd.py -c 500 -ts 8.8.8.8,bbc.com,8.8.4.4/31 -D -b 20

-ts - is a coma separated string of targets to execute commands against
-c - count of times to execute command
-D - tells the script to get and print DNS info on the screen
-b - regulates the length of results printed to screen
all commands executed in (semi)parallel using python threading module (thread count can be set with -t argument).

Script saves logs into "LOGS" directory.

Example output for Windows

Source: https://github.com/apraksim/ccmd.git

apraksim
  • 11
  • 2
0

for those who's using Mac OS-X or Linux and want to ping multiple hosts: I've just released ping-xray which facilitates multiple hosts pinging. Tried to make it as visual as possible under ascii terminal plus it creates CSV logs with exact millisecond resolution for all targets.

https://dimon.ca/ping-xray/ enter image description here

Hope you'll find it helpful. Tool is based on open source "fping" and adds ascii "gui" via bash curses to make output a bit more human-readable.

Dmitry Shevkoplyas
  • 6,163
  • 3
  • 27
  • 28
0

On Macbook:
Open terminal,

vim ping.sh

in the vim, type

for i in 35.x.x.x 35.x.x.x
do
ping -c 2 $i
done

save and quite
to run the script, type:

sh ping.sh 
Mike Yang
  • 2,581
  • 3
  • 24
  • 27