Introduction to TCP (Transmission Control Protocol)

Internship at OpenGenus

Get FREE domain for 1st year and build your brand new site

In this article we will talk about TCP or Transmission Control Protocol (TCP), which is one of the elementary topics in Computer Networking. We will discuss about the TCP model, it's uses, need and futher analyze it.

So what is TCP?

TCP is a standard that defines how to establish and maintain a network conversation through which application programs can exchange data. TCP works with the Internet Protocol (IP), which defines how computers send data to each other.

Clubbed together, TCP & IP are the basic rules that define the internet.

Table of Contents

  1. TCP
  2. How Transmission Protocol Works
  3. What TCP is used for
  4. Why TCP is important
  5. Features of TCP protocol
  6. TCP Header format
  7. Need of Transmission Control Protocol
  8. TCP vs UDP protocol
  9. TCP/IP vs OSI model
  10. The disadvantage of TCP

TCP

TCP stands for Transmission Control Protocol. It is a transport layer protocol that facilitates the transmission of packets from source to destination. It is a connection-oriented protocol that means it establishes the connection prior to the communication that occurs between the computing devices in a network. This protocol is used with an IP protocol, so together, they are referred to as a TCP/IP.

The main functionality of the TCP is to take the data from the application layer. Then it divides the data into a several packets, provides numbering to these packets, and finally transmits these packets to the destination. The TCP, on the other side, will reassemble the packets and transmits them to the application layer. As we know that TCP is a connection-oriented protocol, so the connection will remain established until the communication is not completed between the sender and the receiver.

How Transmission Protocol Works?

TCP is what is known as a connection-oriented protocol: a connection is maintained until the applications at each end have finished exchanging messages.

It's job is to determine how to break application data into packets that networks can deliver, send & accept packets from the network layer, manage flow control, handle retransmission of garbage packets and acknowledge all arriving packets.

In the OSI model, TCP covers parts of Layer 4: Transport layer & Layer 5: Session layer.

Eg: when a server sends an HTML file to a client, it uses the Hypertext Transfer Protocol (HTTP) to do so.

The HTTP layer signals the TCP layer to set up a connection and send the file. TCP breaks the file into data packets, assigns them numbers and delivers each of them individually to the IP layer. Even though each packet has the same source & destination address, packets can and may be sent along multiple routes. The TCP layer of client waits till all the packets have arrived, and then acknowledges those that it received and requests for re-transmission based on the number of missing packets.

After that, the TCP layer assembles the packets into a file and delivers it to the recieving end.

What TCP is used for?

TCP organizes data in a way that ensures secure transmission between the server and client. To guarantee the integrity of data sent over.

This is why it is used to transmit data from other high level protocols that require all transmitted data arrival.

Examples:

Secure Shell (SSH), File Transfer Protocol (FTP), Telnet: For peer-to-peer file sharing, and, in Telnet's case, logging into another user's computer to access a file.

Simple Mail Transfer Protocol (SMTP), Post Office Protocol (POP), Internet Message Access Protocol (IMAP): For sending and receiving email

HTTP: For web access

Why TCP is important?

The importance of TCP lies in the fact that it establishes the standard procedures by which communication happens over the internet.

It is one the foundations for the internet and the reason it is as it exists today and ensuring uniform data transmission is carried out, regardless of the location of source and destination, hardware/software etc.

That is also the reason, it is flexible and highly scalable: new protocols can be introduced to it and it will accommodate them. It is also nonproprietary, meaning no one person or company owns it, making it's use widespread.

Features of TCP protocol

The following are the features of a TCP protocol:

Transport Layer

TCP is a transport layer protocol as it is used in transmitting the data from the sender to the receiver.

Reliable

TCP is a reliable as it follows the flow & error control mechanism. It checks the state and sound arrival of the data which is known as acknowledgement mechanism. In it, the receiver sends a +ve or -ve acknowledgment to the sender so that the sender can get to know whether the data packet has been received or needs to be resended.

Order of the data is maintained

Ensures that the data reaches the intended receiver in the order that was sent. It sorts & numbers segments so that the destination's TCP layer reassembles them based on ordering.

Connection-oriented

This protocol is very connection-oriented which means the data exchange happens after the connection has been established. When the data transfer is complete, connection gets terminated.

Full duplex

It is a full-duplex which means that the data can transfer in both directions simultaenously.

Stream-oriented

TCP is also very stream-oriented as it allows sending and recieving data in the form of a stream of bytes. It creates an environment in which both the sender and receiver are connected by a virtual circuit. This virtual circuit carries the stream across the internet.

TCP Header format

Source port: contains the source port address, which is 16 bits.

Destination port: This field contains the destination port address, which is 16 bits.

Sequence number: contains the sequence number of data bytes in a session.

Acknowledgment number: contains the next sequence number of the data byte and an acknowledgment for previous data. If the receiver gets the segment number 'x', then it responds 'x+1' as the acknowledgment number.

Reserved: A 4-bit field kept for future use, and by default, all bits set to 0.

Flags

There are six control bits/flags in TCP:

URG: It represents an urgent pointer to process data urgently.
ACK: If the ACK is set to 0, it means that the data packet does not contain an acknowledgment.
PSH: If this is set, it requests the receiving end to push the data to the receiving application without buffer.
RST: it requests to restart a connection.
SYN: used to establish a connection between hosts.
FIN: used to release a connection, and no data exchange will happen.

Window size

It is a 16-bit field. It contains the size of data that receiver accepts. It is used for the flow control between the sender and receiver and determines the amount of buffer allocated by the receiver for each segment. The value of it is determined by the receiver.

Checksum

It is a 16-bit field. It's optional in UDP, but in TCP/IP, it is mandatory.

Urgent pointer

It is a pointer to the urgent data byte if the URG flag is 1. It defines a value that will add to the sequence number to get the sequence number of the last urgent byte.

Options

It provides additional options. This optional field is represented in 32-bits.

Need of Transport Control Protocol

In the network model, the whole task is divided into smaller parts. Each part is assigned to a layer that processes it.

In TCP/IP, the five layers are application, transport, network, data link, and physical layers.

The transport layer provides end-to-end communication to the application processes. It creates 65,000 ports so that the multiple applications can be accessed simulataneously. It takes the data from the upper layer, and it divides the data into smaller packets- transmitting them to the network layer.

TCP vs UDP protocol

UDP (User Datagram Protocol) is a connectionless, simple protocol that requires no recovery and error-checking. UDP causes zero overhead for opening, maintaining, or terminating a connection. It sends data continuously to any recipient, irrespective of whether they receive it.

UDP isn’t an ideal protocol for most needs. However, one can prefer it in cases of real-time communications such as broadcasts or multi-task network transmission.

The key differences between TCP and UDP are:

  1. TCP is connection-oriented, whereas UDP is connectionless.
  2. TCP is slower than UDP
  3. TCP uses handshake protocols like SYN, SYN-ACK, ACK, UDP none.
  4. TCP does error checking & recovery, UDP discards erroneous packets.
  5. TCP has acknowledgment segments, UDP does not have any.
  6. TCP is heavy-weight while UDP is lightweight.

OSI vs TCP/IP model

Similarities between OSI and TCP / IP Reference Models

  1. Both the models use layered architecture.
  2. The layers are compared with each other. The physical and the data link layers of the OSI model correspond to the link layer of the TCP/IP. The network layers and the transport layers are the same in both the models. The session, presentation and the application layers of the OSI model correspond to the application layer of the TCP/IP model.
  3. Protocols are defined layer-wise in both of the models
  4. In both of the models, data is divided in the form of packets and each packet may take individual routes to the destination.

Differences between OSI and TCP / IP Reference Models

  1. OSI model is a generic model that is based upon the different functionalities of each layer while TCP/IP is protocol-oriented
  2. OSI model recognizes and uses these three concepts that are: services, interfaces, and protocols. TCP/IP does not have a clear line between these three concepts.
  3. OSI model gives guidelines on how to communicate, while TCP/IP protocols layout standards on which the Internet was developed. So, TCP/IP is a more practical model.
  4. In OSI, the model was developed first and then the protocols in each layer came later but in TCP/IP, the protocols were developed first and then the model.
  5. The OSI has 7 layers while the TCP/IP has 4.

The Disadvantage of TCP

The disadvantage of the TCP protocol is that it adds a large overhead as each segment gets to have it's own TCP header, so fragmentation by the router increases the overhead which causes performance issues.

With this article at OpenGenus, you must have the complete idea of TCP.