[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-----
Hash: SHA256

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
of UDP.

fgmasdr
IOhannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCAAGBQJS1PmmAAoJELZQGcR/ejb414EP/AwaeJiu3tAb3kKFwrzikO7d
aU1YdtDbN0MVxWVbkSk5KU7eKVai65k5DEmBbnM+rAaERUQC6JtrclOXOYCInywG
mh74VxKweU8tkrXuRjw6gpmR0T0UmTZQO1OczW97xJ33W9zovPOM4YotwxHMklKO
fYI4MGhZV5HgPWVEllnoT9FW1QO07zx8Dcwko1pPeAlUsOXIAcGht980p/toYPmF
192k8gZcSh7ud5zKWff8vYzVtua+8dxVwVnpCzyRMSXdrcsErKbzOolbNmikBXp1
5glqIZWIox7f0airlhT7qwMCR86pd1ZPHXpScnfBJ2oHjpe2oublLlub5mxDPLpb
cKEtr0px/XmYoQ4Ef3RWVq//AFGH5bB6IFgwrjgmcu2Coioks4/oUyCbYIR9OnHk
GdM4T+imViN453sj5RUMdC2fMu159YV7IaUk4cn654Kou7MRPySYsGXKtaKHc9sf
VHX2hripwztVQos6O2P/sP70uPVZl5R7sbE0KO1NPmkkOGLQNQXlxv8Hq/Ky4kBp
PAPCXqjhvSYPWb/gFiGAd2x1qmWilRI37/3Dzffrecp5rXnPX1UYGmbjMskD/2Oa
CH5mSaAFZMnC54R6MKfommd85HfOVVX5MgR/FLbUwtuo46NgHwqtzyWf5oRlS971
yxcZlv8euJipKAdmmdpy
=xTCY
-----END PGP SIGNATURE-----



More information about the Pd-list mailing list