当前位置:网站首页>Understand the encapsulation and de encapsulation of network model data
Understand the encapsulation and de encapsulation of network model data
2022-07-27 20:55:00 【Hua Weiyun】
Excerpt from :《 In depth understanding of computer networks 》 Wang Dazhu Mechanical industry press
IPv4 Please click here for datagram format
IPv4 Encapsulation and de encapsulation of datagrams
IPv4 Datagram encapsulation
Generated by the sender network layer IP Datagrams will continue to be transmitted down , After reaching the data link layer, it will be encapsulated into data frames .IP The data report “ Frame encapsulation ” The principle is simple , Just put the whole from the network layer IP The datagram ( Including header part and data part ) As the data part of the data link layer , Then add the protocol header corresponding to the data link layer to the front . Ethernet LAN , Because the data link layer is divided into LLC Sublayer MAC Sub layer protocol header encapsulation , Finally, Ethernet of data link layer is formed MAC frame , As shown in the figure below . In the frame header, we usually add the source and destination nodes MAC Address , Because the data link layer is through MAC Address address .

IPv4 The encapsulation and de encapsulation process of datagrams

The above is the case of passing through a network , If one IP When datagrams go through several networks in the whole transmission process , What shall I do? ? This is actually a de encapsulation process . Unpacking is to unpack the frame format of the data link layer into the original datagram format . When the source host sends a IP The encapsulation and unsealing process of datagrams passing through three networks connected by two routers is as follows ( The flow chart is shown in the figure above ):
1. When the source host sends a IP The data tell the time , On the intranet 1 The transmission in is in the form of frames , So first of all, we need to put the element IP Datagrams are encapsulated into frames , On the Internet 1 Transmission on the link in . Now put the original IP Datagram as a whole MAC The frame of “ data ” part , Then add the network 1 Header information of link layer protocol , As a frame header , Frame header 1.
2. When the frame is transmitted to the router 1 Connect to the network 1 When the interface of , It is equivalent to uploading frames from the data link layer to the network layer , So we need to unpack the original frame , Remove the header and footer information ( In the case of frame tail ), Restore the original IP The datagram , To identify the destination address information in the package , Then route forwarding is carried out according to the routing table information in the router . here IP The contents of datagrams have not changed , Include IP Source and destination address information in the header .
3. When IP Datagrams are on the router 1 From the network 1 Route to the network 2 after , It also needs to be on the network 2 The link layer of , So it has to be repackaged into frames , Still put the original whole IP Datagram as data part , But at this time, the network is added 2 The protocol header information of the link layer is used as the frame header , Frame header 2.
4. When the frame is transmitted to the router 2 Connect to the network 2 When the interface of , It is equivalent to moving from the data link layer to the network layer , So we have to unpack the frame , Still restore the original IP The datagram , Make the router 2 It can identify the destination address information in the package , This is the only router 2 In order to correctly route datagrams according to the information in its routing table 、 forward .
5. When IP Datagrams are on the router 2 From the network 2 To the network 3 after , It also needs to be on the network 3 The link layer of , So we have to reseal and unseal , Still put the original whole IP Datagram as data part , But at this time, the network is added 3 The protocol header information of the link layer is used as the frame header , Frame header 3.
6. When from the Internet 3 When the data link layer of transmits frames to the destination host , The frame will be unpacked on the destination host , Remove the head and tail of the frame , Restore the original IP The datagram , In order to get IP The real data in the datagram .
From the above process, we can see ,IP No matter how many networks the datagram goes through , The whole datagram content will not change , Including the source and destination address information of the header . What changes is only the frame header information transmitted on different network data links , That is, the frame sources transmitted on different network links MAC The address will change , Purpose MAC The address will not change .
边栏推荐
- 用户和权限限制用户使用资源
- 好开不贵,舒适安全!深度体验比亚迪宋Pro DM-i
- Flask Mdict builds online MDICT Dictionary Service
- Can tonghuashun open an account on weekends? Is it safe to open an account
- Swiftui view onReceive method receives "redundant" event resolution
- 用户组织架构的管理
- SQL高级技巧CTE和递归查询
- Users and permissions revoke user permissions
- 未定义变量 “Lattice“ 或类 “Lattice.latticeEasy“(Matlab)
- 认识传输介质通信方式
猜你喜欢
![[hierarchical reinforcement learning] HAC paper and code](/img/f5/d5f791d0f9da749eafa912be9dfbb5.png)
[hierarchical reinforcement learning] HAC paper and code

说透缓存一致性与内存屏障

【分层强化学习】HAC论文及代码

学术分享 | 清华大学 康重庆:电力系统碳计量技术与应用(Matlab代码实现)
![[Numpy] 数组索引和切片](/img/ce/34db7aef3fefe8a03e638d0838492f.png)
[Numpy] 数组索引和切片

After working for bytek for two years, he got 15 offers at one go

Hexagon_V65_Programmers_Reference_Manual(5)

Nailing development document

Why does Alibaba prohibit more than three forms from joining?

Jetpack compose performance optimization guide - compilation metrics
随机推荐
RK3399平台开发系列讲解(进程篇)15.36、理解进程和协程
IPv4/IPv6、DHCP、网关、路由
Some contents related to cmsis-rtos
R语言使用t.test函数执行t检验验证总体均值是否是某个特定的值(从样本集推论总体均值)
adb shell ls /system/bin(索引表)
How to calculate the execution time in the function resource usage when using the timer trigger type to process database data?
SQL高级技巧CTE和递归查询
R语言dplyr包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组加和值(sum)
全局样式与图标
Express WEB服务器的简单使用
Programmer growth Chapter 18: project launch
JVS基础介绍
Go --- automatic recompilation of air
认识网络模型OSI模型
Kingbasees heterogeneous database migration guide (4. Application migration process)
IM即时通讯开发如何提升移动网络下图片传输速度和成功率
【深度学习】Pytorch Tensor 张量
[program life] "stage summary" - unwilling to be ordinary
Introduction to JVs Foundation
R语言dplyr包summarise_at函数计算dataframe数据中多个数据列(通过向量指定)的计数个数、均值和中位数、使用list函数指定函数列表(使用.符号和~符号指定函数语法purr)