Skip to content

Commit

Permalink
Add/update installation scripts, update README with versions (#25)
Browse files Browse the repository at this point in the history
* Add/update installation scripts, update README with versions

* Update scripts/README.md

Co-authored-by: Radostin Stoyanov <[email protected]>

* Add disclaimer about dependency versions

---------

Co-authored-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
stano45 and rst0git authored Aug 25, 2024
1 parent 5249616 commit 52f389e
Show file tree
Hide file tree
Showing 8 changed files with 1,105 additions and 31 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ For more information about the project, please refer to the [final report](REPOR
- [Installation](#installation)
- [Prerequisites](#prerequisites)
- [Install Python Dependencies](#install-python-dependencies)
- [Installing PI](#installing-pi)
- [Build Custom Podman Images](#build-custom-podman-images)
- [Running examples](#running-examples)


## Installation

### Prerequisites
- [Podman](https://podman.io/docs/installation)
- [Python 3](https://www.python.org/downloads/)
- [pip](https://pip.pypa.io/en/stable/installation/)
- [P4 Compiler (p4c)](https://github.com/p4lang/p4c)
- [Python 3](https://www.python.org/downloads/) (3.10+)
- [pip3](https://pip.pypa.io/en/stable/installation/)
- [CRIU](https://criu.org/Main_Page) (v3.19)
- [crit](https://criu.org/CRIT) (v3.19)
- [P4 Compiler](https://github.com/p4lang/p4c) (v1.2.4.14)
- [PI](https://github.com/p4lang/PI)
- [Podman](https://podman.io/docs/installation) (v5.2.1)
The versions mentioned above are the ones used during development. Newer versions may work, but have not been tested.

We have provided [scripts](scripts) to install CRIU (with crit), the P4 compiler, PI, and Podman. The scripts have been tested on Ubuntu 22.04 and 24.04 and are not guaranteed to work on all machines. If you encounter any issues, please refer to the official documentation of the respective projects.

### Install Python Dependencies
```bash
Expand All @@ -29,21 +35,17 @@ source .venv/bin/activate
pip install -r requirements.txt
```

### Installing PI
This project uses the P4Runtime API to communicate with the switch. The P4Runtime API is implemented in the [P4Runtime Interface (PI)](https://github.com/p4lang/PI).

When installing PI, make sure to configure with the `--with-proto` flag to compile proto files and `--with-python_prefix=/path/to/this/repo/.venv` to install the p4 library in your virtual environment. For example:
```bash
./configure --with-proto --with-python_prefix=/absolute/path/to/p4containerflow/.venv
```
After running:
### Build Custom Podman Images
```bash
sudo make install
make images
```
The p4 library files in your `.venv` will be owned by the root user. Make sure to change owner by running:
```bash
sudo chown -R $USER .venv
```
This will build the following images:
- `tcp-client`: A simple TCP client that sends a message to a server (this will run in h1-pod)
- `tcp-server`: A simple TCP server that listens for a message from a client (this will run in all other pods)

You can configure the target IP of the client and the port of the server in the [tcp/Containerfile.server](tcp/Containerfile.server) and [tcp/Containerfile.client](tcp/Containerfile.client) files respectively.

Furthermore, you can specify which image to run in the hosts by changing the `IMG` and `ARGS` variables in [scripts/switch_container/build.sh](scripts/switch_container/build.sh).

## Running examples
There are three examples in the `examples` directory:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ grpcio==1.64.1
itsdangerous==2.2.0
Jinja2==3.1.4
MarkupSafe==2.1.5
protobuf==5.27.2
protobuf==3.20.0
scapy==2.5.0
Werkzeug==3.0.3
5 changes: 5 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Scripts

This directory contains scripts to install CRIU, the P4 compiler, PI and Podman. The scripts have been tested on Ubuntu 22.04 and 24.04. If you encounter any issues with other Linux distributions, please refer to the official documentation of the respective projects.

The `edit_files_img.py` script is used to edit the `files.img` file in a container checkpoint by rewriting the socket IP address. This is used by some of the examples to successfully restore containers with a changing IP address.
Loading

0 comments on commit 52f389e

Please sign in to comment.