Theory: Network foundation (OSI seven-layer reference model, TCP/IP protocol family, data encapsulation and decapsulation, etc.)

OSI seven-layer reference model

The International Organization for Standardization (ISO)
promulgated the Development System Interconnection (OSI) Reference Model in 1984,
an open architecture that divides the network into seven layers

Stratification Features
Application layer An interface between network services and end users
Presentation layer Data representation, security, compression
Session layer Establish, manage, and terminate sessions
Transport layer Define the protocol port number for data transmission, as well as flow control and error checking
Network layer Perform logical address addressing to achieve path selection between different networks
data link layer Establish logical connection, perform hardware address addressing, error checking and other functions
Physical layer Establish, maintain, and disconnect physical connections

Insert picture description here

TTCP/IP protocol family

Insert picture description here

Encapsulation and decapsulation of data

Insert picture description here
Data encapsulation process: (Take two communication hosts as an example)
Application layer: Original data is converted into binary data;
Transport layer: Binary data is divided into small data segments, and TCP header (data segment) is encapsulated
(TCP header) The key information of the part-port number);
network layer: the data from the transport layer is encapsulated with an IP header (data packet)
(key information of the IP header-IP address); the
data link layer: the data from the network layer The data is encapsulated in the MAC header (data frame)
(key information of the MAC header-MAC address);
physical layer: the bit stream composed of binary data is converted into electrical signals for transmission in the network. (Bitstream)

The process of unpacking data is the reverse process of encapsulation:

Data decapsulation process:
physical layer: convert electrical signals into binary data, and send it to the data link layer.
Data link layer: check the MAC address, the address is oneself, then remove the MAC header, continue to transmit the
address is not oneself , Discard the data;
network layer: check the IP address, if the address is yourself, remove the IP header, continue to transmit the
address is not yourself, discard the data;
transport layer: check the TCP header, determine where it should be transmitted, and then reorganize the data ,Transfer to the application layer
Application layer: Binary conversion into raw data.

The difference between TCP and UDP

TCP

  1. Connection-oriented
  2. reliable
  3. Suitable for applications with high reliability requirements
  4. Expensive

UDP

  1. no connection
  2. Unreliable
  3. Suitable for applications that pay more attention to transmission efficiency
  4. Reliability is the responsibility of the application layer

TCP three-way handshake and four waved hands

The process of TCP establishing a connection is called a three-way handshakeInsert picture description here

A brief description of the four waves of TCP disconnection
Insert picture description here
: three handshake and four waves

Three-way handshake
(1) The sender sends a SYN request
to the receiver (2) The receiver actively responds with an ACK after receiving this request, and also sends a SYN request
(3) After the sender receives the SYN request from the receiver, Give an ACK confirmation.

Waves four times
(1) The sender sends a FIN request to the
receiver (2) The receiver gives an ACK confirmation after receiving this request
(3) The receiver sends a FIN request to the sender
(4) The sender receives the receiver After the FIN request, reply an ACK

ARP protocol overview

What is ARP protocol

  1. Address Resolution Protocol, Address Resolution Protocol
  2. Resolve a known IP address into a MAC address

ARP command in Windows system

  1. arp -a: View the ARP cache table
  2. arp -d: Clear the ARP cache
  3. ARP binding

The working principle of ARP:

ARP: It is used when the target IP is known but the MAC address is unknown.
Example: If PC1 wants to send a message to PC2, but only knows the IP of PC2, and when the MAC of PC2 is unknown, it will send a broadcast frame to the switch through ARP. When the switch receives the broadcast frame, it will perform broadcast processing unconditionally. All hosts can receive this broadcast frame. They will compare whether their IP is consistent with the target IP. If they are inconsistent, they will discard it. If they are consistent, they will reply to the sender. They will naturally add their own MAC in the process of returning the packet. And IP, when the sender receives this data, check the receiver's MAC and IP address and put them into the ARP cache table together.

Guess you like

Origin blog.csdn.net/weixin_48190875/article/details/106968160