LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pinging a pool of hosts at the same time

I would like to ping a range of hosts (169.254.1.2 to 169.254.1.13) at the same time. If a certain number of them respond (less than or equal to the number of the hosts in the range), then I would like to stop the pings and have an array of the responding IPs returned.

 

As the hosts respond to pings, we can mark them as alive and stop pinging them.

 

I was thinking of starting with a pool of all the valid host IPs, pass that pool into a VI that evaluates them over a short period of time like a few seconds, and then remove the known good hosts from the pool before sending it through for another round. Once the number of desired good hosts has been reached, we can stop.

 

Any thoughts on how to accomplish this? I have a VI that does the pinging, but I'm not sure how to do the pinging in parallel for an arbitrary number of hosts.

0 Kudos
Message 1 of 12
(4,364 Views)

Hi,

 

Is there any chance you can post the VI you have currently developed? It will be beneficial to evaluate what you currently have and see how we can use that going forward.

 

My immediate thought would be a state machine architecture. Initialize in a 'ping' state, and then have a corresponding 'successful' or 'failed' state that handles successful and timed out pings. Return to your 'ping' state and iterate through the list of addresses. When the number of good hosts is reached, use a 'close' state and uninitialize any connections and display the useful info to the user of good hosts, etc...

 

 

Regards,

 

Finch Train

 

0 Kudos
Message 2 of 12
(4,302 Views)

Wouldn't this be sequential, if you iterate through the list of VIs for each host? How do I start a batch of n pings at the same time?

 

I'm trying to avoid writing n instances of ping.vi in a for loop.

 

In python I would write a ping function, make a list of IP addresses, and map the function to the IP list using multiprocessing.Pool.

Download All
0 Kudos
Message 3 of 12
(4,294 Views)

If you are wanting to send the pings at the same time you can build all the IP addresses into one array, for example the array that you have in the first for loop. Then you would not have to concatenate and add one each iteration. I cannot open the ping test.vi becasue it is password protected. Does this make sense?

0 Kudos
Message 4 of 12
(4,257 Views)

Sorry, removed password protection.

So the first loop is fine; it just returns an array of IP addresses.

The 2nd loop peels off one IP address at a time and the ping.vi processes it until it is finished. I'm not following how this can happen in parallel.

 

ping snippet.png

0 Kudos
Message 5 of 12
(4,255 Views)

Here is a working python example. 'ping <ip> -n 1' takes 3.5 seconds to run on 12 threads at the same time.

0 Kudos
Message 6 of 12
(4,241 Views)

Right-click the sequential loop and find the parallelize option.

Message 7 of 12
(4,232 Views)

You can combine the two loops, just place the Build IP in the second loop and change it to a parallel loop.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 12
(4,216 Views)

Thanks Yamaeda. That is what I needed.

 

The results are still very slow. The slowest that the ping vi should run is about 6 seconds, but the parallel operation takes 56 seconds.

 

Also, any thoughts on the way I handled the error cluster?

 

Download All
0 Kudos
Message 9 of 12
(4,200 Views)

I believe that in order for that loop to run in parallel, your Ping Test needs to be parallelizable.  i.e. It should be set to reentrant execution.

0 Kudos
Message 10 of 12
(4,195 Views)