Homework 1: P5: Practicing P4

This assignment is due at 10:59 PM on Part 1: Friday, September 13th (09/13/19). Part 2: Monday, September 30th (09/30/19).

NOTE: All of the P4 programs for this homework should be written in P4_16!

The purpose of this assignment is to give you hands on experience with P4. This assignment has two sections:

  1. Writing new test cases for existing P4 examples.
  2. Writing a new P4 program for Axon routing.
  3. Writing a new P4 program for Ethernet-in-Ethernet routing.

NOTE: Only 1 of Section 2 and 3 is required.

This section concludes with details about the assignment submission and grading

P4 Examples Test Cases

This part of the homework is based on the P4 tutorial at SIGCOMM 2018. As part of this assignment, you are encouraged to try to write the exercise programs blind if you want to. However, because the example programs have online solutions, they are not part of the assignment.

Instead, in this assignment, you are required to to create new control programs and test cases for two different example P4 programs from this repository. Importantly, you should at minimum add a new switch to the topology and test connectivity with a flow that traverses the new switch.

Specifically, to create additional (and more complex) test cases, you will need to create new files of the following types: s-*.json and topology.json send.py and receive.py, and output.txt. Together, these files will specify a new virtual topology and forwarding tables for all of the switches in the topology.

Setup

Follow the instructions from the P4 tutorial at SIGCOMM 2018 to set up your development environment. Also, you are strongly encouraged to use source control like git to manage the files needed for this assignment submission.

If you are unable to find a machine to run VirtualBox on, let the instructor know!

Axon Routing in P4:

In this part of the assignment, you will implement Axon routing in P4.

Key protocol aspects

The packet header is described in Section 3.1 and Figure 2 in the above paper. In more detail:

  1. All Axon packets should start with a single byte cookie (type) followed by a two byte Axon header length, two bytes of forward hop count, and two bytes of reverse hop count.

  2. The hop-by-hop forward source route is next in the packet header, with each hop being one byte. After that is the hop-by-hop reverse source route. When an Axon proccess a packet, it pops off the forward hop, pushes the input port as a reverse hop, and updates the counts appropriately.

  3. All ports in every switch should be configured to be an Axon port. Importantly, this means that normal Linux programs run in mininet like ping and iperf3 will not work. Instead, you will create multiple send-test<N>.py and receive-test<N>.py for each of your N tests.

  4. Invalid packets should be detected and dropped.

Test cases

To demonstrate both the correctness of your implementation and your knowledge of the Axon routing protocol, you need to create two different test cases for your Axon P4 program (axon.p4).

  1. Bi-directional Multi-hop routing: In this configuration, you should have two Ethernet ports attached to different switches that are separated by multiple hops of switches, i.e., a multi-hop topology. You should program the forwarding tables of each switch as necessary to establish connectivity both between host A -> B and host B -> A. Since normal Linux programs will not work in mininet, you should create send-test<N>.py and receive-test<N>.py programs for every test case of your program.

  2. Invalid packets: In this test case, you will demonstrate that your implementation correctly handles invalid packets. Specifically, you should look at two different types of invalid packets:

    1. Ethernet packets that do not have a forwarding table entry.
    2. Ill-formed Axon packets with invalid lengths or counts.

    An important aspect of this part of the submission is in including the appropriate output.txt files and discuss in the writeup what the error case is and how the output demonstrates that the error was correctly handled.

Ethernet-in-Ethernet encapsulation in P4:

Ethernet-in-Ethernet encapsulation is not typically used in practice because most networks are L3 networks (IP). However, it is still possible to create an overlay network that uses Ethernet-in-Ethernet encapsulation in an L2 network.

Key protocol aspects

In this aspect of the homework, you will create an overlay network. In this overlay, each port on every switch is statically configured to be either an external port or an internal port. Standard Ethernet packets must be received and sent on external ports. However, internal ports instead send Ethernet-in-Ethernet encapsulated packets.

For a refresher on the Ethernet packet format, see Network Sorcery.

Briefly, non-encapsulated packets will be of the format:

DA (6 bytes) SA (6 bytes) EtherType (2 bytes)

In contrast, the format of encapsulated packets is as follows:

DA (6 bytes) SA (6 bytes) EtherType = 0xBAD1 (2 bytes) DA (6 bytes) SA (6 bytes) EtherType (2 bytes)

The following is more key protocol aspects for Ethernet-in-Ethernet encapsulation:

  1. The EtherType of all outer EtherTypes should be 0xBAD1 (for “Bad Idea”).

  2. All MAC addresses used for the outer Ethernet addresses should have the locally administered bit set (See wikipedia for more information).

  3. When a packet is received from an external port, it must be encapsulated. When a packet is sent out an external port, it must be decapsulated.

Test cases

To demonstrate both the correctness of your implementation and your knowledge of the Axon routing protocol, you need to create two different test cases for your Ethernet-in-Ethernet P4 program (eth-in-eth.p4).

  1. Bi-directional Multi-hop routing: In this configuration, you should have two Ethernet ports attached to different switches that are separated by multiple hops of switches, i.e., a multi-hop topology. You should program the forwarding tables of each switch as necessary to establish connectivity both between host A -> B and host B -> A. Crucially, you should use mininet to use standard Linux programs like ping and iperf3 to demonstrate the correctness of your program.

  2. Invalid packets: In this test case, you will demonstrate that your implementation correctly handles invalid packets. Specifically, you should look at two different types of invalid packets:

    1. Ethernet packets that do not have a forwarding table entry.
    2. Ill-formed packets with invalid outer Ether types.
    3. Standard Ethernet packets received on internal ports.

    An important aspect of this part of the submission is in including the appropriate output.txt files and discuss in the writeup what the error case is and how the output demonstrates that the error was correctly handled.

Submission and Grading

Submission format

Your submission should be three folders that is in the same format as the P4 example programs folders (See this example).

Every folder must at least include at least the following files:

  • WRITEUP.md
  • <source>.p4
  • s-*.json and topology.json
  • output.txt
  • send.py and receive.py
  • Makefile

The writeups should follow the format used in the P4 tutorial as close as possible. They should have the following sections:

  1. A protocol description that describes the P4 program.
  2. A description of the test cases that were created for this P4 program. This description should include discussion of the topology, forwarding table rules, and packets generated and received.
  3. Step-by-step running instructions. This should include all of the necessary commands that need to be run to generate the output text file.

Every program should also have an output.txt (or output-testX.txt) file that is exactly the output generated when the test program is run.

Submission points

There are a total of 100 possible points for this assignment, 50 for each half:

  • 30 points (2 * 15): New test cases for two different existing P4 examples.
  • 20 points (2 * 10): Two writeups (WRITEUP.md) describing the new topology, forwarding table rules, and packets used in the new test cases and example output (output.txt) that is generated when the program is run.
  • 35 points: A P4 program, test cases, and writeup (WRITEUP.md) for Axon routing in the bi-directional test case. The writeup should describe the new topology, forwarding table rules, and packets used in the new test cases and example output (output.txt) that is generated when the program is run.
  • 15 points: The test cases and writeup (WRITEUP.md) for Axon routing in the invalid packet test case.

Submission Website:

This homework assignment will be submitted via github classroom.

If you have any problems, please make a post on the course discussion website.

This assignment is due at 10:59 PM on Part 1: Friday, September 13th (09/13/19). Part 2: Monday, September 30th (09/30/19).