[PD] UDP vs TCP, for OSC networking
IOhannes m zmoelnig
zmoelnig at iem.at
Tue Jan 14 09:47:41 CET 2014
-----BEGIN PGP SIGNED MESSAGE-----
On 2014-01-14 04:41, Ryan Smith wrote:
> packet loss is an issue and most people use UDP since it will be
> faster. Then if you're running into packet loss, for whatever
> reason, try switching to TCP.
UDP will be faster, as it has less overhead:
- it's a stateless protcol (doesn't know, whether there is actually
somebody listening on the far side)
- since it doesn't know nor care about the far side, there is also no
way to signal back to the sender, that some data was missing - so there
is no need for a complicated error correction stack
another cool thing about UDP is, that it is pretty stable in un-reliable
situations (that is: if you can live with lossing some packets
alltogether): if one side suddenly dies, the other side will not be
affected. with TCP/IP this often means hangs of the remote side.
the issue of UDP being an unreliable protocol, is often found to be
none, as it is used mostly in small well-behaving networks (LAN), were
the chances of congestion are small, compared to the wild internet
(though even in the wild internet you find crucial services that build
on top of UDP - the most important is probably DNS).
however, i think the reason why OSC is used mostly with UDP is slightly
different: the first OSC implementations only used UDP. furthermore,
iirc the original OSC draft only mentioned UDP as a transport protocol
(though it also claimed to be "transport portocol independent").
since OSC is a packet-based protocol (data is sent in atomic chunks),
and UDP is one as well, they match quite well.
TCP/IP is a stream-based protocol (data is sent serially; all chunk
information is lost), which means, that you have to add some packetizing
mechanism. the OSC specs that first mention TCP/IP (OSC-1.0) also
mentioned such a packetizing mechanism (prefix each chunk with it's
length), but unfortunately they chose a very bad packetizing algorithm
(unrecoverable when you have drop-outs or otherwise miss parts of the
stream). this was only fixed later (OSC-1.1, in 2009!), when serial
procotols were explicitely requested to use SLIP as a packetizer.
to cut a long story short: in the beginnings, most OSC implementations
*only* supported UDP. that's why OSC is still most often used on top
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/
-----END PGP SIGNATURE-----
More information about the Pd-list