in computer science at NCTU • Was a Information Technology Service Center Network & System Engineer at NCTU before • You can find me at ◦ GitHub: @sufuf3 ◦ Twitter: @sufuf3149 2
Membership • The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion 3
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 4
Benefits • P4.org Membership • The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 7
from the forwarding plane (data plane) • Control plane controls several devices • The network control to become directly programmable • Motivation • Benefits Ref: https://www.sdxcentral.com/sdn/definitions/inside-sdn-architecture/ 9
protocol headers on which it operates. This set has grown from 12 to 41 fields in a few years, increasing the complexity of the specification while still not providing the flexibility to add new headers. • Motivation • Benefits Versio n Date Header Fields 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, etc.) OF 1.3 Jun 2012 40 fields OF 1.4 Oct 2013 41 fields Ref: https://www.sigcomm.org/sites/default/files/ccr/papers/2014/July/0000000-0000004.pdf 11
Protocol independence ◦ Switches should not be tied to any specific network protocols. ◦ Controller should be able to specify ▪ A packet parser for extracting header fields with particular names and types ▪ A collection of typed match + action tables that process these headers • Target independence ◦ Programmers should be able to describe packet-processing functionality independently of the specifics of the underlying hardware. • Motivation • Benefits Ref: https://www.sigcomm.org/sites/default/files/ccr/papers/2014/July/0000000-0000004.pdf 12
Features - Add new protocols • Reduce complexity - Remove unused protocols • Efficient use of resources - flexible use of tables • Greater visibility - New diagnostic techniques, telemetry, etc. • Software style development - rapid design cycle, fast innovation, fix data plane bugs in the field • You keep your own ideas Think programming rather than protocols... • Motivation • Benefits Ref: https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.html#sec-benefits-of-p4 && https://p4.org/assets/P4_tutorial_01_basics.gslide.pdf 13
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 14
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 16
to process the packet. • How does the switch process the headers’ value? 1. Write some logical program to deal with them ▪ Actions 2. Invoke the actions according to the rules which are sent from the SDN controller ▪ Tables • Control Program ◦ Determines the order of tables that are applied to a packet. A simple imperative program describe the flow of control between match + action tables The concept of Packet processing w/ P4 (Cont’d) 20
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 23
series of fields • Parsers ◦ Specifies how to identify headers & valid header sequences within packets • Tables (match + action tables) ◦ The mechanism for performing packet processing • Actions ◦ P4 supports construction of complex actions from simpler protocol-independent primitives. These complex actions are available within match + action tables. • Control Program ◦ Determines the order of tables that are applied to a packet. A simple imperative program describe the flow of control between match + action tables Key Components of P4 24
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language ◦ Program Template ◦ Approach ▪ Target ▪ Architecture • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 25
◦ Architecture • Provides an interface to program a target via some set of P4-programmable components, externs, fixed components 29 Ref: https://p4.org/assets/P4_tutorial_01_basics.gslide.pdf
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline ◦ Topology ◦ Source code ◦ Architecture ◦ Explain • P4 Compiler • Environments • Try P4 • What can you do with P4? Outline 30
must perform: ◦ Update the source and destination MAC addresses ◦ Decrement the time-to-live (TTL) in the IP header ◦ Forward the packet out the appropriate port • Topology • Source code • Architecture • Explain 31 • Have a single table: the control plane will populate with static rules • Each rule will map an IP address to the MAC address and output port for the next hop • Already defined the control plane rules
standard_metadata_t standard_metadata) { state start { transition parse_ethernet; } state parse_ethernet { packet.extract(hdr.ethernet); transition select(hdr.ethernet.etherType) { TYPE_IPV4: parse_ipv4; default: accept; } } state parse_ipv4 { packet.extract(hdr.ipv4); transition accept; Parser (Cont’d) Parsers are functions that map packets into headers and metadata, written in a state machine style • packet_in: reads its input from a packet_in • in: read-only • out: are treated as a storage • inout: both in & out 43
inout standard_metadata_t standard_metadata) { state start { transition parse_ethernet; } state parse_ethernet { packet.extract(hdr.ethernet); transition select(hdr.ethernet.etherType) { TYPE_IPV4: parse_ipv4; default: accept; } } state parse_ipv4 { packet.extract(hdr.ipv4); transition accept; } Every parser has three predefined states • start • accept • reject Parser (Cont’d) packet.extract is from include file: core.p4 select statement that can be used to branch in a parser 45 start parse_ethernet Ethernet header extract is_IPv4: parse_ipv4 IPv4 header extract Accept Accept
variables, create tables, instantiate externs, etc. • Functionality specified by code in apply statement • Represent all kinds of processing that are expressible as DAG(Directed Acyclic Graph): ◦ Additional forms of packet processing (updating checksums) ◦ Match-Action Pipelines ◦ Deparsers Controls control MyVerifyChecksum(inout headers hdr, inout metadata meta) { apply { } } Evaluating a program that has several instantiations of the same component. parameters of control • Controls ◦ CV ◦ Ingress ◦ Egress ◦ CC ◦ Deparser 47
in tables; invoked automatically on table match. ◦ Can be declared inside a control or globally ◦ Parameters have type and direction ◦ Variables can be instantiated inside ◦ Many standard arithmetic and logical operations are supported Controls (Cont’d) • Controls ◦ CV ◦ Ingress ◦ Egress ◦ CC ◦ Deparser 49
headers hdr){ apply { packet.emit(hdr.ethernet); packet.emit(hdr.ipv4); } } Deparser • Assembles the headers back into a well-formed packet • P416 does not provide a separate language for packet deparsing • Deparsing is done in a control block that has at least one parameter of type packet_out • packet_out extern is defined in core.p4: emit(hdr): serializes header if it is valid • Advantages: ◦ Makes deparsing explicit...but decouples from parsing • Controls ◦ CV ◦ Ingress ◦ Egress ◦ CC ◦ Deparser 55
MyVerifyChecksum(), MyIngress(), MyEgress(), MyComputeChecksum(), MyDeparser() ) main; • Instantiate the top-level V1Switch package • All the arguments of the V1Switch package constructor have been evaluated (instances of MyParser, MyVerifyChecksum ...). • Their signatures are matched w/ the V1Switch declaration • The result of the program evaluation is the value of the main variable Switch 57
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 58
P4 16 • Provides a standard frontend and midend which can be combined with a target-specific backend to create a complete P4 compiler • The compiler supports several backends: • p4c-bmv2 – targets the behavioral model • p4c-ebpf, p4c-graphs, p4test … etc. • Repository: https://github.com/p4lang/p4c • Eg. P4 Compiler $ p4c -b bmv2-ss-p4org program.p4 -o program.bmv2.json 59
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 60
P4 software switch (aka behavioral model) • nicknamed BMv2 • A simulation environment to run the P4 software switch, standalone or in Mininet • Allows you to easily simulate new architectures by implementing new externs • Enabling you to organize the forwarding elements as needed • Repository: https://github.com/p4lang/behavioral-model 62
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 64
need to setup the environment ◦ OS & HW requirement ▪ OS: Ubuntu 16.04 64-bits ▪ CPU: at least 2 cores ▪ RAM: at least 2G ▪ Disk: at least 25G ◦ Run command by yourself (not root), after finish OS installation $ wget -O setup.sh https://goo.gl/EHgk4v && sudo bash setup.sh && wget -O - https://goo.gl/NKaau7 | bash 65
• The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion Outline 66
• Low Latency Congestion Control – NDP[2] • Fast In-Network cache for key-value stores – NetCache[3] • In-band Network Telemetry – INT[4] • Consensus at network speed – NetPaxos[5] • ... and much more [1] Miao, Rui, et al. "SilkRoad: Making Stateful Layer-4 Load Balancing Fast and Cheap Using Switching ASICs." SIGCOMM, 2017. [2] Handley, Mark, et al. "Re-architecting datacenter networks and stacks for low latency and high performance.” SIGCOMM, 2017. [3] Xin Jin et al. “NetCache: Balancing Key-Value Stores with Fast In-Network Caching.” To appear at SOSP 2017 [4] Kim, Changhoon, et al. "In-band network telemetry via programmable dataplanes.” SIGCOMM. 2015. [5] Dang, Huynh Tu, et al. "NetPaxos: Consensus at network speed.” SIGCOMM, 2015 What can you do with P4? 67
Membership • The concept of Packet processing w/ P4 • Key Components of P4 • P4 16 Language • Example of P4 pipeline • P4 Compiler • Environments • Try P4 • What can you do with P4? • Conclusion 68
• With P4, SDN programmers can design these goals ◦ Can keep the new ideas secret ▪ Don’t have to let switch chip vendor know ◦ Unique features in every network 69