SlideShare a Scribd company logo
1
Network stack personality in
Android phone
Cristina Opriceana, Hajime Tazaki (IIJ Research Lab.)
Linux netdev 2.2, Seoul, Korea
08 Nov. 2017
2
Librarified Linux taLks (LLL)
Userspace network stack (NUSE) in general (netdev0.1)
kernel CI with libos and ns-3 (netdev1.1)
Network performance improvement of LKL (netdev1.2, by Jerry Chu)
How bad/good with LKL and hrtimer (BBR) (netdev2.1)
Updating Android network stack (netdev2.2)
3
Android
a platform of billions devices
billions installed Linux kernel
Questions
When our upstreamed code
available ?
What if I come up with
a great protocol ? https://developer.android.com/about/dashboards/index.html
4
Android (cont'd)
When our upstreamed code available ?
wait until base kernel is upgraded
backport specific function
What if I come up with a great protocol ?
craft your own kernel and put into your image
Long delivery to all billions devices
Approaches to alleviate the issue
Virtualization (KVM on Android)
Overhead isn't negligible to embedded devices
Project Treble (since Android O)
More modular platform implementation
Fushia
Rewrite OS from scratch
QUIC (transport over UDP)
Rewrite transport protocols on UDP
5
https://source.android.com/devices/architecture/treble
6
An alternate approach
network stack personality
use own network stack implemented in userspace
no need to replace host kernels
but (try to) preserve the application compatibility
NUSE (network stack in userspace)
No delay of network stack update
Application can choose a network stack if needed
7
Userspace implementations
Toys, Misguided People Selfish
Motivation
Trying to present that a Toy is practically useful
8
Linux Kernel Library intro (again)
Out-of-tree architecture
(h/w-independent)
Run Linux code on various ways
with a reusable library
h/w dependent layer
on Linux/Windows
/FreeBSD uspace,
unikernel, on UEFI,
network simulator (ns-3)
Android
9
LKL: current status
Sent RFC (Nov. 2015)
no update on LKML since then
have evolved a lot
fast syscall path
offload (csum, TSO/LRO)
CONFIG_SMP (WIP)
json config
qemu baremetal (unikernel)
on UEFI
https://github.com/lkl/linux
10
Extensions to LKL
Android (arm/arm64) support (lkl/linux#372)
raw socket extension (only handle ETH_P_IP) (not upstreamed yet)
hijack library enhance (not upstreamed yet)
11
HOWTO
% LD_PRELOAD=liblkl-hijack.so netperf XXX # console app
% setprop wrap.app LD_PRELOAD=liblkl-hijack.so # Java app
{
"gateway": "10.206.211.1",
"interfaces": [
{
"ifgateway": "202.214.86.129",
"ip": "202.214.86.168",
"mac": "02:87:f8:27:22:02",
"masklen": "26",
"param": "/dev/tap23",
"type": "macvtap"
}
],
"debug": "0",
"singlecpu": "1",
"delay_main": "500000",
"sysctl": "net.ipv4.tcp_wmem=4096 87380 2147483647;net.mptcp.mptcp_debu
}
12
hijack library
For smooth replacement (i.e., hijack) for Android UI app syscalls
(java-based)
bionic is more familiar than glibc
only socket-related calls are redirected
handling a mixture of host and lkl descriptors
13
New feature introduction
Example
Multipath TCP ( )
out-of-tree for long time
http://multipath-tcp.org/
14
Multipath TCP
An extension to TCP subsystem
application compatibility
(unlike SCTP)
Use multiple paths
better throughput
(aggregation)
smooth recovery from failure
(handover)
http://blog.multipath-tcp.org/blog/html/2015/12/25/commercial_usage_of_multipath_tcp.html
15
Demo
verify site (cat /proc/net/mptcp base detection)
http://amiusingmptcp.de/
16
No penalty with userspace
network stack ?
Condition
To use Linux mptcp w/o replacing kernel
Questions
Is NUSE working fine (Will users wanna use it) ?
How different from native Linux kernel ?
With tolerable amount of overhead ?
17
netperf measurement
Client
Nexus5 anrdoid 6.01 (rooted)
LTE, wifi
LKL arm/android patched
or native kernel
Server
Ubuntu 16.04 (amd64) on KVM
virtio/Etherlink (uplink: 100 Mbps)
mptcp-4.4.70 (v0.92)
Software
netperf 2.7.x
10 seconds TCP_STREAM,
TCP_MAERTS
5 trials, over 64-64K byte packet
18
Single path (Wi-Fi only)
Tx (TCP_STREAM) Rx (TCP_MAERTS)
Condition
phone: LKL v.s. (stock) kernel
Comparable goodput
CPU utilization: LKL < native
19
Multipath TCP
Tx (TCP_STREAM) Rx (TCP_MAERTS)
Condition
phone: LKL v.s. mptcp kernel
Goodput (Tx) LKL > native
even it's using multipath
CPU: unstable (LKL)
LKL > native
20
Multipath TCP (Korea/KT)
Tx (TCP_STREAM) Rx (TCP_MAERTS)
Condition
phone: LKL v.s. (stock) kernel
native uses single-path/
LKL uses multi-path
at Ibis hotel
Goodput: No much gain with LKL
even it's using multipath
CPU: unstable (LKL)
LKL > native
21
Observations
IP conflicts may heavier
processed twice (host/lkl)
per packet
Results are often unstable
difficult measurement under
wireless media
22
Limitations
Implementations
DHCP only boot time (handover will fail)
IPv4 only on cellular interface (rmnet0)
Fundamental limitations of hijack library
asynchronous signal unsafe
MT unsafe
Required tweaks
grant NET_RAW permission (packet socket)
need filter out RST packet from host
iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP
23
Further investigations
other platform
iOS11 now shipped userspace implementation
profiling
24
Summary
Use out-of-tree kernel as a library on Android
make your code easier to distribute
with privileged installation/operation
Comparable goodput over WiFi/LTE
Unstable CPU utilization with LKL
You can prepare your library file for your own purpose
25
Backups
26
Alternate network stacks
lwip (2002~)
mTCP [NSDI '14]
SandStorm [SIGCOMM '14]
rumpkernel [ATC '09]
SolarFlare (2007~?)
libuinet (2013~)
SeaStar (2014~)
None of them are feature-rich, or one-shot porting

More Related Content

What's hot (20)

PDF
NUSE (Network Stack in Userspace) at #osio
Hajime Tazaki
 
PDF
mTCP使ってみた
Hajime Tazaki
 
PDF
Kernelvm 201312-dlmopen
Hajime Tazaki
 
PPTX
Realizing Linux Containers (LXC)
Boden Russell
 
PDF
Achieving Performance Isolation with Lightweight Co-Kernels
Jiannan Ouyang, PhD
 
PDF
Introduction to eBPF
RogerColl2
 
PDF
Linux Kernel Cryptographic API and Use Cases
Kernel TLV
 
PDF
CETH for XDP [Linux Meetup Santa Clara | July 2016]
IO Visor Project
 
PDF
Shoot4U: Using VMM Assists to Optimize TLB Operations on Preempted vCPUs
Jiannan Ouyang, PhD
 
PPTX
Introduction to DPDK
Kernel TLV
 
PPSX
FD.io Vector Packet Processing (VPP)
Kirill Tsym
 
PPTX
DPDK KNI interface
Denys Haryachyy
 
PDF
LinuxCon 2015 Linux Kernel Networking Walkthrough
Thomas Graf
 
PDF
VLANs in the Linux Kernel
Kernel TLV
 
PDF
How to Speak Intel DPDK KNI for Web Services.
Naoto MATSUMOTO
 
PDF
Recent advance in netmap/VALE(mSwitch)
micchie
 
PDF
introduction to linux kernel tcp/ip ptocotol stack
monad bobo
 
PDF
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
Thomas Graf
 
PDF
Introduction to RCU
Kernel TLV
 
PDF
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
harryvanhaaren
 
NUSE (Network Stack in Userspace) at #osio
Hajime Tazaki
 
mTCP使ってみた
Hajime Tazaki
 
Kernelvm 201312-dlmopen
Hajime Tazaki
 
Realizing Linux Containers (LXC)
Boden Russell
 
Achieving Performance Isolation with Lightweight Co-Kernels
Jiannan Ouyang, PhD
 
Introduction to eBPF
RogerColl2
 
Linux Kernel Cryptographic API and Use Cases
Kernel TLV
 
CETH for XDP [Linux Meetup Santa Clara | July 2016]
IO Visor Project
 
Shoot4U: Using VMM Assists to Optimize TLB Operations on Preempted vCPUs
Jiannan Ouyang, PhD
 
Introduction to DPDK
Kernel TLV
 
FD.io Vector Packet Processing (VPP)
Kirill Tsym
 
DPDK KNI interface
Denys Haryachyy
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
Thomas Graf
 
VLANs in the Linux Kernel
Kernel TLV
 
How to Speak Intel DPDK KNI for Web Services.
Naoto MATSUMOTO
 
Recent advance in netmap/VALE(mSwitch)
micchie
 
introduction to linux kernel tcp/ip ptocotol stack
monad bobo
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
Thomas Graf
 
Introduction to RCU
Kernel TLV
 
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
harryvanhaaren
 

Similar to Network stack personality in Android phone - netdev 2.2 (20)

PDF
Rlite software-architecture (1)
ARCFIRE ICT
 
PDF
Leveraging Android's Linux Heritage at ELC-E 2011
Opersys inc.
 
PDF
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
 
PDF
Leveraging Android's Linux Heritage
Opersys inc.
 
PDF
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
PDF
ABS 2013: Dive into Android Networking - Adding Ethernet Connectivity
Benjamin Zores
 
PDF
Leveraging Android's Linux Heritage at AnDevCon3
Opersys inc.
 
PPT
Enea Linux and LWRT FTF China 2012
EneaSoftware
 
PDF
ELCE 2012 - Dive into Android Networking: Adding Ethernet Connectivity
Benjamin Zores
 
PDF
Android Internals at Linaro Connect Asia 2013
Opersys inc.
 
PDF
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 
PDF
Embedded Linux primer
Drew Fustini
 
PPTX
Continuous Integration for BSP
Witekio
 
PDF
Leveraging Android's Linux Heritage at AnDevCon V
Opersys inc.
 
PPTX
Extreme security in web servers
Daniel Garcia (a.k.a cr0hn)
 
PDF
Linux Kernel Networking Implementation and Theory Expert s Voice in Open Sour...
rychlabelvia
 
PDF
Leveraging Android's Linux Heritage at Android Open 2011
Opersys inc.
 
PDF
Linux kernel TLS и HTTPS / Александр Крижановский (Tempesta Technologies)
Ontico
 
PDF
Geep networking stack-linuxkernel
Kiran Divekar
 
PPTX
High performace network of Cloud Native Taiwan User Group
HungWei Chiu
 
Rlite software-architecture (1)
ARCFIRE ICT
 
Leveraging Android's Linux Heritage at ELC-E 2011
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
 
Leveraging Android's Linux Heritage
Opersys inc.
 
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
ABS 2013: Dive into Android Networking - Adding Ethernet Connectivity
Benjamin Zores
 
Leveraging Android's Linux Heritage at AnDevCon3
Opersys inc.
 
Enea Linux and LWRT FTF China 2012
EneaSoftware
 
ELCE 2012 - Dive into Android Networking: Adding Ethernet Connectivity
Benjamin Zores
 
Android Internals at Linaro Connect Asia 2013
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 
Embedded Linux primer
Drew Fustini
 
Continuous Integration for BSP
Witekio
 
Leveraging Android's Linux Heritage at AnDevCon V
Opersys inc.
 
Extreme security in web servers
Daniel Garcia (a.k.a cr0hn)
 
Linux Kernel Networking Implementation and Theory Expert s Voice in Open Sour...
rychlabelvia
 
Leveraging Android's Linux Heritage at Android Open 2011
Opersys inc.
 
Linux kernel TLS и HTTPS / Александр Крижановский (Tempesta Technologies)
Ontico
 
Geep networking stack-linuxkernel
Kiran Divekar
 
High performace network of Cloud Native Taiwan User Group
HungWei Chiu
 
Ad

Recently uploaded (20)

PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
July Patch Tuesday
Ivanti
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
Français Patch Tuesday - Juillet
Ivanti
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
July Patch Tuesday
Ivanti
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Français Patch Tuesday - Juillet
Ivanti
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
Ad

Network stack personality in Android phone - netdev 2.2

  • 1. 1 Network stack personality in Android phone Cristina Opriceana, Hajime Tazaki (IIJ Research Lab.) Linux netdev 2.2, Seoul, Korea 08 Nov. 2017
  • 2. 2 Librarified Linux taLks (LLL) Userspace network stack (NUSE) in general (netdev0.1) kernel CI with libos and ns-3 (netdev1.1) Network performance improvement of LKL (netdev1.2, by Jerry Chu) How bad/good with LKL and hrtimer (BBR) (netdev2.1) Updating Android network stack (netdev2.2)
  • 3. 3 Android a platform of billions devices billions installed Linux kernel Questions When our upstreamed code available ? What if I come up with a great protocol ? https://developer.android.com/about/dashboards/index.html
  • 4. 4 Android (cont'd) When our upstreamed code available ? wait until base kernel is upgraded backport specific function What if I come up with a great protocol ? craft your own kernel and put into your image Long delivery to all billions devices
  • 5. Approaches to alleviate the issue Virtualization (KVM on Android) Overhead isn't negligible to embedded devices Project Treble (since Android O) More modular platform implementation Fushia Rewrite OS from scratch QUIC (transport over UDP) Rewrite transport protocols on UDP
  • 6. 5 https://source.android.com/devices/architecture/treble 6 An alternate approach network stack personality use own network stack implemented in userspace no need to replace host kernels but (try to) preserve the application compatibility NUSE (network stack in userspace) No delay of network stack update Application can choose a network stack if needed
  • 7. 7 Userspace implementations Toys, Misguided People Selfish Motivation Trying to present that a Toy is practically useful
  • 8. 8 Linux Kernel Library intro (again) Out-of-tree architecture (h/w-independent) Run Linux code on various ways with a reusable library h/w dependent layer on Linux/Windows /FreeBSD uspace, unikernel, on UEFI, network simulator (ns-3) Android
  • 9. 9 LKL: current status Sent RFC (Nov. 2015) no update on LKML since then have evolved a lot fast syscall path offload (csum, TSO/LRO) CONFIG_SMP (WIP) json config qemu baremetal (unikernel) on UEFI https://github.com/lkl/linux
  • 10. 10 Extensions to LKL Android (arm/arm64) support (lkl/linux#372) raw socket extension (only handle ETH_P_IP) (not upstreamed yet) hijack library enhance (not upstreamed yet)
  • 11. 11 HOWTO % LD_PRELOAD=liblkl-hijack.so netperf XXX # console app % setprop wrap.app LD_PRELOAD=liblkl-hijack.so # Java app { "gateway": "10.206.211.1", "interfaces": [ { "ifgateway": "202.214.86.129", "ip": "202.214.86.168", "mac": "02:87:f8:27:22:02", "masklen": "26", "param": "/dev/tap23", "type": "macvtap" } ], "debug": "0", "singlecpu": "1", "delay_main": "500000", "sysctl": "net.ipv4.tcp_wmem=4096 87380 2147483647;net.mptcp.mptcp_debu }
  • 12. 12 hijack library For smooth replacement (i.e., hijack) for Android UI app syscalls (java-based) bionic is more familiar than glibc only socket-related calls are redirected handling a mixture of host and lkl descriptors
  • 13. 13 New feature introduction Example Multipath TCP ( ) out-of-tree for long time http://multipath-tcp.org/
  • 14. 14 Multipath TCP An extension to TCP subsystem application compatibility (unlike SCTP) Use multiple paths better throughput (aggregation) smooth recovery from failure (handover) http://blog.multipath-tcp.org/blog/html/2015/12/25/commercial_usage_of_multipath_tcp.html
  • 15. 15 Demo verify site (cat /proc/net/mptcp base detection) http://amiusingmptcp.de/
  • 16. 16 No penalty with userspace network stack ? Condition To use Linux mptcp w/o replacing kernel Questions Is NUSE working fine (Will users wanna use it) ? How different from native Linux kernel ? With tolerable amount of overhead ?
  • 17. 17 netperf measurement Client Nexus5 anrdoid 6.01 (rooted) LTE, wifi LKL arm/android patched or native kernel Server Ubuntu 16.04 (amd64) on KVM virtio/Etherlink (uplink: 100 Mbps) mptcp-4.4.70 (v0.92) Software netperf 2.7.x 10 seconds TCP_STREAM, TCP_MAERTS 5 trials, over 64-64K byte packet
  • 18. 18 Single path (Wi-Fi only) Tx (TCP_STREAM) Rx (TCP_MAERTS) Condition phone: LKL v.s. (stock) kernel Comparable goodput CPU utilization: LKL < native
  • 19. 19 Multipath TCP Tx (TCP_STREAM) Rx (TCP_MAERTS) Condition phone: LKL v.s. mptcp kernel Goodput (Tx) LKL > native even it's using multipath CPU: unstable (LKL) LKL > native
  • 20. 20 Multipath TCP (Korea/KT) Tx (TCP_STREAM) Rx (TCP_MAERTS) Condition phone: LKL v.s. (stock) kernel native uses single-path/ LKL uses multi-path at Ibis hotel Goodput: No much gain with LKL even it's using multipath CPU: unstable (LKL) LKL > native
  • 21. 21 Observations IP conflicts may heavier processed twice (host/lkl) per packet Results are often unstable difficult measurement under wireless media
  • 22. 22 Limitations Implementations DHCP only boot time (handover will fail) IPv4 only on cellular interface (rmnet0) Fundamental limitations of hijack library asynchronous signal unsafe MT unsafe Required tweaks grant NET_RAW permission (packet socket) need filter out RST packet from host iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP
  • 23. 23 Further investigations other platform iOS11 now shipped userspace implementation profiling
  • 24. 24 Summary Use out-of-tree kernel as a library on Android make your code easier to distribute with privileged installation/operation Comparable goodput over WiFi/LTE Unstable CPU utilization with LKL You can prepare your library file for your own purpose
  • 26. 26 Alternate network stacks lwip (2002~) mTCP [NSDI '14] SandStorm [SIGCOMM '14] rumpkernel [ATC '09] SolarFlare (2007~?) libuinet (2013~) SeaStar (2014~) None of them are feature-rich, or one-shot porting