Transmission Control Protocol (TCP) is a standard that defines how to establish and maintain a network conversation via which application programs can exchange data. TCP works with the Internet Protocol (IP), which defines how computers send packets of data to each other.
The absolute limitation on TCP packet size is 64K (65535 bytes), but in practicality this is far larger than the size of any packet you will see, because the lower layers (e.g. Ethernet) have lower packet sizes. The Maximum Transmission Unit (MTU) for Ethernet, for instance, is 1500 bytes.
A 20-byte header contains almost 13 multipurpose fields, which hold specific related object information such as application, data type and source/destination addresses. The following are detailed header field descriptions.
- Version: This contains the Internet header format and uses only four packet header bits.
- Internet header length (IHL): This 4-bit field stores IP header length information.
- Type of service (ToS): This 8-bit field provides network service parameters.
- Datagram size: (16-bit) This contains combined data and header length.
- Identification: This 16-bit field contains a specific number for primary data identification.
- Flags: This router fragment activity is controlled by three flags.
- Fragmentation offset: This is a fragment identification via offset value.
- Time to Live (TTL): This contains the total number of routers allowing packet pass-through.
- Protocol: This 8-bit field contains header transport packet information.
- Header checksum: It checks and monitors communication errors.
- Source address: It stores source IP address.
- Destination address: It stores destination IP address.
- Options: This is the last packet header field and is used for additional information. When it is used, the header length is greater than 32 bits.
- Data field (variable length) contains upper-layer information.
The TCP packet format consists of these fields:
- Source Port and Destination Port fields (16 bits each) identify the end points of the connection.
- Sequence Number field (32 bits) specifies the number assigned to the first byte of data in the current message. Under certain circumstances, it can also be used to identify an initial sequence number to be used in the upcoming transmission.
- Acknowledgement Number field (32 bits) contains the value of the next sequence number that the sender of the segment is expecting to receive, if the ACK control bit is set. Note that the sequence number refers to the stream flowing in the same direction as the segment, while the acknowledgement number refers to the stream flowing in the opposite direction from the segment.
- Data Offset(a.k.a. Header Length) field (variable length) tells how many 32-bit words are contained in the TCP header. This information is needed because the Options field has variable length, so the header length is variable too.
- Reserved field (6 bits) must be zero. This is for future use.
- Flags field (6 bits) contains the various flags:
- URG—Indicates that some urgent data has been placed.
- ACK—Indicates that acknowledgement number is valid.
- PSH—Indicates that data should be passed to the application as soon as possible.
- RST—Resets the connection.
- SYN—Synchronizes sequence numbers to initiate a connection.
- FIN—Means that the sender of the flag has finished sending data.
- Window field (16 bits) specifies the size of the sender’s receive window (that is, buffer space available for incoming data).
- Checksum field (16 bits) indicates whether the header was damaged in transit.
- Urgent pointer field (16 bits) points to the first urgent data byte in the packet.
- Options field (variable length) specifies various TCP options.