Hello,
I'm trying to understand how the "Scan Network" function of CodeSys operates.
I looked at the packets using wireshark and it looks like it sends an UDP frame on the broadcast address of the network and wait for answers:
This broadcasted packet contains 20 bytes of data and looks like this :
I tried to send this frame using a python script and I was able to get some answers from devices on the network ! However if the network switch (for example going from wifi to ethernet), it doesn't work anymore.
It looks like these 20 bytes of data are changing based on the network / computer ?
I was wondering if this was documented somewhere ? How is this frame built ?
The only thing I really don't understand now is the 9th byte : what is it ? How is it computed ?
It seems like it changes every time I restart my computer, but stays the same during the whole sessions afterwards...
I hope someone can help me with this
BR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay I finally understood this !
The 9th byte is the last part of my IP address : for example if my ip is 192.168.1.42 then the 9th byte has to be equal to 42 (0x2A).
So in case anybody needs this one day (who knows), to perform the same type of network scan CodeSys uses you have to send a UDP broadcast frame containing the following data :
Hello,

I'm trying to understand how the "Scan Network" function of CodeSys operates.
I looked at the packets using wireshark and it looks like it sends an UDP frame on the broadcast address of the network and wait for answers:
This broadcasted packet contains 20 bytes of data and looks like this :
I tried to send this frame using a python script and I was able to get some answers from devices on the network ! However if the network switch (for example going from wifi to ethernet), it doesn't work anymore.
It looks like these 20 bytes of data are changing based on the network / computer ?
I was wondering if this was documented somewhere ? How is this frame built ?
Thank you for your time,
BR
Ok so far I understood this :
So now my frame for WiFI interfaces looks like this :
The only thing I really don't understand now is the 9th byte : what is it ? How is it computed ?
It seems like it changes every time I restart my computer, but stays the same during the whole sessions afterwards...
I hope someone can help me with this
BR
After some investigation, it looks like the 9th byte changes depending on the network IP.
For example on the same WiFI network :
192.168.100.xxxthen byte 9 is "05"192.168.99.xxxthen byte 9 is "03"192.168.43.xxxthen byte 9 is "8A"192.168.1.xxxthen byte 9 is "34"I tried some math operations on the ip to get those values as results but I can't figure out how it's calculated...
Okay I finally understood this !
The 9th byte is the last part of my IP address : for example if my ip is 192.168.1.42 then the 9th byte has to be equal to 42 (0x2A).
So in case anybody needs this one day (who knows), to perform the same type of network scan CodeSys uses you have to send a UDP broadcast frame containing the following data :
Where "xx" is the last byte of your ip address.
I don't know how it works on networks where the mask is not 255.255.255.0 though...
Last edit: paulpotat 2022-09-16