ONOS+P4 tutorial (master) - Google 幻灯片 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38
At a glance
Powered by AI
The presentation provides an introduction to P4, P4Runtime and how they can be used with ONOS. P4 is a language for programming the data plane of switches and aims to provide a standardized way to control both programmable and fixed switches. P4Runtime provides an interface for a control plane like ONOS to dynamically configure P4 switches. Examples provided include using P4 for a leaf-spine fabric and offloading virtual network functions.

P4 is a domain-specific language used to define the packet processing pipeline in switches. It aims to provide a standardized way to program both programmable and fixed switches. P4 defines the 'contract' between the control plane and data plane for runtime control.

P4Runtime provides an interface for a control plane like ONOS to dynamically install, update and remove rules on P4 switches. It allows the control plane to configure P4 tables and counters on the data plane at runtime.

2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

ONOS+P4 Tutorial
Controlling P4 data planes with ONOS

Last updated: December 10, 2018

Link to slides:
http://bit.ly/onos-p4-tutorial-slides
Copyright © 2018 - Open Networking Foundation

Before we start...
Use these instructions to download tutorial VM now:

http://bit.ly/onos-p4-vm-instr-offline

Copyright © 2018 - Open Networking Foundation

Goal of this session


● Learn the basics of P4, P4Runtime and ONOS
● Show you the “big picture” of P4
○ Acquire enough knowledge to build full-stack network applications
○ Go from a P4 idea to an end-to-end solution
● Learn the tools to practically experiment with it

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 1/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Your App SDN apps

ONOS SDN control plane

P4Runtime Runtime control

Your P4 program P4 switch

Copyright © 2018 - Open Networking Foundation

Instructors

Carmelo Cascone Brian O’Connor Yi Tseng 曾毅


ONF ONF ONF

Copyright © 2018 - Open Networking Foundation

Outline
● Introduction (45 min)
○ P4 language
○ P4Runtime
○ ONOS
● P4 and P4Runtime support in ONOS and use cases (30 min)
○ P4 support in Trellis leaf-spine fabric
○ VNF offloading for S/PGW
● Break (15 min)
● Hands-on lab (1h 30 min)

Copyright © 2018 - Open Networking Foundation

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 2/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

P4
The Data Plane Programming Language

Copyright © 2018 - Open Networking Foundation

What is a pipeline?

Pipeline of match-action tables

Packets

ASIC, FPGA, NPU, or CPU

Copyright © 2018 - Open Networking Foundation

8
P4
● Domain-specific language to formally define the data plane pipeline
○ Describe protocol headers, lookup tables, actions, counters, etc.
○ Can describe fast pipelines (e.g ASIC, FPGA) as well as a slower ones (e.g. SW switch)
● Good for programmable switches, as well as fixed-function ones
○ Defines “contract” between the control plane and data plane for runtime control

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 3/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Table
mypipeline.p4
{
Compiler (provided by switch vendor)
matc
Configure programmable ASIC/FPGA
h
actio or maps to fixed-function ASIC tables
ns
}

Packets

Programmable or fixed-function
pipeline
Copyright © 2018 - Open Networking Foundation

Evolution of the language


● P414
○ Original version of the language
○ Assumed specific device capabilities
○ Good only for a subset of programmable switch/targets
● P416 (Focus of this tutorial)
○ More mature and stable language definition
○ Does not assume device capabilities
○ Defined via external libraries/architecture definition
○ Good for many targets
○ E.g., switches or NICs, programmable or fixed-function

Copyright © 2018 - Open Networking Foundation

PISA: Protocol-Independent Switch Architecture 10

Abstract machine model of a high-speed programmable switch architecture

Programmer defines Programmer declares


Programmer declares the tables and the how the output packet
which headers should exact processing will look on the wire
be extracted and in algorithm
which order

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 4/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

- To design a programming language, it is very useful to se le on the abstract machine, that is suited for the algorithms we'd like to
express.

- P4 is based on an abstract machine model named PISA, which stands for…

- P4 is based on the abstract model of a high-speed packet processing device, called PISA, which stands for Protocol-Independent Switch
Architecture.
- PISA incorporates four basic components:
- First, it is a programmable parser, which determines, which packet headers will be recognized by the data plane program. It is modeled as
a simple, determinis c state machine, that consumes packet data and iden fiers headers. It transi ons between states typically by looking
at specific fields in the previously iden fied headers. For example: The first 14 bytes are an Ethernet header. Then, if you look at the
Ethertype, you know that the next header is a VLAN tag, an IPv4 or IPv6 header, an MPLS label, etc. If a parser iden fied an IPv4 header, it
can jump to the next state based on IP protocol and so on.
- At the heart of the PISA architecture is a pipeline, consis ng of a set of “Match-Ac on” stages. What they can do is to match some data
against a table that contains some entries and execute a corresponding ac on. If you think about it, that’s pre y much all the networking
devices do. For example, an L2 switch will use a Des na on MAC address (and a VLAN) to perform a match in an L2 table and then execute
an ac on, such as “send a packet to this egress port”. Similarly, L3 switching is also easily reduced to a sequence of matches, such as
Des na on IP address lookup will produce a NexthopID and a lookup on a Nexthop ID will produce ac ons, such as “send to port”, “change
MAC address”, “decrement TTL”, etc. ACLs, MPLS switching, everything can be expressed this way. Even basic things like if() or switch()
statements can also be reduced to the basic opera on of match and Ac on.
- At the end of the pipeline, there is a programmable deparser that performs (as its name says)the opera on, which is a reverse of the
parsing. It re-assembles the packets back (e.g., by serializing the headers) so that the packets can go back onto the wire, into the
queueing/replica on engine etc.

Compiling a simple logical pipeline on PISA 11

Large

Small

P4 compiler
Allocate resources to
realize the pipeline

Ethernet IPv4 IPv4 IPv6


address address address address
table table table table
ACL
table

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

Let’s make an example of how PISA is used to realize a given logical pipeline

In this example, we have a simple pipeline comprising 4 tables: L2 bridging table, routing tables for IPv4 and IPv6 and an ACL table. We also
have the requirement to support a large number of IPv4 routing entries, while the IPv6 table can be smaller

Here the P4 compiler is responsible of mapping this logical pipeline to the PISA architecture.

For example, a compiler can decide to allocate, Ethernet table on the first stage,
Dedicate two stages for the IPv4 table, and use the last stage to allocate both the Ipv6 and ACL tables, which can be executed in parallel

12
V1Model P4 Switch Architecture
● Parser/deparser → P4 programmable
● Checksum verification/update
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 5/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

● Ingress Pipeline → P4 programmable


→ P4 programmable
● Egress Pipeline → P4 programmable
○ Match on egress port
● Traffic Manager
→ Fixed
○ Queueing, Replication function
(multicast), scheduling

Traffic manager

Parser Ingress match+action pipeline Traffic manager Egress match+action pipeline Deparser
/ checksum verification / checksum update
Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

Not everything is programmable

Another example of a switch architecture for P4 is called V1Model

This is the architecture used by the first version of the language, P4_14

It is based on PISA, but adds some more blocks

Parser/deparser
Checksum verification/update
2 pipelines of match/action stages, ingress pipeline and egress pipeline
Where the egress pipeline can match on the packet egress port
We also have a fixed function block called the traffic manager, this is used to perform operations like buffering, scheduling, and replication of
packets for example for multicast
This is fixed function, meaning that we cannot use P4 to program the behavior of this block.

P4 architectures 13

my_program.p4
Written against a specific architecture
Defines the processing of each block

Defines which blocks are


architecture.p4 available, the interfaces of each
Provided by switch vendor block, and their capabilities
Copyright © 2018 - Open Networking Foundation

Preliminary takeaways
● Can I implement/describe this or that feature with P4?
○ It depends on the architecture
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 6/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ The P4 language is flexible enough to express almost any behavior


based on match-action tables
○ Specific capabilities depend on the architecture
■ e.g. ternary match vs. longest-prefix match vs. exact match
● Can I execute my P4 program on a switch X from vendor Y?
○ Probably yes, if vendor Y provides a P4 compiler for the specific
architecture used

Architectures enable portability of P4 programs


across different HW and SW targets

Copyright © 2018 - Open Networking Foundation

15
PSA - Portable Switch Architecture
● Community-developed architecture (P4.org Arch WG)
○ https://github.com/p4lang/p4-spec/tree/master/p4-16/psa
● Describes common capabilities of a network switch
● 6 programmable P4 blocks + 2 fixed-function blocks
● Defines capabilities beyond match+action tables
○ Counters, meters, stateful registers, hash functions, etc.

Copyright © 2018 - Open Networking Foundation

Other P4 architectures
● FlexSAI
○ Hybrid programmable/fixed-function switch based on SAI
○ https://github.com/opencomputeproject/SAI/tree/master/flexsai/p4

Fixed function Programmable Hybrid

● Portable NIC Architecture (PNA)


○ Work in progress by the P4.org Architecture WG

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 7/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Copyright © 2018 - Open Networking Foundation

17
P4 program template (V1Model)

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

18
P4 program example: simple_router.p4

header ethernet_t { action set_next_hop(bit<48> dst_addr) {


bit<48> dst_addr; ethernet.dst_addr = dst_addr;
bit<48> src_addr; ipv4.ttl = ipv4.ttl - 1;
bit<16> eth_type; }
} ...
table ipv4_routing_table {
header ipv4_t { key = {
bit<4> version; ipv4.dst_addr : LPM; // longest-prefix match
bit<4> ihl; }
bit<8> diffserv; actions = {
… set_next_hop();
} drop();
}
parser parser_impl(packet_in pkt, out headers_t hdr) { size = 4096; // table entries
/* Parser state machine to extract header fields */ }
}

Copyright © 2018 - Open Networking Foundation

19
Runtime: simple_router.p4 action ipv4_forward(bit<48> dst_addr, bit<9>
port) {
ethernet.dst_addr = dst_addr;
● Data plane program (P4) standard_metadata.egress_spec = port;
ipv4.ttl = ipv4.ttl - 1;
○ Defines the match-action tables }
table ipv4_routing_table {

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 8/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ Performs the lookup key = {


ipv4.dst_addr : LPM; // longest-prefix match
○ Executes the chosen action }
actions = {
● Control plane (runtime) ipv4_forward();
drop();
○ Populates table entries with specific }
information }

○ Based on configuration, automatic


discovery, protocol calculations

Control plane populates table entries

Copyright © 2018 - Open Networking Foundation

We now have a P4 program that describes the data plane, but we miss the control plane logic

20
P4 workflow summary
User supplied
Control Plane

P4 Program P4 Compiler Packet-in/out


Add/remove Extern
table entries control

CPU port
P4 Architecture Target-specific
Data Plane
Model Tables Extern
configuration Load objects
binary

Vendor supplied P4Runtime

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

P4Runtime
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 9/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Runtime control API for P4-defined data planes

Copyright © 2018 - Open Networking Foundation

22
Do we need yet another data plane control API?
Can’t we re-use existing APIs such as OpenFlow or SAI?

Credits XKCD
Copyright © 2018 - Open Networking Foundation

Which problems are we trying to solve? I want you to convince you that P4Runtime is needed

23
Yes, we need P4Runtime
Target-independent Protocol-independent Pipeline-independent

API Same API works with Same API allows control of any Same API allows control of many
different switches from data plane protocol, standard or arbitrary pipelines formally
different vendors custom specified


OpenFlow ✔ Protocol headers and actions ✔ (with TTP)
hard-coded in the spec

Switch ✘

Abstraction ✔ Designed for legacy forwarding
Interface (SAI) Implicit fixed-function pipeline
pipelines (L2/L3/ACL)

P4Runtime ✔ ✔ ✔ (with P4)


Copyright © 2018 - Open Networking Foundation

24
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 10/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

P4Runtime overview
● API for runtime control of P4-defined switches
○ Designed around PSA architecture but can be extended to others
● Community-developed (p4.org API WG)
Control plane
○ Initial contribution by Google and Barefoot
(P4Run me client)
○ RC of version 1.0 available: https://p4.org/p4-spec/
● gRPC/protobuf-based API definition p4runtime.proto
○ Automatically generate client/server code for many languages (API)
● P4 program-independent
○ API doesn’t change with the P4 program
● Enables field-reconfigurability P4Run me server
○ Ability to push new P4 program, i.e. re-configure the switch (e.g. Stratum)
pipeline, without recompiling the switch software stack Target driver

P4 target

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

25
Protocol Buffers (protobuf) Basics
● Language for describing data for
syntax = "proto3";
serialization in a structured way message Person {
● Strongly typed string name = 1;
int32 id = 2;
● Auto-generate code to string email = 3;
serialize/deserialize messages in:
○ Code generators for: Action Script, C, enum PhoneType {
C++, C#, Clojure, Lisp, D, Dart, Erlang, MOBILE = 0;
HOME = 1;
Go, Haskell, Java, Javascript, Lua,
WORK = 2;
Objective C, OCaml, Perl, PHP, Python, }
Ruby, Rust, Scala, Swift, Visual Basic, ...
● Platform-neutral message PhoneNumber {
string number = 1;
● Extensible and backwards compatible PhoneType type = 2;
}

repeated PhoneNumber phone = 4;


}

Copyright © 2018 - Open Networking Foundation

Describe messages to be exchanged by two systems

Great for describing the API of a service

Binary format for efficient tranmission over

26
gRPC Basics
● Use Protobuf to define service API
and messages
● Automatically generate native
client and server code in:
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 11/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ C / C++, C#, Dart, Go, Java,


Node.js, PHP, Python, Ruby
● Transport over HTTP/2.0 and TLS
○ Efficient single TCP connection
implementation that supports
bidirectional streaming

Copyright © 2018 - Open Networking Foundation

27
p4runtime.proto (gRPC service)
Enables a local or remote control plane to
● Load the pipeline/P4 program
● Write/read pipeline state (e.g. table entries, meters, groups, etc.)
● Send/receive packets to/from controller (packet-in/out)
● Arbitrate mastership (for distributed control planes)
service P4Runtime {
rpc Write(WriteRequest) returns (WriteResponse) {}
rpc Read(ReadRequest) returns (stream ReadResponse) {}
rpc SetForwardingPipelineConfig(SetForwardingPipelineConfigRequest)
returns (SetForwardingPipelineConfigResponse) {}
rpc GetForwardingPipelineConfig(GetForwardingPipelineConfigRequest)
returns (GetForwardingPipelineConfigResponse) {}
rpc StreamChannel(stream StreamMessageRequest)
returns (stream StreamMessageResponse) {}
}

From: https://github.com/p4lang/p4runtime/blob/master/proto/p4/v1/p4runtime.proto
Copyright © 2018 - Open Networking Foundation

28
P4Runtime Write Request
message WriteRequest { message Entity {
uint64 device_id = 1; oneof entity {
uint64 role_id = 2; ExternEntry extern_entry = 1;
Uint128 election_id = 3; TableEntry table_entry = 2;
repeated Update updates = 4; ActionProfileMember
} action_profile_member = 3;
ActionProfileGroup
action_profile_group = 4;
message Update { MeterEntry meter_entry = 5;
enum Type { DirectMeterEntry direct_meter_entry = 6;
UNSPECIFIED = 0; CounterEntry counter_entry = 7;
INSERT = 1; DirectCounterEntry direct_counter_entry = 8;
MODIFY = 2; PacketReplicationEngineEntry
DELETE = 3; packet_replication_engine_entry = 9;
} ValueSetEntry value_set_entry = 10;
Type type = 1; RegisterEntry register_entry = 11;
Entity entity = 2; }

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 12/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

} }

Copyright © 2018 - Open Networking Foundation

29
P4Runtime TableEntry
p4runtime.proto simplified excerpts:
message TableEntry { message FieldMatch {
To add a table entry, the control
uint32 table_id; uint32 field_id; plane needs to know:
repeated FieldMatch match; message Exact {
Action action; bytes value;
}
int32 priority;
message Ternary {
· IDs of P4 entities
...
bytes value; ◦ Tables, field matches, actions,
} bytes mask;
}
params, etc.
message LPM {
message Action { bytes value;
uint32 action_id; uint32 prefix_length;
· Field matches for the
message Param { } particular table
uint32 param_id; ...
bytes value; oneof field_match_type { ◦ Match type, bit width, etc.
} Exact exact;
repeated Param params; Ternary ternary;
} LPM lpm; · Parameters for the particular
...
}
action
} · Other P4 program attributes
Copyright © 2018 - Open Networking Foundation

Here I have an excerpt from the protocol definition showing the message format for installing a table entry.
Explain each line in the code.
Now, both the control plane and the dataplane have to agree on this message format. Let’s see how P4Runtime achieves this.

30
P4 compiler workflow
P4 compiler generates 2 outputs:
test.p4
1. Target-specific binaries
○ Used to realize switch pipeline
(e.g. binary config for ASIC, bitstream for FPGA, etc.)
2. P4Info file p4c
Control plane
(compiler)
○ Describes “schema” of pipeline for runtime
control
■ Captures P4 program attributes such as tables,
actions, parameters, etc.
○ Protobuf-based format test.p4info p4run me.proto
○ Target-independent compiler output
■ Same P4Info for SW switch, ASIC, etc.
P4Run me server
test.bin
Target driver
Switch ASIC

Full P4Info protobuf specification:


https://github.com/p4lang/p4runtime/blob/master/proto/p4/config/v1/p4info.proto

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

31
P4Info example
basic_router.p4 basic_router.p4info

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 13/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

... actions {
id: 16786453
name: "ipv4_forward"
action ipv4_forward(bit<48> dstAddr, params {
bit<9> port) { id: 1
/* Action implementation */ name: "dstAddr"
} bitwidth: 48
...
id: 2
...
name: "port"
bitwidth: 9
table ipv4_lpm { }
key = { }
hdr.ipv4.dstAddr: lpm; ...
} P4 compiler tables {
id: 33581985
actions = {
name: "ipv4_lpm"
ipv4_forward; match_fields {
... id: 1
} name: "hdr.ipv4.dstAddr"
... bitwidth: 32
match_type: LPM
}
}
action_ref_id: 16786453
Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation }

32
P4Runtime table entry example
basic_router.p4 Protobuf message

action ipv4_forward(bit<48> dstAddr, table_entry {


bit<9> port) { table_id: 33581985
/* Action implementation */ match {
} field_id: 1
table ipv4_lpm { lpm {
key = { Control plane value: "\n\000\001\001"
hdr.ipv4.dstAddr: lpm; generates prefix_len: 32
} }
actions = { }
ipv4_forward; action {
... action_id: 16786453
} params {
... param_id: 1
} value: "\000\000\000\000\000\n"
}
Logical view of table entry params {
param_id: 2
hdr.ipv4.dstAddr=10.0.1.1/32 value: "\000\007"
-> ipv4_forward(00:00:00:00:00:10, 7) }
}
}
Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

● Protobuf bytes encoding in ASCII format

33
P4Runtime SetPipelineConfig
message SetForwardingPipelineConfigRequest { test.p4
enum Action {
UNSPECIFIED = 0; Pipeline config
VERIFY = 1; p4info json Control plane
VERIFY_AND_SAVE = 2;
VERIFY_AND_COMMIT = 3; p4c SetPipelineConfig()
COMMIT = 4; (compiler)
Pipeline config bits
RECONCILE_AND_COMMIT = 5;
}
P4Run me server
uint64 device_id = 1;

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 14/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

uint64 role_id = 2; Target driver


Switch ASIC
Uint128 election_id = 3;
Action action = 4;
ForwardingPipelineConfig config = 5; message ForwardingPipelineConfig {
} config.P4Info p4info = 1;
// Target-specific P4 configuration.
bytes p4_device_config = 2;
}

Copyright © 2018 - Open Networking Foundation

P4Runtime provides a way to push a new pipeline configuration to the switch

34
Silicon-independent remote control

table_entry { Target-independent
table_id: protobuf format
SDN routing app P4-defined etc.
33581985
over gRPC transport custom protocol p4info
match {
field_id: 1
lpm {
Remote SDN control plane (e.g. ONOS/ODL)
value:
"\f\000\...
prefix_len: 8
}
}
action {
action_id:
16786453
params {
param_id: 1
value: "\000\0... p4info p4info p4info
} P4Run me P4Run me P4Run me
params { server (e.g. Stratum) server (e.g. Stratum) server (e.g. Stratum)
param_id: 2
value: 7 Target driver Target driver Target driver
}
}
}

Vendor A Vendor B Vendor C


(programmable) (fixed-function) (fixed-function)
Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

In this slide we can see how P4Runtime can be used in the context of a remote SDN controller

Here we have switches from different vendors, some are programmable, some are fixed-function.

Here the p4info file is used as a contract to between the control plane and the data plane

35
Portability of local control plane

Same target- table_entry {


independent table_id:
OSPF BGP P4-defined etc. 33581985
protocol
protobuf format match {
p4inf (gRPC or other field_id: 1
Local control plane o mechanism) lpm {
value:
"\f\000\...
p4inf prefix_len: 8
P4Run me agent o }
}
(e.g. Stratum) action {
action_id:
Target driver 16786453
params {
param_id: 1
value: "\000\0...
}
params {
param_id: 2

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 15/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
P4 target value: 7
}
}
}

Slide courtesy P4.org Copyright © 2018 - Open Networking Foundation

P4Runtime summary
● P4Runtime is an improvement over previous data plane APIs
○ Realizes the vision of OpenFlow 2.0
○ Provides protocol and pipeline-independence
○ Protocols supported and pipeline are formally specified using P4
● Based on protobuf and gRPC
○ Makes it easy to implement a P4Runtime client/server by auto-
generating code
● P4Info as a contract between control and data plane
○ Generated by P4 compiler
○ Needed by the control plane to format the body of P4Runtime messages
(e.g. to add table entry)

Copyright © 2018 - Open Networking Foundation

ONOS
A control plane for P4Runtime devices

Copyright © 2018 - Open Networking Foundation

38
What is ONOS?
● Open Network Operating System (ONOS)
● Provides the control plane for a software-defined network
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 16/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ Logically centralized remote controller


○ Provides APIs to make it easy to create apps to control a network
● Focus on service provider for access/edge applications
● Runs as a distributed system across many servers
○ For scalability, high-availability, and performance
● Open source project
○ Created by ON.Lab and currently hosted by the Linux Foundation
○ Active community: 8,152 commits and 276 authors in last 2 years

Copyright © 2018 - Open Networking Foundation

39
ONOS releases
4-month release cycles
● Avocet (1.0.0) 2014-12
●…
● Loon (1.11.0) 2017-08 (Initial P4Runtime support)
● Magpie (1.12.0) 2017-12
● Nightingale (1.13.0) 2018-04
● Owl (1.14.0) 2018-08
● Peacock (1.15.0) 2018-12 (latest release)

Copyright © 2018 - Open Networking Foundation

40
Deployments
● Access network for residential customers
○ In production with a major US telecom provider
○ Edge leaf-spine fabric: ~10K clients, ~150K routes, ~1.5M flows
○ OpenFlow

● Research & Education


○ SDN-IP, VPLS apps

● SDN in Air-Traffic Management


○ Safety-critical, ATM-grade deployment in Brazil (~22M km2)
○ Radar relays, remote control towers, pilot voice, etc.

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 17/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ NetBroker from Frequentis developed on ONOS


○ Brown-field & OpenFlow

Copyright © 2018 - Open Networking Foundation

41
ONOS architecture
Control and configure the network
using a global topology view Apps
Apps
and independently of the device-specific details Apps

Northbound API ...


Device/protocol-agnostic Topology API FlowRule API FlowObjective API Intent API Packet API
Java, REST, CLI, gRPC
Distributed core
State management, notifications, high-availability & scale-out
Device driver
Allow device-specific variants
of standard protocols OVS Arista Barefoot Cavium Mellanox Ciena Cisco Corsa

Fujitsu HP Huawei Juniper Lumentum Microsemi Polatis ...


Shared protocol
libraries OpenFlow P4Runtime Netconf ...more

Copyright © 2018 - Open Networking Foundation

42
Network programming API

Abstract
to Intent
concrete
Host-Host Single-Point to Protected
Multi-point Intent

Flow Objective
OF-DPA Single Table P4 Program
Pipeline Pipeline Defined Pipeline

Flow Rule
Mapping through drivers
OpenFlow P4Runtime Netconf TL1

Copyright © 2018 - Open Networking Foundation

Assuming we want to provide connectivity between point A and point B….


There’s three ways of doing that in ONOS….

43
Flow objective example
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 18/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Peering Router Match on Switch port, MAC address, VLAN, IP

FlowObjective Service

HP Pipeliner OF-DPA Pipeliner

HP OpenFlow 1.3 Pipeline OF-DPA OpenFlow 1.3 Pipeline

Copyright © 2018 - Open Networking Foundation

44
Driver behaviors in ONOS
● ONOS defines APIs to interact with device called
“behaviors”
○ DeviceDescriptionDiscovery → Read device information and ports
○ FlowRuleProgrammable → Write/read flow rules
○ PortStatisticsDiscovery → Statistics of device ports (e.g. packet/byte counters)
○ Pipeliner → FlowObjective-to-FlowRules mapping logic
○ Etc.
● Behavior = Java interface
● Driver = collection of one or more behavior implementations
○ Implementations use ONOS protocol libraries to interact with device

App

ONOS Driver 1 Driver 2

P4Runtime OpenFlow

Copyright © 2018 - Open Networking Foundation

45
ONOS key takeaways
● Apps are independent from switch control protocols
○ Same app can work with OpenFlow and P4Runtime devices
● Different network programming APIs
○ FlowRule API – pipeline-dependent
○ FlowObjective API – pipeline-independent
■ Drivers translate 1 FlowObjective to many FlowRule
● FlowObjective API enables application portability
○ App using FlowObjectives can work with switches with different pipelines
○ For example, switches with different P4 programs
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 19/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Copyright © 2018 - Open Networking Foundation

P4 and P4Runtime support in ONOS

Copyright © 2018 - Open Networking Foundation

P4 and P4Runtime support in ONOS


Goals:
1. Allow ONOS users to bring their own P4 program
2. Allow existing apps to control any P4 pipeline without
changing the app
○ i.e. enable app portability across many P4 pipelines
3. Allow apps to control custom/new protocols as defined in
the P4 program

Copyright © 2018 - Open Networking Foundation

Pipeconf - Bring your own pipeline! 48

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 20/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

● Package together everything necessary to let ONOS


understand, control, and deploy an arbitrary pipeline
● Provided to ONOS as an app pipeconf.oar
○ Can use .oar binary format for distribution

1. Pipeline model
○ Description of the pipeline understood by ONOS
○ Automatically derived from P4Info
2. Target-specific binaries to deploy pipeline to device
○ E.g. BMv2 JSON, Tofino binary, FPGA bitstream, etc.
3. Pipeline-specific driver behaviors
○ E.g. “Pipeliner” implementation: logic to map FlowObjectives to P4 pipeline

Copyright © 2018 - Open Networking Foundation

49
Pipeconf support in ONOS
Pipeline-agnostic Pipeline-aware
app app

Pipeline-specific
FlowObjectives Events FlowRules, Groups,
(packet, topology, etc.) Meters, etc

ONOS
Translation services
Uses pipeconf’s pipeline drivers
Pipeconf
Store Pipeconf
Core (.oar)

Device drivers Barefoot Mellanox BMv2


(with P4Runtime support)
Allow for variations of
Protocol P4Runtime
(default driver) P4Runtime, e.g. specify
different ways of pushing
gRPC pipeline configuration
Deploy P4 program
Table management
Device (Tofino, BMv2, etc.)

Copyright © 2018 - Open Networking Foundation

Explain pipeconf

Explain apps

Explain drivers

50
Pipeconf deploy and device discovery

my-pipeconf.oar
ONOS
Extensions: Pipeconf Service
BMV2_JSON REGISTER
P4INFO DeviceID: bmv2:1
Get pipeconf P4Runtime
Bind pipeconf+device driver - Server addr: 192.168.56.1
- Port: 5001

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 21/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Pipeconf ID: my-pipeconf
Device Provider Driver: BMv2
1 PUSH

Deploy pipeconf Connect device

Pipeline Device netcfg.json 2


Programmable Handshaker

SetPipelineConfig
Open connection to
ONOS core
gRPC server
Device/protocol driver
4 Device bmv2:1
3
Pipeconf
Copyright © 2018 - Open Networking Foundation

51
Flow operations
Define flow rules using same headers/action
names as in the P4 program. E.g match on
“hdr.my_protocol.my_field”

Pipeline-agnostic Pipeline-aware
Pipeconf-based 3 phase translation: App App
1. Flow Objective → Flow Rule
● Maps 1 flow objective to many flow rules
Flow Objective Flow Rule
2. Flow Rule → Table entry Serv. Serv.
● Maps standard headers/actions to P4-defined
ones E.g. ETH_DST→“hdr.ethernet.dst_addr” Flow Objective

Pipeliner Pipeline
3. Table Entry → P4Runtime message Interpreter
● Maps P4 names to P4Info numeric IDs Flow Rules
(many)
P4Runtime Flow Rule Flow Rule
Behaviour Translation Serv.
Table Entry
P4Runtime Client P4Info
ONOS Core
Device/protocol driver
P4Runtime protobuf
messages
Pipeconf driver

Copyright © 2018 - Open Networking Foundation

52
Pipeline Interpreter

● Driver behavior
○ Provides mapping between ONOS well-known headers/actions and P4 program-
specific entities
● Example: flow rule mapping
○ Match
■ 1:1 mapping between ONOS known headers and P4 header names
■ E.g. ETH_DST → “ethernet.dst_addr” (name defined in P4 program)
○ Action
■ ONOS defines standard actions as in OpenFlow (output, set field, etc)
■ Problem: P4 allows only one action per table entry, ONOS many (as in OpenFlow)
■ E.g. header rewrite + output: 2 actions in ONOS, 1 action with 2 parameters in P4
■ How to map many actions to one? Need interpretation logic (i.e. Java code)!

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 22/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Copyright © 2018 - Open Networking Foundation

53
P4Runtime support in ONOS 1.14 (Owl)

P4Runtime control entity ONOS API

Flow Rule Service, Flow Objective Service


Table entry
Intent Service

Packet-in/out Packet Service

Action profile group/members, PRE multicast


Group Service
groups

Meter Meter Service (indirect meters only)

Flow Rule Service (direct counters)


Counters
P4Runtime Client (indirect counters)

Pipeline Config Pipeconf

Unsupported features - community help needed!


Parser value sets, registers, digests, clone sessions

Copyright © 2018 - Open Networking Foundation

54
ONOS+P4 workflow recap
● Write P4 program and compile it
○ Obtain P4Info and target-specific binaries to deploy on device
● Create pipeconf
○ Implement pipeline-specific driver behaviours (Java):
■ Pipeliner (optional - if you need FlowObjective mapping)
■ Pipeline Interpreter (to map ONOS known headers/actions to P4 program ones)
■ Other driver behaviors that depend on pipeline
● Use existing pipeline-agnostic apps
○ Apps that program the network using FlowObjectives
● Or... write new pipeline-aware apps
○ Apps can use same string names of tables, headers, and actions as in the P4 program
● Enjoy!

Copyright © 2018 - Open Networking Foundation

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 23/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Use case 1:
silicon-independent fabric

Copyright © 2018 - Open Networking Foundation

Thanks to this integration, we were able to demonstrate few use cases of ONOS

Trellis – Multi-purpose Leaf-Spine Fabric


● Prominent example of ONOS application
○ In production at Comcast in the US
● Designed for NFV and access/edge applications
○ Built with white-box switches, open source software, SDN based
● Extensive feature set
○ Bridging/VLANs, IPv4/v6 unicast and multicast routing, DHCP-relay,
pseudowires, QinQ, vRouter & more
● Works with OpenFlow and P4/P4Runtime

Copyright © 2018 - Open Networking Foundation

57
Trellis & P4
Pipeline-agnostic apps - use ONOS FlowObjective API

Trellis apps Segment Rou ng DHCP L3 Relay vRouter Mul cast ...
Fabric.p4
ONOS pipeconf
OF-DPA driver fabric.p4 driver

OpenFlow P4Runtime
Flow table/group mgmt Deploy pipeline config
Flow table/group mgmt

Broadcom Qumran Barefoot Tofino

Broadcom Tomahawk Mellanox Spectrum 1


Broadcom Trident2

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 24/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

White-box switches
Copyright © 2018 - Open Networking Foundation

Trellis originally designed to support white-box with Broadcom chips using the OF-DPA pipeline abstrac on….

58
fabric.p4
● P4 implementation of the Trellis reference pipeline
○ Inspired by Broadcom OF-DPA pipeline
○ Tailored to Trellis needs (fewer tables, easier to control)
○ Work in progress:
■ Missing support for IPv6
● Bring more heterogeneity in Trellis with P4-capable silicon
○ Works with both programmable and fixed-function chips
○ Logical simplified pipeline of L2/L3/MPLS features
○ Any switch pipeline that can be mapped to fabric.p4 can be used with Trellis
● Extensible open-source implementation
○ https://github.com/opennetworkinglab/onos/.../fabric.p4

Copyright © 2018 - Open Networking Foundation

“Easier” silicon independence


● Mapping FlowObjective is hard
○ Underspecified/ambiguous pipeline abstraction
● Any switch ASIC that can be mapped to fabric.p4 can be used with Trellis
○ Both programmable and fixed function
● Mapping effort is left to P4 compilers or ASIC vendors (manual), not ONOS drivers
○ Fabric.p4 pipeliner (driver) unchanged

Trellis apps (Segment Routing, Multicast, etc)

Flow objectives
ONOS core

OFDPA pipeliner Other pipeliner Fabric.p4 pipeliner


Mapping Other mapping Almost 1-to-1 mapping
complex impl!
P4Runtime
OpenFlow OpenFlow

OFDPA Other switch agent Stratum Stratum Stratum


Mapping 1 Mapping 2 Mapping X
Broadcom ASIC Other ASIC ASIC 1 ASIC 2 ASIC X

Copyright © 2018 - Open Networking Foundation

Shifting complexity from control plane developers to switch ones, complexity is not eliminated but reduced.

Switch developers are more used to this kind of job


Formal pipeline specification allows for tools to ease the mapping job (Mellanox example)

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 25/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

OF-DPA vs fabric.p4 Pipeliner

fabric.p4 OF-DPA

$ cd onos/pipelines/fabric/.../pipeliner $ cd onos/drivers/.../pipeline/ofdpa/
$ wc -l *.java $ wc -l Ofdpa*.java
106 AbstractObjectiveTranslator.java 1985 Ofdpa2GroupHandler.java
284 FabricPipeliner.java 1933 Ofdpa2Pipeline.java
58 FabricPipelinerException.java 514 Ofdpa3GroupHandler.java
237 FilteringObjectiveTranslator.java 913 Ofdpa3Pipeline.java
252 ForwardingFunctionType.java 49 Ofdpa3QmxPipeline.java
43 ForwardingFunctionTypeCommons.java 772 OfdpaGroupHandlerUtility.java
284 ForwardingObjectiveTranslator.java 6166 total
498 NextObjectiveTranslator.java
209 ObjectiveTranslation.java x3 more LOCs
20 package-info.java
1991 total

Copyright © 2018 - Open Networking Foundation

For ONOS developers life is definitely easier...

Fabric.p4 design rationale


ONOS FlowObjective API (3-stage logical pipeline)
Permit
/deny Next ID To ports
Filtering Forwarding Next

VLAN-based Forwarding information base for different Next ID implementation: rewrite headers, push VLAN/MPLS, replication
port filtering behaviors (bridging, routing, MPLS SR). (broadcast/multicast) and ECMP.
Set Next ID.

filtering.p4 forwarding.p4 next.p4 Fixed-function next.p4

Table Table Table Traffic manager Table


Table Table Table (replication engine, Table
Table Table Table buffering) Table

Ingress pipeline Egress pipeline

V1Model P4 architecture

Copyright © 2018 - Open Networking Foundation

62
Fabric.p4 pipeline
In-port + VLAN filtering table

Filtering

Forwarding classifier

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 26/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Bridging MPLS IPv4 routing IPv6 routing


(WIP)

Forwarding

ACL

Next ID mapping

Next
Unicast Hashed Multicast VLAN cross-
(ECMP) connect

Copyright © 2018 - Open Networking Foundation

Use case 2:
VNF offloading

Copyright © 2018 - Open Networking Foundation

VNF Offloading

• Implement Network Functions in HW as part of the switch pipeline


• Replace middleboxes of VNFs
• Many benefits
▪ Increased performance - VNFs executed at switch line rate, i.e. O(Tbit/s)
▪ Reduced latency and jitter - Avoid non-determinism of x86 processing
▪ Reduced costs - Less CPU resources, less power consumption

Compute (x86)
Programmable ASIC Control VNF VNF ...
VNF building blocks
capabilities plane
Arbitrary header Domain specific encap/decap
parsing/deparsing (e.g. PPPoE termination, GTP, etc.)
TCP connection tracking Fast plumbing Fast
Stateful memories
(L4 load balancing, NAT, firewall, etc.) VNF
Computational capabilities Billing
P4 switch
with programmable ASIC

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 27/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Copyright © 2018 - Open Networking Foundation 64

65
M-CORD without VNF offloading
● CORD: NFV platform for the Telco central office
● M-CORD: CORD Mobile profile (other profiles exist, e.g. for Residential access)

Mobile subscriber traffic


Trellis …
Traffic processing intensive VNF:
- GTP tunnel terminations
ONOS
- Filtering and lawful interception
- Downlink QoS
- Downlink buffering during handover Spine Spine
- Charging

ToR ToR
GTP tunnels Upstream
eNodeB Backhaul SPGW-u MME router
network
SPGW-c HSS Control plane VNFs
Data plane VNF

Copyright © 2018 - Open Networking Foundation

66
M-CORD with offloaded SPGW-u VNF


Mobile subscriber traffic
Trellis Apps SPGW-u App …
SPGW-u executed
directly on the ONOS
switching ASIC
P4Runtime
spgw.p4 P4 program deployment and table
Spine Spine management

ToR ToR
GTP tunnels Upstream
eNodeB Backhaul MME router
network
SPGW-c HSS

Copyright © 2018 - Open Networking Foundation

67
spgw.p4
● PoC P4 implementation of the SPGW-u data plane
○ ~300 lines of P4_16 code
○ Integrated with fabric.p4
○ https://github.com/opennetworkinglab/onos/.../spgw.p4
● Good enough to demonstrate end-to-end connectivity
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 28/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ Support GTP encap/decap, filtering, charging functionalities


● Important missing features (future work - need help)
○ Buffering during handovers
○ Downlink QoS

Copyright © 2018 - Open Networking Foundation

68
SPGW-u App

3GPP Control and User Plane Separation (CUPS) protocol


Create/modify/delete GTP sessions

SPGW-u App Trellis Apps …


ONOS Pipeline-specific app
Works only with spgw.p4
P4Runtime
spgw.p4 table entries

Spine Spine

ToR ToR

MME
Open source EPC from Intel/Sprint
SPGW-c 3GPP
HSS

Copyright © 2018 - Open Networking Foundation

69
Demo 1 @ MWC and ONS 2018
End-to-end connectivity
Trellis Apps SPGW-u App …
ONOS
Video streaming P4Runtime
P4 program deployment and
table management
Mellanox Cavium
Spectrum 1 Xpliant
Spine Spine
fabric.p4
Barefoot Barefoot
Tofino Tofino
ToR ToR
Upstream
fabric+spgw.p4 router

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 29/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Copyright © 2018 - Open Networking Foundation

70
Demo 2 @ ONS 2018
spgw.p4 performance with Inband Network Telemetry (INT)
Trellis Apps SPGW-u App …
ONOS
P4Runtime
P4 program deployment and
Mellanox Cavium table management
Spectrum 1 Xpliant
Spine Spine
fabric+spgw+int_transit.p4 fabric.p4
Barefoot Barefoot fabric+int_transit.p4
Tofino Tofino
int_sink.p4 ToR ToR

Netcope
Netcope 100G NIC
100G NIC Downlink traffic
Traffic sink generator
(eNodeB emulator)
INT reports to collector
(Barefoot Deep Insight)
Copyright © 2018 - Open Networking Foundation

71
Demo 2 @ ONS 2018
Throughput

Overhead due to GTP and


INT headers

Hop latency

~490ns to perform GTP encap


plus forwarding (ToR 1)

~480ns to perform forwarding


(ToR 2)

Copyright © 2018 - Open Networking Foundation

Residential service edge/BNG (se.p4)


● ONF is working with Deutsche Telekom to open-source a
production-grade implementation of a residential service
edge/BNG in P4
● Enables fast path for residential access
● Features:
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 30/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ PPPoE termination
○ Reverse-path filtering (MAC, IPv4/v6)
○ Metering
○ TR-101 double-VLAN termination
○ 2-label MPLS termination
● Community help needed for integration with Trellis and fabric.p4

Copyright © 2018 - Open Networking Foundation

ONOS+P4 Hands-on Lab

Copyright © 2018 - Open Networking Foundation

Tutorial VM
● Download tutorial VM now:
○ http://bit.ly/onos-p4-vm-instr-offline
● Or, ask USB drive to instructors
○ Contains VM image and VirtualBox for mac OS and Windows

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 31/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Copyright © 2018 - Open Networking Foundation

P4 tools overview
ONOS

p4c Control Plane

P4 Program P4 Compiler
Add/remove Packet-in/out
table entries

CPU port
P4 Architecture Target-specific
Data Plane
Model Tables
configuration Load
binary

BMv2

Copyright © 2018 - Open Networking Foundation

BMv2 – Reference P4 software switch


● Open-source user-space implementation
○ https://github.com/p4lang/behavioral-model
● BMv2 = Behavioral-Model version 2
● Aimed at being 100% conformant to the P4 specification
○ Performance is non-goal, i.e. low throughput
● Architecture-independent
○ Mostly generic code which can be used to implement any P4
architecture
● We use the “simple_switch_grpc” target
○ Implementation of V1Model architecture with P4Runtime support over gRPC

Copyright © 2018 - Open Networking Foundation

BMv2’s simple_switch_grpc target

Table Mul cast groups Table


management management management

P4Run me API

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 32/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Packets Parse Ingress pipeline Packet Egress pipeline Depa


r Replica on rser
Engine
(PRE)

configure
v1model.p4 architecture
p4c-bm-ss

p4c compiler with


my_program.p4 simple_switch back-end my_program.json
Copyright © 2018 - Open Networking Foundation

p4c
● Open-source frontend compiler
○ https://github.com/p4lang/p4c
● Generates P4Info
● Support multiple backends (vendor-supplied)
○ Generate code for ASICs, NICs, FPGAs, software switches and other targets
○ Some backends are open-source (BMv2, eBPF)

Slide courtesy: M. Budiu, C. Doss. The architecture of the P4_16 compiler. P4 Workshop
Copyright © 2018 - Open Networking Foundation
2017

Example of p4c command


p4c-bm2-ss -o mytunnel.json \
--p4runtime-file mytunnel.p4info \
--p4runtime-format text \
mytunnel.p4
Or check Makefile under:
$ONOS_ROOT/apps/p4-tutorial/pipeconf/src/main/resources/Makefile

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 33/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Copyright © 2018 - Open Networking Foundation

Exercises overview
● Run ONOS with BMv2/P4Runtime drivers
● Load “tutorial” pipeconf
● Example P4 program that implements a custom tunneling protocol
● Run Mininet with BMv2
● Run applications to provide connectivity between hosts
○ Exercise 1: pipeline-agnostic application (Reactive Forwarding)
○ Exercise 2: pipeline-aware application (MyTunnelApp)
■ Requires to write few lines of ONOS Java code

Copyright © 2018 - Open Networking Foundation

ONOS environment
Pipeline-agnostic apps Pipeline-aware app
use FlowObjective API use FlowRule API

LLDP Provider Host Provider ARP Proxy Reac ve MyTunnel


(link discovery) (host discovery) forwarding App

ONOS Tutorial
REGISTER
BMv2/P4Run me Driver Pipeconf

netcfg.json
Contains IP address and port of P4Runtime
P4Runtime server of each switch

Mininet with custom script bmv2.py BMv2’s


BMv2’s
simple_switch_target
BMv2’s
simple_switch_target
simple_switch_grpc

Copyright © 2018 - Open Networking Foundation

LLDP Provider App


● Provides means to discover network links by injecting LLDP
packets in the network
○ Install packet request (flow objective) on each device
■ Match: ETH_TYPE = LLDP
■ Instructions: OUTPUT(CONTROLLER)
○ Periodically issues LLDP packets via packet-out for each switch port
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 34/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

Copyright © 2018 - Open Networking Foundation

Host Provider
● Learns location of hosts and IP-MAC mapping by passively
intercepting ARP packets
○ Mapping: MAC-IP addr ⟷ Switch-ID:Port-ID
● No rules installed, listens for packet requests installed by
other applications (e.g. ARP Proxy)

Copyright © 2018 - Open Networking Foundation

ARP Proxy App


● Replies to ARP requests received by hosts
○ Intercepts ARP requests sent by hosts via packet-in. For each device,
install packet request (flow rule)
■ Match: ETH_TYPE = ARP
■ Instructions: OUTPUT(CONTROLLER)
○ Generates ARP replies based on previously learned IP-MAC mappings
■ E.g. by looking at received ARP requests
○ ARP packets are not forwarded on the network, but are handled
exclusively by the controller

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 35/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Copyright © 2018 - Open Networking Foundation

Reactive Forwarding App


● Intercepts IP packets for which there are no matching flow
rules on the switch
○ Match: ETH_TYPE = IPv4, Instruction: OUTPUT(CONTROLLER)
● When a packet-in is received…
○ If the location of the destination host is known, installs the necessary
flow rule to forward subsequent packets
■ Match: IN_PORT, ETH_SRC, ETH_DST, Instruction: OUTPUT(port)
○ Otherwise, packet is flooded on all ports of the switch where it was
received via packet-out

Copyright © 2018 - Open Networking Foundation

Mininet script: bmv2.py


● Provided with ONOS
● Executes BMv2’s simple_switch_grpc inside Mininet
○ Automatically generates and push to ONOS the netcfg.json
■ With P4Runtime server IP/port and pipeconf ID
● Files located under /tmp
● Example command to use bmv2.py
○ sudo -E mn --custom $BMV2_MN_PY \
--switch onosbmv2,pipeconf=p4-tutorial-pipeconf
--controller remote,ip=127.0.0.1
○ $BMV2_MN_PY env variable points to the location of the bmv2.py script

Copyright © 2018 - Open Networking Foundation

ONOS terminology
● Criteria
○ Match fields used in a FlowRule
● Traffic Treatment
○ Actions/instructions of a FlowRule
● Pi* classes
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 36/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片

○ Classes used to describe protocol-independent constructs


○ Equivalent of P4Runtime generic entities
○ Examples
■ PiTableId: name of a table as in the P4 program
■ PiMatchFieldId: name of a match filed in a table
■ PiCriterion: list of match fields each one defined by it’s name and
value
■ PiAction: action defined by it’s name and list of parameters

Copyright © 2018 - Open Networking Foundation

Start now

Tutorial VM

Double-click on
“Tutorial README”

You can work on your own using the instructions.


Ask for instructors help when needed.

Copyright © 2018 - Open Networking Foundation

Bonus 3rd exercise: modify P4 program


● Look for tables t_tunnel_ingress and t_tunnel_fwd in mytunnel.p4
○ We need to add counters to these 2 tables
● Look for the way we have added counters to table t_l2_fwd
○ First, we instantiate the counter
■ direct_counter(CounterType.packets_and_bytes)
l2_fwd_counter;
○ Then, we added the counter instance to t_l2_fwd
■ counters = l2_fwd_counter; (Inside t_l2_fwd table defini on)
● Do the same for t_tunnel_ingress and t_tunnel_fwd
○ Using a different name for the counter instance, i.e. not l2_fwd_counter
● Re-compile mytunnel.p4
○ cd ~/onos/apps/p4-tutorial/pipeconf/src/main/resources
○ make
● Execute again Exercise 2
○ When executing `ok clean` ONOS will be rebuilt automatically, and so the pipeconf
● Now you should see flow counters being updated in the ONOS CLI and UI for the
t_tunnel_ingress and t_tunnel_fwd tables

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 37/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Copyright © 2018 - Open Networking Foundation

Links recap
● Download and import the tutorial VM:
○ http://bit.ly/onos-p4-vm-instr-offline
● These slides:
○ http://bit.ly/onos-p4-tutorial-slides
● Exercise instructions:

Tutorial VM

Double-click on
“Tutorial README”
Copyright © 2018 - Open Networking Foundation

I want more!
● Trellis+P4 tutorial (with hands-on exercises)

https://docs.google.com/presentation/d/1AFPZ_vJW1UNUHxgGWSPB7o
OjkW-iRWvXowluIajjKWY/edit#slide=id.p1
○ Based on fabric.p4

Copyright © 2018 - Open Networking Foundation

https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 38/38

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy