TCP Learning (1)--Message Segment header format

Source: Internet
Author: User

Key features of 1.TCP(1). TCP's connection-oriented Transport layer protocol;(2). Each TCP connection can have only two endpoints (endpoint), which is the connection between point to points, each endpoint is called socket (socket), Socket socket= (IP address: port number). (3). TCP provides reliable payment of services;(4). TCP provides duplex communication;(5). Byte stream oriented.

header format for 2.TCP message segmentsAlthough TCP is a byte-stream oriented, TCP transmits a data unit that is a message segment. A TCP message segment is divided into headers and data two parts, and the full functionality of TCP is reflected in the function of each field in its header. The first 20 bytes of the header of the TCP packet are fixed, followed by 4 N bytes, which is an option added as needed. Therefore, the minimum length of the TCP header is 20 bytes. the TCP message segment header is shown
The fixed section is described below:(1). Souce Port: Source ports. (2). Destination Port: Destination ports. (3). Sequence Number: The ordinal number that represents the first byte ordinal of the data sent by this section. (4). Acknowledge number: Confirm that you expect to receive the ordinal of the first data byte of the next message segment of the other party, and if the confirmation number equals n, then all data with the sequence number n-1 has been received correctly. (5). Data offset: The distance from the start position of the data in the message segment to the starting position of the message segment, in 32-bit words. (6). Reserved: Reserved(7). URG: The emergency bit, when the bit is 1 o'clock, indicates that the emergency pointer (Urgent Pointer) is valid. When Urg 1 o'clock, the sending application process tells the sender that TCP has emergency data to transmit. As a result, sender TCP inserts emergency data into the front of the data in this section, and the data behind the emergency data is still normal data. To be used in conjunction with the emergency pointer (Urgent Pointer). (8). ack: The acknowledge number is valid only when ack=1. TCP provides that all transmitted message segments must have an ACK set 1 after the connection is established. (9). PSH: Push, push, sender puts PSH position 1 o'clock, TCP immediately creates a message segment to send out. The receiver TCP receives the PSH=1 message segment and delivers it to the receiving application process as soon as possible, rather than waiting until the entire cache is filled. (10). RST: Reset, when Rst=1, indicates that the connection is released and then re-established. RST 1 is also used to reject an illegal message segment or to refuse to open a connection. (11). SYN: Synchronization, synchronous, used to synchronize serial numbers when establishing a connection . 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 are made in the Response message section. Therefore, a SYN set of 1 indicates that this is a connection request or a connection acceptance message. (12). FIN: Terminating, used to release a connection. When Fin=1, it indicates that the sender's data for this segment has been sent and that the connection is required to be released. (13). window, which refers to the receiving window of the party sending the text segment (not its own sending window). The window value tells the other party, starting from the confirmation number in the first paragraph of this section, the amount of data sent by the message receiver at acknowledge. (14). Check Sum: Checksum, which is used to check for errors in the received data. (15). Urgent point: Emergency pointer. Valid only at Urg=1, it indicates the position of the end of the emergency data in the message segment. Emergency data can be sent even if the window is 0 o'clock. (16). Options: option, variable length, up to 40 bytes. When no option is used, TCP's header length is 20 bytes.
The various parts of these segments will appear in different states when TCP establishes a connection, TCP data transfer, and TCP disconnects, especially Six Flags: Urg,ack,psh,rst,syn and Fin. The establishment and disconnection of TCP connections is described later.


Reference DocumentsShehiren, computer Network (fifth Edition): Electronic industry press,.


Copyright, welcome reprint, reproduced Please indicate the source, thank you




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

TCP Learning (1)--Message Segment header format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.