TCP (Transmission Control Protocol)

TCP (Transmission Control Protocol)

Exploring TCP: Detailed Look at Services, Header Segments, and Connections

TCP (Transmission Control Protocol) is a protocol that uses connection-oriented transmission protocol. It is mainly known for its reliability and process-to-process communication. TCP is a connection-oriented protocol; it creates a virtual connection between two TCPs to send data. In addition, TCP uses flow and error control mechanisms at the transport level. In brief, TCP is called a connection-oriented, reliable transport protocol. It adds connection-oriented, and reliability features to the services of IP.

TCP Services:

  1. Process-to-Process Communication

TCP provides process-to-process communication using port numbers. Below Table lists some well-known port numbers used by TCP.

PortProtocolDescription
17EchoEchoes a received diagram back to the sender
29DiscardDiscard any Diagram that is received
311UsersActive Users
413DaytimeReturns the Date and Time
517QuoteReturns the Quote of the day
619ChargenReturns a string of characters
720FTP, DataFile Transfer Protocol (data connection)
821FTP, ControlFile Transfer Protocol (control connection)
923TELNETTerminal Network
1025SMTPSimple Mail Transport Protocol
1153DNSDomain Name System
1267BOOTPBootstrap Protocol
1379FingerFinger
1480HTTPHyper Text Transfer Protocol
15111RPCRemote Procedure Call
  1. Stream Delivery Service:

    TCP, on the other hand, allows the sending process to deliver data as a stream of bytes and allows the receiving process to obtain data as a stream of bytes.

  2. Sending and Receiving Buffers:

    Sending and Receiving Buffers Because the sending and the receiving processes may not write or read data at the same speed, TCP needs buffers for storage. There are two buffers, the sending buffer and the receiving buffer, one for each direction.

  3. TCP Segments:

    At the transport layer, TCP groups a number of bytes together into a packet called a segment. TCP adds a header to each segment (for control purposes) and delivers the segment to the IP layer for transmission. The segments are encapsulated in IP datagrams and transmitted.

  4. Full Duplex:

    TCP offers full-duplex service, in which data can flow in both directions at the same time. Each TCP then has a sending and receiving buffer, and segments move in both directions.

  5. Connection Oriented:

    1. The Two TCPs establish connection between them.

    2. Data are exchanged in both directions.

    3. The connection is terminated.

  6. Reliable Service:

    TCP is a reliable transport protocol. It uses an acknowledgment mechanism to check the safe and sound arrival of data. We will discuss this feature further in the section on error control.

TCP Segment Format:

Source port address. This is a 16-bit field that defines the port number of the application program in the host that is sending the segment.

Destination port address. This is a 16-bit field that defines the port number of the application program in the host that is receiving the segment.

Sequence number. This 32-bit field defines the number assigned to the first byte of data contained in this segment. As we said before, TCP is a stream transport protocol. To ensure connectivity, each byte to be transmitted is numbered. The sequence number tells the destination which byte in this sequence comprises the first byte in the segment. During connection establishment, each party uses a random number generator to create an initial sequence number (ISN), which is usually different in each direction.

Acknowledgment number. This 32-bit field defines the byte number that the receiver of the segment is expecting to receive from the other party. If the receiver of the segment has successfully received byte number x from the other party, it defines x + I as the acknowledgment number. Acknowledgment and data can be piggybacked together.

Header length. This 4-bit field indicates the number of 4-byte words in the TCP header. The length of the header can be between 20 and 60 bytes.

Therefore, the value of this field can be between 5 (5 x 4 =20) and 15 (15 x 4 =60). Reserved. This is a 6-bit field reserved for future use. Control. This field defines 6 different control bits or flags as shown in Figure. One or more of these bits can be set at a time.

TCP Connection:

TCP is connection-oriented. A connection-oriented transport protocol establishes a virtual path between the source and destination. All the segments belonging to a message are then sent over this virtual path. Using a single virtual pathway for the entire message facilitates the acknowledgment process as well as retransmission of damaged or lost frames.

In TCP, connection-oriented transmission requires three phases

  1. connection establishment.

  2. data transfer.

  3. connection termination

TCP connection establishment (3-Way handshake)

  1. The client sends the first segment, a SYN segment, in which only the SYN flag is set. NOTE: A SYN segment cannot carry data, but it consumes one sequence number.

  2. The server sends the second segment, a SYN +ACK segment, with 2 flag bits set: SYN and ACK. This segment has a dual purpose. It is a SYN segment for communication in the other direction and serves as the acknowledgment for the SYN segment. It consumes one sequence number.

    NOTE: A SYN+ACK segment cannot carry data but does consume one sequence number.

  3. The client sends the third segment. This is just an ACK segment. It acknowledges the receipt of the second segment with the ACK flag and acknowledgment number field. Note that the sequence number in this segment is the same as the one in the SYN segment; the ACK segment does not consume any sequence numbers.

    NOTE: An ACK segment, if carrying no data, consumes no sequence number.

    TCP 3-Way handshake

Thank you for reading this article.