为什么 UDP 在标头中有长度字段而 TCP 没有?中有、字段、长度、UDP

2023-09-08 09:12:54 作者:故事配酒你配狗

为什么 UDP 的头部有长度字段,而 TCP 没有?

Why does UDP have a length field in the header and TCP does not?

我猜测 TCP 中的段长度是从 IP 标头推断出来的,但是对于 UDP 数据报应该能够做到这一点

I am guessing that the length of the segment in TCP is inferred from the IP header but one should be able to do the same for a UDP datagram

推荐答案

根据TCP/IP Illustrated Volume 1,长度字段是多余的.这就是史蒂文斯对此事所说的全部内容.

According to TCP/IP Illustrated Volume 1, the length field is redundant. That's all Stevens says on the matter.

我个人认为这是为了使 UDP 标头长度(以位为单位)可被 32 整除 :)

I personally believe it was to make the UDP header length (in bits) divisible by 32 :)