| tocdepth: | 2 |
|---|---|
| orphan: |
Note
We tested this tutorial on Debian 12 bookworm, but feel free to adapt to your preferred Linux distribution.
This tutorial shows how to setup your development environment in order to run the latest Kytos SDN Platform code (python-openflow, kytos, kytos NApps, ...) and contribute to it.
!DANGER!
Do not use this procedure in production environments. This setup is for development only.
Caution!
Code to be run in terminal begins with the dollar sign ($). If you copy and paste, don't forget to skip this symbol.
The average time to go through it is: 10 min.
- How to create an isolated environment for development;
- How to install the Kytos Projects in a development environment;
- How to install Mininet.
In order to start using and coding with Kytos, you need a few required dependencies. One of them is Python 3.11.x
Install the dependencies necessary to build Python:
sudo apt update
sudo apt install python3.11-dev python3.11-venvThe required Debian package can be installed by:
sudo apt install gitTo make changes to Kytos projects, we recommend you to use Virtual Environments. The main reason for this recommendation is to keep the dependencies required by different projects in separate places by creating virtual Python environments for each one. It solves the “Project X depends on version 1.x, but Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
In this tutorial, we will use the new built-in :mod:`venv` Python module, but if you wish to use another tool to create isolated environments or install libraries on your global system, feel free to do it your way.
To create a new virtualenv, use the command below (you can replace test42
by another name, if you wish):
python3.11 -m venv test42This command will create a virtualenv named test42 and a folder with the same name for it.
Note
Kytos requires Python 3.11.x
If you want to remove an existing virtualenv, just delete its folder
(e.g. rm -rf test42).
If you want to use an existing environment you can use the following command:
source test42/bin/activateAfter that, your console prompt will show the activated virtualenv name between
parenthesis. Now, update the pip package that is already installed in the
virtualenv, with setuptools and wheel as well to the following versions:
(test42) pip install pip==24.3.1 setuptools==75.6.0 wheel==0.46.3Having this packages updated is important to avoid some conflicts. For more imformation check out Python packaging documentation on setup.py
The parenthesis marker identifies that the test42 virtualenv is activated. If
you want leave this virtualenv you can use the command deactivate.
After this, the virtualenv name will disappear from your prompt and you will be
using your regular Linux environment.
Note
Inside the virtualenv, all pip packages will be installed within the test42 folder. Outside the virtualenv, all pip packages will be installed into the default system environment (standard Linux folder).
If you want to read more about it, please visit: virtualenv and virtualenv docs pages.
To install the latest Kytos from source, first you need to start your environment:
$ source YOURENV/bin/activateThen you need to run the commands below to clone the python-openflow, kytos-utils and kytos projects locally.
for repo in python-openflow kytos-utils kytos; do
git clone https://github.com/kytos-ng/"${repo}"
doneAfter cloning, the Kytos installation process is done running setuptools installation procedure for each cloned repository, in order. Below we execute its commands.
for repo in python-openflow kytos-utils kytos; do
cd "${repo}"
python -m pip install --editable .
cd ..
doneWe will now install some NApps developed by the Kytos team, which will be used later in the following tutorials.
Note
Currently, NApps should be installed by cloning the source code and installing through the setup.py file
Currently, flow_manager and topology require MongoDB to be setup. Before installing the Napps, follow the instructions below
Python unit tests are run with tox, which will create its own virtual venv, isolating the testing libraries dependencies. If you need to run unit tests to validate code changes, first install tox and virtualenv with the following versions. You can still use the same test42 venv to install tox, having it in the same venv can be convenient, it's up to you:
(test42) pip install tox==4.13.0 virtualenv==20.25.1Once installed, to run the tests and linters:
(test42) toxKytos with MongoDB requires docker and docker-compose to be installed on your linux environment. The following tutorials have been tested on Debian 12 for docker and docker-compose
Set up non-root user (Follow only the "Manage Docker as a non-root user" section)
After installing docker and docker-compose you can follow this link to setup Kytos with MongoDB: Kytos-MongoDB
Note
MongoDB 5.0+ requires a CPU that supports AVX instructions.
Also, if you're running VirtualBox on Windows as host and a Debian guest you'll need to disable Hyper-V: Find the Command Prompt icon, right click it and choose Run As Administrator. Enter this command: bcdedit /set hypervisorlaunchtype off. Some report this command was needed also: DISM /Online /Disable-Feature:Microsoft-Hyper-V. Reboot.
of_core, flow_manager, topology, of_lldp, of_l2ls:
for repo in of_core flow_manager topology of_lldp of_l2ls; do
git clone https://github.com/kytos-ng/"${repo}"
donefor repo in of_core flow_manager topology of_lldp of_l2ls; do
cd "${repo}"
python -m pip install --editable .
cd ..
doneIf you wish to disable all NApps you can use the following command, or for an individual NApp you can use replace "all" with the NApp name
$ kytos napps disable allNow open another terminal window and run the following command to start the kytos server if it is not already running
$ kytosd -f --database mongodbThat's it! you can type quit to exit
Kytos.
One more step: Mininet.
Mininet is a network simulator that creates a network of virtual hosts, switches, controller and the links among them. Mininet hosts run standard Linux network software, and its switches support Openflow for highly flexible custom routing and Software Defined Networking.
First, we need to install the mininet package. The Mininet project lists a few methods for installing the simulator. For instance, you can use a virtual machine or you can install it to you operating system.
$ sudo apt install mininetTo test if the mininet is working for you, run the command:
$ sudo mn --test pingall --controller=remote,ip=127.0.0.1,port=6653
*** No default OpenFlow controller found for default switch!
*** Falling back to OVS Bridge
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
s1 ...
*** Waiting for switches to connect
s1
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
*** Stopping 0 controllers
*** Stopping 2 links
..
*** Stopping 1 switches
s1
*** Stopping 2 hosts
h1 h2
*** Done
completed in 0.154 secondsTo see more about Mininet, you can access the webpage mininet.org.