Talentica believes in continuous learning and innovation. We the Talenticians have always been encouraged to undertake learning and experimenting with emerging technologies. With the same objective, we have setup an internal R&D group working on upcoming areas. Software defined networking (SDN) is one the areas where we are developing proficiency.
As a part of SDN group, we are working on a measuring Hadoop Map Reduce shuffle phase network transfer and also possible traffic engineering solutions for optimizing shuffle phase network transfer. While working on the same, we encountered several challenges, this blog is highlighting solution to one the challenges we faced.
One of the primary requirements of our project was to set up a SDN-enabled fat tree topology using mininet python API. Mininet provides network isolation to the end hosts which it creates from base machine, but the file system and the processes of the base machine are shared. We wanted to have a complete isolation including the isolation of the processes and file system as well. In this post we explain how to replace mininet hosts with docker containers to ensure that the applications which we are running on the end hosts are completely isolated from each other.
Using Docker Containers as Mininet Hosts
Here are the steps to replace mininet hosts with docker containers in a mininet topology:
Install mininet natively from source using below commands.
git clone git://github.com/mininet/mininet ~/mininet/util/install.sh –a
- Install the latest version of docker using this guide.
- Install POX controller using this guide.
We are using POX which is an OpenFlow based controller to install the forwarding paths on switches in the topology.We assume that you have successfully installed mininet, docker and POX controller on your base machine. In next steps we will create the topology. We need a docker image to instantiate docker containers.
- Pull a basic Ubuntu docker image from docker hub using below command.
sudo docker pull Ubuntu
Download the source code fattree.py to create the topology from our git hub repository.
We are using a custom class that spin-up docker container for every host. This article “Docker Container as Mininet Host” lists down all the methods to be implemented by the class, but the code doesn’t work with the latest version of docker. We modified this code as well to make it work with the latest docker engine (version 1.10.3). Referring the source code, “DockerHost” class creates and starts a docker host from the specified docker image. The DockerHost class is passed as a parameter to mininet API while creating the hosts. Mininet creates all the hosts which are docker containers started without any network or connection to default docker bridge, then it adds a network interface to host and host is connected to the edge switch to create topology. To enable ssh/ping on docker containers from the base machine, we need to create a virtual node in root network namespace and link the created node to one of the core switches in the topology. When the link has been established, topology network is connected with root namespace. Finally in routing table in base machine, add a static route to route traffic to docker hosts via root node interface. (Refer enableSSH method in our topology code).
Run the source code using below command to create a fat tree topology as shown in Figure 1.
sudo python fattree.py
7. Start POX controller. To start POX, Go to POX containing directory and run below command:
./pox.py forwarding.l2_learning openflow.discovery openflow.spanning_tree --no-flood --hold-down
How To Verify
We can verify by checking the docker containers created through our topology code using below command:
sudo docker ps -a
We can see that sixteen docker containers are up and running.
We can also verify by pinging from one docker container to another docker container using below command:
sudo docker exec -ti <container1-name> ping -c 4 <container2-IP-address>
(Replace container1-name with the name of the container from you want to ping and container2-IP-address with the IP address of the container to you want to ping). We can also check that base machine is also able to ping all the docker containers by pinging the containers from base machine.
In this post, we explained how we can use docker containers in a mininet topology. Using docker containers as mininet hosts is an advantage where we can simulate a network consisting of hosts capable of running application in isolation with each other.