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:
Process-to-Process Communication
TCP provides process-to-process communication using port numbers. Below Table lists some well-known port numbers used by TCP.
Port | Protocol | Description | |
1 | 7 | Echo | Echoes a received diagram back to the sender |
2 | 9 | Discard | Discard any Diagram that is received |
3 | 11 | Users | Active Users |
4 | 13 | Daytime | Returns the Date and Time |
5 | 17 | Quote | Returns the Quote of the day |
6 | 19 | Chargen | Returns a string of characters |
7 | 20 | FTP, Data | File Transfer Protocol (data connection) |
8 | 21 | FTP, Control | File Transfer Protocol (control connection) |
9 | 23 | TELNET | Terminal Network |
10 | 25 | SMTP | Simple Mail Transport Protocol |
11 | 53 | DNS | Domain Name System |
12 | 67 | BOOTP | Bootstrap Protocol |
13 | 79 | Finger | Finger |
14 | 80 | HTTP | Hyper Text Transfer Protocol |
15 | 111 | RPC | Remote Procedure Call |
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.
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.
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.
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.
Connection Oriented:
1. The Two TCPs establish connection between them.
2. Data are exchanged in both directions.
3. The connection is terminated.
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
connection establishment.
data transfer.
connection termination
TCP connection establishment (3-Way handshake)
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.
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.
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.