Software-Defined Networking
I took a fun course on Software-Defined Networking (with P4), and later also wrote my Master thesis about SDN. Here is what I did and learned.
Master thesis: FPGA-based packet forwarding
The code
Thesis Defence Talk
Thesis
Help! I have an FPGA!
Course project: Load balancer
The project
Presentation
Report
P4 notes
Useful links:
- P4 spec: https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.html
- P4 includes: https://github.com/p4lang/p4c/blob/master/p4include/
How to…
-
work with tables: https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.html#sec-tables
- add headers:
- order is the expected one: outside to inside
- before setting stuff in a header, it must be .setValid()
- when cloning packets, standard_metadata aren’t copied => if I need that stuff later, I have to carry them around in metadata
- add an extern to the compiler and emulator: https://github.com/joelwanner/p4c/compare/master...joelwanner:extern, https://github.com/joelwanner/behavioral-model/compare/master...joelwanner:extern
Multicast
- multicast group is a thingy with an ID, created via control plane and used from data plane
- CLI for creating it:
mc_mgrp_create <group_id>
- using it from P4 code:
standard_metadata.mcast_grp = 47
- CLI for creating it:
- multicast node is for informing the switch that this port can be used for multicast. Nodes are associated with (/put into) groups. Usually there would be a 1:1 correspondence with a port, but it can be multiple ports too – that makes sense if these ports will always be used together.
- CLI for making a multicast node from a port:
mc_node_create <node_id> <port_number(s)>
- this returns a
node handle ID
, which is numbered from 0 in the order it was created ==> first node will be handle ID 0, second handle ID 1… - in order to make it even more confusing,
node_id
is actually called “replication ID” - multicast nodes are assigned into multicast groups by the control plane via CLI:
mc_node_associate <mcast_grp_id> <node_handle_id>
(many nodes to 1 group)
- this returns a
- CLI for making a multicast node from a port:
therefore:
- create group in control plane:
mc_mgrp_create 1
- create multicast node(s):
mc_node_create 0 1 2 3
- put nodes into groups:
mc_node_associate 1 0