TCP - Transmission Control Protocol

The Transmission Control Protocol (TCP) is responsible for reliable end to end delivery of segments of information. Segments is the term that is used to describe the data that is transmitted and received at the Transport level of the OSI model where TCP resides. TCP also redirects the data to the appropriate which port (upper level service) that is required.

The reliable end to end delivery of data is accomplished by:

  • Connection-oriented service

    Segments are acknowledged to the source when received by the destination. A sliding window is used to enable unacknowledged segments on the "wire" in order to speed up transmission rates

  • Sequencing of segments

    Data is broken up into segments that are numbered (sequenced) when transmitted. The destination TCP layer keeps track of the received segments and places them in the proper order (resequences).

  • Requesting retransmission of lost data

    If a segment is lost in transmission (missing sequence number). The destination will timeout and request that all segments starting at the lost segment be retransmitted.

  • Error checking

    Segments are checked for data integrity when received using a 32 bit CRC check.

The redirection of data to the upper level service is accomplished by using Source and Destination Port numbers. Multiple connections to the same service is allowed. For example, you may have many users (clients) connected to a single web server (http is normally port 80). Each client will have a unique Port number assigned (typically above 8000) but the web server will only use Port 80.

i. TCP Header

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1516 17 18 19 20 21 22 2324 25 26 27 28 29 30 31
Source Port (16 bits)Destination Port (16 bits)
Sequence Number
Acknowledgement Number
Offset (1st 4 bits)Flags (last 6 bits)Window
ChecksumUrgent Pointer
Options + Padding
Data

Source Port

The Source Port is a 16 bit number that Indicates the upper level service that the source is transmitting. For example:

  • 21 - ftp servers
  • 23 - telnet servers
  • 25 - smtp servers (Internet mail)
  • 80 - http servicers (web)

Here is a complete listing of Well Known Ports. TCP allows port numbers to be in the range from 0 to 65,535. Clients will have a unique port number assigned to them by the server. Typically the number will be above 8,000.

Destination Port

The Destination Port is a 16 bit number that Indicates the upper level service that the source wishes to communicate with at the destination.

Sequence Number

The Sequence Number is a 32 bit number that indicates the first octet of information in the data field. This is used to number each TCP segment transmitted in order to keep track of segments for sequencing of segments and error checking of lost segments. The source numbers the sequence of transmitted segments.

Acknowledgement Number

The Acknowledgement Number is a 32 bit number that is used to acknowledge the receipt of segments by the destination. The acknowledgement is the next sequence number expected. If the sender does not receive an acknowledgement for a segment transmitted, the sender will time-out and retransmit.

Offset (4 bits)

The Offset field consists of the first 4 bits (xxxx0000) of the first byte. The last 4 bits are reserved for future use and are set to 0. The Offset measures the number of 32 bit (4 byte) words in the TCP header to where the Data field starts. This is necessary because the TCP header has a variable length. The minimum length of the TCP header is 20 bytes which gives an Offset value of 5.

Flags (last 6 bits)

The Flags Field consist of the last 6 bits (00xxxxxx) of the second byte with the first 2 bits reserved for future use and they are set to 0. The Flags field consists of the following flag bits:

  • URG (Urgent Flag)

    When set indicates that the Urgent Pointer field is being used.

  • ACK (Acknowledge Flag)

    When set indicates that the Acknowledgement Number is being used.

  • PSH (Push Flag)

    An upper level protocol requires immediate data delivery and would use the Push (PSH) flag to immediately forward all of the queued data to the destination.

  • RST (Reset Flag)

    When set the connection is reset. This is typically used when the source has timed out waiting for an acknowledgement and is requesting retransmission starting at a sequence number.

  • SYN (Synchronize Flag)

    When set, it indicates that this segment is the first one in the sequence. The first sequence number assigned is called the Initial Sequence Number (ISN)

  • FIN (Finish Flag)

    When set, it indicates that this is the last data from the sender.

Windows (16 bits)

This contains the number of unacknowledged segments that are allowed on the network at any one time. This is negogiated by the Source and Destination TCP layers.

Checksum

The Checksum field is 16 bits long and calculates a checksum based on the complete TCP Header and what is called the TCP Pseudo header. The TCP Pseudo header consists of the Source IP Address, Destination IP Address, Zero, IP Protocol field and TCP Length. The IP Protocol field value is 6 for TCP

Urgent Pointer

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.

Options

Options may occupy space at the end of the TCP header and are a multiple of 8 bits in length. The allowed options are:

  • Kind 0 - End of option list.
  • Kind 1 - No Operation.
  • Kind 2 - Length 4 Maximum Segment Size. This is used to indicate the maximum segment size allowed.

Padding

The TCP header padding is used to ensure that the TCP header ends and data begins on a 32 bit boundary. The padding is composed of zeros.

Data

Finally here's the data that is being transmitted.

If this page has helped you, please consider donating $1.00 to support the cost of hosting this site, thanks.

Return to

TelecomWorld 101

Copyright July 2013 Eugene Blanchard