TCP Header:

Description:

Sequence number (32-bits): Sequence numbers count segments as they are transmitted and received. But with TCP, the sequence numbers count octets within the transmission stream. The sequence number in the header of a segment identifies the position in the overall data stream of the first data octet in that segment. On connection setup, new sequence numbers are agreed by both nodes and the connection starts. For systems integrity after a machine crash, new sequence numbers don't start at zero. If IP never delivered datagrams in a different order from that in which thay were transmitted, data would always arrive in sequence and sequence numbers would increase smoothly. The sequence number allows TCP to slot a segmentinto the correct position in the data stream, even if IP delivers data out of order.

Acknowledgement number (32-bits): It acknowledges correct receipt of all octets up to the acnowledgement number -1. When a data sender receives a new value, it can dispose of data which was held for possible retransmission. The acknowledgement number is only valid if the ACK flag is set. Acknowledgement numbers are responses to correct receipt of sequence numbers and in-sequence data from the remote end. An acknowledgement number contains the (sequence) number of the next octet in its received data stream that the sender will pass to its application (with the octet zero numbered with sequence numbers which were exchanged at connection setup.) Thus, the acknowledgement number is one greater than the octet number of the last in-sequence octet received. It is teherfore the same as the sequence number that will be in the next segment of immediately useful data. In TCP, it is possible that have been received correctly but have not been acknowledged, because the critical segment, which is the next in sequence, has fialed to arrive. Either it is delayed, because it was routed via a slow path, or it was discarded by IP. the acknowledgement number cannot advance until this missing piece of the jigsaw is provided through retransmission on the retransmission timer.

Data Offset: This measures the offset to the start of the application data field in 32-bit words. The normal value is 5 (20 octet header) when no option are used.

Flags: The flags are used to indicate the validity of other fields and for connection control. There are six sepsrate flags:

            -URG: This indicates that the urgent pointer field is valid. This field points to an octet in the data field which is the end of urgent data. Urgent data is not considered as part of the normal data stream and should be processed before any other data. This operation is used in instances where a message has to be passed across the network to the application, even if some mechanism is preventing normal data from doing so. It can be used to interrupt programs.

            -ACK: This flag indicates that the acknowledge field is valid, which it is on most segments. The acknowledge field is normally only valid on connection setup, before each node has been able to determine which sequence and acknowledge valuesto use. The value in the acknowledge field may not have changed between segments, so although the field is valid it may not acknowledge new data.

            -PSH: The push flag causes the remote TCP layer to pass this segment immediately to the application layer. TCP would normally hold on the data from incoming segments and pass them to the application layer in large buffers to reduce processing overheads, but in some situations, such as character-by-character terminal operation, this must not happen, even if only one octet of data has been received.

            -RST: The reset flag is used when all else fails. It indicates that an error has occured and the connection should be forcibly closed.

            -SYN: The syncronize flag is used at the beginning of connection setup between two nodes. At this stage neither end knows what acknowledge number to use. A connection setup consists of a two-way exchange of segments with the SYN flag set, each of which is acknowledged in a segment with the ACK flag set. Data transfer can then commence.

            -FIN: The FIN flag is used to terminate connections. When one end of a connection has no more data to send, it sends a segment with the FIN flag set. When both ends of a connection have sent the FIn flag, the connection is closed.

Window (16-bits): The window advertises the amount of buffer space this node has allocated to this connection. The other node must not send more unacknowledged data than the buffer space indicated.

Checksum (16-bits): The TCP checksum is a basic check on the header and data. It is calculated in the same fashion as that in UDP, from the 16-bit 1st complement of the 1st complement sum of all 16-bit words in the header and data.

Urgent Pointer (16-bits): The value in this field points to the end of data field that is considered as urgent and requires immediate attention. This field is only valid if the URG flag is set.

Options: There is only one option used with TCP, which is Maximum Segment Size (MSS). It tells the destination TCP layer the maximum size of the segment (including TCP header) which should be sent. The format of this option is shown below.

Kind 2 is the MSS option; kinds 0 and 1 are end-of-option list and no operation, respectively. The length field indicates the length in octets of the complete option, that is, it includes the kind and length fields.

Padding: If the options field is valid, padding ensures that the data starts on a 32-bit boundary, so that the data offset may correctly point to it.

<Back>