From 09dba5c63d7a72dffcfa407db881bca00ea1ac91 Mon Sep 17 00:00:00 2001 From: Robert Soule Date: Fri, 3 Nov 2017 12:20:44 -0700 Subject: [PATCH] Updates the examples to use the new build scripts (except Hula). (#74) * Added Makefile and topology.jsons for all examples. * use branch * Updated MRI exercise (#73) * Updated MRI exercise * Updated basic_tunnel.p4 for changes to p4 lang * updated other examples --- .../exercises/basic_tunnel/Makefile | 1 + .../exercises/basic_tunnel/basic_tunnel.p4 | 2 +- .../exercises/basic_tunnel/p4app.json | 32 ---------------- P4D2_2017_Fall/exercises/basic_tunnel/run.sh | 5 --- .../exercises/basic_tunnel/topology.json | 16 ++++++++ P4D2_2017_Fall/exercises/calc/Makefile | 1 + P4D2_2017_Fall/exercises/calc/README.md | 2 +- P4D2_2017_Fall/exercises/calc/p4app.json | 10 ----- P4D2_2017_Fall/exercises/calc/run.sh | 5 --- .../calc/{calc.config => s1-commands.txt} | 0 P4D2_2017_Fall/exercises/calc/topology.json | 12 ++++++ P4D2_2017_Fall/exercises/ecn/README.md | 2 +- .../exercises/load_balance/Makefile | 1 + .../exercises/load_balance/README.md | 12 +++--- .../exercises/load_balance/p4app.json | 32 ---------------- P4D2_2017_Fall/exercises/load_balance/run.sh | 4 -- .../exercises/load_balance/topology.json | 16 ++++++++ P4D2_2017_Fall/exercises/mri/Makefile | 1 + P4D2_2017_Fall/exercises/mri/README.md | 18 ++++----- P4D2_2017_Fall/exercises/mri/p4app.json | 37 ------------------- P4D2_2017_Fall/exercises/mri/run.sh | 5 --- P4D2_2017_Fall/exercises/mri/s1-commands.txt | 4 +- P4D2_2017_Fall/exercises/mri/s2-commands.txt | 4 +- P4D2_2017_Fall/exercises/mri/topology.json | 18 +++++++++ P4D2_2017_Fall/exercises/scrambler/Makefile | 1 + P4D2_2017_Fall/exercises/scrambler/README.md | 12 +++--- P4D2_2017_Fall/exercises/scrambler/p4app.json | 33 ----------------- P4D2_2017_Fall/exercises/scrambler/run.sh | 5 --- .../exercises/scrambler/topology.json | 16 ++++++++ .../exercises/source_routing/Makefile | 1 + .../exercises/source_routing/README.md | 8 ++-- .../exercises/source_routing/p4app.json | 30 --------------- .../exercises/source_routing/run.sh | 5 --- .../exercises/source_routing/s1-commands.txt | 0 .../exercises/source_routing/s2-commands.txt | 0 .../exercises/source_routing/s3-commands.txt | 0 .../exercises/source_routing/topology.json | 16 ++++++++ P4D2_2017_Fall/vm/user-bootstrap.sh | 1 + 38 files changed, 133 insertions(+), 235 deletions(-) create mode 100644 P4D2_2017_Fall/exercises/basic_tunnel/Makefile delete mode 100644 P4D2_2017_Fall/exercises/basic_tunnel/p4app.json delete mode 100755 P4D2_2017_Fall/exercises/basic_tunnel/run.sh create mode 100644 P4D2_2017_Fall/exercises/basic_tunnel/topology.json create mode 100644 P4D2_2017_Fall/exercises/calc/Makefile delete mode 100644 P4D2_2017_Fall/exercises/calc/p4app.json delete mode 100755 P4D2_2017_Fall/exercises/calc/run.sh rename P4D2_2017_Fall/exercises/calc/{calc.config => s1-commands.txt} (100%) create mode 100644 P4D2_2017_Fall/exercises/calc/topology.json create mode 100644 P4D2_2017_Fall/exercises/load_balance/Makefile delete mode 100644 P4D2_2017_Fall/exercises/load_balance/p4app.json delete mode 100755 P4D2_2017_Fall/exercises/load_balance/run.sh create mode 100644 P4D2_2017_Fall/exercises/load_balance/topology.json create mode 100644 P4D2_2017_Fall/exercises/mri/Makefile delete mode 100644 P4D2_2017_Fall/exercises/mri/p4app.json delete mode 100755 P4D2_2017_Fall/exercises/mri/run.sh create mode 100644 P4D2_2017_Fall/exercises/mri/topology.json create mode 100644 P4D2_2017_Fall/exercises/scrambler/Makefile delete mode 100644 P4D2_2017_Fall/exercises/scrambler/p4app.json delete mode 100755 P4D2_2017_Fall/exercises/scrambler/run.sh create mode 100644 P4D2_2017_Fall/exercises/scrambler/topology.json create mode 100644 P4D2_2017_Fall/exercises/source_routing/Makefile delete mode 100644 P4D2_2017_Fall/exercises/source_routing/p4app.json delete mode 100755 P4D2_2017_Fall/exercises/source_routing/run.sh create mode 100644 P4D2_2017_Fall/exercises/source_routing/s1-commands.txt create mode 100644 P4D2_2017_Fall/exercises/source_routing/s2-commands.txt create mode 100644 P4D2_2017_Fall/exercises/source_routing/s3-commands.txt create mode 100644 P4D2_2017_Fall/exercises/source_routing/topology.json diff --git a/P4D2_2017_Fall/exercises/basic_tunnel/Makefile b/P4D2_2017_Fall/exercises/basic_tunnel/Makefile new file mode 100644 index 0000000..f378756 --- /dev/null +++ b/P4D2_2017_Fall/exercises/basic_tunnel/Makefile @@ -0,0 +1 @@ +include ../../utils/Makefile diff --git a/P4D2_2017_Fall/exercises/basic_tunnel/basic_tunnel.p4 b/P4D2_2017_Fall/exercises/basic_tunnel/basic_tunnel.p4 index a7339da..9d371c3 100644 --- a/P4D2_2017_Fall/exercises/basic_tunnel/basic_tunnel.p4 +++ b/P4D2_2017_Fall/exercises/basic_tunnel/basic_tunnel.p4 @@ -90,7 +90,7 @@ parser MyParser(packet_in packet, ************ C H E C K S U M V E R I F I C A T I O N ************* *************************************************************************/ -control MyVerifyChecksum(in headers hdr, inout metadata meta) { +control MyVerifyChecksum(inout headers hdr, inout metadata meta) { apply { } } diff --git a/P4D2_2017_Fall/exercises/basic_tunnel/p4app.json b/P4D2_2017_Fall/exercises/basic_tunnel/p4app.json deleted file mode 100644 index 9080e0d..0000000 --- a/P4D2_2017_Fall/exercises/basic_tunnel/p4app.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "program": "basic_tunnel.p4", - "language": "p4-16", - "targets": { - "multiswitch": { - "auto-control-plane": true, - "cli": true, - "pcap_dump": true, - "bmv2_log": true, - "links": [["h1", "s1"], ["s1", "s2"], ["s1", "s3"], ["s3", "s2"], ["s2", "h2"], ["s3", "h3"]], - "hosts": { - "h1": { - }, - "h2": { - }, - "h3": { - } - }, - "switches": { - "s1": { - "entries": "s1-commands.txt" - }, - "s2": { - "entries": "s2-commands.txt" - }, - "s3": { - "entries": "s3-commands.txt" - } - } - } - } -} diff --git a/P4D2_2017_Fall/exercises/basic_tunnel/run.sh b/P4D2_2017_Fall/exercises/basic_tunnel/run.sh deleted file mode 100755 index d5c1947..0000000 --- a/P4D2_2017_Fall/exercises/basic_tunnel/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -P4APPRUNNER=../../utils/p4apprunner.py -mkdir -p build -tar -czf build/p4app.tgz * --exclude='build' -#cd build -sudo python $P4APPRUNNER p4app.tgz --build-dir ./build diff --git a/P4D2_2017_Fall/exercises/basic_tunnel/topology.json b/P4D2_2017_Fall/exercises/basic_tunnel/topology.json new file mode 100644 index 0000000..e33477c --- /dev/null +++ b/P4D2_2017_Fall/exercises/basic_tunnel/topology.json @@ -0,0 +1,16 @@ +{ + "hosts": [ + "h1", + "h2", + "h3" + ], + "switches": { + "s1": { "cli_input" : "s1-commands.txt" }, + "s2": { "cli_input" : "s2-commands.txt" }, + "s3": { "cli_input" : "s3-commands.txt" } + }, + "links": [ + ["h1", "s1"], ["s1", "s2"], ["s1", "s3"], + ["s3", "s2"], ["s2", "h2"], ["s3", "h3"] + ] +} diff --git a/P4D2_2017_Fall/exercises/calc/Makefile b/P4D2_2017_Fall/exercises/calc/Makefile new file mode 100644 index 0000000..f378756 --- /dev/null +++ b/P4D2_2017_Fall/exercises/calc/Makefile @@ -0,0 +1 @@ +include ../../utils/Makefile diff --git a/P4D2_2017_Fall/exercises/calc/README.md b/P4D2_2017_Fall/exercises/calc/README.md index 1e63bbc..c1b826d 100644 --- a/P4D2_2017_Fall/exercises/calc/README.md +++ b/P4D2_2017_Fall/exercises/calc/README.md @@ -19,7 +19,7 @@ switch in Mininet to test its behavior. 1. In your shell, run: ```bash - ./run.sh + make ``` This will: * compile `calc.p4`, and diff --git a/P4D2_2017_Fall/exercises/calc/p4app.json b/P4D2_2017_Fall/exercises/calc/p4app.json deleted file mode 100644 index 5c92c80..0000000 --- a/P4D2_2017_Fall/exercises/calc/p4app.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "program": "calc.p4", - "language": "p4-16", - "targets": { - "mininet": { - "num-hosts": 2, - "switch-config": "calc.config" - } - } -} diff --git a/P4D2_2017_Fall/exercises/calc/run.sh b/P4D2_2017_Fall/exercises/calc/run.sh deleted file mode 100755 index d5c1947..0000000 --- a/P4D2_2017_Fall/exercises/calc/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -P4APPRUNNER=../../utils/p4apprunner.py -mkdir -p build -tar -czf build/p4app.tgz * --exclude='build' -#cd build -sudo python $P4APPRUNNER p4app.tgz --build-dir ./build diff --git a/P4D2_2017_Fall/exercises/calc/calc.config b/P4D2_2017_Fall/exercises/calc/s1-commands.txt similarity index 100% rename from P4D2_2017_Fall/exercises/calc/calc.config rename to P4D2_2017_Fall/exercises/calc/s1-commands.txt diff --git a/P4D2_2017_Fall/exercises/calc/topology.json b/P4D2_2017_Fall/exercises/calc/topology.json new file mode 100644 index 0000000..29d7cdf --- /dev/null +++ b/P4D2_2017_Fall/exercises/calc/topology.json @@ -0,0 +1,12 @@ +{ + "hosts": [ + "h1", + "h2" + ], + "switches": { + "s1": { "cli_input" : "s1-commands.txt" } + }, + "links": [ + ["h1", "s1"], ["h2", "s1"] + ] +} diff --git a/P4D2_2017_Fall/exercises/ecn/README.md b/P4D2_2017_Fall/exercises/ecn/README.md index 115d84a..a12e43f 100644 --- a/P4D2_2017_Fall/exercises/ecn/README.md +++ b/P4D2_2017_Fall/exercises/ecn/README.md @@ -176,7 +176,7 @@ There are several ways that problems might manifest: 4. `ecn.p4` compiles and all rules are installed. Packets go through and the logs show that the queue length was not high enough to set the ECN bit. Then either lower the threshold in the p4 code or - reduce the link bandwidth in `p4app.json` + reduce the link bandwidth in `topology.json` #### Cleaning up Mininet diff --git a/P4D2_2017_Fall/exercises/load_balance/Makefile b/P4D2_2017_Fall/exercises/load_balance/Makefile new file mode 100644 index 0000000..f378756 --- /dev/null +++ b/P4D2_2017_Fall/exercises/load_balance/Makefile @@ -0,0 +1 @@ +include ../../utils/Makefile diff --git a/P4D2_2017_Fall/exercises/load_balance/README.md b/P4D2_2017_Fall/exercises/load_balance/README.md index 1ff40fb..23279f0 100644 --- a/P4D2_2017_Fall/exercises/load_balance/README.md +++ b/P4D2_2017_Fall/exercises/load_balance/README.md @@ -24,7 +24,7 @@ up a switch in Mininet to test its behavior. 1. In your shell, run: ```bash - ./run.sh + make ``` This will: * compile `load_balance.p4`, and @@ -64,7 +64,7 @@ with parameters supplied by the control plane as part of the rule. In this exercise, the control plane logic has already been implemented. As part of bringing up the Mininet instance, the -`run.sh` script will install packet-processing rules in the tables of +`make` script will install packet-processing rules in the tables of each switch. These are defined in the `s1-commands.txt` file. **Important:** A P4 program also defines the interface between the @@ -112,12 +112,12 @@ messages, some should be received by each server. There are several ways that problems might manifest: -1. `load_balance.p4` fails to compile. In this case, `run.sh` will +1. `load_balance.p4` fails to compile. In this case, `make` will report the error emitted from the compiler and stop. 2. `load_balance.p4` compiles but does not support the control plane -rules in the `sX-commands.txt` files that `run.sh` tries to install -using the BMv2 CLI. In this case, `run.sh` will report these errors +rules in the `sX-commands.txt` files that `make` tries to install +using the BMv2 CLI. In this case, `make` will report these errors to `stderr`. Use these error messages to fix your `load_balance.p4` implementation. @@ -129,7 +129,7 @@ detailed and can help pinpoint logic errors in your implementation. #### Cleaning up Mininet -In the latter two cases above, `run.sh` may leave a Mininet instance +In the latter two cases above, `make` may leave a Mininet instance running in the background. Use the following command to clean up these instances: diff --git a/P4D2_2017_Fall/exercises/load_balance/p4app.json b/P4D2_2017_Fall/exercises/load_balance/p4app.json deleted file mode 100644 index 4754fda..0000000 --- a/P4D2_2017_Fall/exercises/load_balance/p4app.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "program": "load_balance.p4", - "language": "p4-16", - "targets": { - "multiswitch": { - "auto-control-plane": true, - "cli": true, - "pcap_dump": true, - "bmv2_log": true, - "links": [["h1", "s1"], ["s1", "s2"], ["s1", "s3"], ["s3", "s2"], ["s2", "h2"], ["s3", "h3"]], - "hosts": { - "h1": { - }, - "h2": { - }, - "h3": { - } - }, - "switches": { - "s1": { - "entries": "s1-commands.txt" - }, - "s2": { - "entries": "s2-commands.txt" - }, - "s3": { - "entries": "s3-commands.txt" - } - } - } - } -} diff --git a/P4D2_2017_Fall/exercises/load_balance/run.sh b/P4D2_2017_Fall/exercises/load_balance/run.sh deleted file mode 100755 index 15f7868..0000000 --- a/P4D2_2017_Fall/exercises/load_balance/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -P4APPRUNNER=../../utils/p4apprunner.py -mkdir -p build -tar -czf build/p4app.tgz * --exclude='build' -sudo python $P4APPRUNNER p4app.tgz --build-dir ./build diff --git a/P4D2_2017_Fall/exercises/load_balance/topology.json b/P4D2_2017_Fall/exercises/load_balance/topology.json new file mode 100644 index 0000000..e33477c --- /dev/null +++ b/P4D2_2017_Fall/exercises/load_balance/topology.json @@ -0,0 +1,16 @@ +{ + "hosts": [ + "h1", + "h2", + "h3" + ], + "switches": { + "s1": { "cli_input" : "s1-commands.txt" }, + "s2": { "cli_input" : "s2-commands.txt" }, + "s3": { "cli_input" : "s3-commands.txt" } + }, + "links": [ + ["h1", "s1"], ["s1", "s2"], ["s1", "s3"], + ["s3", "s2"], ["s2", "h2"], ["s3", "h3"] + ] +} diff --git a/P4D2_2017_Fall/exercises/mri/Makefile b/P4D2_2017_Fall/exercises/mri/Makefile new file mode 100644 index 0000000..f378756 --- /dev/null +++ b/P4D2_2017_Fall/exercises/mri/Makefile @@ -0,0 +1 @@ +include ../../utils/Makefile diff --git a/P4D2_2017_Fall/exercises/mri/README.md b/P4D2_2017_Fall/exercises/mri/README.md index 30d20b1..a3a70d5 100644 --- a/P4D2_2017_Fall/exercises/mri/README.md +++ b/P4D2_2017_Fall/exercises/mri/README.md @@ -31,7 +31,7 @@ switch in Mininet to test its behavior. 1. In your shell, run: ```bash - ./run.sh + make ``` This will: * compile `mri.p4`, and @@ -46,7 +46,7 @@ switch in Mininet to test its behavior. 2. We want to send a low rate traffic from `h1` to `h2` and a high rate iperf traffic from `h11` to `h22`. The link between `s1` and `s2` is common between the flows and is a bottleneck because we - reduced its bandwidth to 512kbps in p4app.json. Therefore, if we + reduced its bandwidth to 512kbps in topology.json. Therefore, if we capture packets at `h2`, we should see high queue size for that link. @@ -90,7 +90,7 @@ with parameters supplied by the control plane as part of the rule. In this exercise, the control plane logic has already been implemented. As part of bringing up the Mininet instance, the -`run.sh` script will install packet-processing rules in the tables of +`make` script will install packet-processing rules in the tables of each switch. These are defined in the `sX-commands.txt` files, where `X` corresponds to the switch number. @@ -204,11 +204,11 @@ got a packet There are several ways that problems might manifest: -1. `mri.p4` fails to compile. In this case, `run.sh` will report the +1. `mri.p4` fails to compile. In this case, `make` will report the error emitted from the compiler and stop. 2. `mri.p4` compiles but does not support the control plane rules in -the `sX-commands.txt` files that `run.sh` tries to install using the BMv2 CLI. -In this case, `run.sh` will report these errors to `stderr`. Use these error +the `sX-commands.txt` files that `make` tries to install using the BMv2 CLI. +In this case, `make` will report these errors to `stderr`. Use these error messages to fix your `mri.p4` implementation. 3. `mri.p4` compiles, and the control plane rules are installed, but the switch does not process packets in the desired way. The @@ -220,16 +220,16 @@ packets on each interface. Use `tcpdump -r -xxx` to print the hexdump of the packets. 4. `mri.p4` compiles and all rules are installed. Packets go through and the logs show that the queue length is always 0. Then either -reduce the link bandwidth in `p4app.json`. +reduce the link bandwidth in `topology.json`. #### Cleaning up Mininet -In the latter two cases above, `run.sh` may leave a Mininet instance +In the latter two cases above, `make` may leave a Mininet instance running in the background. Use the following command to clean up these instances: ```bash -mn -c +make stop ``` ## Next Steps diff --git a/P4D2_2017_Fall/exercises/mri/p4app.json b/P4D2_2017_Fall/exercises/mri/p4app.json deleted file mode 100644 index 2931e53..0000000 --- a/P4D2_2017_Fall/exercises/mri/p4app.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "program": "mri.p4", - "language": "p4-16", - "targets": { - "multiswitch": { - "auto-control-plane": true, - "cli": true, - "pcap_dump": true, - "bmv2_log": true, - "links": [["h1", "s1"], ["h11", "s1"], ["s1", "s2", "0", 0.5], ["s1", "s3"], ["s3", "s2"], ["s2", "h2"], ["s2", "h22"], ["s3", "h3"]], - "hosts": { - "h1": { - }, - "h2": { - }, - "h3": { - }, - "h11": { - }, - "h22": { - } - - }, - "switches": { - "s1": { - "entries": "s1-commands.txt" - }, - "s2": { - "entries": "s2-commands.txt" - }, - "s3": { - "entries": "s3-commands.txt" - } - } - } - } -} diff --git a/P4D2_2017_Fall/exercises/mri/run.sh b/P4D2_2017_Fall/exercises/mri/run.sh deleted file mode 100755 index d5c1947..0000000 --- a/P4D2_2017_Fall/exercises/mri/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -P4APPRUNNER=../../utils/p4apprunner.py -mkdir -p build -tar -czf build/p4app.tgz * --exclude='build' -#cd build -sudo python $P4APPRUNNER p4app.tgz --build-dir ./build diff --git a/P4D2_2017_Fall/exercises/mri/s1-commands.txt b/P4D2_2017_Fall/exercises/mri/s1-commands.txt index d476195..5f15633 100644 --- a/P4D2_2017_Fall/exercises/mri/s1-commands.txt +++ b/P4D2_2017_Fall/exercises/mri/s1-commands.txt @@ -1,6 +1,6 @@ table_set_default ipv4_lpm drop table_set_default swtrace add_swtrace 1 -table_add ipv4_lpm ipv4_forward 10.0.1.1/32 => 00:00:00:00:01:01 1 -table_add ipv4_lpm ipv4_forward 10.0.1.11/32 => 00:00:00:00:01:0b 2 +table_add ipv4_lpm ipv4_forward 10.0.1.1/32 => 00:00:00:00:01:01 2 +table_add ipv4_lpm ipv4_forward 10.0.1.11/32 => 00:00:00:00:01:0b 1 table_add ipv4_lpm ipv4_forward 10.0.2.0/24 => 00:00:00:02:03:00 3 table_add ipv4_lpm ipv4_forward 10.0.3.0/24 => 00:00:00:03:02:00 4 diff --git a/P4D2_2017_Fall/exercises/mri/s2-commands.txt b/P4D2_2017_Fall/exercises/mri/s2-commands.txt index 915c888..8b9bd15 100644 --- a/P4D2_2017_Fall/exercises/mri/s2-commands.txt +++ b/P4D2_2017_Fall/exercises/mri/s2-commands.txt @@ -1,6 +1,6 @@ table_set_default ipv4_lpm drop table_set_default swtrace add_swtrace 2 -table_add ipv4_lpm ipv4_forward 10.0.2.2/32 => 00:00:00:00:02:02 1 -table_add ipv4_lpm ipv4_forward 10.0.2.22/32 => 00:00:00:00:02:16 2 +table_add ipv4_lpm ipv4_forward 10.0.2.2/32 => 00:00:00:00:02:02 2 +table_add ipv4_lpm ipv4_forward 10.0.2.22/32 => 00:00:00:00:02:16 1 table_add ipv4_lpm ipv4_forward 10.0.1.0/24 => 00:00:00:01:03:00 3 table_add ipv4_lpm ipv4_forward 10.0.3.0/24 => 00:00:00:03:03:00 4 diff --git a/P4D2_2017_Fall/exercises/mri/topology.json b/P4D2_2017_Fall/exercises/mri/topology.json new file mode 100644 index 0000000..2640a2b --- /dev/null +++ b/P4D2_2017_Fall/exercises/mri/topology.json @@ -0,0 +1,18 @@ +{ + "hosts": [ + "h1", + "h2", + "h3", + "h11", + "h22" + ], + "switches": { + "s1": { "cli_input" : "s1-commands.txt" }, + "s2": { "cli_input" : "s2-commands.txt" }, + "s3": { "cli_input" : "s3-commands.txt" } + }, + "links": [ + ["h1", "s1"], ["h11", "s1"], ["s1", "s2", "0", 0.5], ["s1", "s3"], + ["s3", "s2"], ["s2", "h2"], ["s2", "h22"], ["s3", "h3"] + ] +} diff --git a/P4D2_2017_Fall/exercises/scrambler/Makefile b/P4D2_2017_Fall/exercises/scrambler/Makefile new file mode 100644 index 0000000..f378756 --- /dev/null +++ b/P4D2_2017_Fall/exercises/scrambler/Makefile @@ -0,0 +1 @@ +include ../../utils/Makefile diff --git a/P4D2_2017_Fall/exercises/scrambler/README.md b/P4D2_2017_Fall/exercises/scrambler/README.md index e5ae870..63c3562 100644 --- a/P4D2_2017_Fall/exercises/scrambler/README.md +++ b/P4D2_2017_Fall/exercises/scrambler/README.md @@ -23,7 +23,7 @@ up a switch in Mininet to test its behavior. 1. In your shell, run: ```bash - ./run.sh + make ``` This will: * compile `scrambler.p4`, and @@ -61,7 +61,7 @@ with parameters supplied by the control plane as part of the rule. In this exercise, the control plane logic has already been implemented. As part of bringing up the Mininet instance, the -`run.sh` script will install packet-processing rules in the tables of +`make` script will install packet-processing rules in the tables of each switch. These are defined in the `sX-commands.txt` files, where `X` corresponds to the switch number. @@ -92,12 +92,12 @@ Follow the instructions from Step 1. This time, your message from There are several issues that might arise when developing your solution: -1. `scrambler.p4` fails to compile. In this case, `run.sh` will +1. `scrambler.p4` fails to compile. In this case, `make` will report the error emitted from the compiler and stop. 2. `scrambler.p4` compiles but does not support the control plane -rules in the `sX-commands.txt` files that `run.sh` tries to install -using the BMv2 CLI. In this case, `run.sh` will report these errors +rules in the `sX-commands.txt` files that `make` tries to install +using the BMv2 CLI. In this case, `make` will report these errors to `stderr`. Use these error messages to fix your `scrambler.p4` implementation. @@ -109,7 +109,7 @@ help pinpoint logic errors in your implementation. #### Cleaning up Mininet -In the latter two cases above, `run.sh` may leave a Mininet instance +In the latter two cases above, `make` may leave a Mininet instance running in the background. Use the following command to clean up these instances: diff --git a/P4D2_2017_Fall/exercises/scrambler/p4app.json b/P4D2_2017_Fall/exercises/scrambler/p4app.json deleted file mode 100644 index 5215605..0000000 --- a/P4D2_2017_Fall/exercises/scrambler/p4app.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "program": "scrambler.p4", - "language": "p4-16", - "targets": { - "multiswitch": { - "auto-control-plane": true, - "cli": true, - "pcap_dump": true, - "bmv2_log": true, - "links": [["h1", "s1"], ["s1", "s2"], ["s1", "s3"], ["s3", "s2"], ["s2", "h2"], ["s3", "h3"]], - "hosts": { - "h1": { - }, - "h2": { - }, - "h3": { - } - - }, - "switches": { - "s1": { - "entries": "s1-commands.txt" - }, - "s2": { - "entries": "s2-commands.txt" - }, - "s3": { - "entries": "s3-commands.txt" - } - } - } - } -} diff --git a/P4D2_2017_Fall/exercises/scrambler/run.sh b/P4D2_2017_Fall/exercises/scrambler/run.sh deleted file mode 100755 index d5c1947..0000000 --- a/P4D2_2017_Fall/exercises/scrambler/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -P4APPRUNNER=../../utils/p4apprunner.py -mkdir -p build -tar -czf build/p4app.tgz * --exclude='build' -#cd build -sudo python $P4APPRUNNER p4app.tgz --build-dir ./build diff --git a/P4D2_2017_Fall/exercises/scrambler/topology.json b/P4D2_2017_Fall/exercises/scrambler/topology.json new file mode 100644 index 0000000..e33477c --- /dev/null +++ b/P4D2_2017_Fall/exercises/scrambler/topology.json @@ -0,0 +1,16 @@ +{ + "hosts": [ + "h1", + "h2", + "h3" + ], + "switches": { + "s1": { "cli_input" : "s1-commands.txt" }, + "s2": { "cli_input" : "s2-commands.txt" }, + "s3": { "cli_input" : "s3-commands.txt" } + }, + "links": [ + ["h1", "s1"], ["s1", "s2"], ["s1", "s3"], + ["s3", "s2"], ["s2", "h2"], ["s3", "h3"] + ] +} diff --git a/P4D2_2017_Fall/exercises/source_routing/Makefile b/P4D2_2017_Fall/exercises/source_routing/Makefile new file mode 100644 index 0000000..f378756 --- /dev/null +++ b/P4D2_2017_Fall/exercises/source_routing/Makefile @@ -0,0 +1 @@ +include ../../utils/Makefile diff --git a/P4D2_2017_Fall/exercises/source_routing/README.md b/P4D2_2017_Fall/exercises/source_routing/README.md index 003e7a7..6289732 100644 --- a/P4D2_2017_Fall/exercises/source_routing/README.md +++ b/P4D2_2017_Fall/exercises/source_routing/README.md @@ -31,14 +31,14 @@ bring up a network in Mininet to test its behavior. 1. In your shell, run: ```bash - ./run.sh + make ``` This will: * compile `source_routing.p4`, and * start a Mininet instance with three switches (`s1`, `s2`, `s3`) configured in a triangle, each connected to one host (`h1`, `h2`, `h3`). Check the network topology using the `net` command in mininet. - You can also change the topology in p4app.json + You can also change the topology in topology.json * The hosts are assigned IPs of `10.0.1.1`, `10.0.2.2`, etc (`10.0..`). @@ -117,7 +117,7 @@ path, so that source routing would be transparent to end-hosts? There are several ways that problems might manifest: -1. `source_routing.p4` fails to compile. In this case, `run.sh` will +1. `source_routing.p4` fails to compile. In this case, `make` will report the error emitted from the compiler and stop. 2. `source_routing.p4` compiles but switches or mininet do not start. Do you have another instance of mininet running? Did the previous @@ -133,7 +133,7 @@ There are several ways that problems might manifest: #### Cleaning up Mininet -In the cases above, `run.sh` may leave a Mininet instance running in +In the cases above, `make` may leave a Mininet instance running in the background. Use the following command to clean up these instances: diff --git a/P4D2_2017_Fall/exercises/source_routing/p4app.json b/P4D2_2017_Fall/exercises/source_routing/p4app.json deleted file mode 100644 index 6508868..0000000 --- a/P4D2_2017_Fall/exercises/source_routing/p4app.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "program": "source_routing.p4", - "language": "p4-16", - "targets": { - "multiswitch": { - "auto-control-plane": true, - "cli": true, - "pcap_dump": true, - "bmv2_log": true, - "links": [["h1", "s1"], ["s1", "s2"], ["s1", "s3"], ["s3", "s2"], ["s2", "h2"], ["s3", "h3"]], - "hosts": { - "h1": { - }, - "h2": { - }, - "h3": { - } - - }, - "switches": { - "s1": { - }, - "s2": { - }, - "s3": { - } - } - } - } -} diff --git a/P4D2_2017_Fall/exercises/source_routing/run.sh b/P4D2_2017_Fall/exercises/source_routing/run.sh deleted file mode 100755 index d5c1947..0000000 --- a/P4D2_2017_Fall/exercises/source_routing/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -P4APPRUNNER=../../utils/p4apprunner.py -mkdir -p build -tar -czf build/p4app.tgz * --exclude='build' -#cd build -sudo python $P4APPRUNNER p4app.tgz --build-dir ./build diff --git a/P4D2_2017_Fall/exercises/source_routing/s1-commands.txt b/P4D2_2017_Fall/exercises/source_routing/s1-commands.txt new file mode 100644 index 0000000..e69de29 diff --git a/P4D2_2017_Fall/exercises/source_routing/s2-commands.txt b/P4D2_2017_Fall/exercises/source_routing/s2-commands.txt new file mode 100644 index 0000000..e69de29 diff --git a/P4D2_2017_Fall/exercises/source_routing/s3-commands.txt b/P4D2_2017_Fall/exercises/source_routing/s3-commands.txt new file mode 100644 index 0000000..e69de29 diff --git a/P4D2_2017_Fall/exercises/source_routing/topology.json b/P4D2_2017_Fall/exercises/source_routing/topology.json new file mode 100644 index 0000000..e33477c --- /dev/null +++ b/P4D2_2017_Fall/exercises/source_routing/topology.json @@ -0,0 +1,16 @@ +{ + "hosts": [ + "h1", + "h2", + "h3" + ], + "switches": { + "s1": { "cli_input" : "s1-commands.txt" }, + "s2": { "cli_input" : "s2-commands.txt" }, + "s3": { "cli_input" : "s3-commands.txt" } + }, + "links": [ + ["h1", "s1"], ["s1", "s2"], ["s1", "s3"], + ["s3", "s2"], ["s2", "h2"], ["s3", "h3"] + ] +} diff --git a/P4D2_2017_Fall/vm/user-bootstrap.sh b/P4D2_2017_Fall/vm/user-bootstrap.sh index 3a2b14e..a396b49 100644 --- a/P4D2_2017_Fall/vm/user-bootstrap.sh +++ b/P4D2_2017_Fall/vm/user-bootstrap.sh @@ -111,6 +111,7 @@ cd .. # Tutorials pip install crcmod git clone https://github.com/p4lang/tutorials +git checkout p4d2_2017_fall sudo mv tutorials /home/p4 sudo chown -R p4:p4 /home/p4/tutorials