[tcpinc] Simultaneous open tie breaking

Tero Kivinen <kivinen@iki.fi> Tue, 25 August 2015 11:56 UTC

Return-Path: <kivinen@iki.fi>
X-Original-To: tcpinc@ietfa.amsl.com
Delivered-To: tcpinc@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 120371B2F8C for <tcpinc@ietfa.amsl.com>; Tue, 25 Aug 2015 04:56:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 2.867
X-Spam-Level: **
X-Spam-Status: No, score=2.867 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FRT_STOCK2=3.988, SPF_NEUTRAL=0.779] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iv7iRg1O-U6V for <tcpinc@ietfa.amsl.com>; Tue, 25 Aug 2015 04:56:41 -0700 (PDT)
Received: from mail.kivinen.iki.fi (fireball.acr.fi [83.145.195.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id BA9241B2F8B for <tcpinc@ietf.org>; Tue, 25 Aug 2015 04:56:40 -0700 (PDT)
Received: from fireball.acr.fi (localhost [127.0.0.1]) by mail.kivinen.iki.fi (8.15.1/8.14.8) with ESMTPS id t7PBcaBe029435 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for <tcpinc@ietf.org>; Tue, 25 Aug 2015 14:38:36 +0300 (EEST)
Received: (from kivinen@localhost) by fireball.acr.fi (8.15.1/8.14.8/Submit) id t7PBcavR021652; Tue, 25 Aug 2015 14:38:36 +0300 (EEST)
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <21980.21436.540892.217417@fireball.acr.fi>
Date: Tue, 25 Aug 2015 14:38:36 +0300
From: Tero Kivinen <kivinen@iki.fi>
To: tcpinc <tcpinc@ietf.org>
In-Reply-To: <CACsn0cnq9cZdkn=yp8-GJfXDGMP8r1sib3qrQQEQYhF25kYZPg@mail.gmail.com>
References: <CABcZeBNEFVkDi38y3G-C2nQF=dzW2mGDsj5DVK_OKVkPwK=G0g@mail.gmail.com> <878u92oadf.fsf@ta.scs.stanford.edu> <CACsn0ckQskjLqo0=YfJrmBEsyCaq0jpcSzGUwKhRo0BzzQ=wDA@mail.gmail.com> <871teuo7nu.fsf@ta.scs.stanford.edu> <CACsn0ckn-QdoXmTgjW8gYQyVqZ0x9JHEYvZO5VHQkG9nKA3-Ew@mail.gmail.com> <87wpwmnenv.fsf@ta.scs.stanford.edu> <CACsn0cnq9cZdkn=yp8-GJfXDGMP8r1sib3qrQQEQYhF25kYZPg@mail.gmail.com>
X-Mailer: VM 8.2.0b under 24.5.1 (x86_64--netbsd)
X-Edit-Time: 37 min
X-Total-Time: 37 min
Archived-At: <http://mailarchive.ietf.org/arch/msg/tcpinc/14QNGuBL1lspCaXeFCOTK5AVJTc>
Subject: [tcpinc] Simultaneous open tie breaking
X-BeenThere: tcpinc@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "Discussion list for adding encryption to TCP." <tcpinc.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tcpinc>, <mailto:tcpinc-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tcpinc/>
List-Post: <mailto:tcpinc@ietf.org>
List-Help: <mailto:tcpinc-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tcpinc>, <mailto:tcpinc-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 25 Aug 2015 11:56:43 -0000

[I changed the subject to make the discussion easier to follow.]

Watson Ladd writes:
> On Sun, Aug 23, 2015 at 9:38 AM, David Mazieres
> <dm-list-tcpcrypt@scs.stanford.edu> wrote:
> > No, encryption fails 100% of the time, because the b bit defaults to 0.
> > As currently written, TCP-ENO requires application involvement to enable
> > encryption under simultaneous open.
> 
> Ok, I got confused about what b was doing. I thought it was
> disambiguating and picked randomly.

I do not think the b bit is really going to work, and I agree with
others that we need proper tie-breaker to solve this issue.

On the other hand I do not think we need to add large tie breaker to
the frame, we can most likely use something like very small tie
breaker and sequence numbers for tie-breaker. I.e. whoever has smaller
8-bit (or 6-bit) tie breaker is winner, if the tie breakers are same,
then we compare initial sequence numbers, and whoever has smaller
initial sequence number is the initiator and other end responder.

After that we just need to have rules specifying how we pick up the
protocol from two ordered list. The most simple solution would be to
just say we take initiators list, remove all of the protocols not in
the responders list, and then take first item from initiators list
that is also supported by responder.

I.e. the negotiation would be (with same tie breaker selected randomly
in both ends):

A->B(0x9453f454) SYN: Tie breaker=33; I can speak Z, Y
B->A(0x434945e5) SYN: Tie breaker=33; I can speak X, Y, Z

As tie breaker is same, we will check sequence numbers, and as B has
smaller he is the winner, and both ends know this. Following the rules
above, the protocol to be used is Y.

There are of course some middleboxes who do mess up with sequence
numrbers. To detect this we want to tell the result of the exchange to
both ends:

A->B(0x9453f455) ACK: We are using protocol Y
B->A(0x434945e6) ACK: We are using protocol Y, I am initiator

If both ends claim to be initiator, or neither end claims to be
initiator, both ends will know that immediately when they get receive
ACK, and will know that someone messed up the sequence numbers
(provided they didn't happen to be exactly same initially :-).

In that case we need to do something more complicated, or we could
simply say we drop the connection and try again. This is such rare
happening, that wasting extra round trips is much more preferred to
having more complicated protocol solving the tie (simultaneous opens
are rare, both ends happening to select same 8-bit (or 6-bit or
whatever) tie breaker is not very common, having exactly same initial
sequence number is rare, or even if we have middle box messing up
sequence numbers, there is 50% them being in right order anyways).

On the next try both ends will pick new random tie breaker, and this
time they most likely will not be same, and then the simulatenous open
will succeed (or there might even be timing differences, causing one
of them be bit faster, and one of the ends might receive SYN before it
has time to send his SYN out, in which case this will not be
simultaneous open anymore). 

Also if application will know it will NEVER do simulatenous opens
(like web server, or web client), it can do setsockopt that will
disable the Tie breaker option from the option list, saving byte or
two.

Normal open would be:

A->B(0x9453f454) SYN: Tie breaker=33; I can speak Z, Y
B->A(0x434945e5) SYN-ACK: We are using protocol Y
A->B(0x9453f455) ACK: We are using protocol Y, I am initiator

"We are using protocol Y" could also include the initial key exchange
messages for protocol Y, if they fit in option space.
-- 
kivinen@iki.fi