[zeromq-dev] Fwd: [hybi] WebSockets: UDP
ph at imatix.com
Tue Jun 1 14:08:15 CEST 2010
I'm just reposting an email that came from the WHATWG and HyBi lists,
because it provides an interesting use case for 0MQ, namely real-time
game architectures where each player sends 20k-30k updates a second to
a server over UDP.
Apart from the use case, it is maybe interesting that websockets is
(as well as a protocol) a socket-style API, like 0MQ's API.
---------- Forwarded message ----------
From: Erik Möller <emoller at opera.com>
Date: Tue, Jun 1, 2010 at 12:24 PM
Subject: [hybi] WebSockets: UDP
To: Hybi <hybi at ietf.org>
[originally (mis-)posted to WHATWG, reposting here]
The use case I'd like to address in this post is Real-time client/server
The majority of the on-line games of today use a client/server model over
UDP and we should try to give game developers the tools they require to
create browser based games. For many simpler games a TCP based protocol is
exactly what's needed but for most real-time games a UDP based protocol is
a requirement. Games typically send small updates to its server at 20-30Hz
over UDP and can with the help of entity interpolation and if required
entity extrapolation cope well with intermittent packet loss. When a
packet loss occur in a TCP based protocol the entire stream of data is
held up until the packet is resent meaning a game would have to revert to
entity extrapolation possibly over several seconds, leading to an
unacceptable gameplay experience.
It seems to me the WebSocket interface can be easily modified to cope with
UDP sockets (a wsd: scheme perhaps?) and it sounds like a good idea to
leverage the work already done for WebSockets in terms of interface and
The most important distinction between ws: and wsd: is that messages sent
by send() in wsd: need not be acknowledged by the peer nor be resent. To
keep the interface the same to the largest possible extent I'd suggest
implementing a simple reliable 3-way handshake over UDP, keep-alive
messages (and timeouts) and reliable close frames. If these are
implemented right the interface in it's entirety could be kept. Only one
new readonly attribute long maxMessageSize could be introduced to describe
the min path MTU (perhaps only valid once in connected mode, or perhaps
set to 0 or 576 initially and updated once in connected mode). This
attribute could also be useful to expose in ws: and wss: but in that case
be set to the internal limit of the browser / server.
The actual content of the handshake for wsd: can be vastly simplified
compared to that of ws: as there's no need to be http compliant. It could
contain just a magic identifier and length encoded strings for origin,
location and protocol.
To minimize the work needed on the spec the data framing of wsd: can be
kept identical to that of ws:, though I'd expect game developers would
choose whatever the binary framing will be once the spec is done.
I'd be very interested to hear peoples opinion on this.
hybi mailing list
hybi at ietf.org
More information about the zeromq-dev