当前位置:网站首页>[concept of network principle]
[concept of network principle]
2022-07-07 20:23:00 【DJL_ new_ life】
( Click jump )
List of articles
Network principle
Basic principle
User mode and kernel mode are just different areas of memory User mode -> Kernel mode : The process of copying data in memory
network card : Realize physical signal <-> Digital signal conversion
Data transmission between two hosts
User mode -> Kernel mode : The process of copying data in memory
Internal replication here It's code like this ( It's just like )
byte[] User mode = new byte[1024]; // Data to be sent
byte[] Kernel mode = new byte[1024]; // Kernel buffer
os.write( User mode );
for(int i = 0; i < bytes.length; i++){
Kernel mode [i] = User mode [i];
}
How to deal with the data sent by the network card ?
- Load the data into the network card : Replication of data
- Send data :fire()
- To send data, you need to change the data signal into a physical signal
The data is on the transmission medium ( Ethernet cable 、 Optical fiber ) Spread on ( Signal decay 、 Signal error and other problems )
When the data goes to another host , here CPU Stop the current execution cycle , Give Way CPU Execute a piece of code prepared in advance ( This is the interrupt processing flow ). Transfer the data from the corresponding location of the network card Copied to the Kernel memory
here , Only one network medium can be used to connect the two hosts , Data exchange can be realized from the perspective of hardware
How about the networking of multiple hosts ?
The basic structure of network topology : Bus type 、 Stars 、 ring 、 Tree form
agreement / layered
To complete the whole communication , The problems to be dealt with in the middle are still very complex . Therefore, it is very necessary to adopt division of labor and cooperation
When there is layering , You need to target each layer , Specify some specifications , Let everyone abide by , And then better complete the work .
These norms are authoritative , Under the network discipline , Call it agreement (protocal)
Network standard layering :
- Academic school :OSI (Open System Interconnect) Provides a 7 Layer solution
application layer
The presentation layer
The session layer
Transport layer
The network layer
Data link layer
The physical layer
Practical school :TCP / IP 5 Layer protocol ( four layers , In expression The physical layer is omitted )
application layer (Application Layer): Implement and apply your own business problems ( Business is different , Different agreements )
Transport layer (Transmission Layer): Realize any process on the host To The problem of any process communication on another host
The network layer (NetWork Layer): Based on the function of data routing , Finally, cross LAN The host To The communication problem of the host
Data link layer (Data Link Layer) : The problem of connecting and communicating between one host and another host in the LAN ( Conflict domain / Broadcast area )
The physical layer (Physical Layer) : Hardware ensures data conversion / How to spread in network media
The physical layer
LAN Internal communication problems :
- The simplest LAN : That is, two hosts are directly connected
- LAN with certain topology
These hosts are using a channel together, and the channel can only travel a limited number of signals at a time , This will cause the signal to conflict on the channel
Conflict domain :
For example, in the scene of self-study , Everyone can take the initiative to speak , As a result, they can't hear each other's statements
Hub can effectively solve the problem of data transmission in network topology
The hub works in The physical layer (1. Copy the data 2. Signal amplification )
Use a hub for networking , Born in the same conflict domain , This is caused by the working principle of the hub
Data link layer
Already under the same conflict domain , How to solve , Through a certain conflict avoidance algorithm , Avoid conflicts .—— Data link layer to solve
The most common conflict avoidance algorithm : After discovering the conflict , Silent random time , Send... Again
Even if there is a conflict avoidance algorithm , The data in the same conflict domain can be effectively transmitted , But the efficiency of signal transmission will still have an impact
- Don't have too many hosts in the conflict domain
- Minimize the occurrence of conflict domains
Switch (switch) Used to reduce conflict domains ( Divide the conflict domain )
A hub : Just copy , I don't know what the data is
Switch : You need to understand the target address put into the data link layer ( Need to be able to parse the data link layer protocol ), Destination address of format data , Decide who to give the data or not
The switch works at the data link layer , According to the target address in the data , Send data only to the corresponding target
therefore , LAN can also be built through switches .
Address : The address of the data link layer refers to MAC Address ( Physical address )
MAC The length of the address is 48 position (6 Bytes ), Usually expressed as 12 individual 16 Hexadecimal number , Such as 00-16-EA-AE-3C-40 It's just one. MAC Address
The network card was dead when it was produced . Network cards all over the world MAC The address will not conflict
Between different routers Divided into different broadcast domains
Responsibilities of data link layer protocol : One LAN Inside , No matter what kind of equipment 、 Which topology , The host and the host can communicate normally
The network layer
Solve through data routing Span LAN Communication problems between hosts .
The router is located in at least two LANs ( There are at least two network cards )
Routers work on the network layer .
Data can only be in the same LAN transmission , Routers span Two LAN, So cross LAN The transmission of needs to pass through the router .
route (route): Do pathfinding ;
Router (router): A device used to complete the pathfinding function
The network layer protocol is to complete pathfinding , Realize cross LAN Host to host
The network layer has its own address :IP Address
IP The address is a 32 The binary number of bits , Usually divided into 4 individual ”8 Bit binary number “ ( That is to say 4 Bytes )
Usually use ” dotted decimal “ In the way of , namely a.b.c.d In the form of (a,b,c,d All are 0~255 A decimal integer between )
IP The address is the software address : Within the same network IP It shouldn't be ” repeat “ Of .IP The address changes at any time .
Transport layer
Host to host has been fully connected . A process Want to be with Processes on another host communicate .
port (port):0~65525 Unsigned number of two bytes
process <-> port : Write the port , Corresponding to the specific process
people <-> cell-phone number : Express delivery : Recipient phone
A process can have multiple ports ( No conflict )
A port can only be assigned to one person ( Can't repeat )
Three important network devices
A hub
Working on the physical level
Switch
Working at the data link layer
Router
Working at the network layer
Summary :
| application layer | Business | User mode | ||
|---|---|---|---|---|
| Transport layer | process To the process | port | Inside | |
| The network layer | Span LAN Of Host to host | IP Address / route | Router | nucleus |
| Data link layer | LAN Inside Host to host | MAC Address / Broadcast area / Conflict domain | Switch | state OS Completion of the code |
| The physical layer | Physically ensure that the line is unblocked | A hub | Hardware |
Important agreement :
HTTP/HTTPS/DNS Belongs to application layer
TCP/UDP Belong to Transport layer
IP Belong to The network layer
send out : encapsulation ( You must carry the distribution and unpacking information )
Accept : Unpack / Divide up ( According to the control information of this layer )
Packaging and distribution
Different protocol layers have different names for packets , At the transport layer, it's called segments (segment), In the network layer, it's called datagram (datagram), In the link layer, it's called frames (frame).
When the application layer data is sent to the network through the protocol stack , Each layer of protocol has to add a data header (header), It's called encapsulation (Encapsulation).
The first message contains something similar to how long the first one is , load (payload) How long is , What is the upper layer protocol .
Data is packaged into frames and sent to the transmission medium , After reaching the destination host, the corresponding header of each layer protocol is stripped , According to the first part Of “ Upper layer protocol field ” The data is handed over to the corresponding upper layer protocol for processing .
Each layer can perform necessary operations according to the control information added by each layer
Between corresponding levels , It's completely transparent , This process can be completely ignored
If it helps you , Please give me a compliment .
边栏推荐
- Force buckle 1037 Effective boomerang
- TS quick start - Generic
- 理财产品要怎么选?新手还什么都不懂
- 深度学习模型压缩与加速技术(七):混合方式
- 4G设备接入EasyGBS平台出现流量消耗异常,是什么原因?
- 力扣 1037.有效的回旋镖
- Data island is the first danger encountered by enterprises in their digital transformation
- 一文读懂数仓中的pg_stat
- 九度 1201 -二叉排序数遍历- 二叉排序树「建议收藏」
- 开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
猜你喜欢

OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验

Mrs offline data analysis: process OBS data through Flink job

AIRIOT助力城市管廊工程,智慧物联守护城市生命线

上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法

智能软件分析平台Embold

Micro service remote debug, nocalhost + rainbow micro service development second bullet

CodeSonar网络研讨会

How to test CIS chip?

Machine learning notes - explore object detection datasets using streamlit

php 获取图片信息的方法
随机推荐
Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry
4G设备接入EasyGBS平台出现流量消耗异常,是什么原因?
H3C S7000/S7500E/10500系列堆叠后BFD检测配置方法
如何满足医疗设备对安全性和保密性的双重需求?
Opencv学习笔记 高动态范围 (HDR) 成像
Network principle (1) - overview of basic principles
Force buckle 2315 Statistical asterisk
《数字图像处理原理与实践(MATLAB版)》一书之代码Part2[通俗易懂]
TS quick start - Generic
搞定带WebKitFormBoundary post登录
Machine learning notes - explore object detection datasets using streamlit
基于深度学习的目标检测的更新迭代总结(持续更新ing)
【mysql篇-基础篇】事务
CodeSonar网络研讨会
[award publicity] issue 22 publicity of the award list in June 2022: Community star selection | Newcomer Award | blog synchronization | recommendation Award
想杀死某个端口进程,但在服务列表中却找不到,可以之间通过命令行找到这个进程并杀死该进程,减少重启电脑和找到问题根源。
使用 BR 备份 TiDB 集群数据到 Azure Blob Storage
With st7008, the Bluetooth test is completely grasped
AIRIOT助力城市管廊工程,智慧物联守护城市生命线
取两个集合的交集