Skip to main content

Command Palette

Search for a command to run...

TCP and UDP

Published
4 min read
TCP and UDP

In the previous blogs we talked about how DNS resolves and helps us reach the ip related to the domain name we want to visit, but what specifically happens after that. The basic need of any transaction on internet is Data, so after connecting to the ip we need to share data.

This sharing/tranportation of data is done using some protocols, some of most widely used of which are TCP and UDP, but understanding that data is done by http(Hytper Text Transfer Protocol). Its basically a language, set of rules used to communicate while using TCP or UDP.

Now adding the DNS, TCP and http req sent we form the client side of a basic request.Lets get to know more about the these protocols.

TCP (Transmission Control Protocol)

It is reliable way of sharing data. It shares the data in ordered method, with flow and congestion control.It also has the loss detections which prevent data packets lost during transmission. But due to retransmission and confirmation at every step, causes it to be slower but reliable.

UDP (User Diagram Protocol)

Its is also a way sharing data just like TCP, but its not reliable and it doesnt send the data in order. Alspo there is no rentransmission and congestion control which causes some packets to get lost. Its not reliable like TCP but it surely is faster ,and some protocols are developed which prevent data packets loss while minimally affecting speed.

Use Cases

We can’t debate on the topic that TCP is better or UDP is better as both are used, just depending on their usecases and the requirements.

For eg :- You need to attend a video call, so your requirements are : It must be realtime,I should be able to recieve/send audio & video as fast as possibble. In this scneario when missing some data packets might not that big of an issue UDP can be used.

The usecase for TCP are mainly where data reliability is a priority. Like in bank transfers, you need to ensure that all details like:- Account Number, amount etc. being sent are correct. At that point loss of data packets could cause a disaster. In such cases the TCP is the option, we would choose.

HTTP dielmma

Now the question arises, okay we are resolving DNS then also sending data but why do we need something like HTTP. Lets understand it with help of an analogy:

You have been sent a courier, then the transport company made sure that package reaches your address. But after you recieve the package , you don’t understand whats the use of the things in package and where to use them. So what will you do , use google or chat gpt to search about it, nope the google and chatgpt are sending some gibberish which you don’t understand. And thats what we need http for.

In the analogy

  • The package stand for Data

  • The transport company as the TCP/UDP, which ensures you recieve the data

  • The Internet as the roads and transportation network

  • The http as the manual + rules required inside the package

Application Level Programs

So, every language in world is communicated along sentiments while communicating, based on what we are talking about .Similarly HTTP as a language has its own sentiments that helps us makes sense of the , what its talking about and in what intent, like its sending data, recieving data, updating or deleting etc..

To add this functionality http uses many types of requests or the so called HTTP methods. The various types of methods are GET, POST, PUT,DELETE,PATCH,HEAD etc. We will talk in depth about the request and responses from http headers in the next blog, related to CURL.

Along with Methods , HTTP also uses Headers which describe the data format, which can be equated to context in a conversation. Similarly, the status code are also carried within HTTP req/response , along with the data.

Now that client has sent the http request , after recieving a http response from the server the data can be accessed two ways.

  • Browser

  • Curl( the programmer’s way)

In the upcoming blogs i will discuss about how data is accessed through curl and browser. We will also go into depth of what things are hidden and what are shown in each process, just like how developers see world in a different way.