Skip to content

Commit 76a9067

Browse files
sibanez12jnfoster
authored andcommitted
SIGCOMM 2019 Tutorial Edits (p4lang#272)
* Updated the utils/run_exercise.py to allow exercises to customize host configuration from the topology.json file. Now hosts and `ping` each other in the basic exercise. Other Linux utilities should work as well (e.g. iperf). ``` mininet> h1 ping h2 PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data. 64 bytes from 10.0.2.2: icmp_seq=1 ttl=62 time=3.11 ms 64 bytes from 10.0.2.2: icmp_seq=2 ttl=62 time=2.34 ms 64 bytes from 10.0.2.2: icmp_seq=3 ttl=62 time=2.15 ms ^C --- 10.0.2.2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 2.153/2.540/3.118/0.416 ms mininet> pingall *** Ping: testing ping reachability h1 -> h2 h3 h2 -> h1 h3 h3 -> h1 h2 *** Results: 0% dropped (6/6 received) ``` Only updated basic exercise, still need to update other exercises. Also, updated the root-bootstrap.sh because I was running into issues with latest version of vagrant. * Accidentially added the solution to the basic exercise in the previous commit. Undoing that here ... * Updated the topology.json file and table entries for the basic_tunnel exercise. * Updated P4Runtime exercise with new topology and table entries. * Fixed MAC addresses in P4Runtime exercise. It is working now. * Fixed MAC addresses in P4Runtime exercise starter code * Updated ECN exercise to use new topology.json file. Updated the table entries / MAC addresses as well. * Updated the topology.json file and table entries for the MRI exercise. * Updated source_routing exercise with new topology file and verified correct functionality. * Updated load_balance exercise with new topology. * Moved basic exercise triangle topology into a separate folder * Added new topology for the basic exercise: a single pod of a fat-tree. * Updated Makefiles and run_exercise.py to allow exercises to configure each switch with a different P4 program. This is mainly for the firewall exercise. * Updated Makefiles of project to work with new utils/Makefile * Updated load_balance and p4runtime exercise Makefiles * Initial commit of the firewall exercise, which is a simple stateful firewall that uses a bloom filter. Need to update README files * Initial commit of the path_monitor exercise. It is working but still need to update the README and figure out what we want the tutorial attendees to implement. * Updated README file in firewall exercise. Also removed the bits from the starter code that we want the tutorial attendees to implement * Renamed path_monitor exercise to link_monitor * Updated the README in the link_monitor exercise and removed the bits from the starter code that we want the tutorial attendees to implement. * Updated README for the firewall exercise * Adding pod-topo.png image to basic exercise * Added firewall-topo.png image to firewall exercise * Added link-monitor-topo.png to link_monitor exercise * Updated README files to point to topology images * Updated top-level README to point to new exercises. * Fixed link for VM dependencies script in README * Updated bmv2/pi/p4c commits * Updated README files for exercises to fix some typos and added a note about the V1Model architecture. * Added a note about food for thought in the link_monitor README * Updated the firewall.p4 program to use two register arrays rather than a single one. This is to make the design more portable to high line rate devices which can only support a single access to each register array. * Minor fix to firewall exercise to get rid of compiler warning. * Updated comment in firewall exercise. * Minor (typo) fixes in the firewall ReadMe * More info in firewall exercise ReadMe step 2 * Updated firewall.p4 to reuse direction variable * More testing steps, small fixes in firewall exercise Readme * Added food for thought to firewall Readme * Cosmetic fixes to firewall ReadMe * Made a few updates to the basic exercise README and added more details to the link_monitor exercise README. Also added a command to install grip when provisioning the VM. This could be useful for rendering the markdown README files offline. * Updated top level README so it can be merged into the master branch. * Moved cmd to install grip from root-bootstrap to user-bootstrap
1 parent b5c8270 commit 76a9067

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3015
-246
lines changed

README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ you get started with P4 programming, organized into several modules:
2121
* [Calculator](./exercises/other/calc)
2222
* [Load Balancing](./exercises/load_balance)
2323

24+
5. Stateful Packet Processing
25+
* [Firewall](./exercises/firewall)
26+
* [Link Monitoring](./exercises/link_monitor)
27+
2428
## Presentation
2529

2630
The slides are available [online](http://bit.ly/p4d2-2018-spring) and
@@ -31,9 +35,10 @@ which contains various examples that you can refer to.
3135

3236
## Obtaining required software
3337

34-
If you are starting this tutorial at the Spring 2018 P4 Developer Day,
38+
If you are starting this tutorial at one of the proctored tutorial events,
3539
then we've already provided you with a virtual machine that has all of
36-
the required software installed.
40+
the required software installed. Ask an instructor for a USB stick with
41+
the VM image.
3742

3843
Otherwise, to complete the exercises, you will need to either build a
3944
virtual machine or install several dependencies.
@@ -47,11 +52,11 @@ To build the virtual machine:
4752
- When the machine reboots, you should have a graphical desktop machine with the required
4853
software pre-installed.
4954

50-
*Note: Before running the `vagrant up` command, make sure you have enabled virtualization in your environment; otherwise you may get a "VT-x is disabled in the BIOS for both all CPU modes" error. Check [this](https://stackoverflow.com/questions/33304393/vt-x-is-disabled-in-the-bios-for-both-all-cpu-modes-verr-vmx-msr-all-vmx-disabl) for enabling it in virtualbox and/or BIOS for different system configurations.
55+
*Note*: Before running the `vagrant up` command, make sure you have enabled virtualization in your environment; otherwise you may get a "VT-x is disabled in the BIOS for both all CPU modes" error. Check [this](https://stackoverflow.com/questions/33304393/vt-x-is-disabled-in-the-bios-for-both-all-cpu-modes-verr-vmx-msr-all-vmx-disabl) for enabling it in virtualbox and/or BIOS for different system configurations.
5156

52-
You will need the script to execute to completion before you can see the `p4` login on your virtual machine's GUI. In some cases, the `vagrant up` command brings up only the default `vagrant` login with the password `vagrant`. Dependencies may or may not have been installed for you to proceed with running P4 programs. Please refer the existing issues to help fix your problem or create a new one if your specific problem isn't addressed there.*
57+
You will need the script to execute to completion before you can see the `p4` login on your virtual machine's GUI. In some cases, the `vagrant up` command brings up only the default `vagrant` login with the password `vagrant`. Dependencies may or may not have been installed for you to proceed with running P4 programs. Please refer the [existing issues](https://github.com/p4lang/tutorials/issues) to help fix your problem or create a new one if your specific problem isn't addressed there.
5358

54-
To install dependencies by hand, please reference the [vm](../vm) installation scripts.
59+
To install dependencies by hand, please reference the [vm](./vm) installation scripts.
5560
They contain the dependencies, versions, and installation procedure.
5661
You should be able to run them directly on an Ubuntu 16.04 machine:
5762
- `sudo ./root-bootstrap.sh`

exercises/basic/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
BMV2_SWITCH_EXE = simple_switch_grpc
2-
NO_P4 = true
3-
P4C_ARGS = --p4runtime-files $(basename $@).p4.p4info.txt
2+
TOPO = pod-topo/topology.json
43

54
include ../../utils/Makefile

exercises/basic/README.md

+31-33
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ MAC address and output port for the next hop. We have already defined
1717
the control plane rules, so you only need to implement the data plane
1818
logic of your P4 program.
1919

20+
We will use the following topology for this exercise. It is a single
21+
pod of a fat-tree topology and henceforth referred to as pod-topo:
22+
![pod-topo](./pod-topo/pod-topo.png)
23+
24+
Our P4 program will be written for the V1Model architecture implemented
25+
on P4.org's bmv2 software switch. The architecture file for the V1Model
26+
can be found at: /usr/local/share/p4c/p4include/v1model.p4. This file
27+
desribes the interfaces of the P4 programmable elements in the architecture,
28+
the supported externs, as well as the architecture's standard metadata
29+
fields. We encourage you to take a look at it.
30+
2031
> **Spoiler alert:** There is a reference solution in the `solution`
2132
> sub-directory. Feel free to compare your implementation to the
2233
> reference.
@@ -36,27 +47,18 @@ up a switch in Mininet to test its behavior.
3647
```
3748
This will:
3849
* compile `basic.p4`, and
39-
* start a Mininet instance with three switches (`s1`, `s2`, `s3`)
40-
configured in a triangle, each connected to one host (`h1`, `h2`,
41-
and `h3`).
42-
* The hosts are assigned IPs of `10.0.1.1`, `10.0.2.2`, and `10.0.3.3`.
50+
* start the pod-topo in Mininet and configure all switches with
51+
the appropriate P4 program + table entries, and
52+
* configure all hosts with the commands listed in
53+
[pod-topo/topology.json](./pod-topo/topology.json)
4354

44-
2. You should now see a Mininet command prompt. Open two terminals
45-
for `h1` and `h2`, respectively:
46-
```bash
47-
mininet> xterm h1 h2
48-
```
49-
3. Each host includes a small Python-based messaging client and
50-
server. In `h2`'s xterm, start the server:
55+
2. You should now see a Mininet command prompt. Try to ping between
56+
hosts in the topology:
5157
```bash
52-
./receive.py
58+
mininet> h1 ping h2
59+
mininet> pingall
5360
```
54-
4. In `h1`'s xterm, send a message to `h2`:
55-
```bash
56-
./send.py 10.0.2.2 "P4 is cool"
57-
```
58-
The message will not be received.
59-
5. Type `exit` to leave each xterm and the Mininet command line.
61+
3. Type `exit` to leave each xterm and the Mininet command line.
6062
Then, to stop mininet:
6163
```bash
6264
make stop
@@ -66,7 +68,7 @@ server. In `h2`'s xterm, start the server:
6668
make clean
6769
```
6870

69-
The message was not received because each switch is programmed
71+
The ping failed because each switch is programmed
7072
according to `basic.p4`, which drops all packets on arrival.
7173
Your job is to extend this file so it forwards packets.
7274

@@ -77,7 +79,7 @@ within each table are inserted by the control plane. When a rule
7779
matches a packet, its action is invoked with parameters supplied by
7880
the control plane as part of the rule.
7981

80-
In this exercise, we have already implemented the the control plane
82+
In this exercise, we have already implemented the control plane
8183
logic for you. As part of bringing up the Mininet instance, the
8284
`make run` command will install packet-processing rules in the tables of
8385
each switch. These are defined in the `sX-runtime.json` files, where
@@ -86,7 +88,7 @@ each switch. These are defined in the `sX-runtime.json` files, where
8688
**Important:** We use P4Runtime to install the control plane rules. The
8789
content of files `sX-runtime.json` refer to specific names of tables, keys, and
8890
actions, as defined in the P4Info file produced by the compiler (look for the
89-
file `build/basic.p4info` after executing `make run`). Any changes in the P4
91+
file `build/basic.p4.p4info.txt` after executing `make run`). Any changes in the P4
9092
program that add or rename tables, keys, or actions will need to be reflected in
9193
these `sX-runtime.json` files.
9294

@@ -120,20 +122,22 @@ A complete `basic.p4` will contain the following components:
120122
121123
## Step 3: Run your solution
122124

123-
Follow the instructions from Step 1. This time, your message from
124-
`h1` should be delivered to `h2`.
125+
Follow the instructions from Step 1. This time, you should be able to
126+
sucessfully ping between any two hosts in the topology.
125127

126128
### Food for thought
127129

128-
The "test suite" for your solution---sending a message from `h1` to
129-
`h2`---is not very robust. What else should you test to be confident
130-
of your implementation?
130+
The "test suite" for your solution---sending pings between hosts in the
131+
topology---is not very robust. What else should you test to be confident
132+
that you implementation is correct?
131133

132134
> Although the Python `scapy` library is outside the scope of this tutorial,
133135
> it can be used to generate packets for testing. The `send.py` file shows how
134136
> to use it.
135137
136138
Other questions to consider:
139+
- How would you enhance your program to respond to ARP requests?
140+
- How would you enhance your program to support traceroute?
137141
- How would you enhance your program to support next hops?
138142
- Is this program enough to replace a router? What's missing?
139143

@@ -152,7 +156,7 @@ messages to fix your `basic.p4` implementation.
152156

153157
3. `basic.p4` might compile, and the control plane rules might be
154158
installed, but the switch might not process packets in the desired
155-
way. The `/tmp/p4s.<switch-name>.log` files contain detailed logs
159+
way. The `logs/sX.log` files contain detailed logs
156160
that describing how each switch processes each packet. The output is
157161
detailed and can help pinpoint logic errors in your implementation.
158162

@@ -166,9 +170,3 @@ these instances:
166170
make stop
167171
```
168172

169-
## Next Steps
170-
171-
Congratulations, your implementation works! In the next exercise we
172-
will build on top of this and add support for a basic tunneling
173-
protocol: [basic_tunnel](../basic_tunnel)!
174-

exercises/basic/pod-topo/pod-topo.png

130 KB
Loading
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"target": "bmv2",
3+
"p4info": "build/basic.p4.p4info.txt",
4+
"bmv2_json": "build/basic.json",
5+
"table_entries": [
6+
{
7+
"table": "MyIngress.ipv4_lpm",
8+
"default_action": true,
9+
"action_name": "MyIngress.drop",
10+
"action_params": { }
11+
},
12+
{
13+
"table": "MyIngress.ipv4_lpm",
14+
"match": {
15+
"hdr.ipv4.dstAddr": ["10.0.1.1", 32]
16+
},
17+
"action_name": "MyIngress.ipv4_forward",
18+
"action_params": {
19+
"dstAddr": "08:00:00:00:01:11",
20+
"port": 1
21+
}
22+
},
23+
{
24+
"table": "MyIngress.ipv4_lpm",
25+
"match": {
26+
"hdr.ipv4.dstAddr": ["10.0.2.2", 32]
27+
},
28+
"action_name": "MyIngress.ipv4_forward",
29+
"action_params": {
30+
"dstAddr": "08:00:00:00:02:22",
31+
"port": 2
32+
}
33+
},
34+
{
35+
"table": "MyIngress.ipv4_lpm",
36+
"match": {
37+
"hdr.ipv4.dstAddr": ["10.0.3.3", 32]
38+
},
39+
"action_name": "MyIngress.ipv4_forward",
40+
"action_params": {
41+
"dstAddr": "08:00:00:00:03:00",
42+
"port": 3
43+
}
44+
},
45+
{
46+
"table": "MyIngress.ipv4_lpm",
47+
"match": {
48+
"hdr.ipv4.dstAddr": ["10.0.4.4", 32]
49+
},
50+
"action_name": "MyIngress.ipv4_forward",
51+
"action_params": {
52+
"dstAddr": "08:00:00:00:04:00",
53+
"port": 4
54+
}
55+
}
56+
]
57+
}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"target": "bmv2",
3+
"p4info": "build/basic.p4.p4info.txt",
4+
"bmv2_json": "build/basic.json",
5+
"table_entries": [
6+
{
7+
"table": "MyIngress.ipv4_lpm",
8+
"default_action": true,
9+
"action_name": "MyIngress.drop",
10+
"action_params": { }
11+
},
12+
{
13+
"table": "MyIngress.ipv4_lpm",
14+
"match": {
15+
"hdr.ipv4.dstAddr": ["10.0.1.1", 32]
16+
},
17+
"action_name": "MyIngress.ipv4_forward",
18+
"action_params": {
19+
"dstAddr": "08:00:00:00:03:00",
20+
"port": 4
21+
}
22+
},
23+
{
24+
"table": "MyIngress.ipv4_lpm",
25+
"match": {
26+
"hdr.ipv4.dstAddr": ["10.0.2.2", 32]
27+
},
28+
"action_name": "MyIngress.ipv4_forward",
29+
"action_params": {
30+
"dstAddr": "08:00:00:00:04:00",
31+
"port": 3
32+
}
33+
},
34+
{
35+
"table": "MyIngress.ipv4_lpm",
36+
"match": {
37+
"hdr.ipv4.dstAddr": ["10.0.3.3", 32]
38+
},
39+
"action_name": "MyIngress.ipv4_forward",
40+
"action_params": {
41+
"dstAddr": "08:00:00:00:03:33",
42+
"port": 1
43+
}
44+
},
45+
{
46+
"table": "MyIngress.ipv4_lpm",
47+
"match": {
48+
"hdr.ipv4.dstAddr": ["10.0.4.4", 32]
49+
},
50+
"action_name": "MyIngress.ipv4_forward",
51+
"action_params": {
52+
"dstAddr": "08:00:00:00:04:44",
53+
"port": 2
54+
}
55+
}
56+
]
57+
}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"target": "bmv2",
3+
"p4info": "build/basic.p4.p4info.txt",
4+
"bmv2_json": "build/basic.json",
5+
"table_entries": [
6+
{
7+
"table": "MyIngress.ipv4_lpm",
8+
"default_action": true,
9+
"action_name": "MyIngress.drop",
10+
"action_params": { }
11+
},
12+
{
13+
"table": "MyIngress.ipv4_lpm",
14+
"match": {
15+
"hdr.ipv4.dstAddr": ["10.0.1.1", 32]
16+
},
17+
"action_name": "MyIngress.ipv4_forward",
18+
"action_params": {
19+
"dstAddr": "08:00:00:00:01:00",
20+
"port": 1
21+
}
22+
},
23+
{
24+
"table": "MyIngress.ipv4_lpm",
25+
"match": {
26+
"hdr.ipv4.dstAddr": ["10.0.2.2", 32]
27+
},
28+
"action_name": "MyIngress.ipv4_forward",
29+
"action_params": {
30+
"dstAddr": "08:00:00:00:01:00",
31+
"port": 1
32+
}
33+
},
34+
{
35+
"table": "MyIngress.ipv4_lpm",
36+
"match": {
37+
"hdr.ipv4.dstAddr": ["10.0.3.3", 32]
38+
},
39+
"action_name": "MyIngress.ipv4_forward",
40+
"action_params": {
41+
"dstAddr": "08:00:00:00:02:00",
42+
"port": 2
43+
}
44+
},
45+
{
46+
"table": "MyIngress.ipv4_lpm",
47+
"match": {
48+
"hdr.ipv4.dstAddr": ["10.0.4.4", 32]
49+
},
50+
"action_name": "MyIngress.ipv4_forward",
51+
"action_params": {
52+
"dstAddr": "08:00:00:00:02:00",
53+
"port": 2
54+
}
55+
}
56+
]
57+
}

0 commit comments

Comments
 (0)