Simulating Guaranteed & In-order delivery
Note
This post simulates guaranteed & in-order delivery. Which are a feature of TCP and are lacking in UDP. We are going to use 2 of our favourite pandemic games - Skribbl.io & Valorant as examples in this post.
What is Data Sequencing (In-order transmission)
While transimitting the data over the internet, the data packet size that you send can be anything (let's say - 4MB). But there can be intermediate nodes in the network which may not support such a big size. So it is inevitable that your packet will be cut down into smaller packets for convinience.
When this happens, all these packets arrive at receiver in any order, due to any network congestions/ traffic problems. When this happens, it is important to make sure that the receiver is able to re-construct all the scattered packets into the original one. This is where Data Sequencing comes in.
Data Sequencing assigns a packet identification mechanism to each of the packet at the time of packet's separation from its other parts. The Receiver simply reads that property and assembles the packet back to its original state.
What is Guaranteed Delivery
When your 4MB packet is broken into many smaller packets and has to go through hundreds of intermediate nodes, it is inevitable that some packets may get lost in transmission.
In such scenario, the system should be able to let the Sender know that a particular packet is lost and needs to be resent. This is done using acknowledgements(ack).
How do acks work? whenever a packet is received at the receiver, the receiver sends back a (relatively smaller) packet saying that the packet of a particular sequence number was received. If the Sender does not receive this ack for a particular packet for a long time, it resends the packet. This is called Guaranteed Delivery.
Now there are 2 mainstream protocols - TCP & UDP. TCP is generally the one that gives us both of the above features.
Lets demonstrate both of the features discussed above with the help of two of our favourite pandemic video games - Skribbl.io & Valorant.
To give you a technical overview of both of the games -
| Game | Platform | Multiplayer | Protocol Used 1 |
|---|---|---|---|
| Valorant | Windows/PC | Yes | UDP |
| Skribbl | Browser | Yes | TCP |
When a network congestion occurs in Valorant, since it uses UDP, the missing packets are not re-delivered. Hence, glitches like teleportation occur. See below video. The system here isnt even able to distinguish between the latest and outdated packets, which is resulting in a lot of chaos.
Now let's get to Skribbl. Skribbl being a browser based game, uses TCP based protocol. Which means when a network congestion occurs in the game, it is made sure that all the packets are re-delivered and they are presented to the user in the exact same order as user intended. You can see below GIF which shows that as soon as we turn off network thorttling, we get all the drawing segments very quickly, and in the exact same order.
Footnotes
-
Note - This blog is a massive oversimplification of very complicated systems. There are a ton of other factors involved in choosing TCP or UDP while building complex systems like the games shown. This blog tries to isolate a very small piece of information. For all I know, both of the games might not even use the exact protocols that I have stated, but their systems surely don't have the features that I am experimenting with here. And thats all that matters here. ↩
🗨️ You can just talk to this blog!
Interact with content in a whole new way using custom prompts.