LAN protocol UDP size issue

Hello,

I’m currently implementing my own client, and when I do discovery, sending the GetService message, I receive 2 answers from the LIFX bulb, which both seem to have an erroneous UDP size (49 instead of 47).
Is there any way to fix this?

Frames captured (coming from a wireshark capture):
REQUEST:
45 00 00 40 67 05 40 00 40 11 4c f1 c0 a8 02 67
c0 a8 02 ff (IP header)
dd 7c dd 7c 00 2c 4c ad (UDP header, size = 0x2c = 44 = 36 + 8 for UDP header = correct)
24 00 00 34 53 82 f7 41 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00
02 00 00 00 (data)

1ST RESPONSE
45 00 00 45 00 b7 00 00 40 11 f3 d1 c0 a8 02 68
c0 a8 02 67 (IP header)
dd 7c dd 7c 00 31 ba 1c (UDP header, size = 0x31 = 49 = 41 + 8 for UDP header = WRONG because size is 39 + 8)
29 00 00 54 53 82 f7 41 d0 73 d5 21 90 ec 00 00
4c 49 46 58 56 32 00 40 c0 2f 2d fa a1 00 00 00
03 00 00 00 01 7c dd (data)

2ND RESPONSE
45 00 00 45 00 b8 00 00 40 11 f3 d0 c0 a8 02 68
c0 a8 02 67 (IP header)
dd 7c dd 7c 00 31 ec c7 (UDP header, size = 0x31 = 49 = 41 + 8 for UDP header = WRONG because size is 39 + 8)
29 00 00 54 53 82 f7 41 d0 73 d5 21 90 ec 00 00
4c 49 46 58 56 32 00 40 00 84 b6 fa a1 00 00 00
03 00 00 00 05 7c dd (data)

Here are my size calculations for the packets you sent, everything seems to be fine, have I made a mistake somewhere? I’m unclear where you got the number 39 from for both of the response packets? Could you please explain the reasoning there?

Request

# IP Header
4     # Version
5     # IHL
00    # DCSP + ECN
00 40 # Length
67 05 # Identification
40 00 # Flags + Fragment
40    # TTL
11    # Protocol
4c f1 # Header Checksum
c0 a8 02 67 # Source Address
c0 a8 02 ff # Dest Address

# UDP Header
dd 7c # Source Port
dd 7c # Dest Port
00 2c # Length
4c ad # Checksum

# Data (visible size = 18)
24 00 00 34 53 82 f7 41 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00
02 00 00 00

LIFX Packet = 0x24 = 36 bytes
UDP Packet = LIFX Packet + UDP Header = 0x24 + 0x08 = 0x2c = 44 bytes
IP Packet = UDP Packet + IP Header = 0x2c + 0x14 = 0x40 = 64 bytes

1st Response

# IP Header
4     # Version
5     # IHL
00    # DSCP + ECN
00 45 # Length
00 b7 # Identification
00 00 # Flags + Fragment
40    # TTL
11    # Protocol
f3 d1 # Header checksum
c0 a8 02 68 # Source Address
c0 a8 02 67 # Dest Address

# UDP Header
dd 7c # Source Port
dd 7c # Dest Port
00 31 # Length
ba 1c # Checksum

# Data (visible size = 19.5 bytes)
29 00 00 54 53 82 f7 41 d0 73 d5 21 90 ec 00 00
4c 49 46 58 56 32 00 40 c0 2f 2d fa a1 00 00 00
03 00 00 00 01 7c dd

LIFX Packet = 0x0029 = 41 bytes
UDP Packet = LIFX Packet + UDP Header = 0x29 + 0x08 = 0x31 = 49 bytes
IP Packet = UDP Packet + IP Header = 0x31 + 0x14 = 0x45 = 69 bytes

2nd Response

# IP Header
4     # Version
5     # IHL
00    # DSCP + ECN
00 45 # Length
00 b8 # Identification
00 00 # Flags + Fragment
40    # TTL
11    # Protocol
f3 d0 # Header Checksum
c0 a8 02 68 # Source Address
c0 a8 02 67 # Dest Address

# UDP Header
dd 7c # Source Port
dd 7c # Dest Port
00 31 # Length
ec c7 # Checksum

## Data (visible size = 19.5 bytes)
29 00 00 54 53 82 f7 41 d0 73 d5 21 90 ec 00 00
4c 49 46 58 56 32 00 40 00 84 b6 fa a1 00 00 00
03 00 00 00 05 7c dd

LIFX Packet = 0x0029 = 41 bytes
UDP Packet = LIFX Packet + UDP Header = 0x29 + 0x08 = 0x31 = 49 bytes
IP Packet = UDP Packet + IP Header = 0x31 + 0x14 = 0x45 = 69 bytes

Hi Daniel,

In the responses, the size of the LIFX packet is 39, not 41 (which is normal, since it’s 36 bytes for the header, and 3 additional bytes for the response)(please double-check the trace).
Therefore, the UDP size should be 39 + 8 = 47 bytes = 0x2F, not 0x31 (49 bytes)…

The port number should be 32 bits in the LIFX message so your capture is missing two zero bytes.

1 Like

The Device::StateService message has a payload with a service (1 byte) and a port (4 bytes) for a total of 5 bytes, adding the LIFX header (36 bytes) makes that 41 bytes.