Skip to content

Commit

Permalink
added ECMP exercise for May 2016 P4 workshop
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninbas committed May 10, 2016
1 parent f9ccd26 commit 547fc0a
Show file tree
Hide file tree
Showing 31 changed files with 769 additions and 61 deletions.
2 changes: 1 addition & 1 deletion SIGCOMM_2015/.gitignore → .gitignore
Expand Up @@ -10,4 +10,4 @@
*.pcap

# Extracted solutions
solution/
solution*/
6 changes: 3 additions & 3 deletions SIGCOMM_2015/README.md
Expand Up @@ -80,9 +80,9 @@ like this:

You need to tell us where you cloned the `bmv2` and `p4c-bm` repositories
:). Please update the values of the shell variables `BMV2_PATH` and
`P4C_BM_PATH` in the `env.sh` file - located in this directory. Note that if you
cloned both repositories in the same directory as this one (`tutorials`), you
will not need to change the value of the variables.
`P4C_BM_PATH` in the `env.sh` file - located in the root directory of this
repository. Note that if you cloned both repositories in the same directory as
this one (`tutorials`), you will not need to change the value of the variables.

That's all :)

Expand Down
7 changes: 4 additions & 3 deletions SIGCOMM_2015/flowlet_switching/run_demo.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/simple_router.p4 --json simple_router.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch simple_router.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH simple_router.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap &
Expand Down
6 changes: 4 additions & 2 deletions SIGCOMM_2015/source_routing/run_demo.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -25,7 +25,9 @@ SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch
CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py

$P4C_BM_SCRIPT p4src/source_routing.p4 --json source_routing.json
# This gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $BMV2_PATH/targets/simple_switch/simple_switch \
--behavioral-exe $SWITCH_PATH \
--json source_routing.json \
--cli $CLI_PATH
4 changes: 2 additions & 2 deletions SIGCOMM_2015/env.sh → env.sh
@@ -1,8 +1,8 @@
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# ---------------- EDIT THIS ------------------
BMV2_PATH=$THIS_DIR/../../bmv2
BMV2_PATH=$THIS_DIR/../bmv2
# e.g. BMV2_PATH=$THIS_DIR/../bmv2
P4C_BM_PATH=$THIS_DIR/../../p4c-bmv2
P4C_BM_PATH=$THIS_DIR/../p4c-bmv2
# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm
# ---------------- END ------------------
10 changes: 0 additions & 10 deletions examples/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/README.md
Expand Up @@ -55,9 +55,9 @@ build the code once all the dependencies have been installed:

You need to tell us where you cloned the `bmv2` and `p4c-bm` repositories
:). Please update the values of the shell variables `BMV2_PATH` and
`P4C_BM_PATH` in the `env.sh` file - located in this directory. Note that if you
cloned both repositories in the same directory as this one (`tutorials`), you
will not need to change the value of the variables.
`P4C_BM_PATH` in the `env.sh` file - located in the root directory of this
repository. Note that if you cloned both repositories in the same directory as
this one (`tutorials`), you will not need to change the value of the variables.

You will also need to run the `veth_setup.sh` script included in this directory
as `sudo` to setup the veth interfaces needed by the switch.
Expand Down
7 changes: 4 additions & 3 deletions examples/TLV_parsing/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/TLV_parsing.p4 --json TLV_parsing.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch TLV_parsing.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH TLV_parsing.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap &
Expand Down
7 changes: 4 additions & 3 deletions examples/action_profile/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/action_profile.p4 --json action_profile.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch action_profile.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH action_profile.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap &
Expand Down
6 changes: 4 additions & 2 deletions examples/axon/run_demo.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -25,7 +25,9 @@ SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch
CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py

$P4C_BM_SCRIPT p4src/axon.p4 --json axon.json
# This gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $BMV2_PATH/targets/simple_switch/simple_switch \
--behavioral-exe $SWITCH_PATH \
--json axon.json \
--cli $CLI_PATH
7 changes: 4 additions & 3 deletions examples/copy_to_cpu/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/copy_to_cpu.p4 --json copy_to_cpu.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch copy_to_cpu.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH copy_to_cpu.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap &
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/run_demo.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI

Expand Down
7 changes: 4 additions & 3 deletions examples/counter/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/counter.p4 --json counter.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch counter.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH counter.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap &
Expand Down
8 changes: 0 additions & 8 deletions examples/env.sh

This file was deleted.

7 changes: 4 additions & 3 deletions examples/meter/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/meter.p4 --json meter.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch meter.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH meter.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap &
Expand Down
2 changes: 1 addition & 1 deletion examples/register/read_register.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI

Expand Down
7 changes: 4 additions & 3 deletions examples/register/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/register.p4 --json register.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch register.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH register.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc \
--pcap
2 changes: 1 addition & 1 deletion examples/register/write_register.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI

Expand Down
7 changes: 4 additions & 3 deletions examples/resubmit/run_switch.sh
Expand Up @@ -16,7 +16,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -30,8 +30,9 @@ CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI
# process back in the foreground
set -m
$P4C_BM_SCRIPT p4src/resubmit.p4 --json resubmit.json
sudo echo "sudo" > /dev/null
sudo $BMV2_PATH/targets/simple_switch/simple_switch resubmit.json \
# This gets root permissions, and gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH resubmit.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--nanolog ipc:///tmp/bm-0-log.ipc --log-console \
--pcap &
Expand Down
6 changes: 4 additions & 2 deletions examples/simple_nat/run_demo.sh
Expand Up @@ -21,7 +21,7 @@ fi

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

Expand All @@ -46,8 +46,10 @@ sysctl net.ipv6.conf.$intf0.disable_ipv6=1
sysctl net.ipv6.conf.$intf1.disable_ipv6=1

$P4C_BM_SCRIPT p4src/simple_nat.p4 --json simple_nat.json
# This gives libtool the opportunity to "warm-up"
$SWITCH_PATH >/dev/null 2>&1
PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $BMV2_PATH/targets/simple_switch/simple_switch \
--behavioral-exe $SWITCH_PATH \
--json simple_nat.json \
--cli $CLI_PATH \
--thrift-port 22222
2 changes: 1 addition & 1 deletion examples/simple_nat/sswitch_CLI.sh
Expand Up @@ -2,7 +2,7 @@

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../env.sh
source $THIS_DIR/../../env.sh

CLI_PATH=$BMV2_PATH/targets/simple_switch/sswitch_CLI

Expand Down
6 changes: 6 additions & 0 deletions workshop_05_2016/ecmp/.starter_code/commands.txt
@@ -0,0 +1,6 @@
table_set_default send_frame _drop
table_set_default forward _drop
table_set_default ipv4_lpm _drop
table_add send_frame rewrite_mac 1 => 00:aa:bb:00:00:00
table_add forward set_dmac 10.0.1.1 => 00:04:00:00:00:00
table_add ipv4_lpm set_nhop 10.0.0.1/32 => 10.0.1.1 1

0 comments on commit 547fc0a

Please sign in to comment.