为什么 Linux 服务器响应的 TCP 数据包大于客户端请求的 MSS
我看到了一件奇怪的事情,这不是我所期望的 TCP 理论:
客户端在握手时将 MSS(最大段大小)设置为 1360,窗口大小为 64K,但 Linux 服务器正在发送包含以下任一内容的 TCP 数据包: 4KB,7KB,一些8KB的数据包超过1360个,我预计它会小于1360字节。
我通过执行 tcpdump 然后在 Wireshark 中检查它来观察到这一点。
我没想到服务器每个 TCP 数据包发送超过 1360 字节。我对 TCP 工作原理的理论理解是否有错误?
I am seeing a strange thing which is not what I expect as per the TCP theory:
The client while doing a handshake sets a MSS (Maximum Segment Size) of 1360 and a window size of 64K but the Linux server is sending TCP packets containing either 4KB, 7KB, some packets of 8KB which is more than 1360 and I expected it to be less than 1360 bytes.
I observed this by doing a tcpdump
and then inspecting it in Wireshark.
I did not expect the server to send more than 1360 bytes per TCP packet. Am I wrong somewhere in my theoretical understanding of the workings of TCP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,正如 @fernacolo 所说,不要混淆 MSS 和 MTU。
也许您的界面的 generic-segmentation-offload 已开启 - 请阅读此处了解更多信息。
First of all as @fernacolo stated don't confuse MSS and MTU.
Maybe generic-segmentation-offload of your interface is on - read here for more info.
如果您在服务器上捕获数据包,那么您可能会看到 TCP 发送的数据段大于 MTU。然而,线路上的数据包仅具有 MTU 大小。您可以通过在网络设备(交换机)等上捕获来验证这一点。或者,在远程(客户端)计算机上捕获数据包将显示每个数据包 <= MTU 。
此行为是由于启用了 TSO/GSO 后,TCP 段被 NIC 硬件分割成 MTU 大小的数据包。由于 tcpdump 是在软件层捕获的,因此它会看到大于 MTU 的段被发送到 NIC 卡以进行进一步传输。
如果禁用 NIC 的 TSO/GSO,则您将看到所有传出数据包 <= MTU 大小(更可能是 pMTU 大小)。
If you are capturing packets on the server then you might see TCP sending out larger segments than the MTU. The packets on the wire, however, will be MTU size only. You can verify this by capturing on a network device (switch) etc. Alternatively, capturing packets on the remote (client) machine will reveal that each packet is <= MTU .
This behaviour is due to the fact that with TSO/GSO enabled, the TCP segment is split into MTU sized packets by the NIC hardware. Since
tcpdump
captures at the software layer, it sees segments larger than the MTU being sent to the NIC card for further transfer.If you disable TSO/GSO for the NIC, then you will see all outgoing packets to be <= MTU size (more likely pMTU size).
检查您是否混淆了 MSS 和 MTU。数据包大小受 MTU 限制,而不是 MSS。完整的 TCP 数据包包含 MAC 标头、IP 标头、TCP 标头、TCP 选项和有效负载。因此,TCP 数据包很可能大于 MSS。
Check if you are confusing MSS with MTU. The packet size is limited by MTU, not by MSS. A full TCP packet contains MAC header, IP header, TCP header, TCP options and payload. So, a TCP packet can well be greater than MSS.