Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, Networking! ACK!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

Step 3 in our plan is “open a TCP connection!” Let’s learn what this “TCP” thing even is

When you send a packet sometimes it gets lost

jvns.ca server → Cat packets → lightning bolt
laptop: nope never got it

TCP lets you send a stream of data reliably, even if packets get lost or sent in the wrong order.

four butterflies, labelled TCP C, TCP D, TCP D (duplicates), TCP A, and TCP B

laptop: it says “abcd”!

how does TCP work, you ask? WELL!

how to know what order the packets should gо in:

Every packet says what range of bytes it has.

Like this:
once upon a ti ← bytes 0-13
agical oysterbytes ← 30-42
me there was a m ← bytes 14-29

Then the client can assemble all the pieces into:
“once upon a time there was a magical oyster”

The position of the first byte (0,14,30 in our example) is called the “sequence number”

how to deal with lost packets:

When you get TCP data, you have to acknowledge it (ACK):

jvns.ca server: here is part of a cat picture! that should be 28832 bytes so far!
jvns.ca server (thinking): yay

laptop: ACK! I have received all 28832 bytes

If the server doesn’t get an acknowledgement, it will retry sending the data.

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)