In our earlier article about how data travels across networks , we learned about the Transport Layer and how it handles communication between applications running on different devices.
We also briefly discussed two protocols: TCP and UDP .
If you haven't read that article, you can check it out first to understand what the Transport Layer does.
Now, let's understand how TCP and UDP actually work, how they're different, and when we use each of them.
Let's start with UDP .
UDP (User Datagram Protocol)
Let's say you're on a video call with your friend.
While you're talking, some of the audio data gets lost because of a network issue.
You might notice that the audio breaks for a second, but the conversation continues.
Now, imagine if your phone stopped the call and waited for that missing audio to arrive.
By the time it arrives, your friend might have already said something else.
So, in situations like this, receiving the latest data quickly can be more useful than waiting for missing data.
UDP is…