简体   繁体   English

网络层TCP数据包的分片

[英]Fragmentation of TCP packet at network layer

Suppose that a TCP message that contains 900 bytes of data and 20 bytes of TCP header. 假设一个TCP消息包含900字节的数据和20字节的TCP标头。 Now If we have a link that can support a maximum frame size of 512 bytes, will we have 2 TCP packets at transport layer of small enough sizes that they could be sent over this link. 现在,如果我们有一个链接可以支持最大512字节的帧大小,那么在传输层上将有2个TCP数据包,它们的大小足够小,可以通过此链接发送。 Or will they be fragmented further at the Data link layer? 还是将它们在数据链路层进一步细分?

Which of the following will happen: 以下哪一项会发生:

Transport layer:    h1   data
Network layer:      h2 h1 data
data link layer:  frame 1 -  h3 h2 h1 data-part1
                  frame 2 -  h3 h2 h1 data-part2

OR 要么

data link layer:  frame 1 -  h3 h2 h1 data-part1
                  frame 2 -  h3 data-part2

Fragmentation is part of the DNA of IPv4, and it happens in layer-3 for IPv4. 碎片是IPv4 DNA的一部分,它发生在IPv4的第3层中。 IPv6 has eliminated fragmentation, and it is up to the sending host to only send packets of the correct size (pre-fragment the data). IPv6消除了碎片,发送主机只能发送正确大小的数据包(将数据预碎片化)。

Routers operate at layer-3 (Network Layer), and fragmentation happens in routers for IPv4. 路由器在第3层(网络层)运行,并且在IPv4路由器中会发生分段。 If IPv6 packets are too large for the next hop, they are unceremoniously dropped by the router, and an ICMPv6 message is sent back to the source host. 如果IPv6数据包对于下一跳而言太大,则路由器会毫不客气地将其丢弃,并将ICMPv6消息发送回源主机。

RFC 791, INTERNET PROTOCOL : RFC 791,互联网协议

The internet protocol also provides for fragmentation and reassembly of long datagrams, if necessary, for transmission through "small packet" networks. 互联网协议还提供了长数据报的分段和重组(如果需要),以便通过“小数据包”网络进行传输。

and

The internet protocol implements two basic functions: addressing and fragmentation. 互联网协议实现两个基本功能:寻址和分段。

and

In the routing of messages from one internet module to another, datagrams may need to traverse a network whose maximum packet size is smaller than the size of the datagram. 在将消息从一个Internet模块路由到另一个Internet模块时,数据报可能需要遍历最大数据包大小小于数据报大小的网络。 To overcome this difficulty, a fragmentation mechanism is provided in the internet protocol. 为了克服这个困难,在互联网协议中提供了分段机制。

The description of the fragmentation process: 碎片过程的说明:

Fragmentation 碎片化

Fragmentation of an internet datagram is necessary when it originates in a local net that allows a large packet size and must traverse a local net that limits packets to a smaller size to reach its destination. 当Internet数据报起源于允许大数据包大小的本地网络并且必须穿越将数据包限制为较小大小的本地网络到达目的地时,必须进行分段。

An internet datagram can be marked "don't fragment." 互联网数据报可以标记为“不要分段”。 Any internet datagram so marked is not to be internet fragmented under any circumstances. 如此标记的任何Internet数据报在任何情况下都不得进行Internet分段。 If internet datagram marked don't fragment cannot be delivered to its destination without fragmenting it, it is to be discarded instead. 如果标记为“不分段”的互联网数据报无法在不分段的情况下传递到其目的地,则应将其丢弃。

Fragmentation, transmission and reassembly across a local network which is invisible to the internet protocol module is called intranet fragmentation and may be used [6]. Internet协议模块不可见的跨本地网络的分段,传输和重组称为内部网分段,可以使用[6]。

The internet fragmentation and reassembly procedure needs to be able to break a datagram into an almost arbitrary number of pieces that can be later reassembled. Internet分段和重组过程需要能够将数据报分解为几乎任意数量的片段,以便稍后进行重组。 The receiver of the fragments uses the identification field to ensure that fragments of different datagrams are not mixed. 片段的接收者使用标识字段来确保不同数据报的片段不会混合。 The fragment offset field tells the receiver the position of a fragment in the original datagram. 片段偏移字段告诉接收者片段在原始数据报中的位置。 The fragment offset and length determine the portion of the original datagram covered by this fragment. 片段的偏移量和长度确定了此片段覆盖的原始数据报的部分。 The more-fragments flag indicates (by being reset) the last fragment. more-fragments标志指示(通过重置)最后一个片段。 These fields provide sufficient information to reassemble datagrams. 这些字段提供了足够的信息来重组数据报。

The identification field is used to distinguish the fragments of one datagram from those of another. 标识字段用于区分一个数据报的片段和另一个数据报的片段。 The originating protocol module of an internet datagram sets the identification field to a value that must be unique for that source-destination pair and protocol for the time the datagram will be active in the internet system. Internet数据报的始发协议模块将标识字段设置为对于该源-目的地对和协议必须唯一的值,以确保该数据报在Internet系统中处于活动状态。 The originating protocol module of a complete datagram sets the more-fragments flag to zero and the fragment offset to zero. 完整数据报的始发协议模块将more-fragments标志设置为零,并将片段偏移设置为零。

To fragment a long internet datagram, an internet protocol module (for example, in a gateway), creates two new internet datagrams and copies the contents of the internet header fields from the long datagram into both new internet headers. 为了分段较长的Internet数据报,Internet协议模块(例如,在网关中)将创建两个新的Internet数据报,并将Internet报头字段的内容从长数据报复制到两个新的Internet报头中。 The data of the long datagram is divided into two portions on a 8 octet (64 bit) boundary (the second portion might not be an integral multiple of 8 octets, but the first must be). 长数据报的数据在8个八位位组(64位)边界上分为两部分(第二部分可能不是8个八位位组的整数倍,但第一部分必须是)。 Call the number of 8 octet blocks in the first portion NFB (for Number of Fragment Blocks). 在第一部分NFB中调用8个八位位组块的数量(对于分块数量)。 The first portion of the data is placed in the first new internet datagram, and the total length field is set to the length of the first datagram. 数据的第一部分放置在第一个新的Internet数据报中,并且总长度字段设置为第一个数据报的长度。 The more-fragments flag is set to one. more-fragments标志设置为1。 The second portion of the data is placed in the second new internet datagram, and the total length field is set to the length of the second datagram. 数据的第二部分放置在第二个新的Internet数据报中,并且总长度字段设置为第二个数据报的长度。 The more-fragments flag carries the same value as the long datagram. more-fragments标志带有与长数据报相同的值。 The fragment offset field of the second new internet datagram is set to the value of that field in the long datagram plus NFB. 第二个新的Internet数据报的分片偏移字段设置为长数据报加NFB中该字段的值。

This procedure can be generalized for an n-way split, rather than the two-way split described. 可以将此过程推广到n向拆分,而不是所描述的双向拆分。

To assemble the fragments of an internet datagram, an internet protocol module (for example at a destination host) combines internet datagrams that all have the same value for the four fields: identification, source, destination, and protocol. 为了组装Internet数据报的片段,Internet协议模块(例如,在目标主机上)将Internet数据报的四个字段(标识,源,目标和协议)的值都相同。 The combination is done by placing the data portion of each fragment in the relative position indicated by the fragment offset in that fragment's internet header. 通过将每个片段的数据部分放置在该片段的Internet标头中的片段偏移量指示的相对位置来完成组合。 The first fragment will have the fragment offset zero, and the last fragment will have the more-fragments flag reset to zero. 第一个片段的片段偏移量将为零,而最后一个片段的more-fragments标志将重置为零。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM