z*y 发帖数: 1311 | 1 为什么UDP header里有length field,而TCP header却没有? |
a**********k 发帖数: 1953 | 2 datagram vs. stream
【在 z*y 的大作中提到】 : 为什么UDP header里有length field,而TCP header却没有?
|
s*****g 发帖数: 1055 | 3 Good question! I searched Google, the consensus of all answers is that the
length field in either TCP or UDP (or lack there of) is redundant, because
the length can always be inferred from IP payload length minus UDP/TCP
header size.
【在 z*y 的大作中提到】 : 为什么UDP header里有length field,而TCP header却没有?
|
v**n 发帖数: 951 | 4 none of them is needed.
the length field makes it a good alignment, i guess.
【在 z*y 的大作中提到】 : 为什么UDP header里有length field,而TCP header却没有?
|
z*y 发帖数: 1311 | 5
I know, that is why I ask.
Since both are redundant. Why is included in UDP but not TCP?
I guess not every engineering decision has a reason.
【在 v**n 的大作中提到】 : none of them is needed. : the length field makes it a good alignment, i guess.
|
z**r 发帖数: 17771 | 6 agree, and TCP UDP were designed by different groups
【在 v**n 的大作中提到】 : none of them is needed. : the length field makes it a good alignment, i guess.
|
z**r 发帖数: 17771 | 7 did a quick search
http://stackoverflow.com/questions/281606/why-does-udp-have-a-l
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 complemen
t sum of all 16 bit words in the header and text. If a segment contains an o
dd number of header and text octets to be checksummed, the last octet is pad
ded 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 Destina
tion Address, the Protocol, and TCP length. This gives the TCP protection ag
ainst misrouted segments. This information is carried in the Internet Protoc
ol and is transferred across the TCP/Network interface in the arguments or r
esults 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 p
rotocol.
【在 z**r 的大作中提到】 : agree, and TCP UDP were designed by different groups
|
B*****R 发帖数: 1539 | 8 赫赫,面试时没词儿了我就喜欢问UDP CHECKSUM怎么算的
field-in-the-header-and-tcp-does-not
that
complemen
an o
pad
The
【在 z**r 的大作中提到】 : did a quick search : http://stackoverflow.com/questions/281606/why-does-udp-have-a-l : 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 complemen : t sum of all 16 bit words in the header and text. If a segment contains an o : dd number of header and text octets to be checksummed, the last octet is pad : ded on the right with zeros to form a 16 bit word for checksum purposes. The
|
x*********n 发帖数: 28013 | 9 you are way too evil..
【在 B*****R 的大作中提到】 : 赫赫,面试时没词儿了我就喜欢问UDP CHECKSUM怎么算的 : : field-in-the-header-and-tcp-does-not : that : complemen : an o : pad : The
|
z**r 发帖数: 17771 | 10 good question
【在 B*****R 的大作中提到】 : 赫赫,面试时没词儿了我就喜欢问UDP CHECKSUM怎么算的 : : field-in-the-header-and-tcp-does-not : that : complemen : an o : pad : The
|
f*****n 发帖数: 646 | 11 UDP里的length看来是多余的, stevens那本书里也这么说
但是TCP要length有啥用? 本来就是stream oriented protocol, length这个概念就不
适合TCP
that
complemen
o
pad
The
【在 z**r 的大作中提到】 : did a quick search : http://stackoverflow.com/questions/281606/why-does-udp-have-a-l : 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 complemen : t sum of all 16 bit words in the header and text. If a segment contains an o : dd number of header and text octets to be checksummed, the last octet is pad : ded on the right with zeros to form a 16 bit word for checksum purposes. The
|
u**n 发帖数: 44 | 12 TCP has checksum field so that application can verify data integrity by
given TCP packet. UDP checksum could be zero so that application needs to
know how many bytes are valid.
My guess...
【在 z*y 的大作中提到】 : 为什么UDP header里有length field,而TCP header却没有?
|
m**t 发帖数: 1292 | 13 There is an offset field to contain the option header length though |