当前位置:网站首页>[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 .
边栏推荐
- Vulnhub tre1
- Force buckle 2315 Statistical asterisk
- Useful win11 tips
- Mongodb由浅入深学习
- 一文读懂数仓中的pg_stat
- 微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
- ISO 26262 - 基于需求测试以外的考虑因素
- Nebula importer data import practice
- [award publicity] issue 22 publicity of the award list in June 2022: Community star selection | Newcomer Award | blog synchronization | recommendation Award
- 机器学习笔记 - 使用Streamlit探索对象检测数据集
猜你喜欢
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
机械臂速成小指南(十二):逆运动学分析
Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
Opencv learning notes high dynamic range (HDR) imaging
如何满足医疗设备对安全性和保密性的双重需求?
网络原理(1)——基础原理概述
一. 基础概念
数据孤岛是企业数字化转型遇到的第一道险关
机器学习笔记 - 使用Streamlit探索对象检测数据集
Jenkins 用户权限管理
随机推荐
Prometheus remote_write InfluxDB,unable to parse authentication credentials,authorization failed
如何在软件研发阶段落地安全实践
Useful win11 tips
解决/bin/sh进去的容器运行可执行文件报not found的问题
AADL Inspector 故障树安全分析模块
H3C S7000/S7500E/10500系列堆叠后BFD检测配置方法
华为CE交换机下载文件FTP步骤
Oracle 存儲過程之遍曆
CIS芯片测试到底怎么测?
How to implement safety practice in software development stage
机械臂速成小指南(十一):坐标系的标准命名
机器学习笔记 - 使用Streamlit探索对象检测数据集
When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
Mongodb learn from simple to deep
整型int的拼接和拆分
Gorilla official: sample code for golang to open websocket client
第二十章 使用工作队列管理器(三)
Force buckle 989 Integer addition in array form
力扣 912.排序数组
Machine learning notes - explore object detection datasets using streamlit