Computer Network--Chapter 5 Summary of Transport Layer Knowledge Points

1. Services provided by the transport layer

The transport layer provides communication services to the application layer above it. The transport layer provides logical communication between application processes. The layer shields the details of the underlying network (such as network topology, routing protocol used, etc.), and it makes the application process see that there is an end-to-end logical communication channel between two transport layer entities. The entity that actually communicates is the application process in the host, and the application process in one host and the application process in another host are exchanging data (that is, communicating).

2. Functions of the transport layer

The network layer provides logical communication between hosts, and the transport layer provides end-to-end logical communication between application processes. The transport layer also performs error detection on received packets. According to the different needs of the application, the transport layer needs to have two different transport protocols, namely connection-oriented TCP and connectionless UDP.

The transport layer shields the underlying network core details (such as network topology, routing protocol adopted, etc.) , but the performance of this logical communication channel to the upper layer varies greatly due to the different protocols used by the transport layer. When the transport layer adopts connection-oriented TCP protocol, although the underlying network is unreliable (only best-effort service is provided), this logical communication channel is equivalent to a full-duplex reliable channel. But when the transport layer adopts the connectionless UDP protocol, this logical communication channel is still an unreliable channel.

3. Port number

The transport layer identifies a port with a 16-bit port number. The port number has only local significance, and it is only used to mark the interlayer interface of each process in the application layer of the computer when interacting with the transport layer. In different computers on the Internet, the same port number is not related.

The abstract protocol port between the protocol stack layers is a software port, which is a completely different concept from the hardware port on a router or switch. The hardware port is the interface for different hardware devices to interact, and the software port is the place where the various protocol processes of the application layer interact with the transport entity. Different systems can implement different methods of ports (depending on the system used operating system).

The processes in the two computers need to communicate with each other, not only need to know the other party's IP address (in order to find the other party's computer), but also know the other party's port number (in order to find the application process in the other party's computer).

The port number of the transport layer is divided into the port number used by the server (0~1023 is assigned to the well-known port, 1024~49151 is the registered port number) and the port number temporarily used by the client (49152~65535).

4. User Datagram Protocol UDP

The main features of UDP are: ①No connection; ②Best effort delivery; ③Packet-oriented; ④No congestion control; ⑤Support one-to-one, one-to-many, many-to-one and many-to-many interactive communication; ⑥Head overhead Small (only four fields: source port, destination port, length and checksum).

The header field of UDP is only 8 bytes and consists of 4 fields, and the length of each field is 2 bytes.

 ①Source port: source port number. Select it when you need a reply from the other party. All 0s can be used when not needed.

②Destination port: the destination port number. Must be used when delivering packets at the endpoint.

③ Length: The length of the UDP user datagram, the minimum value is 8 (only the header).

④ Checksum: Detect whether there is an error in the transmission of the UDP user datagram, and discard it if there is an error. The UDP checksum checks both the header and the data part together.

5. Transmission Control Protocol TCP

The main features of TCP are: ① connection-oriented; ② each TCP connection can only be point-to-point (one-to-one); ③ provide reliable delivery services; ④ provide full-duplex communication; ⑤ byte stream-oriented.

TCP uses the IP address of the host plus the port number on the host as the endpoint of the TCP connection. Every TCP connection has two endpoints. Such endpoints are called sockets or sockets. A socket is represented by (IP address: port number). Each TCP connection is uniquely identified by two endpoints (that is, socket pairs) at both ends of the communication.

6. Principle of reliable transmission

The segment sent by TCP is handed over to the IP layer for transmission, but the IP layer can only provide best-effort service, that is to say, the network under TCP provides unreliable transmission. Therefore, TCP must take appropriate measures to make the communication between the two transport layers reliable.

Ideal transmission conditions have the following two characteristics: ①The transmission channel does not generate errors; ②No matter how fast the sender sends data, the receiver always has time to process the received data.

The actual network does not meet the above two ideal conditions.

7. Stop waiting for the protocol

Stop-and-wait protocols enable reliable communication over unreliable transport networks. Stop sending every time a packet is sent, wait for the confirmation from the other party, and send the next packet after receiving the confirmation. A copy of the sent packet must be kept temporarily (used in case of timeout retransmission). Both packets and acknowledgment packets must be numbered. Timeout retransmission when an error occurs. Timeout retransmission means that as long as the confirmation is not received after a period of time, the previously sent packet is retransmitted (the packet sent just now is considered lost). Therefore, each time a packet is sent, a timeout timer needs to be set, and its retransmission time should be longer than the average round-trip time of data in packet transmission. This automatic retransmission mode is often called automatic repeat request ARQ.

In the stop-and-wait protocol, if the receiver receives a duplicate packet, it discards the packet, but sends an acknowledgment at the same time.

Channel utilization U=Tᵈ/(Tᵈ+RTT+Tᴬ)

Among them, Tᵈ represents the time required to send the packet, Tᴬ represents the time required to confirm the packet, and RTT represents the round-trip time.

Pipeline transmission means that the sender can send multiple packets continuously without having to stop and wait for confirmation from the other party every time a packet is sent, so that data can be continuously transmitted on the channel. Obviously, this transmission method can obtain high channel utilization.

8. Continuous ARQ protocol

Continuous ARQ protocol can improve channel utilization. The sender maintains a sending window, and all packets within the sending window can be sent out continuously without waiting for confirmation from the other party. The receiver generally adopts cumulative acknowledgment, and sends an acknowledgment to the last packet that arrives in sequence, indicating that all packets up to this packet have been received correctly.

The advantage of cumulative acknowledgment is that it is easy to implement, and there is no need to retransmit even if the acknowledgment is lost, but the disadvantage is that it cannot reflect to the sender that the receiver has correctly received all the packets in time.

9. TCP segment

 Although TCP is byte-oriented, the data unit transmitted by TCP is a segment.

The first 20 bytes of the TCP segment header are fixed, and the following 4N bytes are options that can be added according to needs (N is an integer). Therefore the minimum length of the TCP header is 20 bytes. Each byte in the byte stream transmitted in a TCP connection is numbered sequentially. The sequence number field value in the header refers to the sequence number of the first byte of the data sent in this message segment. The confirmation number in the TCP header is the sequence number of the first data byte expected to receive the next segment of the other party. If the acknowledgment number is N, it means that all the data up to sequence number N-1 have been received correctly. The window field in the TCP header indicates the amount of data the other party is now allowed to send. The window value is often changing dynamically.

10. Sliding window

TCP's sliding window is in bytes. TCP uses a sliding window mechanism. The serial numbers in the sending window indicate the serial numbers that are allowed to be sent. The back part of the sending window’s trailing edge indicates that it has been sent and the confirmation has been received, while the front part of the sending window’s leading edge indicates that sending is not allowed, because the receiver does not reserve a temporary storage buffer space for this part of the data. There are two possibilities for the change of the trailing edge of the sending window, that is, do not move (no new confirmation is received) and move forward (new confirmation is received). The trailing edge of the send window cannot be moved backwards, since received acknowledgments cannot be undone. The leading edge of the send window is usually constantly moving forward, but it may not move. The reason for moving forward is that no new confirmation has been received, and the size of the window notified by the other party has not changed. The reason for not moving is that a new confirmation has been received but the notification window of the other party has shrunk, making the front edge of the sending window just not moving.

11. TCP flow control

Flow control is to make the sender's sending rate not too fast, so that the receiver has time to receive. The sending window of the sender cannot exceed the value of the receiving window given by the receiver. The window unit of TCP is byte, not segment.

Flow control often refers to the control of point-to-point traffic, which is an end-to-end problem. What flow control needs to do is to suppress the rate at which the sending end sends data so that the receiving end can receive it in time.

12. TCP congestion control

In a certain period of time, if the demand for a certain resource in the network exceeds the available part that the resource can provide, the performance of the network will deteriorate. This situation is called congestion. Congestion control is to prevent excessive data injection into the network, so that the routers or links in the network will not be overloaded.

Congestion control is a global process involving all hosts, all routers, and all factors related to reducing network transmission performance.

In order to perform congestion control, the TCP sender maintains a state variable of the congestion window cwdn. The size of the congestion window depends on the degree of network congestion and is changing dynamically. The sender makes its sending window the smaller one of the congestion window and the receiving window of the receiver.

TCP congestion control uses four algorithms, namely slow start, congestion avoidance, fast retransmission and fast recovery. At the network layer, routers can also adopt appropriate packet discarding strategies (such as Active Queue Management AQM) to reduce network congestion.

13. TCP transport connection management

There are three phases in a transport connection, namely connection establishment, data transfer and connection release. The management of the transport connection is to make the establishment and release of the transport connection go on normally.

The establishment of a TCP connection adopts the client server method. The application process that actively initiates the connection establishment is called the client, and the application process that passively waits for the connection establishment is called the server. The TCP connection is established using a three-message handshake mechanism. The server needs to confirm the client's connection request, and then the client needs to confirm the server's confirmation.

The TCP connection release uses a four-packet handshake mechanism. Either party can issue a notification of connection release after the data transmission is completed, and enter the semi-closed state after the other party confirms. When the other party has no data to send again, a connection release notification is sent, and the TCP connection is completely closed after the other party confirms.

Guess you like

Origin blog.csdn.net/weixin_65089091/article/details/131415275