互联网两层模型_互联网的各层

互联网两层模型

In this post I’ll be discussing something most people don’t usually think about: how the internet works. We can open a browser and access more content than we could ever consume in milliseconds, but have you ever stopped to think about how that content is delivered to your computer? It almost seems magical, but there is a vast, complex, and mostly invisible infrastructure that exists to make the internet as we know it possible.

在这篇文章中,我将讨论大多数人通常不会想到的事情:互联网的工作方式。 我们可以打开一个浏览器,访问的内容超过了数毫秒内可以消耗的内容,但是您是否停下来考虑如何将这些内容传递到您的计算机上? 几乎看起来很神奇,但是存在着庞大,复杂且几乎看不见的基础设施,这些基础设施使我们所知道的互联网成为可能。

At its most basic, the internet is just a giant network of networks. Your local network at home might consist of a couple of computers or other devices, but your router connects your local network with the whole internet. When you connect your device to this network you gain access to about 75 million servers that host websites, as well as the ability to message the approximately 5 billion devices that are connected to the internet through email or other services. When you type a URL into your browser, your browser identifies the server that hosts the page your are trying to access, requests the page from the server, and displays the page in a format that you can understand. This is a good starting point for understanding the internet, but it doesn’t explain the details of how the data is actually transferred. That is what I hope to explain in the rest of this post.

从根本上说,互联网只是一个庞大的网络网络。 您在家中的本地网络可能包含几台计算机或其他设备,但是路由器将您的本地网络与整个Internet连接起来。 当您将设备连接到该网络时,您将可以访问托管网站的约7500万台服务器,并能够通过电子邮件或其他服务向大约50亿台连接到Internet的设备发送消息。 在浏览器中键入URL时,浏览器将标识承载您尝试访问的页面的服务器,从服务器请求该页面,并以您可以理解的格式显示该页面。 这是理解Internet的一个很好的起点,但是没有解释数据实际传输方式的详细信息。 我希望在本文的其余部分中对此进行解释。

Protocols are what make communication on the internet possible. In the context of the internet, protocols are a set of rules that govern the exchange of data. If each device had its own set of rules it would be impossible to communicate, so protocols were developed so that each device knows how to communicate with other devices. To aid in my explanation I’ll be using the TCP/IP model of the internet, which breaks these protocols into four layers.

协议使互联网上的通讯成为可能。 在Internet的上下文中,协议是一组控制数据交换的规则。 如果每个设备都有自己的规则集,将无法通信,因此开发了协议,以便每个设备都知道如何与其他设备通信。 为了帮助解释,我将使用Internet的TCP / IP模型,该模型将这些协议分为四层。

  1. Application

    应用
  2. Transport

    运输
  3. Internet

    互联网
  4. Link

    链接

Each layer has its own set of protocols that determines how to communicate, and data will go through all four layers on its journey through the internet.

每一层都有其自己的一组协议,这些协议确定如何通信,数据将在其通过互联网的过程中经过所有四个层。

应用层 (Application Layer)

The application layer is concerned with the transfer of data between applications or processes that are running on computers. The two applications in question are usually the browser (how you access web pages), and the server (a program that responds to requests for resources). The protocol that governs these interactions is HTTP, or Hypertext Transfer Protocol. When sending a message following the rules of HTTP, there are 3 required components: method, path, and host header. The method describes the type of communication taking place. The most common methods are GET, which is for retrieving data, and POST, which is for submitting data. The path is what tells the server which resource you are requesting, and can be seen after the / in a URL. The host refers to where the resource is located, such as medium.com. Once the server receives this request, it will respond with a status code, such as 200 OK or 404 Not Found. If everything went well, it will also include the resource that was requested.

应用程序层与计算机上运行的应用程序或进程之间的数据传输有关。 有问题的两个应用程序通常是浏览器(如何访问网页)和服务器(响应资源请求的程序)。 控制这些交互的协议是HTTP或超文本传输​​协议。 按照HTTP规则发送消息时,需要3个必需的组件:方法,路径和主机头。 该方法描述了发生的通信类型。 最常用的方法是GET(用于检索数据)和POST(用于提交数据)。 该路径告诉服务器您正在请求哪个资源,并且可以在URL中的/后面看到。 主机指的是资源所在的位置,例如medium.com。 服务器收到此请求后,将以状态码响应,例如200 OK或404 Not Found。 如果一切顺利,它还将包括所请求的资源。

All of these requests are sent and received as plaintext, which makes things simple but is also not secure. That’s where HTTPS, or secure HTTP comes in. HTTPS uses the same protocols described above, but also uses TLS for security. TLS stands for Transport Layer Security and enables data to move securely through the transport layer after leaving the application layer. Security services provided by TLS include encryption, authentication, and integrity. The encryption is provided through a process called the TLS handshake. This communication happens before the actual data is exchanged, and enables the client (your browser) and the server to share a key for encryption and decryption of data. During the TLS handshake, the server also sends the client a certificate to authenticate the identity of the server. Finally, to ensure that no data is lost in transmission, the message includes a Message Authentication Code. This code is created from the data being sent using a hashing algorithm, and the client recreates this code from the data it received using the same hashing algorithm. As long as the two codes match, no data was lost or tampered with.

所有这些请求都以纯文本形式发送和接收,这使事情变得简单但也不安全。 这就是HTTPS或安全HTTP出现的地方。HTTPS使用与上述相同的协议,但也使用TLS来确保安全性。 TLS代表传输层安全性,它使数据在离开应用程序层后可以安全地在传输层中移动。 TLS提供的安全服务包括加密,身份验证和完整性。 通过称为TLS握手的过程提供加密。 这种通信发生在交换实际数据之前,并使客户端(您的浏览器)和服务器共享用于加密和解密数据的密钥。 在TLS握手期间,服务器还会向客户端发送证书以验证服务器的身份。 最后,为了确保在传输中不会丢失任何数据,该消息包括消息验证码。 该代码是使用哈希算法从发送的数据中创建的,客户端使用相同的哈希算法从接收到的数据中重新创建此代码。 只要两个代码匹配,就不会丢失或篡改数据。

传输层 (Transport Layer)

After leaving the application layer the data moves to the transport layer. The transport layer is concerned how to get the data to the right application once it arrives at the host. This is accomplished through the use of a network port, which is an identifier for a specific process running on a host. TCP is the most common protocol at this layer, and works by first establishing a connection with the server. This is established through what is called the TCP handshake where the client tries to reach the server with a brief message (SYN), the server acknowledges the message (SYN-ACK), and the client acknowledges the server’s message (ACK). Once the connection is established, the source and destination port numbers are attached to the original message from the application layer, and the message is sent. This process is known as encapsulation, because the original HTTP request is encapsulated in the TCP segment. This means that TCP doesn’t need to know anything about how HTTP works, it is just sending the message where it needs to go. You can think of it like putting a message in an envelope and writing the address on the outside. TCP provides some other features that make it more reliable such as delivering the message in order if it has to be broken into parts, ensuring that all parts are received through message acknowledgment, and retransmitting messages if no acknowledgment is received.

离开应用程序层后,数据移至传输层。 传输层关心的是一旦数据到达主机,如何将数据发送到正确的应用程序。 这是通过使用网络端口完成的,网络端口是主机上运行的特定进程的标识符。 TCP是该层上最常见的协议,它首先与服务器建立连接。 这是通过所谓的TCP握手建立的,在该过程中,客户端尝试通过简短消息(SYN)到达服务器,服务器确认该消息(SYN-ACK),然后客户端确认服务器的消息(ACK)。 建立连接后,源端口号和目标端口号将附加到来自应用程序层的原始消息中,并发送该消息。 此过程称为封装,因为原始的HTTP请求被封装在TCP段中。 这意味着TCP不需要了解HTTP的工作原理,它只是将消息发送到需要发送的地方。 您可以将其想象为在信封中放入邮件,然后在外面写地址。 TCP提供了其他一些使其更可靠的功能,例如按顺序传递消息(如果必须将其分成多个部分),确保通过消息确认接收到所有部分,以及在未收到确认的情况下重新发送消息。

互联网层 (Internet Layer)

Now that we know how data gets to the right application once it arrives at its destination host, how does it get there in the first place? The answer is through IP, which stands for Internet Protocol. This is the main protocol used at the internet layer, and is a protocol for moving data between networks. The message from the transport layer is now further encapsulated and has a source and destination IP address added to it. The IP address is a unique address assigned to each device on a network. Note that your device will have a different IP address if you connect to a different network, so it is not specific to your device. Each router has a list of IP addresses that it can connect to, and will forward the information where it needs to go. In order to obtain the destination IP address, a DNS lookup must be performed. DNS stands for Domain Name System, and DNS servers have a table that associates each webpage with an IP address. Once the destination IP address is obtained, the packet can be sent on its journey across the internet.

现在,我们知道数据到达正确的应用程序后如何到达正确的应用程序,它如何首先到达那里? 答案是通过IP表示的,它代表Internet协议。 这是在Internet层使用的主要协议,并且是用于在网络之间移动数据的协议。 现在,来自传输层的消息被进一步封装,并添加了源IP地址和目标IP地址。 IP地址是分配给网络上每个设备的唯一地址。 请注意,如果您连接到其他网络,则设备将具有不同的IP地址,因此它不是特定于您的设备的。 每个路由器都有一个可以连接的IP地址列表,并将信息转发到需要的位置。 为了获得目标IP地址,必须执行DNS查找。 DNS代表域名系统,DNS服务器具有一个表,该表将每个网页与IP地址相关联。 一旦获得了目的IP地址,就可以在互联网上发送数据包。

链接层 (Link Layer)

This is the lowest layer, and is closest to the physical layer consisting of electrical signals, light signals, or radio waves traveling across a physical distance. The link layer is concerned with how to identify devices on the network, and moving the data between them. In order to identify devices, a MAC address is used. MAC stands for Media Access Control, and is a unique code that is assigned to a device when it is manufactured. Unlike an IP address, this will stick with your device wherever you go. The entire message from the internet layer is encapsulated for the final time, and has the source and destination MAC address attached to it. You may be wondering how your computer is able to obtain the MAC address of a device on the other side of the world. The answer is, it doesn’t. Instead, it obtains the MAC address of the next device it is traveling to. Once it arrives there, it will remove source and destination MAC addresses, and update them to the new ones. This process will be repeated many times as the data passes through different devices on its journey.

这是最低的层,并且最接近由物理距离传播的电信号,光信号或无线电波组成的物理层。 链路层与如何识别网络上的设备以及如何在它们之间移动数据有关。 为了识别设备,使用了MAC地址。 MAC代表媒体访问控制,并且是在制造设备时分配给该设备的唯一代码。 与IP地址不同,无论您身在何处,它都将始终随身携带。 来自Internet层的整个消息在最后一次被封装,并带有源和目标MAC地址。 您可能想知道您的计算机如何能够获取世界另一端的设备的MAC地址。 答案是,不是。 取而代之的是,它获取要移动到的下一个设备的MAC地址。 一旦到达那里,它将删除源和目标MAC地址,并将它们更新为新的。 当数据在传输过程中通过不同的设备时,此过程将重复很多次。

Once the message arrives at its final destination, it will go through all of the layers in reverse until the server receives the original HTTP request from your browser. Although there are many more details involved, this is a basic overview of how data travels through the internet. I hope this has given you a better understanding of the what is happening under the hood each time you access a web page. Next time you’re watching a funny cat video, take a minute to pause and marvel at everything that took place to get it on your screen.

邮件到达其最终目的地后,它将反向遍历所有层,直到服务器从您的浏览器收到原始HTTP请求。 尽管涉及更多细节,但这是数据如何通过Internet传输的基本概述。 我希望这可以使您更好地了解每次访问网页时幕后发生的事情。 下次您观看有趣的猫咪视频时,请花一分钟时间暂停一下,并惊叹于将其显示在屏幕上所发生的一切。

翻译自: https://medium.com/dev-genius/the-layers-of-the-internet-5546b481d848

互联网两层模型

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值