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.
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.