First PageLast Page   

   
Next PageEnd Page
5 - 4 路由器、数据包的分解和再拼装

    这一整个过程在沿途各路由器周而复始,直至数据包抵达最终目的地。如果某路由器收到一个对它下面的网络而言过大的数据包,IP协议会把数据包分割成可操作的小块数据。当这些小数据包到达最终目的地时,IP协议又把这些数据块组装成原来的数据包。这一过程又称为数据包的分块和再组装。分块常常发生在传输媒介混合在一起的环境中,比如兼有以太网和令牌环网的网络。
    让我们看看这个过程是如何实现的。首先,路由器收到了符合IP协议的数据包。IP协议程序把这个数据包分割成三个小一点的数据包,并且为每个新数据包产生新的数据头。新数据包中包含:
  (1)一个标志。它表明还有其它小数据包紧随其后。
  (2)小数据包的标识符,以区分同属于一个大数据包的各个小数据包。还有小数据包的偏置量,以告知接收端主机如何再组装数据包。
    为所有三个小数据包都安排各自通往远方网络的路径。即使它们穿越了多个路径中的多个路由器,三个小数据包也只有在全部到达目标主机时才重新装配。当三个小数据包被远方主机的IP协议程序收到时,由于它们分割后各自的标识符而被识别为属于同一个大数据包。然后,根据每个小数据包在原来大数据包中的偏置量以正确的顺序把他们重新组装起来。最后,再把装配好的数据包向上传递到TCP协议或UDP协议程序。

The entire process is repeated at each router until the packet reaches its final destination. If a router receives a packet that is too large for the underlying network, IP will break the packet into manageable chunks. When the chunks arrive at their final destination, IP assembles the pieces into the original packet. This process is referred to as fragmentation and reassembly. Fragmentation often occurs in environments that have a mix of media such as Ethernet and Token Ring.
Let's look at how this works. An IP packet is received at the router. IP fragments the packet into three smaller packets. A new header is created for each new packet which includes:
  - a flag, to indicate that other fragments follow. A flag is not added to the last packet because no other fragments follow it.
  - a fragment ID to identify all fragments that belong together and a fragment offset to tell the receiving host how to reassemble the packet.
All three packets are routed to the remote network. Even if they travel through multiple routers packets are only reassembled when they reach the destination host. When the three packets are received by IP at the remote host, they are identified by the fragment ID as belonging together. Next, the fragment offset is used to reassemble them in the correct order. Finally, the reassembled packet is passed up the stack to either TCP or UDP.


BACK