This webinar explains why PISA chips are inevitable, provides overview of machine architecture of such switches, presents a brief primer on the P4 language with sample programs for a variety of networks and demonstrates a powerful network diagnostics application implemented in P4.
Programmability in SDNs is confined to the network control plane. The forwarding plane is still largely dictated by fixed-function switching chips. Our goal is to change that, and to allow programmers to define how packets are to be processed all the way down to the wire.
This is made possible by a new generation of high-performance forwarding chips. At the high-end, PISA (Protocol-Independent Switch Architecture) chips promise multi-Tb/s of packet processing. At the mid- and low-end of the performance spectrum, CPUs, GPUs, FPGAs, and NPUs already offer great flexibility with performance of a few tens to hundreds of Gb/s.
In addition to programmable forwarding chips, we also need a high-level language to dictate the forwarding behavior in a target independent fashion. "P4" (www.p4.org) is such a language. In P4, the programer declares how packets are to be processed, and a compiler generates a configuration for a PISA chip, or a programmable target in general. For example, the programmer might program the switch to be a top-of-rack switch, a firewall, or a load-balancer; and might add features to run automatic diagnostics and novel congestion control algorithms.
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[Webinar Slides] Programming the Network Dataplane in P4
1. Programming
The
Network
Data
Plane
in
P4
Changhoon
Kim
(chang@barefootnetworks.com)
P4
Language
Consor9um
–
www.p4.org
2. Status
quo
2
Switch
OS
Run-‐<me
API
Driver
“This
is
roughly
how
I
process
packets
…”
Fixed-‐func<on
ASIC
in
English
• Prone
to
bugs
• Very
long
and
unpredictable
lead
9me
3. Protocols
evolve
…
more
rapidly
than
we
wish
they
would
• Encapsula<on
protocols
for
network
virtualiza<on
– 1st
gen
(~2010):
VXLAN,
NVGRE
– 2nd
gen
(~2012):
STT,
VXLAN-‐GPE
– 3rd
gen
(~2014):
NSH,
Geneve
• OpenFlow
– OF
1.0
(Dec
2009):
12
fields
(Ethernet,
TCP,
IPv4)
– OF
1.1
(Feb
2011):
15
fields
(MPLS,
inter-‐table
metadata)
– OF
1.2
(Dec
2011):
36
fields
(ARP,
ICMP,
IPv6)
– OF
1.3
(Jun
2012):
40
fields
– OF
1.4
(Oct
2013):
41
fields
– OF
1.5
(Dec
2014):
44
fields
3
Everybody
has
opinions!
Can’t
we
just
let
them
build
their
own
protocols?
4. Programmable
network
devices
• Some
devices
are
or
will
be
more
programmable
than
fixed-‐func<on
ASICs
• CPUs:
10s
of
Gb/s
• FPGAs,
NPUs:
100s
of
Gb/s
• Protocol-‐independent
switch
ASICs:
a
few
Tb/s
– RMT
[SIGCOMM’13]
and
a
few
emerging
solu<ons
– Merchant
silicon
with
fully
programmable
parser
and
generic
match-‐ac<on
logic
– In
next
few
years
this
kind
of
silicon
will
dominate
4
5. Turning
the
tables
5
Switch
OS
Run-‐<me
API
Driver
PISA
device
(Protocol-‐Independent
Switch
Architecture)
“This
is
precisely
how
you
must
process
packets”
in
P4
6. What
does
this
mean?
• To
network
device
vendors
– S/W
programming
prac<ces
and
tools
used
in
every
phase
– Extremely
fast
itera<on
and
feature
release
– Differen<a<on
in
capabili<es
and
performance
– Can
fix
even
data-‐plane
bugs
in
the
field
• To
large
on-‐line
service
providers
– No
more
“black
boxes”
in
the
“white
boxes”
– Your
devs
can
program,
test,
and
debug
your
network
devices
all
the
way
down
– You
keep
your
own
ideas
6
7. 7
Why
we
call
it
protocol-‐independent
packet
processing
8. Logical
Data-‐plane
View
(your
P4
program)
Switch
Pipeline
Device
does
not
understand
any
protocols
un9l
it
gets
programmed
Queues
Programmable
Parser
Fixed
Ac<on
Match
Table
Match
Table
Match
Table
Match
Table
L2
IPv4
IPv6
ACL
Ac<on
ALUs
Ac<on
ALUs
Ac<on
ALUs
Ac<on
ALUs
8
packet
packet
packet
packet
CLK
9. Match
Table
Ac<on
ALUs
Mapping
logical
data-‐plane
design
to
physical
resources
Queues
Match
Table
Match
Table
Match
Table
L2
Table
IPv4
Table
IPv6
Table
ACL
Table
Ac<on
ALUs
Ac<on
ALUs
Ac<on
ALUs
L2
IPv4
IPv6
ACL
Logical
Data-‐plane
View
(your
P4
program)
Switch
Pipeline
L2
IPv6
ACL
IPv4
L2
Ac<on
Macro
v4
Ac<on
Macro
v6
Ac<on
Macro
ACL
Ac<on
Macro
9
Programmable
Parser
CLK
13. What
does
a
P4
program
look
like?
13
L2
IPv4
ACL
MyEncap
MyEncap
IPv6
table ipv4_lpm
{
reads {
ipv4.dstAddr : lpm;
}
actions {
set_next_hop; drop;
}
}
action set_next_hop(nhop_ipv4_addr, port)
{
modify_field(metadata.nhop_ipv4_addr, nhop_ipv4_addr);
modify_field(standard_metadata.egress_port, port);
add_to_field(ipv4.ttl, -1);
}
control ingress
{
apply(l2);
apply(my_encap);
if (valid(ipv4) {
apply(ipv4_lpm);
} else {
apply(ipv6_lpm);
}
apply(acl);
}
14. /* Example: A typical IPv4 routing table */
table ipv4_lpm {
reads {
ingress_metadata.vrf : exact;
ipv4.dstAddr : lpm;
}
actions {
nop;
l3_l2_switch;
l3_multicast;
l3_nexthop;
l3_ecmp;
l3_drop;
}
size : 65536;
}
What
does
a
P4
program
look
like?
14
vrf
ipv4.dstAddr
/
prefix
ac9on
data
1
192.168.1.0
/
24
l3_l2_switch
port_id=64
10
10.0.16.0
/
22
l3_ecmp
ecmp_index=12
1
192.168.0.0
/
16
l3_nexthop
nexthop_index=451
1
0.0.0.0
/
0
l3_nexthop
nexthop_index=1
These
are
the
only
possible
ac<ons.
Each
par<cular
entry
in
the
table
is
associated
with
ONE
of
these
15. What
does
a
P4
program
look
like?
• Match
seman<cs
– exact
• port_index
:
exact
– ternary
• ethernet.srcAddr
:
ternary
– valid
• vlan_tag[0]
:
valid
– lpm
• ipv4.dstAddr
:
lpm
– range
• udp.dstPort
:
range
15
16. What
does
a
P4
program
look
like?
• Primi<ve
ac<ons
– modify_field, add_to_field, add,
set_field_to_hash_index
– add_header, remove_header, copy_header
– push, pop
– count, meter
– generate_digest, truncate
– resubmit, recirculate
– clone_*
– no_op, drop
16
17. My
(running)
switch
MyNetVirtualiza9on
(your
new
protocol)
Forwarding
Logic
(P4)
Table
Popula<on
Tenant
Isola<on
Logic
Linux
Switch
Chip
Driver
Switch
Run<me
API
Table
Popula<on
Tenant
Isola<on
Logic
Compiled
Forwarding
Logic
Parser
Program
Control
Flow
Match
Tables
+
Ac9ons
Compiler
PISA
chip
Add/delete
(run
<me)
Program
(boot
or
init
<me)
22. INT
Open-‐source
and
Spec
• hnp://p4.org/p4/inband-‐network-‐telemetry/
22
Spec
Ref
P4
code
Demo
23. This
will
accelerate
innova9ons
• Areas
of
innova<on
(just
to
name
a
few)
– Reducing
feature
set
à
“biggest
bang
for
buck”
– Network
monitoring,
analysis,
and
diagnos<cs
– Tunnel-‐splicing
gateways
– Load
balancing
– Anack
detec<on
and
mi<ga<on
– Host-‐stack
offloading
• Across
various
types
of
network
devices
– Hardware
and
sosware
devices
(OVS,
eBPF,
etc.)
– Switches,
NICs,
middle-‐boxes,
etc.
23
24. This
will
create
lots
of
significant
R&D
and
business
opportuni9es
• Novel
network
and
protocol
designs
– Take
advantage
of
unprecedented
amount
of
visibility
and
control
into
the
network
– Joint
design
and
op<miza<on
between
hosts
and
network
• Development
tools
– Compilers,
debuggers,
sta<c
analyzers,
profilers,
etc.
– P4-‐programming
assistance
tools
• Network
verifica<on,
test,
and
simula<on
• Many
more
…
24
25. P4.org
–
P4
Language
Consor9um
25
Maintains
the
language
spec
26. P4.org
–
P4
Language
Consor9um
26
Maintains
key
dev
tools
under
Apache
license
• Reference
P4
programs
• Compiler
• P4
sosware
switch
• Test
framework
27. P4.org
–
P4
Language
Consor9um
27
Open
for
par9cipa9on
by
any
individuals
or
organiza9ons
28. P4.org
–
P4
Language
Consor9um
28
Hosts
P4
workshops
and
boot
camps
• 2nd
P4
Workshop
on
Nov/18
at
Stanford
• 1st
P4
Boot
camp
in
the
same
week
29. Switch.p4:
A
typical
L2/L3
switch
in
P4
• Feature
set
– Basic
L2
switching:
MAC
learning,
VLAN,
flooding,
and
STP
– Basic
L3
rou<ng:
IPv4
and
IPv4
rou<ng
with
VRF
– LAG
and
ECMP
– Tunneling:
VXLAN,
NVGRE,
Geneve,
and
GRE
– Basic
ACL:
MAC
and
IP
ACLs
– Unicast
RPF
– MPLS:
LER,
LSR,
IPVPN,
VPLS,
and
L2VPN
– Host
interface
– Mirroring:
Ingress
and
egress
mirroring
with
ERSPAN
– Counters/Sta<s<cs
• More
features
coming
soon
– IP
Mul<cast,
NAT,
QoS,
Ingress
policing,
etc.
29
30. Summary
• In
next
few
years
data-‐plane
programmability
will
quickly
become
commonplace
• This
will
accelerate
innova<ons
in
networking
• No
more
“black
boxes”
in
“white
boxes”
• As
the
common
industry-‐wide
forwarding
language,
P4
will
play
crucial
roles
• Lots
of
R&D
and
business
opportuni<es
opening
up
–
join
and
contribute!
30
31. How
to
keep
in
touch?
• Join
P4.org
– p4-‐dev@p4.org
– p4-‐discuss@p4.org
– p4-‐announce@p4.org
• Assign
engineers
to
get
familiar
with
P4
• Start
playing
tools,
language,
and
sample
P4
code
• Contribute
back
to
P4.org
31