Docker Container as Mininet Host

Docker seems to quite the buzz these days. It’s interesting what you could do with it, but I wanted try and see if it can help in any way when used in Mininet. A lot of times when you want to run certain applications inside a Mininet Host, you had to install that software on your PC/VM since the Mininet Host and your physical host share the same file system. This does come in handy a lot of times. But what if I don’t want to clutter up my physical host with extra apps. This seems like a great place for Docker to be used. Since Mininet uses veth pairs to connect the Mininet Host to the switches, it seemed that it wouldn’t be to hard to swap out the Mininet Host with a Docker host since Docker containers can also use veth pairs.

So I wrote a small test class to try it out. I wrote a new DockerHost class and added one to my topology.

    h1 = net.addHost( 'h1', ip='10.0.0.1', cls=DockerHost )
    h2 = net.addHost( 'h2', ip='10.0.0.2')

Then tried it out.

mininet@mininet:~$ sudo ./dockerHost.py
*** Adding controller
*** Adding hosts
Removing any old host still running
mininet-h1
mininet-h1
Start Docker Host
*** Adding switch
*** Creating links
*** Starting network
*** Configuring hosts
h1 h2
*** Starting controller
*** Starting 1 switches
s1
*** Running CLI
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
mininet> 

I was quite happy to see this work. The Docker host I used is a basic Ubuntu image. So it has no special apps in it. Mininet is just starting the Docker container as such.

docker run --priviledged -h h1 --name=mininet-h1 -ti  --net='none' ubuntu /bin/bash

I can see it running here.

mininet@mininet:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
a33e763eb709        ubuntu:latest       /bin/bash           19 seconds ago      Up 18 seconds                           mininet-h1  

You can pick up the experiment and play with it here and most likely improve it. If you add applications, for the above to still work, the container needs to be started as a shell so Mininet can configure the networking inside and send other commands. So any applications that need to start automatically must be started internally, possible using the supervisord process.

A quick note/disclaimer that this is a bit of a hack still. It isn’t considered stable by any means since this was just the beginning of the experiment, but I wanted to share my success so far. So use at your own risk.

If you are able to improve it, please ping me back as I’d love to see what you did.

This post ‘Docker Container as Mininet Host’ first appeared on https://techandtrains.com/.

 

Advertisements

MiniEdit 2.1.0.9

It’s been a little while since I published an update.  Here are a few enhancements and bug fixes.

  • Export Script fixes
    • Link class was not getting set properly for TCLink
    • Now also exports the sFlow and NetFlow configuration you setup in MiniEdit
  • Fix loading saved MiniEdit topologies JSON parsing problem.  Now parses properly back into Python
  • Improve importTopo to support TCLink. Note that MiniEdit does not support all the TCLink parameters at this time.
    sudo ./miniedit-2.1.0.9.py –custom mytopo.py –topo mytopo –link tc
  • Hosts and OF Switches now have text field for user defined shell command/script to run during node startup and shutdown.
    • Start and Stop commands are on the Host and OF switch properties.
    • The Start command is run after all nodes have started(net.start()).
    • The Stop command is the first thing run before the nodes are stopped (net.stop())

Download MiniEdit 2.1.0.9 here.

This will probably be the last release I make using the Mininet 2.1.0 code base.  My next release will be realigned to use the latest code from Mininet to pick up new features introduced after 2.1.0.

Hope everyone enjoys and is having a good summer so far.

This post ‘MiniEdit 2.1.0.9’ first appeared on https://techandtrains.com/.