Replies: 2 comments
-
Both of these are to handle the UDP pseudo header, which is included in the UDP packet checksum. See https://en.wikipedia.org/wiki/User_Datagram_Protocol . The pseudo header contains a copy of the protocol field (which is 0x11 for UDP) and two copies of the UDP length (why two copies, I have no idea...). The length fields include the UDP header length (8 bytes). The checksum is computed on a byte-by-byte basis, so instead of computing the checksum and length separately and then adding them together, that 2 added per byte accounts for 1 byte added to both copies of the length field. And the 0x0010 is double the UDP header length, again to account for both copies of the length field. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Hello!
I have read your code, it is excellent!
I have two questions about the UDP checksum calculation.
I don't understand why add a constant 2 when calculating the checksum in "udp_checksum_gen.v".
You have write a annotation here like "add 2 for length calculation (two length fields in pseudo header)", but I didn't get it.
And why does the "checksum_next" have an initial value of "16'h0011 + 16'h0010"?
Can you give me more annotation please?
Beta Was this translation helpful? Give feedback.
All reactions