Chapter 5. Transport Layer—The Header of a TCP Packet

The following is from the computer network open class notes and personal data collected by Lake University of Science and Technology

The format of the TCP message is as follows:
insert image description here
The Chinese names corresponding to the 6 flags:
insert image description here

The following is an introduction to each field in the order of the TCP header:

The source port and the destination port respectively indicate the application process sending the TCP segment . From the perspective of network programming, create a socket () in the process, use the TCP protocol to connect to another host, and the port number of the current process will be written into the message. So there is a bit of a misunderstanding in the front, thinking that there is a special process for TCP communication, this is wrong, TCP is just a protocol. For example, if a URL is entered in a browser, the browser process will construct a TCP segment encapsulating an HTTP request message, and the source port given is the port number of the browser process.

Serial number:
insert image description here
Note that those numbers in the data payload are not the content, but the number of bytes.

Confirmation Number:
insert image description here

Data offset:
Note that the unit is 4 bytes , so the offset value is 0101, which is 5 in decimal, then 5x4 == 20, and the length of the header can be obtained as 20 bytes
insert image description here

Reserved field : occupies 6 bits, reserved for future use, currently set to 0

Confirmation flag bit ACK:
insert image description here

Synchronization flag SYN:
It will be used to synchronize the serial number when the connection is established, see the three-way handshake for details.
insert image description here
Termination flag FIN:
insert image description here
Reset flag RST:
When RST=1, it means that TCP has an exception, and it must be connected, and then re-establish the connection. Setting RST to 1 is also used to reject an illegal segment or refuse to open a TCP connection.

Push flag bit PSH:
Receiver's TCP will hand over the segment to the application process as soon as possible after receiving the segment with the flag bit set to 1, instead of waiting until the receiving buffer is full before delivering it. Equivalent to urgency.

Urgent flag bit URG and urgent pointer field:
Both are used to implement urgent operations. In fact, it means that if there is urgent data to be sent, the message will be encapsulated and sent immediately.
insert image description here

Window field:
insert image description here
Note that the size of the send window also depends on the size of the congestion window, whichever is smaller between the receive window and the congestion window.

Checksum:
It is used to check whether there is a bit error in the entire TCP segment during transmission , that is, in addition to the TCP message, the data carried will also be checked. However, the error detection function is not the focus of TCP.
insert image description here

Options section:
最大四十字节 .
insert image description here

Padding field:
padding is used to ensure that the message header can be divisible by 4 (Because the data offset field, that is, the header length field, is in units of 4 bytes, said earlier)

Guess you like

Origin blog.csdn.net/mrqiuwen/article/details/130141237