SlideShare a Scribd company logo
A purely functional approach to 
packet processing 
Nicola Bonelli 
Nicola Bonelli, Stefano Giordano, Gregorio Procissi 
University of Pisa 
Luca Abeni 
University of Trento
2 
Facts on Linux 
● Linux is a general purpose operating system often used 
to create middleboxes 
o large amount of open source software 
o a feature-rich subsystem of networking 
● The kernel provides 
o network stack supports a large amount of protocols 
o traffic control (tc), firewall (netfilter) 
o routing (iproute2), bridging 
o monitoring facilities (AF_PACKET and BPF filters) 
● Open-source kernel modules 
o PF_RING-DNA / Netmap (accelerated drivers) 
o PFQ framework for multi-core architectures
3 
Motivation 
● What’s wrong with Linux as a middlebox? 
o Components are designed to be configurable 
! programmability is not fully addressed 
● only low level libraries enable tools to communicate to the kernel 
o Interoperability among heterogeneous components? 
! components are statically linked to each other 
! what about bridging packets that satisfy a given BPF ? 
o With no virtual machines, the configuration is system-wide 
! Multiple applications can concurrently manage the networking for different 
purposes?
4 
Objective 
● Design a new language for programmable middleboxes 
that: 
o at high level enables reusability and interoperability among kernel components 
! interfaces, kernel and sockets are end-points 
o is multi-thread oriented by design 
! allows concurrent execution of networking applications 
o as much close as possible to NICs 
● But where to implement it? 
o Use PFQ as underlying architecture
5 
Why PFQ? 
● Multi-language framework 
o C, C++11-14, Haskell 
o compliant with a plethora of device drivers 
o line-speed with Intel vanilla drivers (14.8Mpps) 
● Flexible parallelism 
o decouple software from hardware parallelism 
● Address multi-core architectures 
o scale almost linearly in any possible configuration 
● Best practices of concurrent programming 
o no mutexes, no spinlocks in fast data-path 
o amortized atomic operations
6 
PFQ/lang overview 
● PFQ/lang as a functional language 
! DLS describing networking application as a sequence of elementary operations 
(functions) 
! simple firewall, bridge, load balancer, etc. 
! early stage of monitoring applications (dispatcher) 
● A PFQ/lang program consists of a functional composition 
o takes a packet and return a packet enriched with a context 
! information about the distribution (Fanout) 
! state, annotation (State) etc. 
! possible side effect (IO)
7 
PFQ/lang features 
● strongly typed language 
● high-order functions 
o functions that take functions as argument (i.e. conditional expressions) 
● currying 
o Used to bind arguments in user-space 
" string, vectors, trivially copyable objects in C++ 
" storable types, storable tuples, list in Haskell 
● immutability of data 
o COW (copy-on-write) 
● deterministic garbage collector (GC) 
o Value semantic with no impact on performance
8 
PFQ/lang principles 
● PFQ/lang computations are defined in user-space 
o C++11/Haskell eDSL 
● AST is transferred to kernel module for a group of 
endpoints 
o runtime strict type-checking (to avoid kernel panic) 
● Converted into an executable data structure by a 
runtime linker 
o structure with data and pointers to functions 
● … and executed on top of network device drivers
9 
PFQ/lang current state 
● In-kernel functions are implemented in C language 
o reusability of Linux kernel functions 
o about a hundred of functions ready to use 
o functional library eases the implementation 
● The runtime linker is extensible 
o users can add custom functions and make them available 
in the DLS 
● What is missing... 
o grammar parser for computations from text 
o PFQ/lang native compiler
10 
PFQ/lang theory (in short) 
● Fanout, State and IO can be seen as mathematical abstractions 
called monads (category theory) 
● Monads are data structures that represent computations 
o extend pure functions with side effect 
● PFQ/Lang elementary operations are monadic functions 
o Action: fanout monad, IO monad and state monad. 
● Functional composition of monadic functions with the Kleisli 
operator
11 
Monads: fanout and state 
● Fanout monad is designed to model packet dispatching 
o fanout values can be: Drop, 
Pass, 
Broadcast, 
Steer, 
Deliver 
and 
Dispatch 
Drop => drop the packet 
Pass => pass this packet to the next function 
Broadcast => broadcast this packet to all the endpoints of this group 
Deliver => send the packet to the endpoints of the given class 
Steer => send the packet to an endpoint by means of a hash (random) 
Dispatch => combination of Deliver + Steer 
● State monad is designed to model a mutable state 
o the state is associated with the computation 
simple state, used to mark packets 
o persistent state assiciated with flows
12 
IO monad 
● IO monad (+GC) is used to implement packet 
forwarding 
o lazy implementation 
carried out after the computation is evaluated 
● Lazy means faster! 
o A shallow copy per packet forwarding 
o The last forward can be done without the copy 
o A posteriori with lazy forwarding we can save 
the last skb_clone
13 
PFQ/lang simple functions 
● Simple functions are divided into the following categories: 
o predicates: 
! is_ip, 
is_udp, 
is_tcp, 
is_icmp, 
is_ip6, 
is_udp6, 
is_tcp6, 
is_flow, 
is_frag, 
is_first_frag, 
is_more_frag, 
has_port, 
has_src_port, 
has_dst_port, 
has_vlan, 
has_vid, 
bloom 
etc... 
o combinators: 
! ||, 
&&, 
^^ 
(binary), 
not 
(unary) 
o properties: 
! ip_tos, 
ip_tot_len, 
ip_id, 
ip_frag, 
ip_ttl, 
tcp_src, 
tcp_dst, 
tcp_hdrlen, 
udp_src, 
udp_dst, 
udp_len, 
icmp_type, 
icmp_code... 
o comparators: 
! >, 
>=, 
<, 
<=, 
==, 
/=, 
any_bit, 
all_bit
14 
PFQ/lang monadic functions 
● Monadic functions are divided into the following categories: 
o filters: 
! ip, 
ip6, 
udp, 
tcp, 
udp6, 
tcp6, 
icmp, 
icmp6, 
flow, 
rtp, 
no_frag, 
no_more_frag, 
vlan_filter, 
bloom_filter, 
etc. 
o steering functions: 
! steer_link, 
steer_vlan, 
steer_ip, 
steer_ip6, 
steer_flow, 
steer_rtp, 
steer_net, 
steer_field 
o conditionals: 
! when, 
unless, 
conditional 
o others: 
! kernel, 
forward, 
bridge, 
tee, 
tap, 
inv, 
par, 
log_msg, 
log_packet,etc.
15 
PFQ/lang example 
Haskell: 
comp 
= 
ip 
>-­‐> 
forward 
"eth1" 
>-­‐> 
log_msg 
"IP 
packet" 
>-­‐> 
addr 
"192.168.0.0" 
16 
>-­‐> 
(when’ 
is_icmp 
log_packet) 
>-­‐> 
kernel 
C++11: 
auto 
comp 
= 
ip 
>> 
forward 
("eth1") 
>> 
log_msg 
("IP 
packet") 
>> 
addr 
("192.168.0.0",16) 
>> 
when(is_icmp, 
log_packet) 
>> 
kernel;
16 
PFQ/lang use cases 
Port mirroring 
forward 
"eth1" 
>-­‐> 
kernel 
Smart Bridging 
(when 
is_udp 
(forward 
"eth1")) 
>-­‐> 
kernel 
tap 
"eth2" 
is_rtp 
>-­‐> 
kernel 
Load Balancer 
steer_flow 
ip 
>-­‐> 
steer_link
17 
PFQ/lang use cases 
Stateless Firewall 
(when 
has_port 
22 
&& 
!address("131.114.0.0", 
16) 
drop) 
>-­‐> 
kernel 
when 
(bloom 
16 
["192.168.0.1", 
"192.168.0.2" 
...]) 
kernel 
Monitoring (early stage application) 
conditional 
is_rtp 
(class 
0 
>-­‐> 
steer_flow) 
class 
1
18 
Performance 
Speed test: 10Gb link, 64B packets, Xeon 6 cores x5650 (Nehalem) @2.67Ghz, 16G Ram + Intel 
82599 10G (Debian Wheezy)
19 
Performance 
Conditional: (when is_tcp steer_flow) bridge: tap is_udp “eth2”
20 
Performance 
speed test: comparisons of different computations
21 
PFQ wiki and download 
http://www.pfq.io 
https://github.com/pfq/PFQ/wiki

More Related Content

What's hot

P4 to OpenDataPlane Compiler - BUD17-304
P4 to OpenDataPlane Compiler - BUD17-304P4 to OpenDataPlane Compiler - BUD17-304
P4 to OpenDataPlane Compiler - BUD17-304
Linaro
 
File Systems: Why, How and Where
File Systems: Why, How and WhereFile Systems: Why, How and Where
File Systems: Why, How and Where
Kernel TLV
 
Introduction to memory order consume
Introduction to memory order consumeIntroduction to memory order consume
Introduction to memory order consume
Yi-Hsiu Hsu
 
General Purpose GPU Computing
General Purpose GPU ComputingGeneral Purpose GPU Computing
General Purpose GPU Computing
GlobalLogic Ukraine
 
Foss Gadgematics
Foss GadgematicsFoss Gadgematics
Foss Gadgematics
Bud Siddhisena
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
Kernel TLV
 
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portlandAsymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Nicola La Gloria
 
Mahti quick-start guide
Mahti quick-start guide Mahti quick-start guide
Mahti quick-start guide
CSC - IT Center for Science
 
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Alexander Krizhanovsky
 
Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7
Kynetics
 
Deep Learning on ARM Platforms - SFO17-509
Deep Learning on ARM Platforms - SFO17-509Deep Learning on ARM Platforms - SFO17-509
Deep Learning on ARM Platforms - SFO17-509
Linaro
 
NS3 Overview
NS3 OverviewNS3 Overview
NS3 Overview
Rahul Hada
 
FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)
Kirill Tsym
 
Run Your Own 6LoWPAN Based IoT Network
Run Your Own 6LoWPAN Based IoT NetworkRun Your Own 6LoWPAN Based IoT Network
Run Your Own 6LoWPAN Based IoT Network
Samsung Open Source Group
 
Ebpf ovsconf-2016
Ebpf ovsconf-2016Ebpf ovsconf-2016
Ebpf ovsconf-2016
Cheng-Chun William Tu
 
BUD17-300: Journey of a packet
BUD17-300: Journey of a packetBUD17-300: Journey of a packet
BUD17-300: Journey of a packet
Linaro
 
TensorRT survey
TensorRT surveyTensorRT survey
TensorRT survey
Yi-Hsiu Hsu
 
Maxwell siuc hpc_description_tutorial
Maxwell siuc hpc_description_tutorialMaxwell siuc hpc_description_tutorial
Maxwell siuc hpc_description_tutorialmadhuinturi
 
introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack
monad bobo
 
HKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on AnsibleHKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on Ansible
Linaro
 

What's hot (20)

P4 to OpenDataPlane Compiler - BUD17-304
P4 to OpenDataPlane Compiler - BUD17-304P4 to OpenDataPlane Compiler - BUD17-304
P4 to OpenDataPlane Compiler - BUD17-304
 
File Systems: Why, How and Where
File Systems: Why, How and WhereFile Systems: Why, How and Where
File Systems: Why, How and Where
 
Introduction to memory order consume
Introduction to memory order consumeIntroduction to memory order consume
Introduction to memory order consume
 
General Purpose GPU Computing
General Purpose GPU ComputingGeneral Purpose GPU Computing
General Purpose GPU Computing
 
Foss Gadgematics
Foss GadgematicsFoss Gadgematics
Foss Gadgematics
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
 
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portlandAsymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
 
Mahti quick-start guide
Mahti quick-start guide Mahti quick-start guide
Mahti quick-start guide
 
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
Tempesta FW: a FrameWork and FireWall for HTTP DDoS mitigation and Web Applic...
 
Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7
 
Deep Learning on ARM Platforms - SFO17-509
Deep Learning on ARM Platforms - SFO17-509Deep Learning on ARM Platforms - SFO17-509
Deep Learning on ARM Platforms - SFO17-509
 
NS3 Overview
NS3 OverviewNS3 Overview
NS3 Overview
 
FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)
 
Run Your Own 6LoWPAN Based IoT Network
Run Your Own 6LoWPAN Based IoT NetworkRun Your Own 6LoWPAN Based IoT Network
Run Your Own 6LoWPAN Based IoT Network
 
Ebpf ovsconf-2016
Ebpf ovsconf-2016Ebpf ovsconf-2016
Ebpf ovsconf-2016
 
BUD17-300: Journey of a packet
BUD17-300: Journey of a packetBUD17-300: Journey of a packet
BUD17-300: Journey of a packet
 
TensorRT survey
TensorRT surveyTensorRT survey
TensorRT survey
 
Maxwell siuc hpc_description_tutorial
Maxwell siuc hpc_description_tutorialMaxwell siuc hpc_description_tutorial
Maxwell siuc hpc_description_tutorial
 
introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack
 
HKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on AnsibleHKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on Ansible
 

Viewers also liked

SCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa IT
SCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa ITSCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa IT
SCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa IT
Redge Technologies
 
100 M pakietów na sekundę dla każdego.
100 M pakietów na sekundę dla każdego. 100 M pakietów na sekundę dla każdego.
100 M pakietów na sekundę dla każdego.
Redge Technologies
 
100Mpps czyli jak radzić sobie z atakami DDoS?
100Mpps czyli jak radzić sobie z atakami DDoS?100Mpps czyli jak radzić sobie z atakami DDoS?
100Mpps czyli jak radzić sobie z atakami DDoS?
Redge Technologies
 
100 M pps on PC.
100 M pps on PC.100 M pps on PC.
100 M pps on PC.
Redge Technologies
 
Cat's anatomy
Cat's anatomyCat's anatomy
Cat's anatomy
Nicola Bonelli
 
Spy hard, challenges of 100G deep packet inspection on x86 platform
Spy hard, challenges of 100G deep packet inspection on x86 platformSpy hard, challenges of 100G deep packet inspection on x86 platform
Spy hard, challenges of 100G deep packet inspection on x86 platform
Redge Technologies
 

Viewers also liked (6)

SCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa IT
SCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa ITSCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa IT
SCAP – standaryzacja formatów wymiany danych w zakresie bezpieczeństwa IT
 
100 M pakietów na sekundę dla każdego.
100 M pakietów na sekundę dla każdego. 100 M pakietów na sekundę dla każdego.
100 M pakietów na sekundę dla każdego.
 
100Mpps czyli jak radzić sobie z atakami DDoS?
100Mpps czyli jak radzić sobie z atakami DDoS?100Mpps czyli jak radzić sobie z atakami DDoS?
100Mpps czyli jak radzić sobie z atakami DDoS?
 
100 M pps on PC.
100 M pps on PC.100 M pps on PC.
100 M pps on PC.
 
Cat's anatomy
Cat's anatomyCat's anatomy
Cat's anatomy
 
Spy hard, challenges of 100G deep packet inspection on x86 platform
Spy hard, challenges of 100G deep packet inspection on x86 platformSpy hard, challenges of 100G deep packet inspection on x86 platform
Spy hard, challenges of 100G deep packet inspection on x86 platform
 

Similar to Functional approach to packet processing

Snabbflow: A Scalable IPFIX exporter
Snabbflow: A Scalable IPFIX exporterSnabbflow: A Scalable IPFIX exporter
Snabbflow: A Scalable IPFIX exporter
Igalia
 
Multicore
MulticoreMulticore
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
Yuuki Takano
 
Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!
Ray Jenkins
 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
Open Networking Summits
 
Architecture of TPU, GPU and CPU
Architecture of TPU, GPU and CPUArchitecture of TPU, GPU and CPU
Architecture of TPU, GPU and CPU
GlobalLogic Ukraine
 
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
siouxhotornot
 
Bharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFVBharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFVBharath Ram Chandrasekar
 
software defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllerssoftware defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllersIsaku Yamahata
 
Tarantool 1.6 talk at SECR 2014 conference
Tarantool 1.6 talk at SECR 2014 conferenceTarantool 1.6 talk at SECR 2014 conference
Tarantool 1.6 talk at SECR 2014 conference
Kostja Osipov
 
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesPerformance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Dr. Fabio Baruffa
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
Emertxe Information Technologies Pvt Ltd
 
Rlite software-architecture (1)
Rlite software-architecture (1)Rlite software-architecture (1)
Rlite software-architecture (1)
ARCFIRE ICT
 
Networks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI ModelNetworks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI Model
Brandon Checketts
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
ScyllaDB
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrongSentifi
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilers
AnastasiaStulova
 
Preparing to program Aurora at Exascale - Early experiences and future direct...
Preparing to program Aurora at Exascale - Early experiences and future direct...Preparing to program Aurora at Exascale - Early experiences and future direct...
Preparing to program Aurora at Exascale - Early experiences and future direct...
inside-BigData.com
 
BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108
Linaro
 
Stacks and Layers: Integrating P4, C, OVS and OpenStack
Stacks and Layers: Integrating P4, C, OVS and OpenStackStacks and Layers: Integrating P4, C, OVS and OpenStack
Stacks and Layers: Integrating P4, C, OVS and OpenStack
Open-NFP
 

Similar to Functional approach to packet processing (20)

Snabbflow: A Scalable IPFIX exporter
Snabbflow: A Scalable IPFIX exporterSnabbflow: A Scalable IPFIX exporter
Snabbflow: A Scalable IPFIX exporter
 
Multicore
MulticoreMulticore
Multicore
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
 
Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!
 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
 
Architecture of TPU, GPU and CPU
Architecture of TPU, GPU and CPUArchitecture of TPU, GPU and CPU
Architecture of TPU, GPU and CPU
 
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
 
Bharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFVBharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFV
 
software defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllerssoftware defined network, openflow protocol and its controllers
software defined network, openflow protocol and its controllers
 
Tarantool 1.6 talk at SECR 2014 conference
Tarantool 1.6 talk at SECR 2014 conferenceTarantool 1.6 talk at SECR 2014 conference
Tarantool 1.6 talk at SECR 2014 conference
 
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesPerformance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 
Rlite software-architecture (1)
Rlite software-architecture (1)Rlite software-architecture (1)
Rlite software-architecture (1)
 
Networks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI ModelNetworks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI Model
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrong
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilers
 
Preparing to program Aurora at Exascale - Early experiences and future direct...
Preparing to program Aurora at Exascale - Early experiences and future direct...Preparing to program Aurora at Exascale - Early experiences and future direct...
Preparing to program Aurora at Exascale - Early experiences and future direct...
 
BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108BSD Sockets API in Zephyr RTOS - SFO17-108
BSD Sockets API in Zephyr RTOS - SFO17-108
 
Stacks and Layers: Integrating P4, C, OVS and OpenStack
Stacks and Layers: Integrating P4, C, OVS and OpenStackStacks and Layers: Integrating P4, C, OVS and OpenStack
Stacks and Layers: Integrating P4, C, OVS and OpenStack
 

Recently uploaded

Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 

Recently uploaded (20)

Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 

Functional approach to packet processing

  • 1. A purely functional approach to packet processing Nicola Bonelli Nicola Bonelli, Stefano Giordano, Gregorio Procissi University of Pisa Luca Abeni University of Trento
  • 2. 2 Facts on Linux ● Linux is a general purpose operating system often used to create middleboxes o large amount of open source software o a feature-rich subsystem of networking ● The kernel provides o network stack supports a large amount of protocols o traffic control (tc), firewall (netfilter) o routing (iproute2), bridging o monitoring facilities (AF_PACKET and BPF filters) ● Open-source kernel modules o PF_RING-DNA / Netmap (accelerated drivers) o PFQ framework for multi-core architectures
  • 3. 3 Motivation ● What’s wrong with Linux as a middlebox? o Components are designed to be configurable ! programmability is not fully addressed ● only low level libraries enable tools to communicate to the kernel o Interoperability among heterogeneous components? ! components are statically linked to each other ! what about bridging packets that satisfy a given BPF ? o With no virtual machines, the configuration is system-wide ! Multiple applications can concurrently manage the networking for different purposes?
  • 4. 4 Objective ● Design a new language for programmable middleboxes that: o at high level enables reusability and interoperability among kernel components ! interfaces, kernel and sockets are end-points o is multi-thread oriented by design ! allows concurrent execution of networking applications o as much close as possible to NICs ● But where to implement it? o Use PFQ as underlying architecture
  • 5. 5 Why PFQ? ● Multi-language framework o C, C++11-14, Haskell o compliant with a plethora of device drivers o line-speed with Intel vanilla drivers (14.8Mpps) ● Flexible parallelism o decouple software from hardware parallelism ● Address multi-core architectures o scale almost linearly in any possible configuration ● Best practices of concurrent programming o no mutexes, no spinlocks in fast data-path o amortized atomic operations
  • 6. 6 PFQ/lang overview ● PFQ/lang as a functional language ! DLS describing networking application as a sequence of elementary operations (functions) ! simple firewall, bridge, load balancer, etc. ! early stage of monitoring applications (dispatcher) ● A PFQ/lang program consists of a functional composition o takes a packet and return a packet enriched with a context ! information about the distribution (Fanout) ! state, annotation (State) etc. ! possible side effect (IO)
  • 7. 7 PFQ/lang features ● strongly typed language ● high-order functions o functions that take functions as argument (i.e. conditional expressions) ● currying o Used to bind arguments in user-space " string, vectors, trivially copyable objects in C++ " storable types, storable tuples, list in Haskell ● immutability of data o COW (copy-on-write) ● deterministic garbage collector (GC) o Value semantic with no impact on performance
  • 8. 8 PFQ/lang principles ● PFQ/lang computations are defined in user-space o C++11/Haskell eDSL ● AST is transferred to kernel module for a group of endpoints o runtime strict type-checking (to avoid kernel panic) ● Converted into an executable data structure by a runtime linker o structure with data and pointers to functions ● … and executed on top of network device drivers
  • 9. 9 PFQ/lang current state ● In-kernel functions are implemented in C language o reusability of Linux kernel functions o about a hundred of functions ready to use o functional library eases the implementation ● The runtime linker is extensible o users can add custom functions and make them available in the DLS ● What is missing... o grammar parser for computations from text o PFQ/lang native compiler
  • 10. 10 PFQ/lang theory (in short) ● Fanout, State and IO can be seen as mathematical abstractions called monads (category theory) ● Monads are data structures that represent computations o extend pure functions with side effect ● PFQ/Lang elementary operations are monadic functions o Action: fanout monad, IO monad and state monad. ● Functional composition of monadic functions with the Kleisli operator
  • 11. 11 Monads: fanout and state ● Fanout monad is designed to model packet dispatching o fanout values can be: Drop, Pass, Broadcast, Steer, Deliver and Dispatch Drop => drop the packet Pass => pass this packet to the next function Broadcast => broadcast this packet to all the endpoints of this group Deliver => send the packet to the endpoints of the given class Steer => send the packet to an endpoint by means of a hash (random) Dispatch => combination of Deliver + Steer ● State monad is designed to model a mutable state o the state is associated with the computation simple state, used to mark packets o persistent state assiciated with flows
  • 12. 12 IO monad ● IO monad (+GC) is used to implement packet forwarding o lazy implementation carried out after the computation is evaluated ● Lazy means faster! o A shallow copy per packet forwarding o The last forward can be done without the copy o A posteriori with lazy forwarding we can save the last skb_clone
  • 13. 13 PFQ/lang simple functions ● Simple functions are divided into the following categories: o predicates: ! is_ip, is_udp, is_tcp, is_icmp, is_ip6, is_udp6, is_tcp6, is_flow, is_frag, is_first_frag, is_more_frag, has_port, has_src_port, has_dst_port, has_vlan, has_vid, bloom etc... o combinators: ! ||, &&, ^^ (binary), not (unary) o properties: ! ip_tos, ip_tot_len, ip_id, ip_frag, ip_ttl, tcp_src, tcp_dst, tcp_hdrlen, udp_src, udp_dst, udp_len, icmp_type, icmp_code... o comparators: ! >, >=, <, <=, ==, /=, any_bit, all_bit
  • 14. 14 PFQ/lang monadic functions ● Monadic functions are divided into the following categories: o filters: ! ip, ip6, udp, tcp, udp6, tcp6, icmp, icmp6, flow, rtp, no_frag, no_more_frag, vlan_filter, bloom_filter, etc. o steering functions: ! steer_link, steer_vlan, steer_ip, steer_ip6, steer_flow, steer_rtp, steer_net, steer_field o conditionals: ! when, unless, conditional o others: ! kernel, forward, bridge, tee, tap, inv, par, log_msg, log_packet,etc.
  • 15. 15 PFQ/lang example Haskell: comp = ip >-­‐> forward "eth1" >-­‐> log_msg "IP packet" >-­‐> addr "192.168.0.0" 16 >-­‐> (when’ is_icmp log_packet) >-­‐> kernel C++11: auto comp = ip >> forward ("eth1") >> log_msg ("IP packet") >> addr ("192.168.0.0",16) >> when(is_icmp, log_packet) >> kernel;
  • 16. 16 PFQ/lang use cases Port mirroring forward "eth1" >-­‐> kernel Smart Bridging (when is_udp (forward "eth1")) >-­‐> kernel tap "eth2" is_rtp >-­‐> kernel Load Balancer steer_flow ip >-­‐> steer_link
  • 17. 17 PFQ/lang use cases Stateless Firewall (when has_port 22 && !address("131.114.0.0", 16) drop) >-­‐> kernel when (bloom 16 ["192.168.0.1", "192.168.0.2" ...]) kernel Monitoring (early stage application) conditional is_rtp (class 0 >-­‐> steer_flow) class 1
  • 18. 18 Performance Speed test: 10Gb link, 64B packets, Xeon 6 cores x5650 (Nehalem) @2.67Ghz, 16G Ram + Intel 82599 10G (Debian Wheezy)
  • 19. 19 Performance Conditional: (when is_tcp steer_flow) bridge: tap is_udp “eth2”
  • 20. 20 Performance speed test: comparisons of different computations
  • 21. 21 PFQ wiki and download http://www.pfq.io https://github.com/pfq/PFQ/wiki