Re: [hybi] [whatwg] WebSockets: UDP

Erik Möller <emoller@opera.com> Tue, 01 June 2010 13:01 UTC

Return-Path: <emoller@opera.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 1FE653A6816 for <hybi@core3.amsl.com>; Tue, 1 Jun 2010 06:01:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.699
X-Spam-Level:
X-Spam-Status: No, score=-3.699 tagged_above=-999 required=5 tests=[BAYES_50=0.001, MIME_8BIT_HEADER=0.3, RCVD_IN_DNSWL_MED=-4]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aqUImi0W8t9n for <hybi@core3.amsl.com>; Tue, 1 Jun 2010 06:01:13 -0700 (PDT)
Received: from smtp.opera.com (smtp.opera.com [213.236.208.81]) by core3.amsl.com (Postfix) with ESMTP id 76DDE3A67AD for <hybi@ietf.org>; Tue, 1 Jun 2010 06:01:13 -0700 (PDT)
Received: from emoller-pc.gothenburg.osa (046-tdc.opera.com [213.236.208.46] (may be forged)) (authenticated bits=0) by smtp.opera.com (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o51D0wkB025044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 1 Jun 2010 13:00:59 GMT
Content-Type: text/plain; charset="iso-8859-15"; format="flowed"; delsp="yes"
To: Philip Taylor <excors+whatwg@gmail.com>
References: <op.vdl9bszhr4mipi@emoller-pc.gothenburg.osa> <AANLkTin8TYLeOdZmKbs6IqklsS5P24Qd4kqtTV_UXp-l@mail.gmail.com>
Date: Tue, 01 Jun 2010 15:00:50 +0200
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
From: Erik Möller <emoller@opera.com>
Organization: Opera Software
Message-ID: <op.vdmg3ov6r4mipi@emoller-pc.gothenburg.osa>
In-Reply-To: <AANLkTin8TYLeOdZmKbs6IqklsS5P24Qd4kqtTV_UXp-l@mail.gmail.com>
User-Agent: Opera Mail/10.53 (Win32)
Cc: "whatwg@whatwg.org" <whatwg@whatwg.org>, Hybi <hybi@ietf.org>
Subject: Re: [hybi] [whatwg] WebSockets: UDP
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Jun 2010 13:01:15 -0000

On Tue, 01 Jun 2010 13:34:51 +0200, Philip Taylor  
<excors+whatwg@gmail.com> wrote:

> On Tue, Jun 1, 2010 at 11:12 AM, Erik Möller <emoller@opera.com> wrote:
>> The use case I'd like to address in this post is Real-time client/server
>> games.
>>
>> 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. [...]
>>
>> It seems to me the WebSocket interface can be easily modified to cope  
>> with
>> UDP sockets [...]
>
> As far as I'm aware, games use UDP because they can't use TCP (since
> packet loss shouldn't stall the entire stream) and there's no
> alternative but UDP. (And also because peer-to-peer usually requires
> NAT punchthrough, which is much more reliable with UDP than with TCP).
> They don't use UDP because it's a good match for their requirements,
> it's just the only choice that doesn't make their requirements
> impossible.
>
> There are lots of features that seem very commonly desired in games: a
> mixture of reliable and unreliable and reliable-but-unordered channels
> (movement updates can be safely dropped but chat messages must never
> be), automatic fragmentation of large messages, automatic aggregation
> of small messages, flow control to avoid overloading the network,
> compression, etc. And there's lots of libraries that build on top of
> UDP to implement protocols halfway towards TCP in order to provide
> those features:
> http://msdn.microsoft.com/en-us/library/bb153248(VS.85).aspx,
> http://opentnl.sourceforge.net/doxydocs/fundamentals.html,
> http://www.jenkinssoftware.com/raknet/manual/introduction.html,
> http://enet.bespin.org/Features.html, etc.
>
> UDP sockets seem like a pretty inadequate solution for the use case of
> realtime games - everyone would have to write their own higher-level
> networking libraries (probably poorly and incompatibly) in JS to
> provide the features that they really want. Browsers would lose the
> ability to provide much security, e.g. flow control to prevent
> intentional/accidental DOS attacks on the user's network, since they
> would be too far removed from the application level to understand what
> they should buffer or drop or notify the application about.
>
> I think it'd be much more useful to provide a level of abstraction
> similar to those game networking libraries - at least the ability to
> send reliable and unreliable sequenced and unreliable unsequenced
> messages over the same connection, with automatic
> aggregation/fragmentation so you don't have to care about packet
> sizes, and dynamic flow control for reliable messages and maybe some
> static rate limit for unreliable messages. The API shouldn't expose
> details of UDP (you could implement exactly the same API over TCP,
> with better reliability but worse latency, or over any other protocols
> that become well supported in the network).
>

I've never heard any gamedevs complain how poorly UDP matches their needs  
so I'm not so sure about that, but you may be right it would be better to  
have a higher level abstraction. If we are indeed targeting the game  
developing community we should ask for their feedback rather than guessing  
what they prefer. I will grep my linked-in account for game-devs tonight  
and see if I can gather some feedback.

I suspect they prefer to be "empowered with UDP" rather than "boxed into a  
high level protocol that doesn't fit their needs" but I may be wrong.  
Those who have the knowledge, time and desire to implement their own  
reliable channels/flow control/security over UDP would be free to do so,  
those who couldn't care less can always use ws: or wss: for their reliable  
traffic and just use UDP where necessary.

So the question to the gamedevs will be, and please make suggestions for  
changes and I'll do an email round tonight:

If browser and server vendors agree on and standardize a socket based  
network interface to be used for real-time games running in the browsers,  
at what level would you prefer the interface to be?
(Note that an interface for communicating reliably via TCP and TLS are  
already implemented.)
- A low-level interface similar to a plain UDP socket
- A medium-level interface allowing for reliable and unreliable channels,  
automatically compressed data, flow control, data priority etc
- A high-level interface with "ghosted entities"

Oh, and I guess we should continue this discussion on the HyBi list... my  
fault for not posting there in the first place.

-- 
Erik Möller
Core Developer
Opera Software