ONOS+P4 tutorial (master) - Google 幻灯片 PDF
ONOS+P4 tutorial (master) - Google 幻灯片 PDF
ONOS+P4 tutorial (master) - Google 幻灯片 PDF
ONOS+P4 Tutorial
Controlling P4 data planes with ONOS
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
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 1/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
Instructors
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)
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
What is a pipeline?
Packets
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
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 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.
Large
Small
P4 compiler
Allocate resources to
realize the pipeline
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 幻灯片
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
This is the architecture used by the first version of the language, P4_14
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
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 幻灯片
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.
Other P4 architectures
● FlexSAI
○ Hybrid programmable/fixed-function switch based on SAI
○ https://github.com/opencomputeproject/SAI/tree/master/flexsai/p4
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 7/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
17
P4 program template (V1Model)
18
P4 program example: simple_router.p4
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 幻灯片
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
CPU port
P4 Architecture Target-specific
Data Plane
Model Tables Extern
configuration Load objects
binary
P4Runtime
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 9/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
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)
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
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;
}
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 幻灯片
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 幻灯片
} }
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
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
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 幻灯片
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
}
}
}
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
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 15/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
P4 target value: 7
}
}
}
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)
ONOS
A control plane for P4Runtime devices
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 幻灯片
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)
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
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 17/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
41
ONOS architecture
Control and configure the network
using a global topology view Apps
Apps
and independently of the device-specific details Apps
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
43
Flow objective example
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 18/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
FlowObjective Service
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
P4Runtime OpenFlow
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 幻灯片
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 20/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
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
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)
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
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
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 幻灯片
53
P4Runtime support in ONOS 1.14 (Owl)
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!
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
Thanks to this integration, we were able to demonstrate few use cases of ONOS
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
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
Flow objectives
ONOS core
Shifting complexity from control plane developers to switch ones, complexity is not eliminated but reduced.
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 25/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
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
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.
V1Model P4 architecture
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 幻灯片
Forwarding
ACL
Next ID mapping
Next
Unicast Hashed Multicast VLAN cross-
(ECMP) connect
Use case 2:
VNF offloading
VNF Offloading
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)
ToR ToR
GTP tunnels Upstream
eNodeB Backhaul SPGW-u MME router
network
SPGW-c HSS Control plane VNFs
Data plane VNF
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
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 幻灯片
68
SPGW-u App
Spine Spine
ToR ToR
MME
Open source EPC from Intel/Sprint
SPGW-c 3GPP
HSS
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
Hop latency
○ 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
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
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
P4Run me API
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 32/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
configure
v1model.p4 architecture
p4c-bm-ss
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
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
ONOS environment
Pipeline-agnostic apps Pipeline-aware app
use FlowObjective API use FlowRule API
ONOS Tutorial
REGISTER
BMv2/P4Run me Driver Pipeconf
netcfg.json
Contains IP address and port of P4Runtime
P4Runtime server of each switch
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)
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 35/38
2020/6/21 ONOS+P4 tutorial (master) - Google 幻灯片
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 幻灯片
Start now
Tutorial VM
Double-click on
“Tutorial README”
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
https://docs.google.com/presentation/d/1LYlI0BVZ44z7DTJBOGo4bBsddUOUjQfR2i_4f7Bo6Sg/htmlpresent 38/38