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

PDF
Linux Kernel Library - Reusing Monolithic Kernel
PDF
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
PDF
Playing BBR with a userspace network stack
PDF
LibOS as a regression test framework for Linux networking #netdev1.1
PDF
Library Operating System for Linux #netdev01
PDF
Direct Code Execution - LinuxCon Japan 2014
PDF
Network Stack in Userspace (NUSE)
PDF
Direct Code Execution @ CoNEXT 2013
Linux Kernel Library - Reusing Monolithic Kernel
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Playing BBR with a userspace network stack
LibOS as a regression test framework for Linux networking #netdev1.1
Library Operating System for Linux #netdev01
Direct Code Execution - LinuxCon Japan 2014
Network Stack in Userspace (NUSE)
Direct Code Execution @ CoNEXT 2013

What's hot (20)

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

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

PDF
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
PPTX
OCP Engineering Workshop at UNH
ODP
CRIU: are we there yet?
PDF
[Podman Special Event] Kubernetes in Rootless Podman
PDF
Network & Filesystem: Doing less cross rings memory copy
PDF
Talk 160920 @ Cat System Workshop
ODT
Cross-compilation native sous android
PPTX
bfarm-v2
PDF
Userspace networking
PDF
Network Programming: Data Plane Development Kit (DPDK)
PDF
How VXLAN works on Linux
PDF
Unifying Network Filtering Rules for the Linux Kernel with eBPF
PDF
DPDK Summit - 08 Sept 2014 - Futurewei - Jun Xu - Revisit the IP Stack in Lin...
PDF
Ceph in the GRNET cloud stack
PPT
Again music
PDF
[KubeCon NA 2020] containerd: Rootless Containers 2020
ODP
Not so brief history of Linux Containers
ODP
Not so brief history of Linux Containers - Kir Kolyshkin
PDF
Linux container & docker
PDF
UniK - a unikernel compiler and runtime
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
OCP Engineering Workshop at UNH
CRIU: are we there yet?
[Podman Special Event] Kubernetes in Rootless Podman
Network & Filesystem: Doing less cross rings memory copy
Talk 160920 @ Cat System Workshop
Cross-compilation native sous android
bfarm-v2
Userspace networking
Network Programming: Data Plane Development Kit (DPDK)
How VXLAN works on Linux
Unifying Network Filtering Rules for the Linux Kernel with eBPF
DPDK Summit - 08 Sept 2014 - Futurewei - Jun Xu - Revisit the IP Stack in Lin...
Ceph in the GRNET cloud stack
Again music
[KubeCon NA 2020] containerd: Rootless Containers 2020
Not so brief history of Linux Containers
Not so brief history of Linux Containers - Kir Kolyshkin
Linux container & docker
UniK - a unikernel compiler and runtime
Ad

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced IT Governance
PDF
KodekX | Application Modernization Development
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Advanced IT Governance
KodekX | Application Modernization Development

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