The UDP header length is fixed at 8 bytes so it doesn't need to be part of the packet. TCP/IP header length is variable so it does.
Why is the UDP header length field needed? Because the payload section can be of variable length, and this lets UDP know where the segment ends.
TCP wraps each data packet with a header containing 10 mandatory fields totaling 20 bytes (or octets). Each header holds information about the connection and the current data being sent.
UDP header is an 8-bytes fixed and simple header, while for TCP it may vary from 20 bytes to 60 bytes.
According to TCP/IP Illustrated Volume 1, the length field is redundant. That's all Stevens says on the matter.
I personally believe it was to make the UDP header length (in bits) divisible by 32 :)
There is a 96 bit pseudo header conceptually prefixed to the TCP header that contains the information already.
The checksum field description from this source gives the answer:
Checksum: 16 bits
The checksum field is the 16 bit one's complement of the one's complement sum of all 16 bit words in the header and text. If a segment contains an odd number of header and text octets to be checksummed, the last octet is padded on the right with zeros to form a 16 bit word for checksum purposes. The pad is not transmitted as part of the segment. While computing the checksum, the checksum field itself is replaced with zeros.
The checksum also covers a 96 bit pseudo header conceptually prefixed to the TCP header. This pseudo header contains the Source Address, the Destination Address, the Protocol, and TCP length. This gives the TCP protection against misrouted segments. This information is carried in the Internet Protocol and is transferred across the TCP/Network interface in the arguments or results of calls by the TCP on the IP.
+--------+--------+--------+--------+ | Source Address | +--------+--------+--------+--------+ | Destination Address | +--------+--------+--------+--------+ | zero | PTCL | TCP Length | +--------+--------+--------+--------+
The information is not needed at the TCP level since TCP is a stream based protocol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With