0

I had recently made a python program that parses broadcast messages sent from a device.

I knew the structure the information was coming in and the sequence (little endian)

Originally when I received the data I parsed it starting from octet one. The information didn't make any sense and I soon realized the first chunk of data must be the UDP header. From the link https://en.wikipedia.org/wiki/User_Datagram_Protocol I found that the data doesn't start til 8 octect. I shifted where I started parsing but still the data shown was not as expected.

Luckily while looking through the data I realized a chunk that I recognized and counted backwards/forwards to get the start and end points of the data. The data didn't start til octet 12

My question now is... why does the header take up 12 octets? What is the structure of this header?

Note: I used wireshark to check the message sizes to make sure Python was getting the whole message to make sure the message wasn't being cut down some how...

tyleax
  • 1,556
  • 2
  • 17
  • 45
  • 1
    If you're writing code that uses a UDP socket in Python, the data returned by `recv()` or `recvfrom()` shouldn't include the header. Are you using a raw socket instead of a UDP socket? – Barmar Mar 31 '17 at 01:09
  • Sorry I was looking at the wrong one when writing up this question. I have edited the original question. Still looking for the difference in 8 -> 12 octets. – tyleax Mar 31 '17 at 01:09
  • Can you show the contents of those 12 octets? – Barmar Mar 31 '17 at 01:13
  • @Barmar I took what you said to be true; that recv() and recvfrom() return does not include the header. I looked at the source code on the opposite end and it looks like they added additional information on top of the relevant data. Definitely learnt something today. Thanks for the help. – tyleax Mar 31 '17 at 01:24

0 Answers0