Connecting two Mininet networks with GRE tunnel

Update1: I have a follow up post with some newer examples and extra which might help you debug any issues.

Update2: I have another post that show how to use Linux GRE tunnels instead of the OVS builtin GRE support.  Seems more stable.

——-

I was wondering if there was a way to connect two separate Mininet networks, then a little while ago, I came across a post about OpenVSwitch and using GRE tunnels.  So today, I thought I would try an experiment and try and connect two separate Mininet networks that are also running in separate VMs.

First, I started two Mininet networks in the separate VMs.

VM2(VirtualBox 192.168.56.102):

  • host2
  • switch2

I use the following mininet custom topology.

from mininet.topo import Topo

class MyTopo( Topo ):
    "Simple topology example."

    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts and switches
        leftHost = self.addHost( 'h2' )
        leftSwitch = self.addSwitch( 's2' )

        # Add links
        self.addLink( leftHost, leftSwitch )


topos = { 'mytopo': ( lambda: MyTopo() ) }

Start the network.

sudo mn –custom ./simple.py –topo mytopo –switch ovsk

VM1 (VirtualBox 192.168.56.101):

  • host1
  • switch1

I use the following mininet custom topology.

from mininet.topo import Topo

class MyTopo( Topo ):
    "Simple topology example."

    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts and switches
        h1 = self.addHost( 'h1' )
        s1 = self.addSwitch( 's1' )

        # Add links
        self.addLink( h1, s1 )


topos = { 'mytopo': ( lambda: MyTopo() ) }

Start the VM and have it point to the controller in the other VM.

sudo mn --custom ./simple.py --topo mytopo --switch ovsk --controller=remote,ip=192.168.56.102,port=6633

But before I can connect them, I have to change the default IP address that the hosts get automatically configured with so that I do not get two hosts with 10.0.0.1.  So I open an xterm in host2 and changed the IP address from the default assigned IP of 10.0.0.1 to 10.0.0.2.

ifconfig h2-eth0 inet 10.0.0.2

To make sure, I try and ping h1 from h2 from VM2 mininet CLI and it fails.

mininet> h2 ping -c 1 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
From 10.0.0.2 icmp_seq=1 Destination Host Unreachable

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

Now we setup the tunnel between the switches.

VM1:

sudo ovs-vsctl add-port s1 s1-gre1 -- set interface s1-gre1 type=gre options:remote_ip=192.168.56.102

VM2:

sudo ovs-vsctl add-port s2 s2-gre1 -- set interface s2-gre1 type=gre options:remote_ip=192.168.56.101

And then I try the test again.

mininet> h2 ping -c 1 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_req=1 ttl=64 time=0.044 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.044/0.044/0.044/0.000 ms

It was a fun test.  Hope someone finds this useful.  I hope to add the feature into my next version on MiniEdit.

Miniedit 2.0.0.5

With September rolling in, family life got pretty busy.  Thought I would put out a release with a few more updates.

  • Connect switch or host nodes to physical interface (like the example hwintf.py)
  • Add host cpu opts
    • cpu: desired overall system CPU fraction
      • scheduler: host, cfs or rt
    • cores: (real) core(s) this host can run on
  • Udpate load and save with above additions
  • Change load/save file format to Python dictionary

Download Miniedit 2.0.0.5 here.

If requested, I can make a script that will convert the pre-2.0.0.5 save file format to the new style.  Just leave a comment.  But hopefully the networks you have created are small enough to just recreate manually.