The TCP protocol provides a reliable, connection-oriented Transmission Control protocol that establishes a logical connection before transmitting data, then transmits the data, and finally releases the connection 3 processes. TCP provides end-to-end, full-duplex communication, byte-stream mode, if the byte stream is too long, segment it, and provide emergency data transfer function.
Although both TCP and UDP use the same network layer (IP), TCP provides a completely different service to the application tier than UDP.
TCP provides a connection-oriented, reliable byte-stream service.
Connection-oriented means that two applications that use TCP (typically a customer and a server) must establish a TCP connection before exchanging data with each other. This process is very similar to the phone call, first dial ringing, waiting for the other side to say "Hello", and then to explain who.
In a TCP connection, only two parties communicate with each other. Broadcasts and multicasting cannot be used with TCP.
TCP provides reliability in the following ways:
- The application data is split into a block of data that TCP considers most suitable for sending. This is completely different from UDP, and the datagram length that the application produces will remain unchanged. The unit of information that is passed to the IP by TCP is called the Segment or segment (segment) TCP How to determine the length of the message segment.
- When TCP sends out a segment, it initiates a timer, waiting for the destination to acknowledge receipt of the message segment. If a confirmation cannot be received in time, the message segment will be re-sent. o When TCP receives data from the other end of the TCP connection, it sends an acknowledgment. This acknowledgement is not sent immediately, and will typically be deferred for a fraction of a second
- TCP will keep its header and data checked and. This is an end-to-end test and is designed to detect any changes in the data during transmission. If the test and errors are received, TCP discards the segment and does not acknowledge receipt of this segment (expecting the originator to timeout and re-send).
- Since TCP packets are transmitted as IP datagrams, and the arrival of IP datagrams can be out of order, the arrival of the TCP message segment may also be out of sequence. If necessary, TCP will reorder the received data and hand the received data to the application tier in the correct order.
- Since IP datagrams are duplicated, the receiving side of TCP must discard duplicate data.
- TCP can also provide traffic control. Each side of a TCP connection has a fixed-size buffer space. The receiving side of TCP only allows the other end to send the data that the receiving buffer can accept. This prevents faster hosts from causing buffer overruns for slower hosts.
two applications Exchange byte streams consisting of 8bit bytes over a TCP connection. TCP does not insert a record identifier in the byte stream. We'll call this the byte stream service (Bytestreamservice). If one party's application passes 10 bytes, then 20 bytes, and then 50 bytes, the other side of the connection will not know how many bytes the sender sent each time. The receiver pays can receive these 80 bytes 4 times and receive 20 bytes at a time. One end places the byte stream on the TCP connection, and the same byte stream appears at 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 stream is binary or ASCII, EBCDIC, or other type of data. The interpretation of the byte stream is explained by the application layer of both sides of the TCP connection.
This processing of byte streams is similar to the way the UNIX operating system handles files. The Unix kernel does not interpret what an application reads or writes, but instead gives it to the application for processing. For the Unix kernel, it cannot differentiate between a binary file and a text file.
TCP is the Transport layer protocol in the Internet, using three-time handshake protocols to establish a connection. When the active party sends a SYN connection request, wait for the other person to answer syn,ack. This method of establishing a connection prevents the wrong connection from being generated, and the traffic control protocol used by TCP is a variable-sized sliding window protocol. First handshake: When a connection is established, the client sends a SYN packet (SEQ=X) to the server and enters the Syn_send state, waiting for the server to confirm. Second handshake: The server receives the SYN packet, it must confirm the customer's SYN (ACK=X+1), and also send itself a SYN packet (seq=y), which is the Syn+ack packet, when the server enters the SYN_RECV state. The third handshake: the client receives the server's Syn+ack packet, sends the acknowledgment packet ACK (ACK=Y+1) to the server, the packet is sent, the client and the server enter the established state, and three handshakes are completed.
Service Flow for TCP