IP分片和重组 [英] IP Fragmentation and Reassembly

查看:256
本文介绍了IP分片和重组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在浏览网络幻灯片,并想知道是否有人可以帮助我解决碎片和重组的概念.

I am currently going through my networking slides and was wondering if someone could help me with the concept of fragmentation and reassembly.

我了解它是如何工作的,即由于网络链接具有MTU,因此如何将数据报拆分为较小的块.但是,图片中的示例使我感到困惑.

I understand how it works, namely how datagrams are split into smaller chunks because network links have a MTU. However the example in the picture is confusing me.

因此,前两个部分的长度为1500,因为这是MSU,但这是否不意味着最后一个部分应具有1000(总共4000字节)而不是1040?这些额外的40个字节是从哪里来的?我的猜测是,因为前两个片段都具有20字节的标头,所以这额外的40字节数据需要放在某个地方,所以它将到达最后一个片段?

So the first two sections show a length of 1500, because this is the MSU, but shouldn't this mean that the last one should have 1000 (for a total of 4000 bytes) and not 1040? Where did these extra 40 bytes come from? My guess is that because the previous two fragments both had a header of 20 bytes, this extra 40 bytes of data needed to go somewhere, so it will arrive in the last fragment?

Fragflag本质上意味着还有另一个片段,因此除了最后一个片段为零之外,所有片段的Fragflag均为1.但是我不明白什么是偏移量或如何计算.为什么第一个偏移量为零?为什么我们将数据字段(1480)中的字节除以8,以获得第二个偏移量?这8是哪里来的?除此之外,我假设每个片段的偏移量只会增加这个值吗?

Fragflag essentially means that there is another fragment, so all of them will have a Fragflag of 1 except the last fragment which will be at zero. However I don't understand what offset is or how it is calculated. Why is the first offset at zero? Why did we divide the bytes in the datafield (1480) by 8 to get the second offset? Where did this 8 come from? Aside from that, I am assuming that each fragments offset will just increase by this value?

例如,第一个片段的偏移量为0,第二个片段的偏移量为0,第三个片段的偏移量为370,第四个片段的偏移量为555? (370 + 185)

For example, the first fragment will have a offset of 0, the second 185, the third 370 and the fourth 555? (370+185)

感谢您的帮助!

推荐答案

每个数据包中都有一个20字节的标头.因此,原始数据包包含3,980字节的数据.片段包含1480、1480和1020字节的数据. 1480 + 1480 + 1020 = 3980

There is a 20 byte header in each packet. So the original packet contains 3,980 bytes of data. The fragments contain 1480, 1480, and 1020 bytes of data. 1480 + 1480 + 1020 = 3980

标头中的每一位都是宝贵的.将偏移量除以8可以使其适合13位而不是16位.这意味着,除最后一个包外,每个包都必须包含一定数量的数据字节,该字节是8的倍数.

Every bit in the header is precious. Dividing the offset by 8 allows it to fit in 13 bits instead of 16. This means every packet but the last must contain a number of data bytes that is a multiple of 8, which isn't a problem.

这篇关于IP分片和重组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆