3 # usage: sudo mn --controller=remote,ip=<controller_ip> --switch=ovsk,protocols=OpenFlow13
4 # --custom <path to customtopo.py> --topo ring ...
6 from mininet.topo import Topo
9 def add_hosts_to_switch(self, switch, hosts, start_host_suffix):
10 host_suffix = start_host_suffix
11 for _ in range(hosts):
12 host = self.addHost("h%s" % host_suffix)
13 self.addLink(switch, host)
18 def __init__(self, switches=3, hosts_per_switch=1, **opts):
19 Topo.__init__(self, **opts)
21 switch = self.addSwitch('s%s' % 1)
23 for i in range(1, switches):
25 add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
26 host_suffix += hosts_per_switch
28 new_switch = self.addSwitch('s%s' % (i + 1))
29 self.addLink(new_switch, switch)
32 add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
33 self.addLink(switch, first_switch)
37 def __init__(self, switches=3, hosts_per_switch=1, **opts):
38 Topo.__init__(self, **opts)
41 for i in range(switches):
42 new_switch = self.addSwitch('s%s' % (i + 1))
44 # add hosts to new switch
45 add_hosts_to_switch(self, new_switch, hosts_per_switch, host_suffix)
46 host_suffix += hosts_per_switch
48 for switch in created_switches:
49 self.addLink(new_switch, switch)
51 created_switches.append(new_switch)
54 topos = {'ring': RingTopo,