7 ms·
OP hasn't addressed the fact that UDP will willfully drop packets and send them out of order. What if I need to stream some data? What if I care about the order
by cyphar 11y ago
OP hasn't addressed the fact that UDP will willfully drop packets and send them out of order. What if I need to stream some data? What if I care about the order my IPC messages arrive in?
- deleted 11y ago[deleted]
- notthetup 11y agoThe article doesn't mention OSC Bundles, which is a group of OSC messages which are designed to be 'interpreted' together. A bundle usually has a timestamp associated with it. I agree this might not be the best method of dealing with out of order reception of packages, but it does exist in the protocol.
- crucialfelix 11y agoa bundle always has a timestamp
- brazzledazzle 11y agoThen UDP won't work for your requirements, right?
- tyingq 11y agoUDP, without some layer on top of it for ack or retry, or ordering, isn't useful for many requirements. Maybe things like displaying stock quotes, where stale data doesn't matter after a few seconds? I think the point is just to say that the article shouldn't tout plain UDP as a fix for TCP being hard in certain languages without calling out the downside.
- klodolph 11y agoTCP and UDP are different solutions for different problems. You also shouldn't tout TCP as a fix for UDP being hard without calling out the downside--TCP doesn't let you drop packets and can suffer from bad latency problems.
- tyingq 11y agoYep. When suggesting a change from one to the other, it might be a good idea to explain the benefits and tradeoffs. I didn't suggest otherwise. That said, most protocol implementations that I'm aware of over UDP have one or more of "retry/order checking/etc" on top of them. Like NFS, Bootp, tftp, etc.
- exDM69 11y ago> That said, most protocol implementations that I'm aware of over UDP have one or more of "retry/order checking/etc" on top of them. But it's a common false belief that it would be "reimplementing TCP". Some guarantees of reliability are required for most practical applications but TCP's "in-order stream of bytes" isn't suitable for everything. For any kind of real time data, when packet loss occurs, TCP will re-send data that may already be outdated, and causing later packets to arrive even later. In real time uses, TCP makes any networking problems worse. It's also worth noting that under ideal conditions (ie. no packet loss), TCP and UDP behave almost identically (after startup, that is). The issues only appear when you're working in less than ideal conditions and are worse the longer the physical distances are.
- tyingq 11y agoIndeed. The example appears to be "spray/pray": https://github.com/joearms/music_experiments/blob/master/pd.erl https://github.com/joearms/music_experiments/blob/master/pd....
- jasonkostempski 11y agoIt's covered: "On the other hand UDP can suffer from packet loss and OSC is an obscure protocol". If you need something UDP doesn't handle, then it makes sense to use something else, but a lot of time is being wasted using something like TCP if you don't need the things it does. With live sound, milliseconds count and it doesn't take a skilled ear to hear when things are even a little later than they should be. It might even be better to have no sound than a late sound.
- subnaught 11y agoRest assured that the designers of SuperCollider considered this use case when deciding to use OSC: http://doc.sccode.org/Guides/ServerTiming.html http://doc.sccode.org/Guides/ServerTiming.html
- ozten 11y agoAgreed, but one specific point referenced by the Alan Kay quote is building small components that message each other over the loopback interface with UDP... Messages never leaving the original machine and there are fewer places to drop the packets.
- paulddraper 11y ago"willfully" is probably overstating it
- rdtsc 11y agoDropped packets might not matter if you send the latest state. Dropped packets can be detected as well if each UDP packet in the protocol has a sequence id, then receiving end keep last time and sequence id it got. So it know if it got packets out of order or duplicated packets. Yeah, you are doing at this point some TCP stuff, but in some cases it is worth doing.
- jfoutz 11y agoReimplementing tcp in udp is either very smart or very dumb. It's a great mid band filter for programmers. When it pays off, it's huge. But when it doesn't, it's death by corner case.
- mej10 11y agoApplications that use OSC are generally running on the same machine or a local network that you have control over. You shouldn't drop packets on single machine unless you are sending a lot of them and run out of buffer. Buffer size is also tunable if you do have issues like that. If you need to do things over the internet it would probably be best to do OSC over TCP.
- tokenrove 11y agoConsider SCTP as an alternative if you want messages but want them in order.
- untothebreach 11y agoOnly if you have control of every device between your sender and your receiver. Don't get me wrong, I love SCTP, but good luck consistently making SCTP connections over the public internet...
- im_dario 11y agoAlso QUIC[0] should be a good candidate to be used instead of UDP. [0] https://docs.google.com/document/d/1lmL9EF6qKrk7gbazY8bIdvq3Pno2Xj_l_YShP40GLQE/edit https://docs.google.com/document/d/1lmL9EF6qKrk7gbazY8bIdvq3...
- ahoka 11y agoUse TIPC if you can: https://en.wikipedia.org/wiki/TIPC https://en.wikipedia.org/wiki/TIPC