Project of Programmable Network Switches Fall 2020 NCTU 可程式化網路交換機 5271
The topic is "Loop-free Flooding on the Data Plane".
Pyenv is used because the development environment is Ubuntu 16.04.
-
Follow instructions in pyenv-installer
-
Define environment variables for Ubuntu
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
-
Add
pyenv init
to the shell$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
-
Restart the shell
$ exec "$SHELL"
-
Install python 3.6.9
$ pyenv install 3.6.9
-
Setup virtual environment for the project
$ cd p4-project $ pyenv local 3.6.9 $ pyenv virtualenv my_p4_environment
-
Use the virtual environment for development
$ pyenv activate my_p4_environment
$ pyenv deactivate
- python >= 3.6.9
- scapy >= 2.4.4
- mininet >= 2.3.0.dev6
- pandas >= 1.1.5
- matplotlib >= 3.3.3
- tmux
- p4-utils
Command | Description |
---|---|
make build |
Compile p4 program |
make clean |
Clean mininet and delete environment-related directory |
make clean_all |
make clean and delete results |
make aggregate |
Aggregate all random results |
Command | Description |
---|---|
make run1 |
Start version 1 test |
make worst1 |
Start version 1 worst case test |
make random1 |
Start version 1 test with random link delay |
make ten1 |
Start version 1 test with random link delay and 10 switches |
make tf1 |
Start version 1 test with random link delay and 25 switches |
make thir1 |
Start version 1 test with random link delay and 30 switches |
Command | Description |
---|---|
make run2 |
Start version 2 test |
make worst2 |
Start version 2 worst case test |
make random2 |
Start version 2 test with random link delay |
make ten2 |
Start version 2 test with random link delay and 10 switches |
make tf2 |
Start version 2 test with random link delay and 25 switches |
make thir2 |
Start version 2 test with random link delay and 30 switches |
Send ARP packets.
$ python3 sender.py [-src srcIP] [-dst dstIP] [-if interface] [-c count] [-ch (0-1)] [-t (0-1)] [-i list_of_ids]
Parameter | Description | Default |
---|---|---|
-src, --source | Source IP address | '10.0.1.1' |
-dst, --destination | Destination IP address | '10.0.2.2' |
-if, --interface | Name of the interface which sends packets | 'h1-eth0' |
-c, --count | Number of packets to be sent | 1 |
-ch, --check | Whether send packets again to test convergence | 0 |
-t, --test | Whether to test variable length field in pure mininet | 0 (False) |
-i, --id | IDs to be placed in variable length field | list(1) |
Receive ARP packets and extract the traversed path.
$ python3 receiver.py [-if interface]
Parameter | Description | Default |
---|---|---|
-if, --interface | Name of the interface on which the sniffer is | 'h2-eth0' |
Randomize the link delay between switches.
$ python3 randomizer.py [-v (0-1)] [-r (0-2)] [-n (>= 3)]
Parameter | Description | Default | others |
---|---|---|---|
-v, --version | Version of the P4 architecture | 0 (version 1) | 1 (version 2) |
-r, --random | Mode of link delay | 0 (equal link delay) | 1 (worst Case), 2 (random link delay) |
-n, --number | Number of switches | 3 |
Aggregate all random results.
$ python3 aggregator.py [-d name_of_the_directory] [-c num_of_packets] [-r num_of_rounds]
Parameter | Description | Default |
---|---|---|
-d, --directory | Name of the directory | 'results' |
-c, --count | Number of packets sent in each round | 5 |
-r, --round | Number of rounds in each test | 2 |
Python programs are executed on mininet hosts.
-
Start testing.
$ make run1 or $ make worst1 or $ make random1 or $ make ten1 or $ make tf1 or $ make thir2
or
$ make run2 or $ make worst2 or $ make random2 or $ make ten2 or $ make tf2 or $ make thir2
-
Show results.
$ make aggregate
-
Setup required files for the environment.
$ python3 randomizer.py [-v (0-1)] [-r (0-2)] [-n (>= 3)]
-
Start the environment.
$ sudo p4run
-
Call the terminals of sender and receiver.
$ xterm h1 h2
-
Start receiver in h2.
$ sh receive.sh
-
Start sender in h1.
$ sh send.sh [0 or 1]
-
Execute the aggregator in another terminal to see the result.
$ python3 aggregator.py [-d name_of_the_directory] [-c num_of_packets] [-r num_of_rounds]
$ pyenv activate my_p4_environment
$ cd host_test
$ python3 sender.py [-src srcIP] [-dst dstIP] [-if interface] [-c count] [-ch (0-1)] [-t (0-1)] [-i list_of_ids]
$ pyenv activate my_p4_environment
$ cd host_test
$ python3 receiver.py [-if interface]