【5.Computer Network--Transport Layer】

1. Transport layer overview

  • The physical layer, data link layer, and network layer that we have learned before jointly solve the problems faced by interconnecting hosts through heterogeneous networks and realize host-to-host communication.
  • In fact, the entities communicating in the computer network are processes located in the hosts at both ends of the communication.
  • How to provide direct communication services for application processes running on different hosts (Provide logical communication between processes) It is the taskof the transport layer, which is also called the end-to-end protocol.

2. Transport layer port numbers, the concepts of multiplexing and demultiplexing

Use the sender and receiver's socket combination to identify the endpoint in the network. The socket uniquely identifies the endpoint in the network. A host and a process on it.
Socket Socket=(host IP address, port number)
Insert image description here
Insert image description here
Examples of the role of port numbers:
Insert image description here

Insert image description here

3. Comparison between TCP and UDP

Insert image description here

  • UDP supports unicast, multicast and broadcast
  • TCP only supports unicast (one-to-one)
  • UDP is oriented toapplication messages and is suitable for applications that transmit a small amount of data at one time< /span>
  • TCPthis sidecharacter flowtarget,
  • UDP provides connectionless and unreliable transmission services to the upper layer without congestion control (suitable for real-time applications such as IP telephony and video conferencing)
  • TCP provides connection-oriented (virtual connection) reliable transmission service to the upper layer, with congestion control (applicable to services requiring reliable transmission, e.g. file transfer)
    • Reliable: Ensure that the byte stream read by the receiver process from the buffer is the same as the byte stream sent by the sender.
  • The UDP user datagram header is only 8 bytes,
  • The minimum TCP segment header is 20 bytes and the maximum is 60 bytes.
  • TCP provides full-duplex communication
    • Receive cache: data arriving in order but not yet read by the accepting application/data arriving out of order
    • Send cache: data ready to be sent/data sent but not yet received confirmation

4. Header format of TCP segment

Insert image description here
Sequence number: Each byte in the byte stream transmitted in a TCP connection is numbered in sequence. This field indicates the first bit of the data sent in this segment. byte sequence number.
Confirmation number: The sequence number of the first data byte expected to be received in the next message segment from the other party. If the confirmation number is N, it proves that all data up to sequence number N-1 have been received correctly.
Data offset (header length): How far is the start of the data of the TCP segment from the start of the TCP segment, in 4B is the unit, that is, a value is 4B.

5. TCP

5.1 Flow control

Flow control: Let the sender’s sending rate not be too fast, so that the recipient can accept it in time (this can be achieved by using the sliding window mechanism) .
Insert image description here
Insert image description here

5.2 Congestion control

Insert image description here
Insert image description here
Insert image description here

Insert image description here
Insert image description here
Insert image description here

5.3 Implementation of TCP reliable transmission

Insert image description here

5.4 TCP transport connection management (handshake, waving issues)

5.4.1 Establishing a connection (handshake)

Insert image description here
Insert image description here

5.4.2 Release the connection (wave your hand)

Terminate FIN: used to release the connection. When it is 1, it indicates that the sender's data of this segment has been sent.
seq: equal to the sequence number of the last byte of data that has been previously transmitted by the TCP client process + 1.
ack: equal to the sequence number of the last byte of data that has received before the TCP client process + 1.
Insert image description here
What would happen if we did not wait for 2MSL?

When waving for the fourth time, the ACK sent by the client to the server may be lost. If the server does not receive the ACK for some reason, the server will resend it
FIN, if the client receives FIN within 2*MSL, it will resend ACK and wait for 2MSL again to prevent the server from continuously resending FIN without receiving ACK
. As shown in the picture:

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_69380220/article/details/130433468