My Wiki!

Mininet tutorial

mytopo.py

#Four fully meshed switches in an "any-to-any" topology plus a host for each switch:
 
#   host --- switch --- switch --- host
#							  |		X		  |
#   host --- switch --- switch --- host
 
 
#Adding the 'topos' dict with a key/value pair to generate our newly defined
#topology enables one to pass in '--topo=mytopo' from the command line.
from mininet.net import Mininet
from mininet.node import OVSSwitch
from mininet.topo import LinearTopo
from mininet.log import output, warn
from mininet.node import Controller, OVSKernelSwitch, RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel, info
 
from random import randint
 
 
from mininet.topo import Topo
 
class MyTopo( Topo ):
    "Simple topology example."
 
    def __init__( self, enable_all = True ):
        "Create custom topo."
 
        # Add default members to class.
        super( MyTopo, self ).__init__()
 
	# Add switches
        leftSwitch = self.addSwitch('leftSwitch')
        rightSwitch = self.addSwitch('rightSwitch')
        topSwitch = self.addSwitch('topSwitch')
	# hosts
        rightHost = self.addHost('rightHost')
        leftHost = self.addHost('leftHost')
 
        # Add links
        self.addLink( leftHost, leftSwitch )
        self.addLink( rightHost, leftSwitch )
 
        self.addLink( leftSwitch, topSwitch )
        self.addLink( rightSwitch, topSwitch )
 
        # Consider all switches and hosts 'on'
        self.enable_all()
 
 
#topos = { 'mytopo': ( lambda: MyTopo() ) }
 mn --topo single,3 --mac --switch ovsk,protocols=OpenFlow13 --controller remote,ip=10.10.11.44,port=6653

Navigation