Understand the OSI seven layer model and TCP three handshakes and four waves

Summary of key points

  • Basic concepts
    • bit, Byte, rate, bandwidth, throughput, delay, delay bandwidth area, round trip time, utilization, packet loss rate
  • OSI seven layer model
    • Physical layer, data link layer, network layer, transport layer, session layer, presentation layer and application layer
  • OSI network standard model
    • Physical layer, data link layer, network layer (Internet layer), transport layer and application layer
  • Interaction process and transmission data format between OSI layers
    • Differences between TCP and UDP
    • TCP shakes hands three times and waves four times

Basic concepts

Bit bit

binary digit(Binary digit) The smallest unit of data storage in a computer. 1 bit is also called 1 bit. Each 0 or 1 represents one bit 
[ cpu The number of digits refers to cpu The maximum number of bits that can be processed at one time ]


Byte also known as B One byte is equal to eight bits, i.e. 1 B = 8b  Is the basic unit of data stored in a computer
 1B = 8b
1KB = 1024B = 2^10 B 
1MB = 1024KB = 2^20 B
1GB = 1024MB = 2^30 B
1TB = 1024GB = 2^40 B
... ...


The amount of data that a computer can transmit per unit time(Bit). Also called bit rate, data rate


The highest data rate that can pass from one point in the network to another in unit time


The amount of data passing through a network per unit time

time delay

The time it takes for data to travel from one end of the network to the other. It consists of transmission delay, propagation delay, processing delay and queuing delay
  • Transmission delay: the time taken by the source host to send data packets to the transmission line. Packet length (b) / transmission rate (b/s)
  • Propagation delay: the time spent when data propagates over a certain length of link. Channel length (m) / electromagnetic wave transmission speed (m/s)
  • Processing delay: the time spent storing and forwarding data at the switching node
  • Queuing delay: the time that data is queued for processing after entering the router

Delay bandwidth area

It can be understood that when the first bit sent by the sender is about to reach the destination, how many bits have been sent by the sender

round trip time

The time spent from the sender sending data to the sender receiving the receiver's confirmation message.

Utilization rate

Used to indicate that half of the time in a channel is utilized
  • According to queuing theory, when the utilization of a channel increases, the delay will be more

Packet loss rate

The ratio of the number of lost packets to the total number of packets in the transmission process within a certain time, such as interface packet loss rate, node packet loss rate, link packet loss rate, network packet loss rate, etc
  • The packet has bit error during transmission and is discarded by the node
  • Network congestion: packets are discarded when they reach a full queue switch

MAC address

Ethernet MAC Address used by self layer		-- data link layer

IP address

TCP/IP Architecture: address used by the network layer		-- network layer

ARP Protocol

TCP/IP Architecture: through IP Address obtained MAC address		-- network layer

OSI model - layer 7 (International Standard)

  • physical layer
  • data link layer
  • network layer
  • Transport layer
  • Session layer
  • Presentation layer
  • application layer

physical layer

Solve the problem of which signal is used to represent bit 0 and 1 transmission in various media connected to the computer
  • Guided transmission media: such as coaxial cable, twisted pair, optical fiber and hub. Non guided transmission media: microwave communication (2~40GHZ), such as Wifi in 2.4GHZ and 5.8GHZ bands

data link layer

Solve the problem of packet transmission in a network or a link
  • Add frame header and frame tail to the data unit delivered by the upper layer to find the MAC address and other information of the destination host [PPP protocol]

network layer

Realize network interconnection and solve the transmission of data packets between multiple networks(route)problem
  • Communication between multiple networks. Including: router

Transport layer

Provide services for network-based communication between application processes
  • TCP/IP protocol: use port number to distinguish different application processes
    • The sender sends TCP or UDP with the protocol field, and the receiver selects the submitted TCP or UDP protocol code through the protocol field: TCP: 6 UDP: 17
    • HTTP (FTP) protocol
    • UDP protocol: DNS(53) RIP(520) TFTP(69)SNMP(161) DHCP(67/68)

Session layer

Solve the problem of conversation between processes

Presentation layer

Solve the problem of representation of communication information between communication parties

application layer

Solve the problem of realizing specific network applications through the interaction between application processes
  • Including character set conversion, data encryption and decryption, text compression and data format conversion

OSI model - (network standard)

physical layer

Transmission bitstream 		001101010100101...

data link layer

Transmit data frame		Packets transmitted on the data link layer

network layer

Transmission network datagram/grouping		IP

Transport layer

transmission TCP Message segment/UDP User data segment		TCP \ UDP

application layer

Transmission data message		HTTP \ SMTP \ FTP \ RTP ...

Data transmission encapsulation process between layers

Differences between TCP and UDP

reliabilityNo connection - unreliableConnected - reliable
Mode of transmissionUnicast, multicast, broadcastunicast
Propagation type[application oriented message][byte stream oriented]
Communication processDirectly add the application message to the UDP header for transmissionThe [sender] stores the byte stream number in the transmission cache, extracts the bytes according to the transmission strategy, constructs a TCP message segment for transmission, and the [receiver] takes the data from the message segment, stores it in the reception cache, and delivers the bytes in the cache to the superior application process
Mode of transmissionUnicast, multicast, broadcastunicast
Guarantee mechanismIf the router or receiver recognizes the error code of the transmitted data, it only discards the dataReliable transmission flow control (sliding window), timeout retransmission, congestion control, etc. by establishing a connection
Application scenarioApplicable to: real-time service telephone, voice and videoApplicable to: file transmission, data transmission, etc. requiring reliability

TCP triple handshake

Establish connection

TCP waved four times

Release connection

Why do I have to shake hands three times to establish a connection? Not twice?

Three handshakes to ensure a safe and reliable connection

Send a connection establishment request to the server for the client for the first time,
For the second time, the server responds to the connection establishment request to the client,
The third time, the client responds to the server and receives the server response
---At this time, the connection is established successfully

If it is modified to two processes, the second server directly establishes a connection:
①: Then the server cannot know whether the client has received the connection request correctly,
If the client does not receive it, the client will not establish a connection with the server, and the server will establish a one-way request. Unreliable connection.
②: If the client does not receive the response from the server for a long time, it will retransmit the connection establishment request, and the server may establish multiple invalid connections

---Generally speaking, two requests can only be received correctly when the client knows the request I sent,
   However, the server cannot know whether the request I sent can be correctly received by the client

Why do you wave four times to close the connection? Three times?

Send a disconnect request for the client to the server for the first time,
The second time is for the server to respond to the client and receive the disconnection request,
The third time, the server sends a disconnection request to the client,
The fourth time is for the client to respond to the server, receive and confirm the disconnection request.

So why does the server not release the connection directly when it responds to the client's disconnection request for the second time, but wave for the third and fourth time?

This is because the server may still have business data to send to the client, so it cannot be disconnected directly,
Just respond to the client and agree to disconnect.

After the server has processed the request, it will actively send a disconnection request to the client, and wait for the client to respond and confirm the request, and finally disconnect the server.

Why does the time-wait state of TCP wave last for 2MSL?

MSL: Maximum message lifetime

TCP The server sends a connection release request to the client and waits 2 minutes before receiving a response MSL Time. If the response from the client is received after this time, it will be retransmitted
	Wait 2 MSL The reason for the duration is that the server sends a request to the client. The maximum time is 1 MSL,The maximum time for the client to respond to the confirmation request is 1 MSL,
	Therefore, it is considered that the request is lost after this time and will be retransmitted
TCP After the client responds to the server, it will wait 2 MSL After this time, it is considered that the server has received my response
	Wait 2 MSL The reason for the duration is that the maximum time for the client to respond to the server is 1 MSL If the server does not receive the retransmission, it is assumed that the retransmission will be initiated
	Wait 1 more MSL If the time does not receive the server's re confirmation, it is considered that the server has received the confirmation response normally

If there are any deficiencies or errors in the above contents, please correct them. Welcome to explore~

Not just before, but in the future···

Keywords: computer networks TCPIP osi

Added by HERATHEIM on Mon, 17 Jan 2022 20:32:46 +0200