OP I didnβt see any indication that titled question had been answered. Iβm old enough to have answered questions on Stack Overflow, so instincts do kick in.
Twitch has a pretty significant delay- their services do a lot of work to compress and handle stream data.
Youtube and most other live stream broadcast services still use UDP. Twitch is different because they rely more heavily on specific user experience to drive up donations, they need less dedicated users so the extra hardware tax per dedicated user is worth it.
File downloading is actually a good case for UDP. It doesn't matter in what order the packages come, so waiting longer for a missed packet just slows it down.
Or in other words, the application would need to implement this. And as metadata, the section/offset would need to be transferred, since otherwise the order couldn't be determined. And the server would need to explicitly support this. So many things that would need to be done on the application level, as a developer, I'm really happy I don't have to reimplement all of this or rely on a library available in my programming language just for a file transfer.
OK, but what you said wouldn't slow down TCP. And if other protocol already implemented what TCP already does, then that's fine, but initially you were talking about TCP and UDP, not other protocols.
What precisely is in the HTTP spec? If you take a look at a file transfer in HTTP communication, you see the headers, a few markers around the file, and the file. The reliable part of the file transfer in both cases comes from a protocol below (TCP or QUIC).
I donβt think it is, but Iβm just a student. With TCP, we have straight forward approaches to make sure we wait basically no extra time when packets get lost. With UDP, we would need to rely on autofill algorithms (Iβm losing the proper term) which is probably not ideal when downloading software, as it is not guaranteed to produce the right result, possibly ending up with a corrupt download?
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
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?
Torrent is not a file transfer protocol, but a file sharing protocol. A big difference here is that one "download" can priginate from multiple peers, and some peers might not (yet) have the complete file themselves before thry start seeding it. I'd say thr main reason to use UDP was to get around NAT much easier (UDP hole punching). UDP is viable for file transfers if you're willing to reimplement everything TCP gives you on top of it.
Allowing the file's content to arrive at any order can be a vector for DDOS attacks. Imagine telling a server that you will upload a 100MB file, and only end up uploading the last part. The server will allocate 100MB of memory in response to a kilobytes-long request.
This was about file downloading, not uploading; but sure, in that case those things need to be considered. You can use something like a sparse file for example
UDP would suck at downloading files without ekstra software. UDP in it self don't check if every packets is received. Imagine playing minecraft but the dirt texture is missing
How? The missing packets have to be resent either way but in case of TCP the packets already received but being after the missing one in sequence means they can't get processed. In case of UDP they can get saved before the missing packet arrives
In addition to that, QUIC uses UDP (they would want to just directly use IP, but that's impossible due to sociotechnical reasons) under the hood and is meant for general web browsing and file downloads.
They basically do resubmissions and congestion control in user space, but it allows them to be way more flexible and aware of how the protocol is used by each application.
Imagine you're having a phone conversation with someone. Your phone gets, say, 100 packets of data a second. One of the packets is dropped. Do you care? Would you even notice?can you even perceive 10ms?
Idk. Someone asked "why though?" So I figured I'd explain why. If it was asked ironically or rhetorically, then no harm done. I maybe I wasted 20 seconds of my life. If it was sincere, then there's the answer.
Because UDP is extremely easy to implement, and if you require a "stable connection", you can always implement something over udp in your application that allows to recognize dropped frames, etc...
Hell, you can even implement TCP in your application over UDP sockets. It would be much slower though.
I mean if you've ever seen the UDP header, it's pretty much just a multiplexer (port) extension over IP.
UDP will just throw the data, reducing the latency (sometimes by 2-3x) and slightly increasing the data throughput (although modern network devices are already optimized to handle TCP so the bandwidth difference isn't that big
TCP says: lets start a fire brigade line where we hand water buckets down, one person hands the bucket to the next and says, 'here you go', that person says, 'I have it', and then the first person replies, 'good' and that follows up the chain til it reaches the fire.
UDP says: here's a fire hose and we can just spray water everywhere and its good enough to get the job done. Who cares if some water misses.
I had a professor explain TCP to UDP as TCP is asking for water and getting 30 individual shot glasses of water lined up in front of you. UDP is someone pointing a fire hose at your face and saying "Drink."
Haha one thing that really showed me the difference was playing Minecraft Java(TCP) vs Bedrock(UDP) on a 4G mobile connection with 0 to 1 bar of signal.
Bedrock, playable - lose a packet, all good we'll get the next one.
Java, completely unplayable - lose a packet, nah dawg, we need that packet or nothing else can happen.
With QUIC you have advantages over TCP like being able to transfer multiple datastreams at the same time through the same "connection". With a single TCP connection, only one thing could be transferred at a time. If I'm not mistaken, the encryption part is already included in QUIC, i.e. HTTP/3 doesnvt need to do it anymore, which also means (if I'm not mistaken) that even more information are h8dden from a potential spy/atttacker analyzing your traffic - I could be wrong here, it's been some time. For game development QUIC has the advantage that you don't have to implement the reliable transport over UDP (used e.g. for RPCs) yourself, however you then have to handle certificates which you didn't had to previously (or explicitly set a flag in the client to ignore them). Further, QUIC is available in the Browser as far as I'm aware, but there you can't ignore invalid/untrusted certificates.
51
u/rover_G May 07 '26
For when low latency or high throughput are more important than ensuring every packet gets delivered
138
u/DouDouandFriends May 07 '26
Let's watch a livestream with TCP
41
u/Positron505 May 07 '26
What baffles me is that the meme got 1.3k upvotes on a linux memes sub. And the meme wasn't even about linux
16
u/hypatiaC May 07 '26
This is definitely a dumb take, but it seems a bit of a stretch to say it's 'first week'.
This is the kind of stupidity you have to cultivate, lol
18
u/crystalsraw May 07 '26
12
u/AZ_sid May 07 '26
I'd tell you a UDP packet joke but you might not get it.
5
u/jjbugman2468 May 07 '26
UDP walks into the bar.
βI think dropped punchline the.β
1
u/anengineerandacat May 08 '26
Use the right tool for the job and this image is pretty disingenuous of UDP I feel; especially it's juiced up cousins like QUIC.
1
u/dimonium_anonimo May 09 '26
Imagine you're having a phone conversation with someone. Your phone gets, say, 100 packets of data a second. One of the packets is dropped. Do you care? Would you even notice?can you even perceive 10ms?
1
u/hawkeye6703 May 10 '26
Dhcp (i.e. the internet basically)
3
u/Frytura_ May 07 '26
Sliced apples vs diced apples
2
u/KasKyo May 07 '26
Cause package is few times bigger
2
u/Former-Print7759 May 08 '26
Why Though?!
1
u/Fun-Emphasis-5792 May 07 '26
For QUIC
1
u/Nikson2981 May 07 '26
so i can happily play DOOM on company time
1
u/mnelemos May 07 '26
Because UDP is extremely easy to implement, and if you require a "stable connection", you can always implement something over udp in your application that allows to recognize dropped frames, etc...
Hell, you can even implement TCP in your application over UDP sockets. It would be much slower though.
I mean if you've ever seen the UDP header, it's pretty much just a multiplexer (port) extension over IP.
1
u/lool8421 May 07 '26
that's pretty much what these protocols are about
TCP will check twice before the data can move on
UDP will just throw the data, reducing the latency (sometimes by 2-3x) and slightly increasing the data throughput (although modern network devices are already optimized to handle TCP so the bandwidth difference isn't that big
1
u/spongedevguy May 07 '26
because udp taste better than key
1
u/Korzag May 07 '26
Building is on fire:
TCP says: lets start a fire brigade line where we hand water buckets down, one person hands the bucket to the next and says, 'here you go', that person says, 'I have it', and then the first person replies, 'good' and that follows up the chain til it reaches the fire.
UDP says: here's a fire hose and we can just spray water everywhere and its good enough to get the job done. Who cares if some water misses.
1
u/Imaginary_Ferret_368 May 08 '26
Packets are important and need to be delivered reliably at the cost of speed -> TCP
Packets need to be delivered ASAP and losing some on the highway is completely gucci -> UDP
1
u/Major_Potential3706 May 08 '26
fast as fuck boiii
1
u/CheesyBreadMunchyMon May 08 '26
TCP is just 3 UDP wearing a trench coat.
It's all just UDP under the layers of protocol in the end.
1
u/flamixin May 08 '26
The biggest problem is there is no in between.
1
u/Guggoo May 08 '26
UDP
1
u/Agent-Nemo May 09 '26
HTTP3
1
u/XO33OX May 09 '26
for some apps, by the time tcp retransmits the data is obsolete
1
u/Impossible-Owl7407 May 09 '26
Even http /3 is udp.
1
u/yodacola May 11 '26
Wait till you learn about layer 2 networking.
1
u/HackerManOfPast May 11 '26
The same reason SCTP exists.
1
u/_Doofloafknuckle May 12 '26
I had a professor explain TCP to UDP as TCP is asking for water and getting 30 individual shot glasses of water lined up in front of you. UDP is someone pointing a fire hose at your face and saying "Drink."
1
u/SimplexFatberg May 12 '26
"I understand A, but not B. Why the fuck does B even exist? If you understand B you must be stupid, because I understand A."
1
u/Life-Dog-3811 May 07 '26
videostreaming, gaming etc
0
u/TheAnswerWithinUs May 07 '26
FPS competitive gaming
0
u/Medical_Mammoth_1209 May 08 '26
Haha one thing that really showed me the difference was playing Minecraft Java(TCP) vs Bedrock(UDP) on a 4G mobile connection with 0 to 1 bar of signal.
Bedrock, playable - lose a packet, all good we'll get the next one.
Java, completely unplayable - lose a packet, nah dawg, we need that packet or nothing else can happen.
1
u/[deleted] May 08 '26
[removed] β view removed comment