Re: [Taps] New Transport Networking APIs in iOS 12 beta

Tommy Pauly <tpauly@apple.com> Fri, 15 June 2018 16:17 UTC

Return-Path: <tpauly@apple.com>
X-Original-To: taps@ietfa.amsl.com
Delivered-To: taps@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C9D28130FC7 for <taps@ietfa.amsl.com>; Fri, 15 Jun 2018 09:17:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.31
X-Spam-Level:
X-Spam-Status: No, score=-4.31 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_DKIMWL_WL_HIGH=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=apple.com
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 6xUZznasgaK5 for <taps@ietfa.amsl.com>; Fri, 15 Jun 2018 09:17:27 -0700 (PDT)
Received: from mail-in4.apple.com (mail-out4.apple.com [17.151.62.26]) (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 BA68D130FDC for <taps@ietf.org>; Fri, 15 Jun 2018 09:17:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1529079428; x=2392993028; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ei8n9FXWh30en3cz8NU/JzeqTOsurOT/ByZvO4fYLIU=; b=hJhctZls9K9LCU4dvaTQ84yc4tqOKaSPuJABeIopd+i2FFyq6e25u31NHa17Dpl0 jwT89LH1b6MWdFg8EYX2rWgHP2TAf8LixSCH12Ni2L0pLQrBFnoyANsYAWIet80t Q4a3xAsZJMKktSG8v0L0nuW4+q5BoFCafxpHkop7eTEq0cPdNGcAGwS5lbq1goiO VmhH0WJ5GhVBysXFyQs12QT+Id1HUy8VBjJcdpiFp5eonupaj0bMoPDMCCGOwfBx YexhYpd2ei9xijciqLsdZNcMxswY0cT5SKatb/XdjrM7t4zeC/ZuKwCB4M939nXT OUI6iIdv/RWxbrxbpjufzw==;
X-AuditID: 11973e12-a01ff700000010b7-70-5b23e6849f34
Received: from mr2-mtap-s01.rno.apple.com (mr2-mtap-s01.rno.apple.com [17.179.226.133]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id 79.61.04279.486E32B5; Fri, 15 Jun 2018 09:17:08 -0700 (PDT)
MIME-version: 1.0
Content-type: multipart/alternative; boundary="Boundary_(ID_d45CHxk1DxfHg1nReTGzQg)"
Received: from ma1-mmpp-sz10.apple.com (ma1-mmpp-sz10.apple.com [17.171.128.150]) by mr2-mtap-s01.rno.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180329 64bit (built Mar 29 2018)) with ESMTPS id <0PAD00JKPH8JF920@mr2-mtap-s01.rno.apple.com>; Fri, 15 Jun 2018 09:17:08 -0700 (PDT)
Received: from [17.230.160.236] (unknown [17.230.160.236]) by ma1-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180403 64bit (built Apr 3 2018)) with ESMTPSA id <0PAD00G14H8IZ230@ma1-mmpp-sz10.apple.com>; Fri, 15 Jun 2018 09:17:07 -0700 (PDT)
X-Va-A:
X-Va-T-CD: 91949cb67ad5a17194231cf3cf1e09f7
X-Va-E-CD: 36910ef1a06ecb6cf7c143959f25f86c
X-Va-R-CD: 523f5b9545ee69ad6998eb029acd3ffa
X-Va-CD: 0
X-Va-ID: 922e4ca1-5269-4fed-8d78-c9685db7eeef
X-V-A:
X-V-T-CD: 28de45ac93053488fd5a3d3ecf6bf00e
X-V-E-CD: 36910ef1a06ecb6cf7c143959f25f86c
X-V-R-CD: 523f5b9545ee69ad6998eb029acd3ffa
X-V-CD: 0
X-V-ID: 2c0dee1b-dfbe-43b8-a27c-e0966f27db67
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-15_09:,, signatures=0
X-Proofpoint-Scanner-Instance: ma-grpmailp-qapp24.corp.apple.com-10000_instance1
Sender: tpauly@apple.com
From: Tommy Pauly <tpauly@apple.com>
Message-id: <7CBAD06E-5299-413C-BA01-9662EC9DE702@apple.com>
Date: Fri, 15 Jun 2018 09:17:05 -0700
In-reply-to: <D75972DB-3F06-4955-8E78-1BD86992E5D7@ifi.uio.no>
Cc: Jonathan Lennox <jonathan@vidyo.com>, "taps@ietf.org" <taps@ietf.org>
To: Michael Welzl <michawe@ifi.uio.no>
References: <1C14F32A-3ADC-4D35-B800-091697E83AD6@apple.com> <63A71B2E-96E4-402A-89E2-667DDF8B1D08@lurchi.franken.de> <268D7E06-1D1D-4F70-9336-98EAF1BB5605@apple.com> <3EEFA4C8-D9D2-45E8-98FD-55BEA12706E9@ifi.uio.no> <5A1D9981-B8C1-46C3-99AD-7F6C89C8B918@vidyo.com> <D75972DB-3F06-4955-8E78-1BD86992E5D7@ifi.uio.no>
X-Mailer: Apple Mail (2.3445.100.13.1)
X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsUiuPlRq27LM+Vog2enZSz2Lz7PbPHj7E5W izsxDsweS5b8ZPJYvfohs0fbszvsAcxRXDYpqTmZZalF+nYJXBmbHnkU3E6rOHnrAFMD4/7w LkZODgkBE4l5bY2sXYxcHEICB5gkHt3bygaS4BUQlPgx+R4LiM0sECaxuWMnG0TReiaJrXce sUM4k5kkfs1YyQYxil3iz68dLBC2tsTmwyeYYOzTd1rh4gd23YSq55JYsPU0K4StK7Hq/BN2 CJtNYv2JJVC9WhJXPt5ihrF7Wv/A2W0TnkPN4ZQ4/2UiUC8HkK0j8eJqBEQ4W6LtxxaokgCJ BR2PGEFKhAUkJDbvSQQJswmoSBz/toEZ4l8bidM9u9kgShwkmnaIgYRZBFQlVm5rYQYJcwrY SZzpzIOEiKfEzbVvwW4XEVCTOLF8NTR0jjJJLJ90F2qrmsT82y9YJzDKzUIK0VlIIToLaCyz gLrElCm5EGFtiSfvLrBC2GoSC38vYkIWX8DItopRKDcxM0c3M89EL7GgICdVLzk/dxMjKGVM txPawXhqldUhRgEORiUeXoHTytFCrIllxZW5hxilOViUxHlt3itFCwmkJ5akZqemFqQWxReV 5qQWH2Jk4uCUamAsYk/52bylr/Hdn/0HRBXuCm65On3K00bFr7feMnyfpV+z5aOQmMWjr928 5TPmHJTtKC2Z8dZzmdy+dqc1fz3/37J0lv12YOr3dTpzlB8uqxcx+/HnyeIQjU1XbTP37vtr XaEkOyd7qUV0sfFXfuGYVRNOPVyyPP+D8DLNF1FHPp6ZsbSoctreEiWW4oxEQy3mouJEABrP B276AgAA
Archived-At: <https://mailarchive.ietf.org/arch/msg/taps/-OFtETzjjCcDrTzmyk1fioGTaZE>
Subject: Re: [Taps] New Transport Networking APIs in iOS 12 beta
X-BeenThere: taps@ietf.org
X-Mailman-Version: 2.1.26
Precedence: list
List-Id: "IETF Transport Services \(TAPS\) Working Group" <taps.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/taps>, <mailto:taps-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/taps/>
List-Post: <mailto:taps@ietf.org>
List-Help: <mailto:taps-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/taps>, <mailto:taps-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 15 Jun 2018 16:17:39 -0000


> On Jun 15, 2018, at 1:00 AM, Michael Welzl <michawe@ifi.uio.no> wrote:
> 
> Hi,
> 
> Thanks for sharing this! It’s quite interesting -
> 
> 
>> On Jun 11, 2018, at 6:47 PM, Jonathan Lennox <jonathan@vidyo.com <mailto:jonathan@vidyo.com>> wrote:
>> 
>> I’ve read over Apple’s new API.  (One note: the URL that Tommy sent a link to doesn’t have the full documentation of the API yet; many of the types and methods still say “No overview available.” If you’re an Apple developer, the header files supplied with the macOS 10.14 and iOS 12 beta SDKs in the Xcode 10 beta contain much fuller versions of the documentation.)
> 
> I agree, things are a bit inconsistent in the online docs for now… e.g. somehow this:
> https://developer.apple.com/documentation/network?language=objc <https://developer.apple.com/documentation/network?language=objc>
> seems to be more complete than
> https://developer.apple.com/documentation/network/nwpath <https://developer.apple.com/documentation/network/nwpath>
> but then there are also differences that are probably not due to the language choice only. Well, it all clearly says “Beta”, so that’s ok, we’ll just have to wait until this documentation is updated.
> 
> 
>> The main difference I’ve found between TAPS and Network.framework is that Network.framework doesn’t have a Preconnection object.  Instead, Connection objects for outgoing connections are directly created from a constructor, and then must have their .start method called before they act.
>> 
>> This part is a relatively minor semantic difference, but more significant is how incoming connections are handled.  In Network.framework, there is a Listener object with a new_connection handler, and this object can produce unlimited numbers of Connections until stopped.  This is unlike TAPS where a Listen action consumes a Preconnection, and to receive multiple connections on the same port, Listen must be called on multiple cloned Preconnections.
> 
> I agree that the first difference is minor (constructor vs. “Preconnection”). I would also say that the latter difference is interesting but not huge… (“under the hood” it’s easy to imagine that these can be two ways to essentially expose the same thing). I’d also agree that the Network.framework method is more convenient though. Tommy - what would you say about moving our API in that direction for Listening?
> 
> 
>> I feel like the Network.framework model is an easier programming model for most use cases, but it has the downside that an API user has no way to pace its handling of incoming connections.
> 
> I haven’t played with the Network.framework myself, but I would guess that, if I want to slow down the rate at which I handle incoming connections, there isn’t really much difference between not calling Listen (current TAPS) vs. ignoring a newly created incoming Connection (Network.framework). Why wouldn’t that work as a way to pace conn. handling?

One first note: a lot of the ‘preconnection’ properties are encapsulated in our NWParameters object. The main difference, conceptually, is that the parameters object is just a container (which may be reused) but doesn’t imply that any work can happen just by creating a parameters object.

Regarding calling listen multiple times vs providing a single completion handler to be called multiple times: I find the Listen model appropriate to have a single completion that gets invoked multiple times because the code in response to a Listen is generally going to be the same—each new connection cannot be assumed to have any relationship or ordering with regards to prior connections, so the logic you need to write to process an inbound connection will be the same. Thus, providing a single completion is cleaner. Contrast this to a Receive completion, in which receiving on a connection is assumed to have order—I may expect to read a “header” message, followed by a “body” message, etc, thus using multiple Receive calls not only provides back pressure, but allows different handling upon completion.

Adding back pressure to inbound connections is something that we do need to add. The approach Michael suggests, of just ignoring an inbound connection until we’re ready to process it, certainly would work. The downside is that this requires the caller of the API to manage their own array of pending inbound connections. One option we’ve considered is allowing the application to specify a “receive connection window size” on a listener, thus defining how many more inbound connections they’re ready to handle at a given time. What do people think about this approach?

Thanks,
Tommy

> 
> Cheers,
> Michael
>