Re: [hybi] [whatwg] WebSockets: UDP

Philip Taylor <excors+whatwg@gmail.com> Wed, 02 June 2010 17:48 UTC

Return-Path: <excors@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 7B4CB3A6837 for <hybi@core3.amsl.com>; Wed, 2 Jun 2010 10:48:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.301
X-Spam-Level:
X-Spam-Status: No, score=0.301 tagged_above=-999 required=5 tests=[BAYES_50=0.001, MIME_8BIT_HEADER=0.3]
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 01iCFBKmt39n for <hybi@core3.amsl.com>; Wed, 2 Jun 2010 10:48:22 -0700 (PDT)
Received: from mail-wy0-f172.google.com (mail-wy0-f172.google.com [74.125.82.172]) by core3.amsl.com (Postfix) with ESMTP id 17BD23A6A0B for <hybi@ietf.org>; Wed, 2 Jun 2010 10:48:21 -0700 (PDT)
Received: by wyf23 with SMTP id 23so1942981wyf.31 for <hybi@ietf.org>; Wed, 02 Jun 2010 10:48:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=UTw0615+0+JegDvEElOAZ2aENrC4l9+jT5wMjCRWsww=; b=ag9+0tA3KwqnOYy0tRI8AA10VTo9A6L1DmGD7GGCbcuLCVASrUl/RRvtrFINUsf/Wk MR+zB80iScQ0nDZZJDtzxqPeDfAie2a4HWTvJRg0MQaWm4GmADaqMFbqUMATQBkil2eA mxIT556HcVOs4LGoPtAbSHiIMfnxxRhZVWsKg=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=bRVrOgMvTlsiOiFe+LC+2wGnFFHqog7msQ/CAin/N5qo/6SwWfIuAFVwXmkBLSbPHC 7pnvAqoGLgQioifpI7VLLiLGWQ0q9og+6sn0ad6DsuqRn3vqqWiB0830IAWAUqGz4fZl o/MB6h50FPEI6JtQHeMVmKu9x7WPs3UgII3nA=
MIME-Version: 1.0
Received: by 10.227.143.211 with SMTP id w19mr8050199wbu.182.1275500886206; Wed, 02 Jun 2010 10:48:06 -0700 (PDT)
Sender: excors@gmail.com
Received: by 10.216.46.205 with HTTP; Wed, 2 Jun 2010 10:48:05 -0700 (PDT)
In-Reply-To: <op.vdm0lrqmr4mipi@emoller-pc.gothenburg.osa>
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>
Date: Wed, 02 Jun 2010 18:48:05 +0100
X-Google-Sender-Auth: 155fcLgZCw-r-ogpVRW7rcaCJHg
Message-ID: <AANLkTimPvtS9hE-frSVQq8dWBEG9-fvCfnTsOVCbVXQt@mail.gmail.com>
From: Philip Taylor <excors+whatwg@gmail.com>
To: Erik Möller <emoller@opera.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Mailman-Approved-At: Thu, 03 Jun 2010 22:26:09 -0700
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: Wed, 02 Jun 2010 17:48:23 -0000

On Tue, Jun 1, 2010 at 9:02 PM, Erik Möller <emoller@opera.com> wrote:
> On Tue, 01 Jun 2010 21:14:33 +0200, Philip Taylor <excors+whatwg@gmail.com>
> wrote:
>
>> More feedback is certainly good, though I think the libraries I
>> mentioned (DirectPlay/OpenTNL/RakNet/ENet (there's probably more)) are
>> useful as an indicator of common real needs (as opposed to edge-case
>> or merely perceived needs) - they've been used by quite a few games
>> and they seem to have largely converged on a core set of features, so
>> that's better than just guessing.
>>
>> I guess many commercial games write their own instead of reusing
>> third-party libraries, and I guess they often reimplement very similar
>> concepts to these, but it would be good to have more reliable
>> information about that.
>>
>
> I was hoping to be able to avoid looking at what the interfaces of a high vs
> low level option would look like this early on in the discussions, but
> perhaps we need to do just that; look at Torque, RakNet etc and find a least
> common denominator and see what the reactions would be to such an interface.

I'm trying to think of them mainly as indirect examples of use cases,
rather than as direct examples of interfaces. Under the assumption
that most games either use a library like these or implement a
comparable one themselves, and that the library designs are driven by
the game requirements, if a feature is supported by most of the
libraries then it's probably needed by many games; and if a feature is
unsupported in many of the libraries then it's probably unnecessary
for most games. (Also an assumption: games running in web browsers
will have similar needs to native games (though lagging many years
behind state-of-the-art); and we only ought to aim to support the
needs of most games, not all games.)

So they seem to suggest things like:
- many games need a combination of reliable and unreliable-ordered and
unreliable-unordered messages.
- many games need to send large messages (so the libraries do
automatic fragmentation).
- many games need to efficiently send tiny messages (so the libraries
do automatic aggregation).
- 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).
- many games need to prioritise certain messages when bandwidth is limited.
- 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.
- ... 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.

(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.)

> So, what would the minimal set of limitations be to make a "UDP WebSocket"
> browser-safe?
>
> -No listen sockets
> -No multicast
> -Reliable handshake with origin info
> -Automatic keep-alives
> -Reliable close handshake
> -Socket is bound to one address for the duration of its lifetime
> -Sockets open sequentially (like current DOS protection in WebSockets)
> -Cap on number of open sockets per server and total per user agent

Perhaps also:
- Cap or dynamic limit on bandwidth (you don't want a single web page
flooding the user's network connection and starving all the TCP
connections)
- Protection against session hijacking
- Protection against an attacker initiating a legitimate socket with a
user and then redirecting it (with some kind of IP (un)hijacking) to a
service behind the user's firewall (which isn't a problem when using
TCP since the service will ignore packets when it hasn't done the TCP
handshake; but UDP services might respond to a single packet from the
middle of a websocket stream, so every single packet will have to be
careful not to be misinterpreted dangerously by unsuspecting
services).

-- 
Philip Taylor
excors@gmail.com