TCP (Transmission Control Protocol).

This is a transport layer protocol which controls the transmission of data. It ensures multiple things like source and destination are verified and data is delivered correctly. Let’s see how the world without TCP would look like. Imagine if an HTTP does not use TCP (in reality it does), but just imagine for a moment. The following would happen

  • When a client sends an HTTP request to the server it can only keep waiting long for the response.  
  • It does not know whether the request has actually reached the server or not.  
  • It does not know whether the request is actually being sent to the correct server or not. 
  • It does not know whether the message sent will be delivered in order or not. (Message should not get jumbled up).
  • It does not know whether the request has been intercepted by a third-party or attacker or not. 
  • It does not know whether someone intercepted and tampered the message body (data). A malicious attacker can delete some data by intercepting the data. 
  • A malicious attacker can also sniff around the data as the request being sent is unencrypted.  

Chaotic right?

Therefore, to address all such drawbacks, TCP was designed. The fundamental of TCP is to establish a connection and not just send and receive messages in the dark! TCP says – first connect then communicate.

The connection established between two machines via TCP will ensure that the packets (bundles of data) are reaching the right destination and in the correct order. It can also track any loss of data packet too. A TCP connection does not directly send the data but performs the 3-Way Handshake as follows. 

First : Source to Destination (SYN) request – Source first tries to synchronise with destination by sending a sequence number like 100. 

Second: Destination to Source (SYN/ACK) response – Destination receives the SYN packet, reads the sequence number 100 and then sends back an ACK of 101 (saying that it has received the package) and at the same time it also sends back its own SYN packet with a sequence number like 200. 

Third: Source to Destination (ACK) response – Source receives the (SYN/ACK) package and sends the ACK response validating the connection. 

Now we send plain data, HTTP request, SMTP request, FTP request or any other protocol request after 3-way handshake.  

TCP can essentially layer any other protocol and at the same time TCP is also a protocols so we can send data directly in TCP format as well.  

TCP also manages, flow control, congestion control, error correction, missing packets, retransmission of lost packets etc. 

We have seen how HTTP request and response looks like but how does TCP request response looks like?  

HTTP request and response is readable and looks like an algorithm whereas TCP request and response is tricky and only contains bits, which is understood by the client and server. Here is the format below – 

Use cases  

  • TCP is most widely used and in places where reliability and ordered delivery and secure connections is important. Almost all network connections like email, web browsing, file transfer etc., use TCP.  

Read about HTTPS and how it uses SSL/TLS here – https://techshshila.in/ssl-tls-sounds-scary-but-no-more/

Leave a Reply

Your email address will not be published. Required fields are marked *