Table of contents
No headings in the article.
Blog on TCP vs UDP
Hey everyone, I am going to start a series of writing blogs on backend-related topics, which will help me to gain knowledge around the backend and will strengthen my foundation. The main purpose of writing is to clarify what I think and the way I grasp knowledge. So let's first see what topics I'm going to learn.
TCP vs UDP
HTTP/http1.1/http2/HTTPS
Web server
TLS
NAT
Proxy and Reverse Proxy
ACID Properties in RDBMS
Pub-Sub Architecture
Database Indexing
... and much more
Let's first cover the first part
- TCP vs UDP
TCP and UDP are the protocols used to transfer data in a network, now you are a little confused about what the heck protocol is ?? basically, protocols are the standard rules that must be followed during any data transfer.
ok now you understand what protocol is and TCP and UDP are those. TCP stands for Transmission control protocol, before transmitting the data TCP does a 3-way handshaking to create a connection between the server.
3 way handshaking in TCP
Let's have a look at what advantages TCP gives us:
Acknowledgement: When you deliver something you must want to know whether is it delivered or not, so in the case of TCP it is there.
Guarantee Delivery: There is a guaranteed delivery of packets
Connection Based: A connection is created before transmitting the Data, it's a 3-way handshaking algorithm.
Ordered Packets: The order in which the packets are sent the server will receive the packet in that order only.
Congestion Control : Controlling the traffic and managing it
Now let's discuss some of the disadvantages
Larger packets:
Slower than UDP:
Stateful
Server memory
A limited number of Connections
Applications of TCP
HTTP uses TCP to transmit data in a network
Databases use TCP
SMTP used TCP
FTP used TCP
UDP stands for User Datagram protocol, it is fast as compared to TCP as it doesn't have that overhead for the larger headers.You can understand about it when we discuss it advantages and disadvantages as compared with TCP
Advantages:
Smaller packets:
Stateless
Fast
Disadvantages:
No Acknowledgement
No Guarantee Delivery
Connection less
No order Packets
Applications of UDP
Video Conferencing
Online games
DNS uses UDP to fetch IP addresses
Thank you for reading this article!
If you enjoyed this article and want to learn more about Javascript, follow me on LinkedIn at Himanshu Singh, where I post regular updates.