Through our understanding of the internet, we found that the TCP transport layer protocol is the core and basis of the network. We will not describe the importance of it too much here. We will give a detailed explanation of its service process, and hope that this part of content can be clearly understood through the article.
The TCP Transport Layer Protocol provides a reliable connection-oriented transmission control protocol, that is, you must establish a logical connection before transmitting data, and then release the connection. TCP provides end-to-end and full-duplex communication. It adopts the byte stream mode. If the byte stream is too long, it is segmented to provide the emergency data transmission function.
Although both TCP and UDP use the same network layer IP address), TCP provides services completely different from UDP to the application layer.
TCP provides a connection-oriented and reliable byte stream service.
Connection orientation means that two applications that use TCP are usually one customer and one server. a tcp connection must be established before data is exchanged. This process is similar to making a phone call. Call the phone and wait for the other party to say "hello.
In a TCP connection, only two parties communicate with each other. Broadcast and multicast cannot be used for TCP.
The TCP transport layer provides reliability in the following ways:
◆ Application data is divided into data blocks that TCP considers to be the most suitable for sending. This is completely different from UDP, and the length of the datagram generated by the application will remain unchanged. The unit of information transmitted by TCP to the IP address is the packet segment or segment. How does TCP determine the length of the packet segment.
◆ When TCP sends a segment, it starts a timer and waits for the destination end to confirm receipt of the segment. If a confirmation message cannot be received in time, the message segment will be resold. • When TCP receives data from the other end of the TCP connection, it sends a confirmation message. This confirmation is not sent immediately. It will usually be postponed by a few seconds.
◆ TCP will maintain the test of its header and data. This is an end-to-end test to detect any changes in data during transmission. If the verification and error of the received segment are found, the TCP Transport Layer Protocol discards the segment and does not confirm the receipt of the segment to re-Send the origin timeout ).
◆ Since the TCP packet segment is transmitted as an IP datagram, the arrival of the IP datagram may be out of order, so the arrival of the TCP packet segment may also be out of order. If necessary, TCP sorts the received data again and delivers the received data to the application layer in the correct order.
◆ Since the IP datagram is repeated, the TCP receiver must discard the duplicate data.
◆ TCP can also provide traffic control. Each side of a TCP connection has a fixed buffer space. The receiving end of the TCP Transport Layer Protocol only allows the other end to send data that can be accepted by the receiving end buffer. This will prevent the buffer overflow of the slow host caused by the fast host.
The two applications exchange byte streams consisting of 8-bit bytes over TCP connections. TCP does not insert record identifiers in byte streams. We call this bytestreamservice ). If the application of one party first transmits 10 bytes, then 20 bytes, and then 50 bytes, the other party connected will not be able to know how many bytes each time the sender sends. The recipient can receive the 80 bytes in four times and receive 20 bytes each time. One end migrates bytes to the TCP connection, and the same byte stream will appear on the other end of the TCP connection.
In addition, TCP does not explain the content of the byte stream. TCP does not know whether the transmitted data byte streams are binary data, ASCII characters, EBCDIC characters, or other types of data. The interpretation of byte streams is explained at the application layer of both TCP connections.
This processing method for byte streams is similar to that for files in Unix operating systems. The Unix kernel does not explain the content read or written by an application, but is handed over to the application for processing. For a Unix kernel, it cannot distinguish a binary file from a text file.
The TCP transport layer uses the three-way handshake protocol to establish a connection. When the active Party sends a SYN connection request, wait for the other party to answer SYN, ACK. This method of establishing a connection can prevent incorrect connections. The traffic control protocol used by TCP is a variable-size Sliding Window Protocol.
First handshake: when a connection is established, the client sends the SYN Packet (SEQ = x) to the server and enters the SYN_SEND status. Wait for the server to confirm.
The second handshake: when the server receives the SYN packet, it must confirm the customer's SYN (ACK = x + 1) and send a SYN Packet (SEQ = y), that is, SYN + ACK packet, the server enters the SYN_RECV status.
The third handshake: the client receives the server's SYN + ACK package and sends the ACK (ACK = y + 1) Confirmation package to the server. After the package is sent, the client enters the Established status with the server, complete three handshakes.