Skip to content

NCTU Project of Programmable Network Switches Fall 2020

Notifications You must be signed in to change notification settings

steven112163/p4-project

Repository files navigation

p4-project

Project of Programmable Network Switches Fall 2020 NCTU 可程式化網路交換機 5271
The topic is "Loop-free Flooding on the Data Plane".

Virtual Environment

Pyenv is used because the development environment is Ubuntu 16.04.

  1. Follow instructions in pyenv-installer

  2. Define environment variables for Ubuntu

    $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
    $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  3. Add pyenv init to the shell

    $ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc
  4. Restart the shell

    $ exec "$SHELL"
  5. Install python 3.6.9

    $ pyenv install 3.6.9
  6. Setup virtual environment for the project

    $ cd p4-project
    $ pyenv local 3.6.9
    $ pyenv virtualenv my_p4_environment
  7. Use the virtual environment for development

    $ pyenv activate my_p4_environment
    $ pyenv deactivate

Prerequisites

  • python >= 3.6.9
  • scapy >= 2.4.4
  • mininet >= 2.3.0.dev6
  • pandas >= 1.1.5
  • matplotlib >= 3.3.3
  • tmux
  • p4-utils

Make

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

Version 1

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

Version 2

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

Python Programs

sender.py

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)

receiver.py

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'

randomizer.py

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

aggregator.py

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

Run

Python programs are executed on mininet hosts.

Auto Test

  1. 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
  2. Show results.

    $ make aggregate

Manual Test

  1. Setup required files for the environment.

    $ python3 randomizer.py [-v (0-1)] [-r (0-2)] [-n (>= 3)]
  2. Start the environment.

    $ sudo p4run
  3. Call the terminals of sender and receiver.

    $ xterm h1 h2
  4. Start receiver in h2.

    $ sh receive.sh
  5. Start sender in h1.

    $ sh send.sh [0 or 1]
  6. 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]

Sender

$ 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]

Receiver

$ pyenv activate my_p4_environment
$ cd host_test
$ python3 receiver.py [-if interface]

About

NCTU Project of Programmable Network Switches Fall 2020

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published