TCP is typically used by applications that require guaranteed delivery. It is a sliding window protocol that provides handling for both timeouts and retransmissions.
TCP establishes a full duplex virtual connection between two endpoints. Each endpoint is defined by an IP address and a TCP port number and is implemented as a finite state machine.
The byte stream is transfered in segments. The window size determines the number of bytes of data that can be sent before an acknowledgement from the receiver is necessary.
Source Port. 16 bits.
Destination Port. 16 bits.
Sequence Number. 32 bits.
The sequence number of the first data byte in this segment. If the
SYN bit is set, the sequence number is the initial sequence number
and the first data byte is initial sequence number + 1.
Acknowledgment Number. 32 bits.
If the ACK bit is set, this field contains the value of the next sequence
number the sender of the segment is expecting to receive. Once a connection
is established this is always sent.
Data Offset. 4 bits.
The number of 32-bit words in the TCP header. This indicates where
the data begins. The length of the TCP header is always a multiple
of 32 bits.
reserved. 3 bits.
Must be cleared to zero.
ECN, Explicit Congestion Notification. 3 bits
Control Bits. 6 bits.
Window. 16 bits, unsigned.
The number of data bytes beginning with the one indicated in the acknowledgment
field which the sender of this segment is willing to accept.
Checksum. 16 bits.
This is computed as the 16-bit one's complement of the one's complement
sum of a pseudo header of information from the IP header, the TCP
header, and the data, padded as needed with zero bytes at the end
to make a multiple of two bytes.
Urgent Pointer: 16 bits
This field communicates the current value of the urgent pointer as
a positive offset from the sequence number in this segment. The urgent
pointer points to the sequence number of the octet following the urgent
data. This field is only be interpreted in segments with the URG control
bit set.