Re: [hybi] [whatwg] WebSockets: UDP

Ben Garney <ben.garney@gmail.com> Wed, 02 June 2010 18:36 UTC

Return-Path: <ben.garney@gmail.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 8520B28C140 for <hybi@core3.amsl.com>; Wed, 2 Jun 2010 11:36:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.002
X-Spam-Level:
X-Spam-Status: No, score=0.002 tagged_above=-999 required=5 tests=[BAYES_50=0.001, HTML_MESSAGE=0.001]
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 DkyHPzZpj2Ez for <hybi@core3.amsl.com>; Wed, 2 Jun 2010 11:36:07 -0700 (PDT)
Received: from mail-yx0-f172.google.com (mail-yx0-f172.google.com [209.85.213.172]) by core3.amsl.com (Postfix) with ESMTP id 4BE9C28C17B for <hybi@ietf.org>; Wed, 2 Jun 2010 11:36:01 -0700 (PDT)
Received: by yxt3 with SMTP id 3so460090yxt.31 for <hybi@ietf.org>; Wed, 02 Jun 2010 11:35:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=6LvHg9LVOlGKQbWM+RfBvbSPcKt9b2B0VN5N4RkO0ig=; b=brS5GNfDR9cO1i9Dx7qq9v4M1BGTEppxVLWlmpgnlRSmZqpzDIKaKL1ALXSCkcVrCP BDOZpreu3at84nAbLWkyC5uD23B5GUVjaZHOwYlQex+xWONIXos1adgwlMb5mzSagPdv jlnAjD7VEZmz+N5Uf8Ba6VmRs4cJO2exgJ5DE=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=Fnwcba6e7L1TC/GFagC2q+wRNpqKRXP6jyYUYR8fV9xEEYy2Nqhpj3zqfrHnUyz5Nn yJiqoB87xC6n+KypV5ERPCWgnrpfrSM81+1g4LSN2gDedaFHl+cwcmykQ7p7G3ga59Mf BkZOcowebv/03MFTCBflFmbWUCtnR23pNQVJI=
Received: by 10.101.4.22 with SMTP id g22mr8613359ani.168.1275503741272; Wed, 02 Jun 2010 11:35:41 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.100.210.14 with HTTP; Wed, 2 Jun 2010 11:35:21 -0700 (PDT)
In-Reply-To: <AANLkTimPvtS9hE-frSVQq8dWBEG9-fvCfnTsOVCbVXQt@mail.gmail.com>
References: <op.vdl9bszhr4mipi@emoller-pc.gothenburg.osa> <AANLkTin8TYLeOdZmKbs6IqklsS5P24Qd4kqtTV_UXp-l@mail.gmail.com> <op.vdmg3ov6r4mipi@emoller-pc.gothenburg.osa> <AANLkTim2j9xbgW4fnKYy69uZ9KwBaDvs1ypu92pG1Hxo@mail.gmail.com> <op.vdm0lrqmr4mipi@emoller-pc.gothenburg.osa> <AANLkTimPvtS9hE-frSVQq8dWBEG9-fvCfnTsOVCbVXQt@mail.gmail.com>
From: Ben Garney <ben.garney@gmail.com>
Date: Wed, 02 Jun 2010 11:35:21 -0700
Message-ID: <AANLkTiklP3JEyhOmmHPRx-sTKxfblPP0j69UQ9dRwkU_@mail.gmail.com>
To: Philip Taylor <excors+whatwg@gmail.com>
Content-Type: multipart/alternative; boundary="001636c92900690bb50488105bc9"
X-Mailman-Approved-At: Thu, 03 Jun 2010 22:26:09 -0700
Cc: Hybi <hybi@ietf.org>, "whatwg@whatwg.org" <whatwg@whatwg.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: Wed, 02 Jun 2010 19:01:45 -0000

On Wed, Jun 2, 2010 at 10:48 AM, Philip Taylor
<excors+whatwg@gmail.com<excors%2Bwhatwg@gmail.com>
> wrote:

>
> I'm trying to think of them mainly as indirect examples of use cases,
> rather than as direct examples of interfaces. Under the assumption
>

This is a very valid approach. (Note that most serious games do not use
DirectPlay and it has not been updated by Microsoft in a while, so don't
burn a lot of braincells on it.)

Games always do weird stuff, focus on what will enable the 80% case and not
break the web! :)

Some thoughts point by point:

So they seem to suggest things like:
> - many games need a combination of reliable and unreliable-ordered and
> unreliable-unordered messages.
>

Yes. But if you unreliable-unordered you can build the rest pretty easily.


> - many games need to send large messages (so the libraries do
> automatic fragmentation).
>

Yes. But many engines do fragmentation more explicitly, since they don't
spend a lot of time dealing with TCP streams. (The usual case is transfer of
asset files over the network connection, for instance, if a client doesn't
have a texture. I suspect for a JS app using UDP this would not be an issue,
they could just ask the web server.)


> - many games need to efficiently send tiny messages (so the libraries
> do automatic aggregation).
>

Sort of. The common cases are most-recent state and message queues. Mostly
they define a packet format and have smart logic for incrementally sending
the most relevant state in each packet.


> - many games need some kind of security (I have no idea exactly what,
> or how much is still relevant when the client is JavaScript and
> trivial to tamper with).
>

What is relevant for this discussion is to prevent man in the middle and DoS
activities. (Smart) game devs always assume the client is compromised - same
as smart web devs. :)


> - many games need to prioritise certain messages when bandwidth is limited.
>

See the aggregation comment. Also, games typically assume bandwidth is
limited - they will target and operate within a fixed bandwidth budget and
often a fixed packet rate. Say, 10 500 byte packets per second. This is
beneficial for many reasons, but primarily it is good because it optimizes
for realtime interaction. For some situations you will want fixed rate, for
others you want to have adaptive rate. (For instance, talking to a game
server in Counterstrike vs. playing an MMO.)


> - most games don't need low-level control over individual datagrams
> and precise packet loss feedback, they're okay with the socket details
> being abstracted away.
>

Disagree, for good networking you need to know about packet delivery state
at quite high levels of the game simulation.


> - ... probably lots more (and/or less); I'm not very familiar with the
> details of the libraries so this is unlikely to be an accurate list,
> but I think it may be a useful way to analyse the requirements.
>

I think you got the major points. (Even though I don't necessarily agree
with all of your conclusions. :))


>
> (The solution suggested in your initial post
> (socket.send(data_smaller_than_mtu) going over UDP) seems to be one
> extreme, which combines with higher-level JS libraries to satisfy
> these needs. I think I initially suggested the other extreme of
> encoding all the features into the browser API. I guess the best
> tradeoff depends largely on what non-game use cases exist that should
> be satisfied by the same solution.)
>

I think the best layer to provide is a notify protocol. That is, provide a
way to send lossy, smaller-than-MTU messages over a connection in realtime,
and notify the dev when a packet has made it (or hasn't). This way the
browser can provide a connection abstraction, which deals with the
DoS/security/origin issues. (For instance, two obvious pieces are connection
puzzles to prevent DoS, and PKI signing to prevent tampering with data. The
browser can also support arranged connections for the p2p case.)

It also keeps the interoperability manageable. Servers have a specific,
fairly small protocol to implement, and can provide some or all of a small
set of features. (For instance, caps might be: basic protocol support,
secure connections, arranged connections.) Beyond that it is application
specific blobs of small size (under a few kb).


All that said, I think looking at the notify protocol in TNL is a good
baseline. On that you can pretty easily implement every game scenario I can
think of. You can reuse a lot of the TCP connection security semantics, too,
since it is a connection - just one with lossy delivery.

Ben