Overview of the header format for TCP message segments
The first 20 bytes of a TCP packet header are fixed, so the minimum length of the TCP header is 20 bytes.
Source Port and Destination port
Each account is 2 bytes, written to the source port number and the destination port number, respectively.
Serial number
is 4 bytes, which represents the number of the first byte of data sent by this section. Each byte of a stream of bytes transmitted in a TCP connection is sequentially numbered . Since the serial number is represented by 32 bits, the serial number wraps around every 2^32 byte, starting from 0 again.
Confirmation number
Account for 4 bytes, which is the ordinal of the first data byte expected to be received by the other party writing a message segment. If the confirmation number =n, it indicates that all data up to the serial number N-1 has been received correctly.
Data offset (TCP first ministerial level)
Occupies 4 bits, it indicates how far from the beginning of the TCP message segment the data at the beginning of the TCP message segment is. This field actually indicates the first ministerial degree of the TCP segment, since the maximum decimal number that the 4-bit binary can represent is 15, so the maximum value for the data offset is 60 bytes, which is the maximum length of the TCP header.
Emergency Urg Control bit
When Urg=1, indicates that the emergency pointer field is valid. It tells the system that there are urgent data in this message and should be transmitted as soon as possible rather than in the original queue order. When Urg 1 o'clock, the sender TCP inserts the emergency data into the front of the data in this section, and the data behind the emergency data is still normal data. This is used in conjunction with the Emergency pointer field in the header.
Confirm ACK Control bit
The confirmation Number field is valid only when ack=1, and TCP specifies that all transmitted message segments after the connection is established must have an ACK of 1.
Push PSH Control bit
Sender TCP puts PSH 1 and immediately creates a message segment to send out. The receiver TCP receives the PSH=1 message segment and delivers the receiving application process as quickly as possible, instead of waiting until the entire cache is filled and then up.
Reset rst Control bit
When rst=1 indicates a serious error in the TCP connection, the connection must be released before the transport connection can be re-established.
Synchronizing SYN control bits
When the connection is established to synchronize the sequence number, when Syn=1 and ack=0, it indicates that this is a connection request message segment. If the other party agrees to establish a connection, the syn=1 and ack=1 should be made in the message section of the response. Therefore, a SYN set of 1 indicates that this is a connection request or a connection acceptance request.
Terminating fin control bit
Used to release a connection. When Fin=1, it indicates that the sending data of this segment has been sent and the transport connection is released.
Window
accounts for 2 bytes. Window refers to the receiving window that sends this section. Window value tells the other side: from the first paragraph of this section of the confirmation, the receiver is currently allowed to send the amount of data. The window value is the basis on which the sender sets its sending window as a receive method. The Window field clearly indicates the amount of data that is now allowed to be sent. The window values are constantly changing dynamically.
Emergency pointers
accounts for 2 bytes. Indicates the number of bytes of emergency data in this section.
Options
The length is variable and can be up to 40 bytes long. When "Options" is not used, TCP's header length is 20 bytes.
The Options section applies:
- MSS Maximum message segment length (maxium Segment Size): Indicates the maximum length of the data field, the length of the data field plus the length of the TCP header is equal to the length of the entire TCP message segment. The MSS value indicates the length of the data field that you expect the other party to send the TCP segment. Both sides of the communication can have different MSS values. If not filled, the default is 536 bytes. MSS only appears in the SYN message. That is, MSS appears in the Syn=1 message segment.
- window enlargement options (Windows scaling): Because the TCP header's window large segment length is 16 bits, the maximum number represented is 65535. But as latency and bandwidth-heavy communications arise (such as satellite communications), larger windows are needed to meet performance and throughput rates, resulting in this window enlargement option.
- Sack Select confirmation (selective acknowledgements): used to ensure that only the missing segments are re-transmitted, not all segments of the message. For example, host A sends the message segment 1, 2, 3, and Host B receives only the message segment 1, 3. Then you need to use the sack option to tell the sender to send only the missing data. So how do you specify which pieces of message are missing? The use of Sack requires two function bytes. One indicates that you want to use the SACK option, and the other indicates how many bytes this option occupies. The description of the missing segment 2 is done by describing its left and right boundary message segment 1 and. And this 1, 3 actually represents the serial number, so describing a missing segment requires 64 bits or 8 bytes of space. You can then extrapolate the entire option field to the maximum description (40-2)/8=4 a missing message segment.
- Timestamp option (timestamps): can be used to calculate the RTT (round trip time), when the sender sends a TCP message, the current time value is put into the timestamp field, the receiving party receives a confirmation message, the value of the timestamp field is copied into the confirmation message, The RTT is calculated when the sender receives a confirmation message. It can also be used to prevent wrapping the serial number paws, or can be used to distinguish the same serial number of different messages. Because the serial number is indicated by 32, each 2^32 serial number will produce a wrap, then it is easy to distinguish different messages with the same serial number using the Timestamp field.
- NOP (no-operation): It requires that each option in the Options section must be a multiple of 4 bytes in length, and that the insufficiency is padded with NOP. It can also be used to split different options fields. such as window enlargement options and sack are separated by NOP.
Computer network (8)-----The header format of the TCP message segment