DEV Community

Discussion on: Explain TCP like I'm five

Collapse
 
jacoby profile image
Dave Jacoby • Edited

I took networking in college, and then a bunch of us went to a coffee shop with free refills, so I always demonstrate network packets with sugar packets.

Let us contrast it with UDP. Imagine you're behind me and ask for a sugar packet. I grab one and throw it over my shoulder. It's not my responsibility to throw it to you, and I don't care if you get it. If you're where I think you are, you can ask for more and more, getting enough sugar to sweeten everyone's coffee, which is why UDP is often used for video, but dropped sugar stays dropped.

TCP has the "three-way handshake", which is more like:

I would like a sugar packet

I heard you ask for a sugar packet

I did ask for a sugar packet

Here's the sugar

This way, the sugar packets don't end up all over the floor.

Collapse
 
jabranr profile image
Jabran Rafique

Is TCP British? It sounds like one from the conversation flow.

Collapse
 
ben profile image
Ben Halpern

So how much sugar do I get to ask for in the first trip to the counter and each subsequent trip, and why is this so?

Collapse
 
tbd profile image
TBD

you ask for sugar and the server starts a session where he sends a numbered sugar sachets (TCP frames) and you confirm the delivery of each sachet (based on checksums) and as @gldraphael said the sugar arrives after the handshake

Thread Thread
 
ben profile image
Ben Halpern

And if I understand correctly, the barista will give give me one packet on the first trip, then two, then four, etc. and in data terms, each packet is about 14k in size.

Collapse
 
galdin profile image
Galdin Raphael

If sugar is the data, shouldn't it be handed over after the three way handshake?