LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

retrieve IP addresses of computers connected to router

Hello All,

 

First thanks for taking the time to read my queries, basically my problem is below

 

1. I have a Dlink router DIR-635 that is connected through my PC, and another ethernet switch connected  to the router with 5 more PC's connected on the switch,

PC-->router-->Ethernet Switch--->5 PC's

Now, the router is giving this 5 PC's each with IP address, is there a way I can retrieve this IP address automatically using CVI? The idea would be once I have this IP addresses acquired by the CVI program, I will send each of the 5 PC's a ping with  ping <ip address> -t>ipaddress.txt.

 

2. Is there also a way, where once a new PC is connected to the ethernet switch, the CVI program will automatically detect and display the IP address given by the router on the program and eventually send the same ping command.

 

 

A sample program is greatly appreciated. Thank you in advance.

 

Regards,

James

0 Kudos
Message 1 of 17
(11,779 Views)
You could send an ARP request to all local IPs and look who replies.

 

 

Message 2 of 17
(11,748 Views)

through CVI

 

execute the command arp -a >iplist.txt

 

this will generate a text file "iplist.txt" with all of the ip addressess connected to the network

(you amy get  outside addressess you have open links to the internet.)

 

open the iplist .txt file and read in the list of ip addressess

 

as you should allready know the  range of  ip addressess that have been allocated to the pc  by the router it should be an easy exercise to identify the IP addresses  and set up the ping commands.

 

colin

 

 

 

Message 3 of 17
(11,738 Views)

Thanks Colin for the full description.

 

I do not get outside IP addresses when I run the arp command.   I do get the PC's that are on a different subnet.  

As a plus, you get the Physical Addresses.

 

RayR

0 Kudos
Message 4 of 17
(11,735 Views)

I only get the IP addresses of computers to which I am currently connected. Computers that are on the network, but not currently with an active connection to mine, do not show up.

 

I guess the success of this approach depends on whether you are running a simple hub or a switch based system.

 

JR

0 Kudos
Message 5 of 17
(11,726 Views)

Hummm...

 

Well... you could always go through a brute force approach..

 

Create an algorithm to ping all possible addresses within your subnet and look for replies.  Don't bother doing statistics (ie repeat test 4 times) as you only case about a response and not lost packets.

0 Kudos
Message 6 of 17
(11,723 Views)

I was away so have not replied early on the topic,

First thank you all for the help, this will be a good start for me to achieve what  want my application to perform.

 

My next exercise would be to place this ip list with their corresponding physical address(MAC) to a  text box and ping each one, how can I drop those IP list on the textbox? thanks in advance.

0 Kudos
Message 7 of 17
(11,639 Views)

I forgot, I drop those Ip list using below

myfile = fopen("C:\\work\\iplist.txt","rt");
while (fgets(fileBuf,256,myfile))
SetCtrlVal(panelHandle,PANEL_TEXTBOX,fileBuf);

 

How can I select each IP address one by one and display on a separate string textbox? In this way I can ping each IP individually.

0 Kudos
Message 8 of 17
(11,637 Views)

Hi,

 

You can find a small sample code for the functionality you requested.

Hope this helps, 

S. Eren BALCI
IMESTEK
Message 9 of 17
(11,620 Views)

thanks Eren for the sample, I will look at it because I can easily implement the same scenario on LV, just need to duplicate it using CVI,

 

will let you know

0 Kudos
Message 10 of 17
(11,592 Views)