3 # usage: sudo mn --controller=remote,ip=<controller_ip> --switch=ovsk,protocols=OpenFlow13 --custom <path to customtopo.py> --topo ring ...
5 from mininet.topo import Topo
8 def add_hosts_to_switch(self, switch, hosts, start_host_suffix):
9 host_suffix = start_host_suffix
10 for _ in range(hosts):
11 host = self.addHost("h%s" % host_suffix)
12 self.addLink(switch, host)
17 def __init__(self, switches=3, hosts_per_switch=1, **opts):
18 Topo.__init__(self, **opts)
20 switch = self.addSwitch('s%s' % 1)
22 for i in range(1, switches):
24 add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
25 host_suffix += hosts_per_switch
27 new_switch = self.addSwitch('s%s' % (i + 1))
28 self.addLink(new_switch, switch)
31 add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
32 self.addLink(switch, first_switch)
36 def __init__(self, switches=3, hosts_per_switch=1, **opts):
37 Topo.__init__(self, **opts)
40 for i in range(switches):
41 new_switch = self.addSwitch('s%s' % (i + 1))
43 # add hosts to new switch
44 add_hosts_to_switch(self, new_switch, hosts_per_switch, host_suffix)
45 host_suffix += hosts_per_switch
47 for switch in created_switches:
48 self.addLink(new_switch, switch)
50 created_switches.append(new_switch)
53 topos = {'ring': RingTopo,