-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1fa5d5c
Showing
11 changed files
with
360 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
commit-message: | ||
prefix: "chore: " | ||
target-branch: "main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
release-images: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
image: ["mininet", "ryu"] | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
- name: set up qemu | ||
uses: docker/setup-qemu-action@v3 | ||
- name: set up docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: login to ghcr | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: generate container metadata | ||
id: metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} | ||
flavor: | | ||
latest=auto | ||
prefix= | ||
suffix= | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- name: Build and Push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./${{ matrix.image }} | ||
file: ./${{ matrix.image }}/Dockerfile | ||
platforms: linux/amd64, linux/arm64/v8 | ||
push: true | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2024 Will Fantom <[email protected]> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Base Images | ||
|
||
To complete SCC365 tasks, you will need to use a set of tools you are unlikely | ||
to have installed on your own devices already. Provided you are using a | ||
UNIX-like system and have Docker installed, you should be able to use the images | ||
found here to install and run the software. | ||
|
||
For specific information as to how to use each image, see the README files in | ||
the given directories. | ||
|
||
## Images | ||
|
||
- Mininet: [here](./mininet/) | ||
- Ryu: [here](./ryu/) | ||
|
||
## Versioning | ||
|
||
All the base images will share the same versioning as one another. This can be | ||
leveraged to make life a little easier. Users should expect that any base images | ||
of the same version are compatible with one another. | ||
|
||
For the sake of course management, base image versions correspond to tags in | ||
this repository, although tags are given metadata in the semver version to | ||
provide the relevant year they were designed for (e.g. `v1.1.1+2024` when the | ||
image is intended for use in 2024). | ||
|
||
The general format for the images is: `ghcr.io/scc365/<baseimage>:v<version>`. | ||
|
||
Also, a `latest` tag is provided where images tagged with `latest` are equal to | ||
the images tagged with the highest semver version. | ||
|
||
--- | ||
|
||
## License | ||
|
||
The license for this base images repository is the do what the fuck you want to | ||
public license. This reflects the license only for the files directly contained | ||
in this repository and not the content that is pulled in during the build | ||
process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
ARG DEBIAN_VERSION=bookworm-slim | ||
ARG MININET_REPO=https://github.com/mininet/mininet | ||
ARG MININET_VERSION=2.3.0 | ||
|
||
FROM debian:${DEBIAN_VERSION} as openflow | ||
ARG MININET_REPO | ||
ARG MININET_VERSION | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update -q && \ | ||
apt-get install -yq \ | ||
autoconf \ | ||
automake \ | ||
libtool \ | ||
make \ | ||
gcc \ | ||
git \ | ||
autotools-dev \ | ||
pkg-config \ | ||
libc6-dev | ||
WORKDIR /src/mininet | ||
RUN git clone -b ${MININET_VERSION} ${MININET_REPO} . | ||
ARG MININET_OF_REPO=https://github.com/mininet/openflow | ||
WORKDIR /src/mnof | ||
RUN git clone ${MININET_OF_REPO} ./openflow | ||
RUN cp -R /src/mininet/util/openflow-patches/ openflow-patches/ | ||
WORKDIR /src/mnof/openflow | ||
RUN patch -p1 < ../openflow-patches/controller.patch | ||
RUN ./boot.sh && ./configure && make install | ||
|
||
|
||
FROM debian:${DEBIAN_VERSION} as mnexec | ||
ARG MININET_REPO | ||
ARG MININET_VERSION | ||
RUN apt-get update -q && \ | ||
apt-get install -yq gcc git | ||
WORKDIR /src | ||
RUN git clone -b ${MININET_VERSION} ${MININET_REPO} . | ||
ARG MNEXEC_VERSION="latest" | ||
RUN mkdir -p /output | ||
RUN gcc -Wall -Wextra -DVERSION=\"\(${MNEXEC_VERSION}\)\" mnexec.c -o /output/mnexec | ||
|
||
|
||
FROM debian:${DEBIAN_VERSION} | ||
ARG MININET_REPO | ||
ARG MININET_VERSION | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update -q && \ | ||
apt-get install --no-install-recommends -yqq \ | ||
arping \ | ||
curl \ | ||
git \ | ||
hping3 \ | ||
iperf3 \ | ||
iproute2 \ | ||
iptables \ | ||
iputils-ping \ | ||
net-tools \ | ||
openvswitch-common \ | ||
openvswitch-switch \ | ||
openvswitch-testcontroller \ | ||
python3 \ | ||
python3-bottle \ | ||
python3-pip \ | ||
python3-setuptools \ | ||
telnet \ | ||
tshark \ | ||
traceroute && \ | ||
rm -rf /var/lib/apt/lists/* | ||
COPY --from=openflow /usr/local/bin/ /usr/local/bin/ | ||
COPY --from=mnexec /output/mnexec /usr/bin/mnexec | ||
WORKDIR /src/mininet | ||
RUN git clone -b ${MININET_VERSION} ${MININET_REPO} . | ||
RUN pip3 install --break-system-packages . | ||
WORKDIR / | ||
COPY entrypoint.sh . | ||
RUN chmod +x entrypoint.sh | ||
WORKDIR /workspace | ||
ENTRYPOINT [ "bash", "/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Mininet Base Image | ||
|
||
This dir contains the means to build a base image for containers needing | ||
Mininet. | ||
|
||
Since there are many ways of running Mininet, this image simply starts a bash | ||
shell (along with the Open vSwitch service). The specific commands needed to run | ||
other executables should be provided as arguments to any `docker run` commands. | ||
Some common examples are given below. | ||
|
||
> 💡 **Remember:** When giving arguments for file paths/names the paths are | ||
> always referring to the container's filesystem. By default, the container's | ||
> current working dir at start is `/workspace`, so relative file paths will be | ||
> relative to that directory. | ||
## Running a Topology (via Python API) | ||
|
||
```bash | ||
docker run --rm -it --privileged \ | ||
-v "$(pwd)"/topology.py:/workspace/topology.py:ro \ | ||
--label scc365=topology --name topology \ | ||
ghcr.io/scc365/mininet:latest \ | ||
python3 topology.py | ||
``` | ||
|
||
## Running a Topology (via the `mn` tool) | ||
|
||
```bash | ||
docker run --rm -it --privileged \ | ||
-v "$(pwd)"/topology.py:/workspace/topology.py:ro \ | ||
--label scc365=topology --name topology-mn \ | ||
ghcr.io/scc365/mininet:latest \ | ||
mn --custom topology.py --topo example | ||
``` | ||
|
||
## Using the `controller` Tool | ||
|
||
```bash | ||
docker run --rm -it --privileged \ | ||
--label scc365=ptcp --name ptcp \ | ||
ghcr.io/scc365/mininet:latest \ | ||
controller ptcp:6633 | ||
``` | ||
|
||
--- | ||
|
||
## Using `ovs-ofctl` and `ovs-vsctl` Commands | ||
|
||
If you just want to run one of the commands in an empty environment, you can like | ||
so: | ||
|
||
```bash | ||
docker run --rm -it --privileged \ | ||
--label scc365=ovs-vsctl --name vsctl \ | ||
ghcr.io/scc365/mininet:latest \ | ||
ovs-vsctl --help | ||
``` | ||
|
||
However, it is more likely that you will want to run the command in a container | ||
where a topology is already running. Provided you know the name of the container | ||
with the topology already running in, that can be done like: | ||
|
||
```bash | ||
docker exec -it topology ovs-vsctl --help | ||
``` | ||
|
||
> 💡 **Check:** Replace the `topology` bit in this command with the name of the | ||
> container that is running the topology. | ||
## Getting a new Shell | ||
|
||
Likewise, if you want to execute any command within a container that is running | ||
a topology (and you know the name of the container), you can get a fresh bash | ||
shell like so: | ||
|
||
```bash | ||
docker exec -it topology bash | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
if [[ "${TRACE-0}" == "1" ]]; then | ||
set -o xtrace | ||
fi | ||
|
||
function becho { | ||
echo -e "\033[1m$1\033[0m" | ||
} | ||
|
||
function start_openvswitch_service { | ||
becho "*** Starting OpenvSwitch service..." | ||
service openvswitch-switch start > /dev/null 2>&1 | ||
ovs-vswitchd --pidfile --detach > /dev/null 2>&1 | ||
ovs-vsctl set-manager ptcp:6640 > /dev/null 2>&1 | ||
becho "*** OpenvSwitch service started ✅" | ||
} | ||
|
||
function stop_openvswitch_service { | ||
becho "*** Stopping OpenvSwitch service..." | ||
service openvswitch-switch stop > /dev/null 2>&1 | ||
becho "*** OpenvSwitch service stopped ✅" | ||
} | ||
|
||
if ! start_openvswitch_service; then | ||
becho "*** Failed to start OpenvSwitch service ❌" | ||
exit 1 | ||
else | ||
trap "stop_openvswitch_service" EXIT | ||
fi | ||
|
||
becho "|-- SCC365: Mininet Docker Image 🐳 --|" | ||
/bin/bash -c "$*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ARG PYTHON_VERSION=3.9 | ||
FROM python:${PYTHON_VERSION}-alpine | ||
|
||
COPY ./requirements.txt . | ||
RUN pip install -r ./requirements.txt | ||
|
||
RUN apk add bash | ||
|
||
RUN apk add --no-cache --virtual .build-deps \ | ||
gcc \ | ||
g++ \ | ||
musl-dev | ||
|
||
RUN pip install eventlet==0.30.2 && \ | ||
pip install setuptools==59.5.0 | ||
|
||
ARG RYU_VERSION=4.34 | ||
RUN pip install ryu==${RYU_VERSION} | ||
|
||
RUN apk del .build-deps | ||
|
||
WORKDIR / | ||
COPY entrypoint.sh . | ||
RUN chmod +x entrypoint.sh | ||
|
||
WORKDIR /workspace | ||
ENTRYPOINT [ "bash", "/entrypoint.sh" ] | ||
CMD [ "--help" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Ryu SDN Controller | ||
|
||
> ⚠️ Since the upstream is no longer actively maintained, the version numbers | ||
> are unlikely to see any change here. Importantly, this means that Ryu will be | ||
> run **using Python 3.9**! | ||
Ryu is a well documented Python-based OpenFlow SDN controller framework. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
if [[ "${TRACE-0}" == "1" ]]; then | ||
set -o xtrace | ||
fi | ||
|
||
function becho { | ||
echo -e "\033[1m$1\033[0m" | ||
} | ||
|
||
becho "|-- SCC365: Ryu Docker Image 🐳 --|" | ||
ryu-manager "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
netaddr |