1. TCP protocol (Transmission Control Protocol) is end-to-end reliable and connection-oriented protocol. The processing object is called a TCP segment (segment) and is a stream-based protocol.
2. Unlike UDP, TCP has two caches for sending and receiving, which are used to store TCP packet segments for retransmission and validation.
3. Features: Number System, traffic control, congestion control, error control, timer (4), etc.
4. TCP segment format: Header (20b-60b) + data (the first field is described below)
(1) Source Port address (2b) and destination port address (2b): Same as UDP
(2) serial number (SEQ) (4b), validation number (4B): As described below, validation number is valid only when Ack is marked as 1
(3) header length (4 Bit): the length of the 32bit header. Therefore, the header length is between 20b-60b.
(4), retain (6 bit)
(5), mark (6 bit), respectively: URG, ack, Psh, Pst, Syn, Fin
(6) window size (2b): In bytes. The current size of the receiving window to notify the recipient.
(7), checksum (2b): The same as the UDP checksum method, the difference is that this function is required for TCP.
(8) Emergency pointer (2b): valid when URG is marked as 1. For details, see.
5. Numbering System
(1) serial number: The serial number is measured in bytes, not in the packet segment. The ISN is randomly generated, and the subsequent byte numbers are incremented by 1. The serial number of the packet segment is the number of the first byte in the packet segment.
If the packet segment does not carry user data, the serial number is not required logically (for example, only the confirmed packet is included), but a serial number is required at the time of a TCP connection and termination, for confirmation by the recipient, for example, both SYN and FIN packets consume 1 byte serial number.
(2) ACK, which is valid only when Ack is set. Indicates the number of bytes that the receiving end expects to receive in the Next Step (the confirmation number is cumulative, which is described in the retransmission confirmation mechanism)
6. Meaning of the Mark bit:
(1) URG indicates an emergency pointer mark. If it is set, the following URG field is valid for TCP outbound data (see "outbound data and emergency Pointer ).
(2) Psh indicates that the packet does not need to wait until the sending buffer is full and can be sent. After receiving the packet, the receiving end immediately assigns the application process (Most TCP implements the function of ignoring this flag)
(3) ack validation mark, which indicates that the following ack serial number field is valid and has the confirmation function (it may be a token with confirmation)
(4) rst: Connection Reset, used to terminate an idle connection and terminate an abnormal connection
(5) Syn is used to synchronize serial numbers when a connection is established.
(6) Fin is used for sequence number synchronization at the end of the connection.