当前位置:网站首页>Xiaobai can also understand how the basic network 03 | OSI model works (classic push)
Xiaobai can also understand how the basic network 03 | OSI model works (classic push)
2022-06-27 09:41:00 【BOGO】
Hello, everyone ! I'm BOGO !
introduction
Welcome to the online world ,《 Xiaobai can also understand the network foundation 》 This series of articles will help you build the basics of the web from scratch . If you haven't touched the Internet at all , Then we are the same , We must have encountered the same problem in our study ! Write these articles on the one hand to record their own learning process , On the other hand, I also hope to help my friends who also want to learn the basics of the network .
Part of the content and material of the article is from 【Youtube platform 】 Of 【Network Direction】 Released a series of videos to learn and collect , Translation is not easy , Some content may not be perfect , There may even be some flaws , I will try my best to make the content easy to understand , The coverage is comprehensive . If you find any problems , I hope you can tell me by message or private letter , Thank you very much ! Of course , I will correct it as soon as possible .
In every subsequent article , I would regard my friends who read articles as little white people who have no network experience at all , My goal is to build a solid network foundation with zero foundation Xiaobai , Please skip this series of articles .
Let's start our journey on the Internet !
One 、OSI Model
1. Dialogue in history
Dialogue in history
If you worked in the network Department of a company earlier , You may hear such a telephone conversation :
Network management :「 Hello , Here is IT department , Have you ever tried to restart ……」;
staff :「 No, , My problem is the server , I can't even fix it 」;
Network management :「 well , It sounds like the number 3 Layer problem , I am not responsible for this , Worship ……」.
This is the dialogue content of the historical technical support telephone , This IT The network management of the department mentioned the problem of which layer , In fact, what he said is OSI A layer of the model , But what does that mean ? Why OSI The model , What is the significance of its existence ? Next , We will discuss this problem .
Internet world
2.OSI How the model was born
Through the previous content , We have learned , All devices on the network have the characteristics of network hardware and software , They need a common rule , In order to achieve friendly exchanges between each other .
Reach an agreement
Who is the unknown support for their communication with each other ? I believe you already know , yes 「 agreement 」. They all follow the same set of 「 Rules of agreement 」, In this way , The communication between them is unimpeded . It should be noted that ,「 agreement 」 Not just one , In different places , We will apply it to different 「 agreement 」, The effect is not the same , And some 「 agreement 」 It requires collaboration to complete the work .
ISO International Organization for Standardization
With the development of the times ,「 agreement 」 More and more , We want to understand that the specific content of one of these agreements is becoming more and more complex . To solve this problem , A place called 「ISO」 Of 「 International Organization for Standardization 」 These regulations have been sorted out and planned , It is convenient for different people to understand different protocols , This is it. 「OSI Model 」.( for example : Agreements between countries can be classified as trade agreements 、 Medical agreement 、 Military agreements 、 Construction agreement, etc , People engaged in relevant work only need to understand the contents of the agreement related to themselves )
The same is true in the Internet ,「 Network protocol 」 The layering of is also for this purpose , That is to divide the huge network into different levels , So that different roles can follow the same 「 agreement 」 Produce software or hardware that can work together .
It may be said that these concepts are still incomprehensible , ad locum , We take real cases in life to explain : Suppose we write a letter , The letter was written until the other party saw it , What are the steps to go through ?
2.1 A model for sending letters
- write letters
- Put it in an envelope
- Fill in the address
- Stamp
- Put the mail in the mailbox
- The post office staff picked up the letter , Divide it by region , Truck to the regional post office
- The local postman picked up the letter , And finally delivered to the other hand
The steps of sending a letter
In this way , We've built a 「 A model for sending letters 」, The model describes how each link works together , And finally realize the delivery of letters . In the process , Some details will change with the actual situation , for example :
2.2 Changes in the model
- Mailing letters / The parcel
- Use envelope / packing box
- Mail local / The international
- Put up stamps / Other payment methods
- Post Office / P.O. Box / Bicycle messenger
- truck / The plane / train / A ship or its conveyance
- House / company / P.O. Box
Changes in the model
Although we don't need to know every detail of it , But it can help us understand more quickly 「OSI Model 」 Core concept of , and 「OSI Model 」 Customers have helped us understand the network more deeply .
therefore , Through this model, we can understand the whole process that we have never known , meanwhile , It can help us understand the details of each process ! and , If the letter is lost , We can trace it back to a specific link , And only solve the problems in this link .
The same is true of the network model , It can help us understand the operation process of the whole network , So that we can find the location of the problem , Facilitate troubleshooting ; meanwhile , It also facilitates the learning of those who have not been exposed to the Internet .
3.OSI Model hierarchy
OSI A model is a network model , We divide it into seven layers , Namely :
- application layer 【 The seventh floor 】(Application)
- The presentation layer 【 The sixth floor 】(Presentation)
- The session layer 【 The fifth floor 】(Session)
- Transport layer 【 The fourth level 】(Transport)
- The network layer 【 The third level 】(Network)
- The link layer 【 The second floor 】(Data Link)
- The physical layer 【 first floor 】(Physical)
OSI Seven layer model
You may notice , There is no Ethernet layer in the seven layer model 、 There are no cables or fiber layers , The reason is ,「OSI Model 」 Not related to specific technologies , Just like the mail model above , It just tells us what process to follow to send a letter , Which manufacturer's stationery is used 、 The envelope , And what means of transportation to use is not directly related to the model .
Maybe we will ask again , What exactly is the model used for ? We can explain it this way , Similar to Ethernet 、 Cables or optical fibers can be specific to 「OSI Model 」 A layer of , For example, Ethernet belongs to the data link layer , The solution of how to connect and build Ethernet is detailed in the rules of this layer ;
Cables or optical fibers belong to the physical layer , If this kind of network cable wants to seamlessly connect with the interfaces produced by different manufacturers , Both cable manufacturers and interface manufacturers need to produce products according to the protocol specified in the physical layer .
4.OSI Model : The data transfer
Ethernet and cable are based on 「OSI Model 」 Make rules to work , In this way, you should understand . Here , Let's take a case study ,「OSI Model 」 How the layers work together .
The data is in OSI Transfer process
In this case , We have two hosts for testing , Namely 「 host A」 and 「 host B」, We use it 「 host A」 Prepare a message , Pass it on to 「 host B」, In this transmission process ,OSI What kind of work is involved in each layer of the ?
4.1 application layer
The emergence of data starts from the application layer ,( For example, using 「 host A」 adopt FTP towards 「 host B」 Transfer a file message ) Applications belong to the content of the application layer ( for example :QQ、 WeChat 、Web Browsers and so on belong to the application layer ); When the application is ready for information , You can pass to the presentation layer .
The data content
4.2 The presentation layer
After the presentation layer receives the file information from the application layer , Will convert the data to be able to communicate with the receiver 「 host B」 The system format is compatible with and suitable for the transmission format ( The presentation layer may encrypt the data 、 Compress 、 Coding and other operations , in any case , This is to cater to 「 host B」), Operation completed , The data is passed to the session layer .
The data content
4.3 The session layer
After the session layer receives the data information from the presentation layer , Be responsible for setting up and maintaining the communication connection between two computers during data transmission , To ensure that this connection will not cause unnecessary trouble due to interruption . After establishing the session connection , Data continues to flow down .
The data content
4.4 Transport layer
Although it seems that the upper three layers have processed a large amount of information , But there may be some problems , For example, the file passed by the application layer is a very large file , Once the connection of the session layer is interrupted during the transmission , This means that we need to retransmit this file , This becomes very troublesome .
If we can split the large file into small pieces for transmission , This problem is solved easily . This is the credit of the transport layer , It can control the flow of data transmission , That is, large files are divided into multiple blocks for transmission . It's like we moved , One car can't fit , Then load more cars , Then let these cars start at the same time , At the same time , To avoid road congestion , It can also select multiple paths for transmission , This is the traffic control of the transport layer 、 Avoid congestion and multiplexing .
meanwhile , The transport layer will also add a to the data 「 Source port 」, On the one hand, tell the other party where the information comes from , On the one hand, let information know where they are going ( for example : I use Google Visit Baidu website by browser , Here we will add Google And Baidu server ).
[ Source port ]
| The data content
4.5 The network layer
The problem of data transmission has been solved , I wonder if you still remember the last chapter 」 Cases of local and remote information printing 「, If the information we want to transmit is received by a remote host , You need to rely on it ip Address to determine the remote network segment . So the network layer will add one to the data 「 Source ip Address 」, Add another 「 Purpose ip Address 」, This solves the problem of where the data comes from , The question of where to go ~
[ Source order ip Address ]
| [ Source port ]
| The data content
4.6 Data link layer
The network layer solves the problem of remote network segment , However, the data cannot be transferred to the machine under the network segment , therefore , The data link layer will 「 host A」 and 「 host B」 Of 「MAC Address 」 And then add , This is it. 「 Source MAC Address 」 And 「 Purpose MAC Address 」, With this unique brand ,「 host B」 Even if it turns into ash, it can't escape 「 host A」 Five finger mountain .
meanwhile , The data link layer adds a... At the end of the data 「FSC Frame check 」, Because our data retransmission layer may have been sliced , therefore , To check the integrity of data , That's it 「FSC Frame check 」.
[ Source order Mac Address ]
| [ Source order ip Address ]
| [ Source port ]
| The data content
| [FSC Frame check ]
4.7 The physical layer
Data is passed through OSI Six layers of tempering , The last layer is still needed to transmit the information , As long as it can meet the data format requirements of this last layer , The physical layer will prepare a way for us , And send the data out . What format of data does the physical layer recognize ?01 Code
, Whether it's an electrical signal or an optical signal , Can only pass this type of data , therefore , The physical layer converts the data into 01 Code
And realize data transmission .
100111010111010110110100001101101011
Data from host A
Pass on to host B
5.OSI Model : Data reception
Pass the previous section , We already know , Data is born from the application layer , Layers of packaging , Finally, the data is sent to another device through the physical layer , The device that receives the data , That is to say 「 host B」 How to deal with this data ?
5.1 The physical layer
received 「 host A」 It's from 01 Code
, And parse the code , Convert it into the data format required by the data link layer .【 here , The data has been converted to a data format recognized by the data link layer 】
100111010111010110110100001101101011
5.2 Data link layer
The data link layer receives the data parsed by the physical layer , And first 「FSC Frame check 」, Check the integrity of the data , Then determine 「 The goal is MAC Address 」 Whether it is right , Final stripping 「 Source order MAC Address 」 And 「FSC Frame check 」 Content , Then the processed data frame is handed over to the network layer .【 here , Have gone through MAC Address find target device 】
[ Source order Mac Address ]
| [ Source order ip Address ]
| [ Source port ]
| The data content
| [FSC Frame check ]
5.3 The network layer
The network layer receives the compiled data packets from the link layer , Confirm the goal ip After the address is correct , be stripped 「 Source order ip Address 」, And send the processed packets to the transport layer .【 here , The target device has been identified ip Address 】
[ Source order ip Address ]
| [ Source port ]
| The data content
5.4 Transport layer
The transport layer continues to unseal packets after receiving them , see 「 Target port 」 Is it unblocked , After confirmation , be stripped 「 Source and destination port information 」, And hand the processed data to the session layer .【 here , What applications have been determined to transfer data to the target computer 】
[ Source port ]
| The data content
5.5 The session layer
After the session layer gets the data , You need to establish a session connection with the corresponding application according to the port , And maintain this connection , Continue to hand over the data to 「 The presentation layer 」.
The data content
5.6 The presentation layer
「 The presentation layer 」 After receiving the data , The data needs to be further decoded , To ensure that the application can recognize the data content , After decoding successfully , Give the data to the application layer .
The data content
5.7 application layer
「 host B」 Finally received 「 host A」 Messages sent .
The data content
Data unpacking
6. partnership
Through the analysis of the above model , We will learn that ,OSI Each layer of the seven layer architecture has its own work , At the same time, each layer should keep close contact with its upper layer , To ensure that there are no problems . The division of labor between levels is clear , There will be no conflict of work . therefore , Different tasks that need to be done using different protocols will become easier to perform .
problem :
- High bandwidth applications result in network speed 「 Slow down 」, The problem lies on which floor ? How should we solve ?
- Please explain that the following contents are from OSI Which floor of the model
- FTP( File transfer protocol )
- Session Control Protocol( Session control protocol )
- Service Requests( Request service )
- JPEG( Image format )
- GIF( Image format )
- MPEG( Image format )
- SMTP( E-mail transmission protocol )
- TIFF( Image format )
- Telnet( Affiliated to the TCP/IP Protocol family )
- Flow Control( flow control )
- Connect the description to the correct OSI Model layering
- application layer Provide error free data
- Transport layer Used to send... On media / The hardware that receives the data
- The network layer End user services , for example Web Browsing and file transfer
- The physical layer Decide how to forward traffic along the path
Two 、HTTP Request example
In this section , Let's take another one to Web The server sends a request to the client to demonstrate , I believe it can deepen your understanding of OSI Further understanding of the model .
1. Write it at the front
How do we usually access web pages ? The answer is to use 「Web browser 」( Google 、 firefox 、 sogou ), Enter the address of a website in the browser , And then go back , This sends a 「HTTP request 」, Here, please pay attention to , Who is this request sent to ? The answer is 「Web The server 」, It can be understood as a computer host in a different place , And there are a lot of web files stored in this host .
We enter different domain names and addresses , Access to different hosts , such as , I typed https://sspai.com, This is the host that accesses the minority home , This host has received our request , Found that we want to see the minority homepage , therefore , It shows us the home page .
and https://sspai.com In fact, it is not the final form of the address , It is treated , Easy to remember website address , Its real address should be ip Address , for example 10.20.30.10, The domain name is only resolved to ip A name on the address , therefore , When we visit http://10.20.30.10/index.html When , It is also possible to access the home page of the minority .
HTTP request
2.HTTP Workflow
2.1 Top level agreement
HTTP Just a simple browser request , Then get the web page response from the server ? Of course not. , If we put HTTP Ask to put in OSI In the model , It can't even be simply put on a layer , Although it is often said that it should be a request from the application layer , But in fact it goes beyond OSI Multiple layers of the model , These layers are 「 application layer 」、「 The presentation layer 」、「 The session layer 」, We also call these three layers a 「 Top level agreement 」.
Top level agreement
When we click http://10.20.30.10/index.html When , It creates a request to send , And ensure that any special characters being sent are correctly encoded , here ,HTTP There is no real sense of the managing upper level conversations .
2.1【 Transport layer 】 Add source and destination ports
In the transport layer , We used a method called 「TCP」 To help us manage . In the last section, we have learned something about , The transport layer will judge the size of the data to be transmitted , If the data is large, it needs to be sliced or segmented , And the role of doing these things is TCP,TCP The first thing to do is to divide the data into several data segments , What will he do next ? Add... To these data segments, of course 「 Source port 」.
Add source and destination ports
HTTP It is usually used on the server side 80 port , This is where we use client-side browsing The target port to be accessed by the browser , therefore , Before these data segments ,「TCP」 Will add 「Dst Port:80」, meanwhile , In order to let the server know what browser we use to request , A source port will be added at the same time , That is to say 「Src Port:32768」, This 32768 May be other values , It varies according to the browser we use .
The source port and the target port are a segment 「 Request header 」, They are tightly attached to the request data .TCP This information will be stored in internal memory , This is why it can track and know which application is waiting for a response .
2.2【 The network layer 】 Add source item IP
Information arrives at the network layer , We need to use IP Address assisted addressing , stay URL In the address , We can know where the request is going to be sent ,10.20.30.10 Is the destination we requested , The information will be appended 「Dst IP:10.20.30.10」, meanwhile , In order to let the server know the requester's IP Address , A source will be appended at the same time IP Address , That is to say 「Src IP:172.16.0.1」, This source IP The address is not fixed , It varies according to the user's network environment .
Add source item IP
2.3 【 Data link layer 】 Add source item MAC Address
By looking at the above picture, it is not difficult to find , There is no direct connection between the client computer and the server , They are on different networks , So packets cannot be sent directly to the server , If you want to realize transmission , The data must be sent to the router in the data link layer , Then let the router forward the data for us .
Add source item MAC Address
Because we have Ethernet protocol , Want to transfer data from one network segment to another , You have to go through a router , therefore , We need to add the client computer network card to the data package MAC Address , That is to say 「Src MAC:AA:BB:CC:11:22:33」 And the router that helps us forward data MAC Address , That is to say 「Dst MAC:2A:34:D2:11:23:A1」, It should be noted that , Switches do not need to MAC Address . Of course , We also add a message for error correction at the end of the packet , This is it. 「CRC(Error Checking)」.
2.4 【 The physical layer 】 Data is sent to the router
Send data to the router through the physical layer
Last , Our client host is appending these 「 Header information 」 after , Finally, the data is sent to the router , When routers , here , We need the help of 「 The network layer 」「 Data link layer 」「 The physical layer 」 Work together , Put... In the packet 「 Source order MAC Address replacement 」, Also is to 「 Source MAC Address 」 From the original 「 Client host MAC Address 」 Replace with this 「 Router's own MAC Address 」, And then 「 Purpose MAC Address 」 Replace with 「 Server's MAC Address 」, thus , The router can realize data forwarding .
Router realizes data forwarding
2.5 Server side data processing
The server receives the data information forwarded by the router through the link layer , And check for errors , If there is no error, it will 「 Source order MAC Address 」 And 「CRC Error checking 」 Information stripping , And give the information to the network layer .
Peel off the source MAC Address
After the network layer receives , Determine the source and destination ip Is the address correct , After making sure the information is accurate , Then forward the information to the transport layer .
Peel off the source IP Address
Transport layer , Determine whether the source and destination port information is accurate , Then pass the data to the upper three layers , Let the application find the specified page according to the requested address , And use the script to get URL Perform subsequent processing on the corresponding parameters .
The transport layer splits the source and destination ports
边栏推荐
- HiTek电源维修X光机高压发生器维修XR150-603-02
- Demand visual Engineer
- Freemarker
- There is no doubt that this is an absolutely elaborate project
- 手把手带你玩摄像头模组
- Flow chart of Alipay wechat payment business
- How do I get the STW (pause) time of a GC (garbage collector)?
- The R language uses the preprocess function of the caret package for data preprocessing: Center all data columns (subtract the average value from each data column), and set the method parameter to cen
- Introduction to websocket protocol
- 高等数学第七章微分方程
猜你喜欢
谷歌浏览器 chropath插件
Understand neural network structure and optimization methods
Google browser chropath plug-in
When multiple network devices exist, how to configure their Internet access priority?
HiTek电源维修X光机高压发生器维修XR150-603-02
.NET 中的引用程序集
快捷键 bug,可复现(貌似 bug 才是需要的功能 [滑稽.gif])
TDengine 邀请函:做用技术改变世界的超级英雄,成为 TD Hero
ucore lab5
初步认识pytorch
随机推荐
通俗易懂理解朴素贝叶斯分类的拉普拉斯平滑
小白也能看懂的网络基础 03 | OSI 模型是如何工作的(经典强推)
How do I get the STW (pause) time of a GC (garbage collector)?
10 常见网站安全攻击手段及防御方法
Pakistani security forces killed 7 terrorists in anti-terrorism operation
微信小程序学习之五种页面跳转方法.
Advanced mathematics Chapter 7 differential equations
谷歌浏览器 chropath插件
最全H桥电机驱动模块L298N原理及应用
详细记录YOLACT实例分割ncnn实现
ucore lab3
Win10 add right-click menu for any file
MYSQL精通-01 增删改
Use CAS to complete concurrent operations with atomic variables
快捷键 bug,可复现(貌似 bug 才是需要的功能 [滑稽.gif])
This application failed to start because it could not find or load the QT platform plugin
js的数组拼接「建议收藏」
std::memory_ order_ seq_ CST memory order
[system design] proximity service
Hitek power supply maintenance X-ray machine high voltage generator maintenance xr150-603-02