138
u/DouDouandFriends May 07 '26
Let's watch a livestream with TCP
49
15
u/popky1 May 07 '26
You do already
5
u/packsolite May 09 '26
Literally. Don't people realize streams in the browser are http websockets, which are (for the most part) still TCP?
1
u/Fleshwende May 10 '26
Maybe like video streams for movies or heavily delayed lives but never actual live streams. Don't beleive me? Boot up wireshark and just watch
4
u/packsolite May 11 '26
2
u/Fleshwende May 12 '26
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.
9
u/Fricki97 May 07 '26
And download files with UDP
22
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 07 '26
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.
1
u/770grappenmaker May 07 '26
TCP has a receive window, you don't really wait for missed packets.
1
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 07 '26
I meant it won't get passed onto to the application if a packet is missing midstream
1
u/Hot-Definition6103 May 07 '26
if a packet is missing midstream with udp youβre screwed
1
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 08 '26
No, you can request it again
6
u/Sacaldur May 08 '26
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.
1
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 08 '26
Sure, it's not easier but it is a valid reason to use UDP over TCP
And when it comes to developing it, you don't have to, such protocols already exist
3
u/Connect_Detail98 May 08 '26
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.
1
u/FuzzyAdvisor5589 May 08 '26
Have you not used a single download manager since the inception of the internet? IT IS ALREADY IN THE HTTP SPEC. Holy kids.
HTTP even has support for reliable UDP via QUIC.
2
u/Sacaldur May 08 '26
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).
→ More replies (0)1
1
u/QuokkaCoder May 07 '26
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?
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
1
May 08 '26
[removed] β view removed comment
2
u/Sacaldur May 08 '26
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.
1
u/teo-tsirpanis May 08 '26
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.
1
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 08 '26
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
1
u/RullendeNumser May 11 '26
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
1
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 11 '26
Minecraft Bedrock actually does use UDP (unlike java edition)
1
u/RullendeNumser May 11 '26
Then they also have some extra software for making sure every package is receive like a launcher
0
May 07 '26
[deleted]
3
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 07 '26
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
6
u/m0j0m0j May 07 '26
Yep. Bittorrent works over UDP
2
u/x0wl May 07 '26
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.
1
u/m0j0m0j May 07 '26
Yeah, but Iβm not sure itβs honest to call QUIC (also known as HTTP 3) just UDP. Itβs like calling TCP just IP because itβs built on top.
All of this is very fuzzy really
1
u/x0wl May 07 '26
Yeah, I agree
Small nit: QUIC is not just http3, you can easily use it without any of the h3 stuff, by just opening streams and sending datagrams.
I think dns over quick is a relatively widely used application of this. But you can do a lot of other stuff, like tunnel ssh over it if you want.
1
1
u/alphapussycat May 07 '26
Wouldn't actually be a problem, there'd just be a delay.
1
u/UnknownError235 May 10 '26
Watching a livestream over TCP would be like a teacher asking the class "you guys got that?" and waiting for a response after every sentence
1
u/alphapussycat May 10 '26
It's buffered. You buffer like 30 seconds, and then play it, while the next sections are being sent.
1
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
2
u/Scared_Accident9138 π΅οΈββοΈπ¨ BS Detector | Truth Teller π―οΈπ₯ May 08 '26
That sub is full of such content
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
12
5
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
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/3nt3_ May 09 '26
who are you explaining this to
1
u/dimonium_anonimo May 09 '26
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.
1
1
3
2
2
1
1
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
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
1
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
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/kat-tricks May 08 '26
to be fair, similarly, every language is just C under the layers of implementation
1
u/CheesyBreadMunchyMon May 08 '26
Even C is just assembly under the layers of bullshit
1
u/kat-tricks May 08 '26
Hey, C is the best damn way of constructing assembly around, thank you! π
though now there's the issue that it's actually usually LLVM IR under the layers
1
1
1
1
1
1
1
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
0
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
May 08 '26
[removed] β view removed comment
1
u/Sacaldur May 08 '26
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