What is TCP header and describe the purpose of each field?

A TCP segment consists of a TCP header, TCP options and the data that the segment transports. Following table represents a TCP header and it’s fields. The fields of TCP header are source port and destination port of a application, 32 bit sequence number, 32 bit acknowledgement number, TCP header length, 6 reserved bits, 6 flags (URG, ACK, PSH, RST, SYS, FIN), 16 bit window size, 16 bit TCP checksum, 16 bit urgent pointer, Options if any and padding if needed. Minimum header length is 20 bytes long i.e 5 32 bit words. The TCP maximum header size can be up to 15, 32 bit words. i.e. 60 byte long.

bits012345678910111213141516171819202122232425262728293031
016-bit source port16-bit destination port
3232-bit sequence number
6432-bit acknowledgement number
96Header Length 4-bitsReserved 6-bitsURGACKPSHRSTSYNFIN16-bit window size
12816-bit TCP checksum16-bit urgent pointer
160OptionsPadding

Source and Destination Ports:

Both source and destination ports are 16-bit fields identify protocol ports of the sending and receiving applications. The source and destination port numbers plus source and destination IP addresses in the IP header combine to uniquely identify each TCP connection referred as a socket.

Sequence Number:

Sequence number is a 32-bit wide field identifies the first byte of data in the data area of the TCP segment. We can identify every byte in a data stream by a sequence number.

Acknowledgement Number:

Acknowledge number is also a 32-bit wide field which identifies the next byte of data that the connection expects to receive from the data stream.

Header Length:

Header length is a field which consists of 4 bit to specifies the length of the TCP header in 32-bit words. Receiving TCP module can calculate the start of the data area by examining the header length field.

Flags:

URG – URG flag tells the receiving TCP module as it is urgent data

ACK – ACK tells the receiving TCP module that the acknowledge number field contains a valid acknowledgement number

PSH – PSH flag tells the receiving TCP module to immediately send data to the destination application

RST – RST flag asks the receiving TCP module to reset the TCP connection

SYN – SYN flag tells the receiving TCP module to synchronize sequence number

FIN – FIN flag tells the receiving TCP module that the sender has finished sending data

Window Size:

Window size field is a 16-bit wide which tells the receiving TCP module the number of bytes that the sending end id willing to accept. The value in this field specifies the width of the sliding window.

Checksum:

TCP checksum is a 16-bit wide filed includes the TCP data in it’s calculations. This field helps the receiving TCP module to detect data corruption. That is, TCP requires the sending TCP module to calculate and include checksums in this field and receiving TCP module to verify checksums when they receive data. The data corruption is detected in this way.

Urgent pointer:

Urgent pointer is a 16-bit wide field specifies a byte location in the TCP data area. It points to the last byte of urgent data in the TCP data area.

Options:

TCP header includes an optional options field like the IP header. During the initial negotiations between two ends of a TCP connection, this field is used with maximum segment size option, which advertise the largest segment that the TCP module expects to receive.

(Visited 6,848 times, 5 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *