为什么分片是在 IP 上完成的,为什么不在 TCP/UDP 上完成

发布于 2024-07-25 06:32:32 字数 184 浏览 6 评论 0原文

我正在寻找为什么碎片在 IP 级别完成但为什么不在 TCP/UDP 级别完成的原因。

假设我的帧看起来像这样 |MAC|IP|TCP|Payload|FCS。 整个大小,例如:1600。PathMTU 发生在这里,为什么在 IP 级别实现分段是我的问题,为什么不在 TCP/UDP 级别/代码实现。

预先感谢。

I am looking for the reason Why Fragmentation is Done at IP level but why not for TCP/UDP.

Suppose say my frame looks like this |MAC|IP|TCP|Payload|FCS. the whole size if say for eg: 1600. PathMTU happens here, why fragmentation is implemented @ IP level is my question and why not implemented @ TCP/UDP level/code.

Thank in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

嗼ふ静 2024-08-01 06:32:33

如果在更高层(TCP、UDP 等)上执行分片,那么这将使分片/重组冗余实现(每个协议一次); 如果在较低层(以太网、ATM 等)上执行分段,则需要在每一跳上执行分段/重组(可能成本相当高)并冗余实现(每个链路层协议一次)。 因此,IP层是分片效率最高的一层。

If fragmentation were performed on higher layers (TCP, UDP, etc.) then this would make fragmentation/reassembly redundantly implemented (once per protocol); if fragmentation were performed on a lower layer (Ethernet, ATM, etc.) then this would require fragmentation/reassembly to be performed on each hop (could be quite costly) and redundantly implemented (once per link layer protocol). Therefore, the IP layer is the most efficient one for fragmentation.

各自安好 2024-08-01 06:32:33

对 TCP 进行分段的意义不如对 UDP 进行分段的意义。 由于 TCP 提供了一种可靠的分段/重组/重传机制,因此可以只发送较小的 TCP 分段并避免分段的全部必要性(这就是 d3jones 所说的)。

然而,在 UDP 中,分段仍然有意义。 您可以发送长度大于 MTU 的单个 UDP 段。 IP层会正确且不可见地对其进行分段。 应用程序开发人员无需确定 MTU 或任何有关网络的信息即可对应用程序层协议进行编码。

It makes less sense to fragment TCP than it does to fragment UDP. Since TCP provides a reliable segmentation/reassembly/retransmission mechanism, one can just send smaller TCP segments and avoid the whole necessity for fragmentation (this is what d3jones is talking about).

In UDP, however, fragmentation still makes sense. You can send a single UDP segment greater in length than the MTU. The IP layer will fragment it correctly and invisibly. The application developer doesn't have to determine the MTU or anything about the network in order to code the application layer protocol.

白况 2024-08-01 06:32:32

这正是 TCP/IP 堆栈和 ISO/OSI 模型中的多层的用途。 TCP/UDP 是传输协议,它们不应该关心碎片 - 这不是它们的问题。 IP 层处理网络并处理分段,因为分段的大小取决于网络属性。 具有解决问题最佳条件的层确实解决了问题。

That's exactly what multiple layers in the TCP/IP stack and in ISO/OSI model are for. TCP/UDP are transport protocols and they shouldn't care of fragmentation - it's not their problem. The IP level deals with the network and it deals with fragmentation since size of fragment depends on the network properties. The layer that has best conditions for solving the problem does solve it.

萌酱 2024-08-01 06:32:32

一些 TCP 实现还确定 MTU 并调整其段大小以避免分段。 这样做可以提高有损情况下的可靠性,因为接收到的任何 TCP 段都可以得到确认并且不会重新传输。 仅重传丢失的 TCP 段。 相反,如果任何 IP 数据报片段丢失,则不会收到有用的信息。

Some TCP implementations also determine the MTU and size their segments to avoid fragmentation as well. Doing so improves reliability under lossy conditions, as any TCP segment that is received can be acknowledged and not retransmitted. Only lost TCP segments are retransmitted. In contrast, if any IP datagram fragment is lost, then no useful information is received.

空心空情空意 2024-08-01 06:32:32

第 4 层 (TCP/UDP) 仅在端点(发送方/接收方)出现。
第 3 层 (IP) 进入每跳图像。

MTU 是链路的一个属性,但基于此链路属性 (MTU) 的分段始终在路由器(跳)的 IP 层完成

现在每个跳之间的链路可以具有不同的带宽,因此在每个跳必须决定如何将数据包转发到目的地。 由于 MTU 是可以推送到链路上的最大数据量,如果它小于要发送的数据包的大小,则必须将其分成更小的块以适应链路。

由于碎片和重组有很多缺点,例如
1.CPU和内存开销小幅增加
2. 由于添加了片段标头,每个数据包的开销更大
3. 如果一个片段丢失,发送方必须传输整个数据包

要解决上述问题,
1. 可以使用路径MTU发现。
2. 在第 4 层,可以使用 TCP MSS 钳位。

Layer-4 (TCP/UDP) comes into picture only at the end points (sender/receiver).
layer-3 (IP) comes into picture per hop basis.

MTU is a property of the link, but fragmentation on the basis of this link property (MTU) always done at IP layer on a router (hop)

Now the link between each hop can be of different bandwidth, so at each hop it has to be decided how to forward the packet to the destination. As MTU is the maximum amount of data that can be pushed onto the link and if it it smaller than the size of packet to be send out, One has to fragment it into smaller chunks to accommodate onto the link.

As fragmentation and reassembly has many drawbacks like
1. small increase in CPU and memory overhead
2. more overhead per packet due to addition of fragment headers
3. If one fragment is lost sender has to transmit the entire packet

To solve above issues,
1. Path MTU Discovery can be used.
2. In Layer 4, TCP MSS-clamping can be used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文