TCP Headers

TCP packets have a header that contains state data and other connection information. The header structure is shown in Figure 12-26.

Source Port

Destination Port

Sequence Number

Offset Reserved ®@®®©©

Window

Check sum

Urgent Pointer

Options | Padding

Payload

Figure 12-26: Structure of a TCP packet.

source and dest specify the port numbers used. As with UDP, they consist of 2 bytes.

seq is a sequence number. It specifies the position of a TCP packet within the data stream and is important when lost data need to be retransmitted.

□ ack_seq holds a sequence number used when acknowledging receipt of TCP packets.

□ doff stands for data offset and specifies the length of the TCP header structure, which is not always the same owing to the variable nature of some of the options.

□ reserved is not available (and should therefore always be set to 0).

□ urg (urgent), ack (acknowledgment), psh (push), rst (reset), syn (synchronize), and fin are control flags used to check, establish, and terminate connections.

□ window tells the connection partner how many bytes it can send before the receiver buffer will be full. This prevents backlog when fast senders communicate with slow receivers.

□ checksum is the packet checksum.

□ options is a variable-length list of additional connection options.

□ The actual data (or payload) follows the header. The options field may be padded because the data entry must always start at a 32-bit position (to simplify handling).

The header is implemented in the tcphdr data structure. The system endianness must be noted because a split byte field is used.

Continue reading here: Info

Was this article helpful?

0 0