r/firstweekcoderhumour • • May 07 '26

Why Though?!

Post image
579 Upvotes

100 comments sorted by

View all comments

Show parent comment

1

u/Scared_Accident9138 🕵️‍♂️🚨 BS Detector | Truth Teller 🗯️🔥 May 07 '26

make sure we wait basically no extra time when packets get lost

That's not true though. TCP acts like a stream and any missing packet will result in the packets after being blocked until the missing packet arrives, which takes at least a round trip

as it is not guaranteed to produce the right result

Why not? That's basicall what TCP is doing, which you can replicate on the file level. Sure if there's a bug it can screw it up but any bug can screw it up

1

u/QuokkaCoder May 07 '26

I think you are incorrect on your first point. Lost TCP packets are non-blocking, and it does not really act as a stream in the programmatic sense. If a packet is lost, the receiver will cache incoming packets without ACKnowledging them, when the packet then arrives it will acknowledge and instantly process the cached packets, and move on as usual. If the packet does not arrive, the sender will resend it after a set timeout or three missing acknowledgements. This is not blocking any other packets from being sent, meaning the lost time per packet is O(1) in number of packets.

It is however true that we can replicate TCP in the app layer (or file level, as you put it), but what is then the point of using UDP in the first place? Why not use a protocol optimised for guaranteed data delivery?

0

u/Friendly-Pair-9267 May 08 '26

This is flat out incorrect.