F-Stack - a full user-space network
service with DMM
Based on DPDK, FreeBSD TCP/IP stack
Hailong Wang
Explosive growth of data services
Challenges
service traffic:CDN,live streaming(RTMP),etc.
DDoS, CC
Solution
NIC: 25GbE40GbE100GbE
CPU: 24Cores48Cores56Cores
L2/L3: Kernel bapass(DPDK)
L4/L7: ?
The problem - Kernel
Thread0
Thread1
Thread2
Thread3
Thread4
Thread5
User space
Kernel space
CPU cores(NUMA)
NIC queues
User space
The solution - Kernel Bypass
Process3
Process2
Process1
Data plane
Process0
Control plane
Kernel space
What does F-Stack do?
APP
SDK
Posix-like API
FreeBSD TCP/IP stack
DPDK
The characteristics of F-Stack
APP …… …… Full user-space
No context switch
SDK …… …… Zero copy
No hirqs and sirqs
Posix-like API …… ……
Shared-nothing architecture
FreeBSD TCP/IP stack …… ……
Linear scalability
No schedule
DPDK …… ……
No lock
No cache locality miss
Why FreeBSD
Why full TCP/IP stack?
Advantageous functional, production ready stack.
Stable.
Network tools.
Why not Linux ?
Complicated logic.
GPL.
TCP/IP stack on Linux
read recv send write
sock_recvmsg sock_sendmsg ip_output
tcp_sendmsg
tcp_recestablished tcp_recvmsg
ip_finish_output
tcp_push
tcp_v4_recv tcp_v4_do_recv
tcp_write_xmit dev_queue_xmit
ip_local_deliver ip_recv
tcp_transmit_skb
netif_rx netif_recv_skb
ip_queue_xmit
TCP/IP stack on FreeBSD
read readv recvmsg recvfrom write writev
soreceive sendto sendmsg
sosend
tcp_input
tcp_outpt
ip_input
ip_output
ether_demux
ether_input ether_output
User space FreeBSD TCP/IP stack
phymem
phymem mtx
timecounter
timecounter kernel,irq
kernel,irq threading
threading
uma_page_slab
uma_page_slab rw
ticks
ticks sched
sched
uma
uma rm
hz
hz wakeup
wakeup
kmem_malloc
kmem_malloc sx
timer
timer sleep
sleep
malloc
malloc cond
remove
hijack replace remove
&
replace
mmap/malloc rte_timer
(rte_mempool/rte_ ticks polling empty macro
malloc) timecounter
memory clock schedule locks
Posix-like api and network tools
ff_socket sysctl
ff_init(argc, argv) ff_read
ff_write ifconfig
……
route
ff_kqueue
ff_kevent
ff_run(loop, arg); ff_epoll_ctl ipfw
ff_epoll_wait
arp
top
etc..
F-Stack Lib
Application Cases
Load Balance
4 layer: ipfw/nat
7 layer: nginx
Web Server
epoll-based http server: httpdns
nginx: live streaming(rtmp).
WAF
nginx+lua/openresty
SCTP
Limitations
Multi-process architecture, not suitable for multi-
thread.
Should modify the application's source code.
Can not be used for multiple apps
Not suitable for heavy logic.
Integrate with DMM
Plug-in interface
module init
Multiple deploy type
run-to-completion
pipe-line
F-Stack with DMM
more easier to use
more scenarios
F-Stack with DMM
app1 app2 app3 app..n
DMM socket compatible layer
F-Stack
dpdk-if- freebsd- freebsd-
stack stack1 stack.n
interface stack
DMM hardware adapter layer
Resources
https://github.com/f-stack
Thanks!