TCP operation

The main purpose of TCP is to provide a reliable and safe logical circuit or connection service between two processes that establish a connection. In order to provide this service on the poorly reliable Internet communication system, the following facilities are required:

  1. Basic data transmission
  2. reliability
  3. flow control
  4. Multiplexing
  5. connection
  6. Priority and safety

The following paragraphs introduce the basic operations of TCP listed above

Basic data transmission:

By packing a certain number of octets into segments for transmission through the Internet system, TCP can transmit a continuous stream of octets in each direction between its users. Usually, TCP decides when to block and forward data according to its own convenience.

Sometimes, users need to ensure that all data that has been submitted to TCP has been transmitted. To this end, a push function is defined. To ensure that the data submitted to TCP has actually been sent, the sending user indicates that it should be pushed to the receiving user. Pushing will cause TCP to immediately forward the data and deliver the data up to that point to the receiver. The exact push point may not be visible to the receiving user, and the push function does not provide record boundary markers.

reliability:

TCP must recover from data that may be damaged, lost, duplicated or delivered out of order in the Internet communication system. This is achieved by assigning a sequence number to each octet sent and asking the receiver TCP to send an acknowledgment (ACK). If the ACK is not received within the timeout interval, the data will be resent. At the receiving end, the sequence number is used to correctly sort the segments that may be received out of order and eliminate duplicates. For the data damage that exists in the transmission process, by adding a checksum to each transmitted segment, the receiver checks it and discards the damaged segment.

As long as TCP continues to operate normally and the Internet system is not completely partitioned, transmission errors will not occur and the correct transmission of data will not be affected. TCP can recover from Internet communication system errors.

flow control:

TCP provides a way for the receiver to manage the amount of data sent by the sender. This is achieved through the "window" carried by each ACK returned, which represents the acceptable sequence number range after the last segment of the successful reception. This window indicates the number of octets that the sender can send before obtaining further permission.

Multiplexing:

In order to allow multiple processes in a single host to use TCP communication at the same time, TCP provides a set of addresses (that is, ports) in each host. It is connected in series with the network and host address from the Internet communication layer (such as the IP layer) to form a socket. Each connection is uniquely identified by a pair of sockets. That is, a socket can be used in multiple connections at the same time.

The binding of ports and processes is handled independently by each host. However, it has proven useful to connect frequently used services (for example, "Log Service" or Time Service) to fixed sockets that are already known to the public. These services can then be accessed through a known address. Establishing and learning the port addresses of other processes may involve more dynamic mechanisms.

connection:

The reliability and flow control mechanisms described above require TCP to initialize and maintain certain state information for each data flow. The combination of this information (including socket, serial number, and window size) is called a connection. Each connection is uniquely determined by a pair of sockets that identify both sides of it.

When two processes want to communicate, their TCP must first establish a connection (initialize state information on each side). After their communication is completed, the connection will be terminated or closed to release resources for other uses.

Since a connection must be established between unreliable hosts and an unreliable Internet communication system, a handshake mechanism with a clock-based serial number is used to avoid incorrectly initializing the connection.

Priority and safety:

Users of TCP can indicate the security and priority of their communications. When these features are not needed, the default values ​​can be used.

 

Guess you like

Origin blog.csdn.net/maimang1001/article/details/112685887