网络数据传输中的封装与解封装详解

news2024/7/7 17:11:16

注:机翻,未校对。

The goal of networks is to transmit data from one host to another.
网络的目标是将数据从一个主机传输到另一个主机。

在这里插入图片描述

Encapsulation 封装

To achieve this goal, each layer adds its own header to the data. A header contains information specific for that layer, and it precedes the data itself.
为了实现此目标,每一层都会向数据添加自己的标头。标头包含特定于该层的信息,并且位于数据本身之前
在这里插入图片描述
Consider a case where we have a lookup service, used in order to find a person’s phone number, given the person’s name. The data consists of the person’s first and last name.
考虑一个案例,我们有一个查找服务,用于查找一个人的电话号码,给定这个人的名字。数据由此人的名字和姓氏组成。

Before the packet is sent, the fifth layer might add its own header, describing that this is a REQUEST packet. The header might also specify that this is a request to map from a person’s name to a phone number, and not vice versa.
在发送数据包之前,第五层可能会添加自己的标头,描述这是一个 REQUEST 数据包。标头还可以指定这是从人员姓名映射到电话号码的请求,反之亦然。

image-64

Header of the 5th layer, with data

Then, the fifth layer passes the data to the fourth layer. Note, that the fourth layer regards everything as data – ones and zeroes. It doesn’t care if the fifth layer added a header, or what is written inside that header.
然后,第五层将数据传递到第四层。请注意,第四层将所有内容视为数据——1 和 0。它不在乎第五层是否添加了标题,也不在乎该标题中写了什么。

The fourth layer then adds its own header. For instance, it might specify that the requested service is the names-and-phones service. It may also include a sequential number for the packet, so it can be identified later.
然后,第四层添加自己的标题。例如,它可能指定请求的服务是姓名和电话服务。它还可能包括数据包的序列号,以便以后可以识别。

image-65

Header of the 4th layer, with data which includes the 5th layer’s header

Afterwards, the fourth layer will pass the packet to the third layer. Again, the third layer will regard everything it has received – including the data itself, the header added by the fifth layer, and the header added by the fourth layer – simply as a chunk of data.
之后,第四层将数据包传递到第三层。同样,第三层将它收到的所有内容(包括数据本身、第五层添加的标头和第四层添加的标头)简单地视为数据块。

Then, the third layer will add its own header. For instance, it may include the source address and destination address of the packet.
然后,第三层将添加自己的标题。例如,它可能包括数据包的源地址和目标地址。

image-66

Header of the 4th layer, with data which includes the 4th layer’s header and data

This process goes on. So, each layer adds its own header to the packet*. This process is called encapsulation.*
这个过程还在继续。因此,每一层都会向数据包*添加自己的标头。此过程称为封装。

On the other end, the receiver gets the packet and needs to read and remove the headers.
在另一端,接收方获取数据包,需要读取和删除标头。

* The second layer may also include a trailer – an additional chunk of bits following the data, with some information.
* 第二层也可包括一个“尾部” —— 一组附加在数据后面的比特块,包含一些信息。

Putting it All Together 把它们放在一起

Now that we have covered the five layers, let’s have one example using all of them together.
现在我们已经介绍了这五个层,让我们举一个例子来同时使用它们。

在这里插入图片描述

Let’s say we would like to send a video file to our friend who lives in France, while we are enjoying a trip in Argentina. For that, we are using an email service.
假设我们想向住在法国的朋友发送一个视频文件,而我们正在阿根廷旅行。为此,我们正在使用电子邮件服务。

The fifth layer defines how the email will be transmitted. For example, it includes the email address of the sender, as well as the receiver. It contains a title, and the body of the message. It requires that we follow a specific template of an email address, that will be included in the header of this layer.
第五层定义了电子邮件的传输方式。例如,它包括发件人和收件人的电子邮件地址。它包含标题和邮件正文。它要求我们遵循电子邮件地址的特定模板,该模板将包含在此图层的标题中。

image-63

The five layers model, with an example of sending an email

Then, the fifth layer uses the fourth layer in order to split the email into chunks. Of course, each chunk will also carry the fourth layer’s header. It is also used in order to specify that we are currently using an email service.
然后,第五层使用第四层将电子邮件拆分为块。当然,每个块也将携带第四层的标题。它还用于指定我们当前正在使用电子邮件服务。

In this case, we definitely want the connection to be reliable – so the receiver will be able to play our video file correctly. Thus, the fourth layer will also handle reliability. On the receiver’s end, it might send an acknowledgment packet for every packet it receives.
在这种情况下,我们绝对希望连接可靠——这样接收器才能正确播放我们的视频文件。因此,第四层也将处理可靠性。在接收方端,它可能会为接收的每个数据包发送一个确认数据包。

The third layer will define the best route for every packet to be sent. It might choose different routes for different packets. Among other things, its header will contain the source and destination addresses for the packet.
第三层将为要发送的每个数据包定义最佳路由。它可能会为不同的数据包选择不同的路由。除其他事项外,其标头将包含数据包的源地址和目标地址。

The second layer will be responsible for every link between two directly connected devices. Its header will include the MAC addresses for each device.
第二层将负责两个直接连接的设备之间的每个链接。其标头将包括每个设备的 MAC 地址。

The first layer is responsible for encoding all the ones and zeros, and to pass them over the line. And then, decoding and reading those ones and zeroes on the other end. On this layer, we don’t really have a header, as it consists of single bits only.
第一层负责对所有 1 和 0 进行编码,并将它们传递到行上。然后,解码并读取另一端的 1 和 0。在这个层上,我们实际上没有标头,因为它只由单个位组成。
在这里插入图片描述

Summary 总结

This way, every layer uses the services provided by the lower layers, and the huge problem of transmitting data over the network becomes doable. How amazing is that?
这样一来,每一层都使用下层提供的服务,通过网络传输数据的巨大问题就变得可行了。


via: Omer Rosenbaum OCTOBER, 2022

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1894307.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

2024年7月5日 十二生肖 今日运势

小运播报:2024年7月5日,星期五,农历五月三十 (甲辰年庚午月庚午日),法定工作日。 红榜生肖:狗、羊、虎 需要注意:鸡、牛、鼠 喜神方位:西北方 财神方位:正…

深圳合规新动向,这个关键环节要做好

随着全球商业环境的日益复杂化,企业合规管理已成为维护公司稳健运营和市场竞争力的核心要素。特别是对于位于创新前沿的深圳市,有效的合规管理系统不仅是满足法律和监管要求的必须,更是企业可持续发展的关键。 深圳市在全国率先探索并成功实…

#数据结构 笔记三

二叉树 1. 概念 二叉树Binary Tree是n个结点的有限集合。它或者是空集n0,或者是由一个根结点以及两颗互不相交、分别称为左子树和右子树的二叉树组成。 二叉树与普通有序树不同,二叉树严格区分左子和右子,即使只有一个子结点也要区分左右。…

cloudreve 设置开机服务

创建一个Systemd服务文件: 打开终端并创建一个新的服务文件: sudo nano /etc/systemd/system/cloudreve.service 在服务文件中添加以下内容: 根据你的设置调整路径和参数,然后将以下配置粘贴到文件中: [Unit] Descri…

二分查找及其变种

一、概念 二分查找算法(Binary Search Algorithm)是一种在有序数组中查找特定元素的高效搜索方法。 其基本思想是将目标值与数组中间的元素进行比较,如果目标值等于中间元素,则查找成功;如果目标值小于中间元素&…

指标和量化交易那些事儿

最近很多朋友都在给我说,我要盘中打板的指标,我要盘中自动交易。今天我们来梳理下关于指标和量化交易这些事儿! 第一:什么是指标?股票指标是属于统计学的范畴,依据一定的数理统计方法,运用一些…

2024 年 亚太赛 APMCM (C题)中文赛道国际大学生数学建模挑战赛 | 量子计算的物流配送 | 数学建模完整代码+建模过程全解全析

当大家面临着复杂的数学建模问题时,你是否曾经感到茫然无措?作为2022年美国大学生数学建模比赛的O奖得主,我为大家提供了一套优秀的解题思路,让你轻松应对各种难题! 完整内容可以在文章末尾领取! 该段文字…

PyTorch - 神经网络基础

神经网络的主要原理包括一组基本元素,即人工神经元或感知器。它包括几个基本输入,例如 x1、x2… xn ,如果总和大于激活电位,则会产生二进制输出。 样本神经元的示意图如下所述。 产生的输出可以被认为是具有激活电位或偏差的加权…

班迪录屏(Bandicam)7.0下载以及安装教程

最近有小伙伴私信我,问我有没有好用的录屏工具,今天给大家分享一个我一直在使用的录屏工具,也是解锁了V1P版本,绿色版打开就可以使用~ Bandicam录屏(PC) Bandicam录屏是一款专为捕捉屏幕精彩瞬间而设计的…

go——Swagger使用

一. 为什么后端需要配置Swagger 在前后端分离的项目中,后端配置swagger可以很好的帮助前端人员了解后端接口参数和数据传输。 Swagger是一个用于设计,构建和文档化API的开源框架。在Go语言中,Swagger可以帮助后端开发人员快速创建和定义RESTf…

电传动无杆飞机牵引车交付用户

自2019年起,我们计划做电传动控制,先后做了电传动水泥搅拌罐车罐体控制(国内首创),初步理解了电机控制的特点。 20-21年接着做了10t飞机牵引车控制,还是电液控制联合的,把越野叉车的行驶控制方…

Python学习之小游戏--坦克大作战

今天跟视频学习了Python实现坦克大作战小游戏,挺有意思的,一起来玩吧~ 按空格发射子弹,上下左右键实现移动,ESC键无限复活。 import pygame,time,random from pygame.sprite import Sprite SCREEN_WIDTH800 SCREEN_HEIGHT500 BG…

玩机进阶教程----MTK芯片杂牌机 小品牌机型解除bl锁以及root的操作步骤解析

在玩机过程中会遇到很多小品牌机型或者杂牌机类的。大多都使用mtk芯片。而且基本很少有官方线刷包。在这些机型中玩机首先我们要想办法导出系统来制作线刷包。以免后续解锁bl或者root出现未知故障可以恢复原系统。 那么对于这些机型该如何进行备份固件和root呢。通过博文可以初…

图书借阅小程序论文(设计)开题报告

一、课题的背景和意义 近些年来,随着移动互联网巅峰时期的来临,互联网产业逐渐趋于“小、轻、微”的方向发展,符合轻应用时代特点的各类技术受到了不同领域的广泛关注。在诸多产品中,被誉为“运行着程序的网站”之名的微信小程序…

开始尝试从0写一个项目--前端(一)

基础项目构建 创建VUE初始工程 确保自己下载了node.js和npm node -v //查看node.js的版本 npm -v //查看npm的版本 npm i vue/cli -g //安装VUE CLI 创建 以管理员身份运行 输入:vue ui 就会进入 点击创建 自定义项目名字,选择npm管理 结…

什么是多态(Polymorphism)

什么是多态(Polymorphism) 1、多态的基本概念2、多态的实现方式2.1 方法重载(Overloading)2.2 方法重写(Overriding)2.3 接口和抽象类 3、为什么要使用多态?4、结论 💖The Begin&…

启明智显Model3A芯片方案7寸高清触摸屏ZX7D00CM21S:开箱、设置与实操全攻略指南

一、背景 本指南将详细介绍启明智显的Model3A芯片方案下的7寸高清触摸屏ZX7D00CM21S的开箱步骤、基础设置以及实操应用。无论您是电子爱好者、开发者还是工程师,这份指南都能助您快速上手并充分利用这款触摸屏的各项功能。 二、硬件介绍 ZX7D00CM21S 7寸高清触摸屏是…

500mA、低压差、低噪声、超快、无需旁路电容的CMOS LDO稳压器RT9013

一般描述 RT9013 SOT23-5封装的外观和丝印 RT9013 是一款高性能的 500mA LDO 稳压器,具有极高的 PSRR 和超低压差。非常适合具有苛刻性能和空间要求的便携式射频和无线应用。 RT9013的静态电流低至25μA,进一步延长了电池的使用寿命。RT9013 也适用于低…

kafka的工作原理与常见问题

定义 kafka是一个分布式的基于发布/订阅模式的消息队列(message queue),主要应用于大数据的实时处理领域 消息队列工作原理 kafka的组成结构 kafka的基础架构主要有broker、生产者、消费者组构成,还包括zookeeper. 生产者负责发送…

【Android源码】Gerrit安装

前言 如果你打开 https://android.googlesource.com/platform/manifest,就会发现,google官方管理Android源码,使用的是Gerrit。Android系统源码是非常大的,用Git肯定是不适合。对于大型项目,得用Gerrit,今…