def addLink(self, node1, node2, port1=None, port2=None, key=None, **opts): if isinstance(node1, VirtualInstance): node1 = node1.getSwitch() if isinstance(node2, VirtualInstance): node2 = node2.getSwitch() return Topo.addLink(self, node1, node2, port1, port2, key, **opts)
def _convert_to_plain_topo(self, topo): """Convert topo to mininet.topo.Topo instance. This helper function allows the user to use topologys which are not direct instances of mininet.topo.Topo in MaxiNet. If the topology was not converted to a Topo instance the transfer via pyro most likely fails as the original class might not be available at the pyro remote. Args: topo: Instance which fullfills the interface of mininet.topo.Topo. Returns: Instance of mininet.topo.Topo, """ r = Topo() for node in topo.nodes(): r.addNode(node, **topo.nodeInfo(node)) for edge in topo.links(): r.addLink(**topo.linkInfo(edge[0], edge[1])) return r
# UserSwitch. import time from src.mininet.topo import Topo from src.mininet.node import OVSSwitch from src.maxinet.Frontend import maxinet_main from src.maxinet.tools import Tools # create topology topo = Topo() topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1)) topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2)) topo.addSwitch("s1", dpid=Tools.makeDPID(1)) topo.addLink("h1", "s1") topo.addLink("h2", "s1") # start cluster cluster = maxinet_main.Cluster(minWorkers=2, maxWorkers=2) # start experiment with OVSSwitch on cluster exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch) exp.setup() print "waiting 5 seconds for routing algorithms on the controller to converge" time.sleep(5) print "pinging h2 from h1 to check network connectivity..." print exp.get_node("h1").cmd("ping -c 5 10.0.0.2") # show network connectivity
import subprocess from src.mininet.node import OVSSwitch from src.mininet.topo import Topo from src.maxinet.Frontend import maxinet_main from src.maxinet.tools import Tools topo = Topo() topo.addSwitch("s1") topo.addSwitch("s2") topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1)) topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2)) topo.addLink("h1", "s1") topo.addLink("s1", "s2") topo.addLink("h2", "s2") cluster = maxinet_main.Cluster() # we need to add the root node after the simulation has started as we do # not know which worker id the frontend machine will get. Therefore we # need a dynamic topology which is only supported in openvswitch exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch) exp.setup() # Start ssh servers h1 = exp.get("h1") h1.cmd("echo \"Welcome to %s at %s\n\" > /tmp/%s.banner" % (h1.name, h1.IP(), h1.name))
"FOGS": len(FOG_NODES), "SENSORS_PER_FOG": SENSORS_PER_FOG } topo = Topo() switch_idx = 1 info('**** Adding Manager\n') mngr = topo.addDocker('m1', ip=MANAGER_ADDR.split(':')[0], dimage="manager:latest", environment=MANAGER_ENV) sw_mngr = topo.addSwitch('s%d' % switch_idx) switch_idx += 1 topo.addLink(mngr, sw_mngr) info('*** Adding docker containers\n') info('*** Cloud\n') c1 = topo.addDocker('c1', ip='10.0.0.2', dimage="cloud:latest", environment={"MANAGER_ADDR": MANAGER_ADDR}) sw_cloud = topo.addSwitch('s%d' % switch_idx) switch_idx += 1 topo.addLink(sw_cloud, c1) topo.addLink(sw_mngr, sw_cloud) info('*** Fogs\n') for idx, f_name in enumerate(FOG_NODES): f = topo.addDocker(f_name, ip='10.0.1.{}'.format(idx + 1), dimage="fog:latest",