Skip to content
Snippets Groups Projects
Commit b4e4e41c authored by MERINDOL PASCAL's avatar MERINDOL PASCAL
Browse files

Merge branch 'main' into 'main'

Docker compose, vim and tmuxp (for ex 1, 2, 3 and 4 learning cpu)

See merge request !3
parents 9ac3f7bb e0895f52
Branches
1 merge request!3Docker compose, vim and tmuxp (for ex 1, 2, 3 and 4 learning cpu)
......@@ -10,7 +10,8 @@ RUN apt-get update && \
pkg-config python3 python3-dev python3-pip python3-setuptools traceroute wget xcscope-el \
zip unzip libthrift-dev thrift-compiler bison clang flex iptables libelf-dev libfl-dev libgc-dev \
llvm net-tools zlib1g-dev lld pkg-config ccache sudo iputils-ping python-is-python3 tcpdump \
iperf3 protobuf-compiler protobuf-c-compiler tmux lsb-release && \
iperf3 protobuf-compiler protobuf-c-compiler tmux lsb-release\
vim tmuxp && \
pip install --upgrade \
pip==21.3.1 scapy==2.5.0 ply pyroute2 \
cffi ipaddress ipdb ipython pypcap \
......
# P4-Utils Docker image
## Credits
## Credits
This image was created by Maxime Friess as an alternative to the ETH Zurich virtual machine for installing p4utils.
Forked by Éloi COLIN to add vim, tmuxp and a Docker Compose.
## Summary
## Summary
This image allows running p4 projets inside a Docker container.
This image bundles the following tools:
......@@ -18,6 +19,7 @@ The p4-utils repository is located in `/p4-utils` in the image.
## Building the image
The build should take around 30 minutes on a modern 8 cores machine. At least 10 GB of free space is needed.
Don't forget to `chmod u+x *.sh`.
```sh
sudo docker build . -t p4-utils
......@@ -65,4 +67,36 @@ Or, after cloning `p4learning` and `cd` into its repository, rely on the the `ru
sh run.sh
```
Instead of `tmux` (as in the `sh` script - check inside), you can rely on `docker exec -it resprog bash` to open new `tty` (for the `mx` or the controller' commands in particular).
\ No newline at end of file
Instead of `tmux` (as in the `sh` script - check inside), you can rely on `docker exec -it resprog bash` to open new `tty` (for the `mx` or the controller' commands in particular).
## Run the container (with :sparkles: *Compose* :sparkles:)
To run the container clone the `p4-learning` repo :
```sh
git clone https://github.com/nsg-ethz/p4-learning.git
cd p4-learning
docker login registry.app.unistra.fr #give your Unistra credentials!
docker pull registry.app.unistra.fr/jr.luttringer/reseaux-programmables-conteneur/p4-utils
docker image tag registry.app.unistra.fr/jr.luttringer/reseaux-programmables-conteneur/p4-utils p4-utils
```
Copy the compose :
```sh
ln <sourcedir>/compose.yaml ./compose.yaml
```
And then use :
```sh
docker-compose run --rm p4-utils
```
## Easy tmux
To enable tmuxp you must either install it directly in the container or rebuild the image from this repo
Copy the `tmuxp` dir :
```sh
cp -r <sourcedir>/tmuxp/ ./tmuxp/
```
After running the container, to launch an exercise simply load the corresponding tmux :
```sh
root@containerid:/# tmuxp load /home/tmuxp/01-Reflector.yaml
```
And don't forget the allmighty [tmux cheat sheet](https://tmuxcheatsheet.com/) <3
services:
p4-utils:
container_name: resprog
# image: "registry.app.unistra.fr/jr.luttringer/reseaux-programmables-conteneur/p4-utils"
image: "p4-utils"
volumes:
# - type: bind
# source: ./tmuxp/
# target: /tmuxp/
- type: bind
source: .
target: /home/
privileged: true
stdin_open: true
tty: true
session_name: 01-Reflector
global_options:
status-bg: purple
status-fg: lime
start_directory: /home/exercises/01-Reflector/
windows:
- window_name: 01-Reflector
layout: even-horizontal
panes:
- shell_command:
- sudo python network.py
- shell_command:
-
session_name: 02-Reflector
global_options:
status-bg: purple
status-fg: lime
start_directory: /home/exercises/02-Repeater/thrift/
windows:
- window_name: main
layout: main-vertical
options:
main-pane-width: 50%
panes:
- shell_command:
- sudo python network.py
- shell_command:
- sleep 5; mx h1
- shell_command:
- sleep 5; mx h2
session_name: 03-L2_Basic_forwarding
global_options:
status-bg: purple
status-fg: lime
start_directory: /home/exercises/03-L2_Basic_forwarding/thrift/
windows:
- window_name: main
layout: main-vertical
options:
main-pane-width: 50%
panes:
-
-
-
-
-
session_name: 03-L2_Flooding
global_options:
status-bg: purple
status-fg: lime
start_directory: /home/exercises/03-L2_Flooding/thrift/
windows:
- window_name: main
layout: main-vertical
options:
main-pane-width: 50%
panes:
-
-
-
-
-
-
session_name: 04-L2_Learning
global_options:
status-bg: purple
status-fg: lime
start_directory: /home/exercises/04-L2_Learning/thrift/
windows:
- window_name: main
layout: main-vertical
options:
main-pane-width: 50%
panes:
-
-
-
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment