This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

IP scanner with STM32f107 and PHY

Hello,

I've designed and programmed a board to communicate with other devices with Ethernet. Everything works fine and in this step I need to create an IP scanner to scan an IP range (for example 192.168.1.100 to 192.168.1.254) but it takes more than one hour to scan this range of IP( 155 IPs) and connect to one device which is located at 192.168.1.150 . Here is my IP scanner code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int ScanTheNetwork(void)
{
int i;
NET_ADDR4 addr = { NET_ADDR_IP4, 5000, 192, 168, 1, 0 };
netInitialize ();
netDHCP_Disable (0);
socket1[0].SCK = netTCP_GetSocket (tcp_cb_func);
for(i=100;i<255;i++)
{
addr.addr[3]=i;
if (socket1[0].SCK >= 0)
{
netTCP_SetOption (socket1[0].SCK , netTCP_OptionTimeout, 1);
netTCP_Connect (socket1[0].SCK, (NET_ADDR *)&addr, 0);
netTCP_SetOption (socket1[0].SCK , netTCP_OptionTimeout, 1);
while(1)
{
IWDG_ReloadCounter();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In the above code I need to find a device ( I didn't put many devices) which is alive and its open port is 5000. I changed the IP range from (148 to 152 ) which the alive one is located at 150 but it takes more than 5minutes to connect to my devices.

I need to know what is best way to find my alive device and connect to it as soon as possible in the an IP range.

0