SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

P4 to OpenDataPlane Compiler - BUD17-304
P4 to OpenDataPlane Compiler - BUD17-304P4 to OpenDataPlane Compiler - BUD17-304
P4 to OpenDataPlane Compiler - BUD17-304Linaro
 
File Systems: Why, How and Where
File Systems: Why, How and WhereFile Systems: Why, How and Where
File Systems: Why, How and WhereKernel TLV
 
Introduction to memory order consume
Introduction to memory order consumeIntroduction to memory order consume
Introduction to memory order consumeYi-Hsiu Hsu
 
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 CasesKernel TLV
 
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portlandAsymmetric Multiprocessing - Kynetics ELC 2018 portland
Asymmetric Multiprocessing - Kynetics ELC 2018 portlandNicola La Gloria
 
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.mx7Kynetics
 
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-509Linaro
 
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
 
BUD17-300: Journey of a packet
BUD17-300: Journey of a packetBUD17-300: Journey of a packet
BUD17-300: Journey of a packetLinaro
 
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 AnsibleLinaro
 

Was ist angesagt? (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
 

Andere mochten auch

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 ITRedge 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
 
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 platformRedge Technologies
 

Andere mochten auch (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
 

Ähnlich wie A purely functional approach to packet processing with PFQ/lang

Snabbflow: A Scalable IPFIX exporter
Snabbflow: A Scalable IPFIX exporterSnabbflow: A Scalable IPFIX exporter
Snabbflow: A Scalable IPFIX exporterIgalia
 
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 P4Open Networking Summits
 
Architecture of TPU, GPU and CPU
Architecture of TPU, GPU and CPUArchitecture of TPU, GPU and CPU
Architecture of TPU, GPU and CPUGlobalLogic 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 conferenceKostja 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 ArchitecturesDr. Fabio Baruffa
 
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 ModelBrandon 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_uringScyllaDB
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrongSentifi
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilersAnastasiaStulova
 
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-108Linaro
 
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 OpenStackOpen-NFP
 

Ähnlich wie A purely functional approach to packet processing with PFQ/lang (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
 

Kürzlich hochgeladen

Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Kürzlich hochgeladen (20)

Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

A purely functional approach to packet processing with PFQ/lang

  • 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