<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to CodeSys UDP Broadcast mystery</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/</id><updated>2022-09-16T09:47:53.631000Z</updated><subtitle>Recent posts to CodeSys UDP Broadcast mystery</subtitle><entry><title>CodeSys UDP Broadcast mystery</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/?limit=25#d4e9" rel="alternate"/><published>2022-09-16T09:47:53.631000Z</published><updated>2022-09-16T09:47:53.631000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com3f002568bd18c33cf098c8d04aad26e0342da2fb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Okay I finally understood this ! &lt;br/&gt;
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).&lt;/p&gt;
&lt;p&gt;So in case anybody needs this one day (who knows), to perform the same type of network scan CodeSys use you have to send a UDP broadcast frame containing the following data :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;WIFI&lt;/span&gt;
&lt;span class="n"&gt;c5&lt;/span&gt; &lt;span class="mi"&gt;74&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt; &lt;span class="mi"&gt;03&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;03&lt;/span&gt; &lt;span class="n"&gt;xx&lt;/span&gt; &lt;span class="mi"&gt;83&lt;/span&gt; &lt;span class="mi"&gt;01&lt;/span&gt; &lt;span class="mi"&gt;02&lt;/span&gt; &lt;span class="n"&gt;c2&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;04&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt;

&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;ETH&lt;/span&gt;
&lt;span class="n"&gt;c5&lt;/span&gt; &lt;span class="mi"&gt;74&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt; &lt;span class="mi"&gt;03&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;03&lt;/span&gt; &lt;span class="n"&gt;xx&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;02&lt;/span&gt; &lt;span class="n"&gt;c2&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;04&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Where "xx" is the last byte of your ip address. &lt;/p&gt;
&lt;p&gt;I don't know how it works on networks where the mask is not 255.255.255.0 though...&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>CodeSys UDP Broadcast mystery</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/?limit=25#7092" rel="alternate"/><published>2022-09-14T07:32:39.995000Z</published><updated>2022-09-14T07:32:39.995000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com1a1f5804c9d6465c0fe9ce8bb741a5209ea16819</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;After some investigation, it looks like the 9th byte changes depending on the network IP.&lt;br/&gt;
For example on the same WiFI network :&lt;br/&gt;
- if network ip is &lt;code&gt;192.168.100.xxx&lt;/code&gt; then byte 9 is "05"&lt;br/&gt;
- if network ip is &lt;code&gt;192.168.99.xxx&lt;/code&gt; then byte 9 is "03"&lt;br/&gt;
- if network ip is &lt;code&gt;192.168.43.xxx&lt;/code&gt; then byte 9 is "8A"&lt;br/&gt;
- if network ip is &lt;code&gt;192.168.1.xxx&lt;/code&gt; then byte 9 is "34"&lt;/p&gt;
&lt;p&gt;I tried some math operations on the ip to get those values as results but I can't figure out how it's calculated...&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>CodeSys UDP Broadcast mystery</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/?limit=25#4586" rel="alternate"/><published>2022-09-12T09:29:05.713000Z</published><updated>2022-09-12T09:29:05.713000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com183a915ec937538ccdf935194b36c19333903515</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Ok so far I understood this :&lt;br/&gt;
- &lt;strong&gt;Byte&lt;span&gt;&lt;span&gt;[0:4]&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; = Some sort of header (it never changes)&lt;br/&gt;
- &lt;strong&gt;Byte 5&lt;/strong&gt; = Change depending on the interface type (10 for ethernet and 20 for WiFi)&lt;br/&gt;
- &lt;strong&gt;Byte&lt;span&gt;&lt;span&gt;[6:7]&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; = ? (can be set to 0 without issues)&lt;br/&gt;
- &lt;strong&gt;Byte 8&lt;/strong&gt; = Always equals to 03&lt;br/&gt;
- &lt;strong&gt;Byte 9&lt;/strong&gt; = ??? (can't be set to 0 otherwise devices won't answer the broadcast message)&lt;br/&gt;
- &lt;strong&gt;Byte&lt;span&gt;&lt;span&gt;[10:11]&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; = Changes depending on the interface type (0000 for ethernet and 8301 for WiFi)&lt;br/&gt;
- &lt;strong&gt;Byte&lt;span&gt;&lt;span&gt;[12:15]&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; = Always equals to 02c20004&lt;br/&gt;
- &lt;strong&gt;Byte&lt;span&gt;&lt;span&gt;[16:19]&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; = Count of UDP broadcast messages sent (can be set to 0 without issues)&lt;/p&gt;
&lt;p&gt;So now my frame for WiFI interfaces looks like this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;c5 74 40 03 00 20 00 00 03 ?? 83 01 02 c2 00 04 00 00 00 00&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The only thing I really don't understand now is the 9th byte : what is it ? How is it computed ? &lt;br/&gt;
It seems like it changes every time I restart my computer, but stays the same during the whole sessions afterwards...&lt;/p&gt;
&lt;p&gt;I hope someone can help me with this&lt;br/&gt;
BR&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>CodeSys UDP Broadcast mystery</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/bba444aef6/?limit=25#eb46" rel="alternate"/><published>2022-09-09T14:58:39.322000Z</published><updated>2022-09-09T14:58:39.322000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com7a3a192f1cdf9342b786d4ed02e3878e359c7443</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;br/&gt;
I'm trying to understand how the "Scan Network" function of CodeSys operates.&lt;br/&gt;
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:&lt;br/&gt;
&lt;img alt="" rel="nofollow" src="https://i.imgur.com/5xfEkoQ.png"/&gt;&lt;/p&gt;
&lt;p&gt;This broadcasted packet contains 20 bytes of data and looks like this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;c5 74 40 03 00 20 b7 8b 03 8a 83 01 02 c2 00 04 01 dc 7d 06&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;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. &lt;/p&gt;
&lt;p&gt;It looks like these 20 bytes of data are changing based on the network / computer ?&lt;/p&gt;
&lt;p&gt;I was wondering if this was documented somewhere ? How is this frame built ?&lt;/p&gt;
&lt;p&gt;Thank you for your time,&lt;br/&gt;
BR&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>