Your App and Next Generation Networks - Apple...

90
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC15 Your App and Next Generation Networks Prabhakar Lakhera Core OS Networking Engineer Stuart Cheshire DEST System Frameworks Session 719

Transcript of Your App and Next Generation Networks - Apple...

Page 1: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC15

Your App andNext Generation Networks

Prabhakar Lakhera Core OS Networking EngineerStuart Cheshire DEST

System Frameworks

Session 719

Page 2: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Part OneTransitioning to IPv6-Only Networks

Part TwoReducing Delays in Networking

Page 3: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Transitioning to IPv6-Only Networks

Page 4: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

IPv4 AccessConnectivity

Cellular Data Network

Page 5: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

IPv4 AccessConnectivityIPv4 Access

Connectivitywith NAT

Cellular Data Network

Page 6: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

IPv4 AccessConnectivityIPv4 Access

Connectivitywith NAT

IPv6 Server

IPv6 AccessConnectivity

Cellular Data Network

Page 7: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Cellular Data Network

25%

50%

75%

Jun, 2012 Mar, 2013 Dec, 2013 Sep, 2014 May, 2015

VerizonAT&TT-Mobile

Page 8: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

IPv4 Access Connectivity

with NAT

Cellular Data Network

IPv6 Server

IPv6 AccessConnectivity

Page 9: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

Cellular Data Network

IPv6 Server

IPv6 AccessConnectivity

Page 10: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

Cellular Data Network

DNS64NAT64

IPv6 Server

IPv6 AccessConnectivity

Page 11: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

Cellular Data Network

DNS64NAT64

IPv6 Server

IPv6 AccessConnectivity

DNS64 synthesizes IPv6 address for IPv4 server

Page 12: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

IPv4 Server

Cellular Data Network

DNS64NAT64

IPv6 Server

IPv6 AccessConnectivity

DNS64 synthesizes IPv6 address for IPv4 serverNAT64 performs IPv6 to IPv4 address translation

Page 13: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Your App Has To Be IPv6 ReadyIt will be an app submission requirement later this year!

Page 14: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Step 1Option Click

Sharing

Page 15: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Step 1Option Click

Sharing

Step 2Option Click

Internet Sharing

Step 3Turn on NAT64

Page 16: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Step 1Option Click

Sharing

Step 2Option Click

Internet Sharing

Step 3Turn on NAT64

Page 17: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

NAT64 + DNS64 Internet Sharing

IPv4 WAN

IPv6 AccessConnectivity

DNS64NAT64

Page 18: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Make NAT64 Testing Part of Your Regular

Development Process

Page 19: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Top 100 Free iOS Applications

30%

70%

IPv6-Savvy Apps

IPv4-Only Apps

* Results for Top 100 Free iOS Applications that need Networking

Page 20: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

What Breaks?IPv4-only code

IPv4-only storage objects: uint32_t, in_addr, sockaddr_inIPv4-only APIs: inet_aton, gethostbynameIPv4-only usage of an API: gethostbyname2(hostname, AF_INET);

Pre-flight checks before connecting• Checking if device has an IPv4 address• Checking for reachability to 0.0.0.0

Page 21: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 22: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 23: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 24: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 25: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

What Works?Address-family agnostic code

Connect without pre-flight• If connection succeeds, great• If connection fails, handle that gracefully

Use higher-layer networking frameworks• NSURLSession and CFNetwork-layer APIs

RFC 4038 “Application Aspects of IPv6 Transition”Connect-by-name APIs

Page 26: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

What Works?IPv4 address literals, in NAT64 + DNS64 networks

New for OS X 10.11 and iOS 9Use higher-layer networking frameworks• NSURLSession and CFNetwork-layer APIs

Client supplies IPv4 address Literal• OS synthesizes IPv6 address

Page 27: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Reducing Delays in Networking

Page 28: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Delay Reduction

Page 29: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Delay Reduction

Reliable Network Fallback

Explicit Congestion Notification

TCP_NOTSENT_LOWAT

TCP Fast Open

Page 30: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Delay ReductionReliable Network Fallback

Reduce Connection Setup Stalls

Explicit Congestion Notification

TCP_NOTSENT_LOWAT

TCP Fast Open

Page 31: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Reliable Network Fallback

Fringe of Wi-FiTCP connection not succeedingOS initiates parallel connection over mobile dataFirst to complete wins—like RFC 6555 (Happy Eyeballs)

Page 32: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Reliable Network Fallback

Fully automaticNo more bill shockUse NSURLSession and CFNetwork-layer APIsFor best user experience:• Better Route Notification

Networking with NSURLSession Pacific Heights Thursday 9:00AM

Page 33: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Delay ReductionReliable Network Fallback

Reduce Connection Setup Stalls

Explicit Congestion NotificationReduce Network Delays

TCP_NOTSENT_LOWAT

TCP Fast Open

Page 34: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Test: 10Mb/s Downstream

256kB FIFO queue with Tail Dropvs.

CoDel with ECN

Gateway Device: CeroWRT 3.10.18-1(< 1 ms intrinsic delay, so any delay is self-induced queueing delay)

Page 35: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

tcptracehttp://www.tcptrace.org/

Page 36: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 37: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 38: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 39: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Data Packet

Page 40: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Data Packet

Cumulative Acknowledgement

Line

Page 41: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Data Packet

Cumulative Acknowledgement

Line

Receive Window Ceiling

Page 42: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 43: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 44: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 45: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 46: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 47: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 48: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 49: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 50: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 51: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 52: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 53: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 54: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Standard FIFO Queue

Page 55: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Smart Queueing and ECN

CoDel• Controlled Delay queueing• Limits Bufferbloat

Explicit Congestion Notification• Signals congestion by marking packets instead of discarding• Available in OS X, iOS, Windows, Linux, etc.

Page 56: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

CoDel with ECN

Page 57: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public
Page 58: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

CoDel with ECN

Page 59: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

CoDel with ECN

Page 60: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Conclusions

CoDel (or similar Smart Queue Management) helpsECN helpsSQM+ECN really helps a lot

Page 61: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP for Streaming Video

Packet loss causes irregular data delivery to clientNo problem for file transfer (e.g. sending an email)Big problem for streaming video over TCP• YouTube• Netflix• etc.

Page 62: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Changing Applications

Fixed data: Email, file transfer, etc.• Fixed data• Variable time (as fast as network can manage)

Adaptive data: Screen Sharing, Video Streaming, etc.• Fixed time• Variable data (as much as network can carry in allotted time)

Page 63: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Current State of ECN

Servers• 56% of Alexa top million web sites already support ECN• http://wan.poly.edu/pam2015/papers/4.pdf

Clients• Routers aren’t doing marking• Some routers might drop the packets—small risk; no reward

Routers• Clients aren’t requesting ECN• Enabling ECN might expose code bugs—small risk; no reward

Page 64: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Apple Is Taking the Initiative

ECN now enabled in OS X 10.11 and iOS 9Test on your own home and work networksReport bugs to AppleWe could have a billion iOS devices using ECN!Finally, an incentive for ISPs to start offering ECN packet markingAll apps get this for free

Page 65: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Delay ReductionReliable Network Fallback

Reduce Connection Setup Stalls

Explicit Congestion NotificationReduce Network Delays

TCP_NOTSENT_LOWATReduce Sender-Side Delay

TCP Fast Open

Page 66: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Screen Sharing

Screen Sharing to home Mac over DSL5 Mb/s downlink, 500 kb/s uplink3-second delay on Screen SharingBut ping time is 35 msHuh?

Page 67: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Socket Send Buffer

Socket Send Buffer is 128 kilobytesNeed send buffer large enough to holdBandwidth-Delay Product (BDP)Any additional buffering just adds extra delayAt approximately 50 kB/sec transfer rate128 kilobytes = 2.5 seconds of delay

Page 68: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Socket Send Buffer

Data in flight

Data waiting to be sent

BDP

Page 69: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Socket Send Buffer

At approximately 50 kB/sec transfer rate128 kilobytes = 2.5 secondsDelay is in host, not just the networkDo screen frames have to be aged in oak barrels before they’re fit for consumption?

Page 70: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP_NOTSENT_LOWAT

setsockopt(skt, IPPROTO_TCP, TCP_NOTSENT_LOWAT, &threshold, sizeof(threshold));Socket Send Buffer remains at 128 kilobytesBut kevent() doesn’t report socket as writable until the unsent TCP data dropsbelow specified threshold (typically 8 kilobytes)Application then writes next single semantic unit of data

Page 71: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP_NOTSENT_LOWAT

setsockopt(skt, IPPROTO_TCP, TCP_NOTSENT_LOWAT, &threshold, sizeof(threshold));Socket Send Buffer remains at 128 kilobytesBut kevent() doesn’t report socket as writable until the unsent TCP data dropsbelow specified threshold (typically 8 kilobytes)Application then writes next single semantic unit of data

Page 72: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Socket Send Buffer

Data waiting to be sentData in flightBDP

Page 73: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Buffer Reaches Threshold

Data waiting to be sentData in flightBDP

Page 74: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Application Sends Next Chunk

Data waiting to be sent

Data in flightBDP

Write One Atomic Semantic Unit

Page 75: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Demo

Page 76: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP_NOTSENT_LOWAT

Screen Sharing now using this in 10.10.3 and laterUsed by AirPlayAvailable in Linux too, for your server software

Page 77: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Good for All Applications

Obvious benefit for “real time” applications• But all applications benefit

Use the NSURLSession and CFNetwork-layer APIsWhen runloop reports socket is writable:• Write a single semantic atomic chunk• Don’t loop until EWOULDBLOCK

Page 78: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Delay ReductionReliable Network Fallback

Reduce Connection Setup Stalls

Explicit Congestion NotificationReduce Network Delays

TCP_NOTSENT_LOWATReduce Sender-Side Delay

TCP Fast OpenAccelerating the TCP handshake

Page 79: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP Fast OpenAccelerating the TCP handshake

TCP handshake takes one round-trip-timeHandshake

Time

Page 80: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP Fast OpenAccelerating the TCP handshake

TCP handshake takes one round-trip-time

Data can only be sent afterwards

Handshake

Data

Time

Page 81: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP Fast OpenAccelerating the TCP handshake

TCP Fast Open

Handshake + Data

TCP Fast Open• Combines the handshake with data• 50% latency reduction for short flows• Secured through Cookie-exchange• Only for “idempotent” data

Time

Page 82: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP Fast Open Only for Idempotent Data

Time

Handshake + Data

Server acts and replies

Page 83: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP Fast Open Only for Idempotent Data

Time

Handshake + Data

Server acts and replies

Server acts and replies again

Page 84: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

TCP Fast OpenHow to use it?

• Socket API- Using connectx() system call to combine handshake with data:connectx(fd, ..., DATA_IDEMPOTENT | CONNECT_RESUME_ON_READ_WRITE, ...); // SYN delayed write(fd, ...); // SYN goes out with first data segment

• Server-side- Must support TFO and application has to opt-in- iOS/OS X: Socket-option TCP_FASTOPEN- Linux (requires v4.1+)

Page 85: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Summary

Use NSURLSession and CFNetwork-layer APIsTest on NAT64 + DNS64 networkReliable Network Fallback• Better Route notifications

Explicit Congestion NotificationTCP_NOTSENT_LOWAT• Don’t over-stuff

TCP Fast Open technology preview

Page 86: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

More Information

Documentation and VideosNetworking Programming Topicshttps://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Introduction/Introduction.html

CFNetworkhttps://developer.apple.com/library/mac/documentation/Networking/Conceptual/CFNetwork/Introduction/Introduction.html

NSURLSessionhttps://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html#//apple_ref/doc/uid/10000165-BCICJDHA

Page 87: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

More Information

Technical SupportApple Developer Forumshttp://developer.apple.com/forums

Developer Technical Supporthttp://developer.apple.com/support/technical

General InquiriesPaul Danbold, Core OS [email protected]

Page 88: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Related Sessions

Networking with NSURLSession Pacific Heights Thursday 9:00AM

What's New in Network Extension and VPN Nob Hill Friday 9:00AM

Page 89: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public

Related Sessions

Networking Lab Frameworks Lab E Friday 1:30PM

Page 90: Your App and Next Generation Networks - Apple Inc.devstreaming.apple.com/videos/wwdc/2015/719ui2k57m/719/719_your... · © 2015 Apple Inc. All rights reserved. Redistribution or public