def post(self): args = Topology_request_parser.parse_args() switch.append(args) print args["switch_name"] exp.addSwitch(args["switch_name"], dpid=Tools.makeDPID(args["worker_id"])) return {"msg": "Switch added", "switch_data": args}
def createInternet(self, internetTopo='singleRouter'): routerIndex = 1 internetRouterList = [] if internetTopo == 'singleRouter': internetRouter = self.addSwitch('intR'+ str(routerIndex), dpid=Tools.makeDPID(routerIndex), **dict(listenPort=(10000+routerIndex-1))) internetRouterList.append(internetRouter) elif internetTopo == 'doubleRouter': internetRouter = self.addSwitch('intR'+ str(routerIndex), dpid=Tools.makeDPID(routerIndex), **dict(listenPort=(10000+routerIndex-1))) internetRouterList.append(internetRouter) routerIndex += 1 internetRouter = self.addSwitch('intR'+ str(routerIndex), dpid=Tools.makeDPID(routerIndex), **dict(listenPort=(10000+routerIndex-1))) internetRouterList.append(internetRouter) print("internet is like: %s" % internetRouterList) return internetRouterList
def _create_switch(experiment, switch): exp = experiments[experiment] switch_id = len(exp.switches) + 1 logger.debug( "creating switch for experiment={}, switch={}, workerId={}, dpid={}". format(experiment, switch['name'], switch['workerId'], switch_id)) sw = exp.addSwitch(switch['name'], dpid=Tools.makeDPID(switch_id), wid=switch['workerId']) return sw
def hello_world(): topo = Topo() topo.addHost("h1", cls=Docker, ip="10.0.0.251", dimage="ubuntu:trusty") topo.addHost("h2", cls=Docker, ip="10.0.0.252", dimage="ubuntu:trusty") topo.addSwitch("s1", dpid=Tools.makeDPID(1)) topo.addLink("h1", "s1") topo.addLink("h2", "s1") # start cluster cluster = maxinet.Cluster(minWorkers=1, maxWorkers=2) # start experiment with OVSSwitch on cluster exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch) exp.setup() return 'Welcome to our Library!'
def create_switch(self): switch_name = 's{}'.format(self._sid) host_name = 'h{}'.format(self._sid) self.expr.addSwitch(switch_name, dpid=Tools.makeDPID(self._sid), wid=self._wid) self.expr.addHost(host_name, ip=self._ip_addr, max=Tools.makeMAC(self._sid), pos=switch_name) self.expr.addLink(switch_name, host_name, autoconf=True) logging.info('Created switch {} ({}) on worker {}'.format( self._sid, self._ip_addr, self._wid + 1, )) time.sleep(2)
def createDC(self, numofDC, numSr, nodesPerSr, DCtopo, subnet, bwlimit, lat): srList = [] nodeList = [] DCIdx = numofDC + 1 srIdx = numofDC * numSr + 1 nodeIdx = numofDC * numSr * nodesPerSr + 1 #create service router for i in range(numSr): sr = self.addSwitch('sr'+ str(srIdx), dpid=Tools.makeDPID(srIdx), **dict(listenPort=(13000+srIdx-1))) print("create sr %s" % sr) # create nodes if i != 0: for j in range(nodesPerSr): h = self.addHost('h' + str(nodeIdx), mac=Tools.makeMAC(nodeIdx), ip=subnet + str(numofDC) + '.' +str(nodeIdx+100)+'/24', defaultRoute ='h'+str(nodeIdx)+'-eth0') print("create host %s" % h) nodeList.append(h) self.addLink(h, sr, bw=2*bwlimit, delay=str(lat)+'ms') print("add link between %s and %s" % (h, sr)) nodeIdx += 1 srIdx += 1 # if fullmesh, ovs should be defined to break loop!!! if DCtopo == 'fullmesh': # connect sr to previous srs for tempSrIdx in range(len(srList)): self.addLink(sr, srList[tempSrIdx], bw=bwlimit, delay=str(lat)+'ms') print("add link between %s and %s" % (sr, srList[tempSrIdx])) elif DCtopo == 'line': if len(srList) > 0: self.addLink(sr, srList[-1], bw=2*bwlimit, delay=str(lat)+'ms') print("add link between %s and %s" % (sr, srList[-1])) srList.append(sr) DC = [DCIdx, srList[0]] return DC, srList, nodeList
def create_topo(topo): t = Topo() i = 1 for host in topo['hosts']: logger.debug("add host {} to topo".format(host['name'])) t.addHost(host['name'], ip=Tools.makeIP(i), mac=Tools.makeMAC(i)) i += 1 i = 1 for switch in topo['switches']: logger.debug("add switch {} to topo".format(switch['name'])) t.addSwitch(switch['name'], dpid=Tools.makeDPID(i)) i += 1 i = 1 for link in topo['links']: logger.debug("add link from {} to {} to topo".format( link['node1']['name'], link['node2']['name'])) t.addLink(link['node1']['name'], link['node2']['name']) i += 1 return t
# create topology cluster = maxinet.Cluster(minWorkers=1, maxWorkers=1) 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.addHost("h3", ip=Tools.makeIP(3), mac=Tools.makeMAC(3)) topo.addHost("h4", ip=Tools.makeIP(4), mac=Tools.makeMAC(4)) topo.addHost("h5", ip=Tools.makeIP(5), mac=Tools.makeMAC(5)) topo.addHost("h6", ip=Tools.makeIP(6), mac=Tools.makeMAC(6)) topo.addHost("h7", ip=Tools.makeIP(7), mac=Tools.makeMAC(7)) topo.addHost("h8", ip=Tools.makeIP(8), mac=Tools.makeMAC(8)) topo.addSwitch("s1", dpid=Tools.makeDPID(1)) topo.addSwitch("s2", dpid=Tools.makeDPID(2)) topo.addSwitch("s3", dpid=Tools.makeDPID(3)) topo.addSwitch("s4", dpid=Tools.makeDPID(4)) topo.addSwitch("s5", dpid=Tools.makeDPID(5)) topo.addSwitch("s6", dpid=Tools.makeDPID(6)) topo.addSwitch("s7", dpid=Tools.makeDPID(7)) topo.addLink("h1", "s4") topo.addLink("h2", "s4") topo.addLink("h3", "s5") topo.addLink("h4", "s5") topo.addLink("h5", "s6") topo.addLink("h6", "s6") topo.addLink("h7", "s7") topo.addLink("h8", "s7")
from mininet.topo import Topo from mininet.node import OVSSwitch from MaxiNet.Frontend.container import Docker from MaxiNet.Frontend import maxinet from MaxiNet.tools import Tools topo = Topo() topo.addHost("h1", cls=Docker, ip="10.0.0.251", dimage="ubuntu:trusty") topo.addHost("h2", cls=Docker, ip="10.0.0.252", dimage="ubuntu:trusty") topo.addSwitch("s5", dpid=Tools.makeDPID(5)) ## set datapath id topo.addLink("h1", "s5") topo.addLink("h2", "s5") cluster = maxinet.Cluster(minWorkers=1, maxWorkers=2) # start experiment with OVSSwitch on cluster exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch) exp.setup() exp.get_node("h1").cmd("ping -c 1 10.0.0.252") exp.get_node("h2").cmd("ping -c 1 10.0.0.251")
# create topology cluster = maxinet.Cluster(minWorkers=2, maxWorkers=2) 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.addHost("h3", ip=Tools.makeIP(3), mac=Tools.makeMAC(3)) topo.addHost("h4", ip=Tools.makeIP(4), mac=Tools.makeMAC(4)) topo.addHost("h5", ip=Tools.makeIP(5), mac=Tools.makeMAC(5)) topo.addHost("h6", ip=Tools.makeIP(6), mac=Tools.makeMAC(6)) topo.addHost("h7", ip=Tools.makeIP(7), mac=Tools.makeMAC(7)) topo.addHost("h8", ip=Tools.makeIP(8), mac=Tools.makeMAC(8)) topo.addSwitch("s1", dpid=Tools.makeDPID(1), wid=0) topo.addSwitch("s2", dpid=Tools.makeDPID(2), wid=0) topo.addSwitch("s3", dpid=Tools.makeDPID(3), wid=1) topo.addSwitch("s4", dpid=Tools.makeDPID(4), wid=0) topo.addSwitch("s5", dpid=Tools.makeDPID(5), wid=0) topo.addSwitch("s6", dpid=Tools.makeDPID(6), wid=1) topo.addSwitch("s7", dpid=Tools.makeDPID(7), wid=1) topo.addLink("h1", "s4") topo.addLink("h2", "s4") topo.addLink("h3", "s5") topo.addLink("h4", "s5") topo.addLink("h5", "s6") topo.addLink("h6", "s6") topo.addLink("h7", "s7") topo.addLink("h8", "s7")
from mininet.node import OVSSwitch # messing with topo from mininet.topo import Topo from MaxiNet.tools import Tools topo = Topo() #empty topo cluster = maxinet.Cluster(minWorkers=5, maxWorkers=5) exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch) exp.setup() # SIGN print "adding switches on workers..." exp.addSwitch("s1", dpid=Tools.makeDPID(1), wid=0) exp.addSwitch("s2", dpid=Tools.makeDPID(2), wid=1) exp.addSwitch("s3", dpid=Tools.makeDPID(3), wid=2) exp.addSwitch("s4", dpid=Tools.makeDPID(4), wid=3) exp.addSwitch("s5", dpid=Tools.makeDPID(2), wid=4) print "adding 5 hosts..." exp.addHost("h1", ip=Tools.makeIP(1), max=Tools.makeMAC(1), pos="s1") exp.addHost("h2", ip=Tools.makeIP(2), max=Tools.makeMAC(2), pos="s2") exp.addHost("h3", ip=Tools.makeIP(3), max=Tools.makeMAC(3), pos="s3") exp.addHost("h4", ip=Tools.makeIP(4), max=Tools.makeMAC(4), pos="s4") exp.addHost("h5", ip=Tools.makeIP(5), max=Tools.makeMAC(5), pos="s5") print "add links between h_i and s_i" exp.addLink("s1", "h1", autoconf=True)
hnames = data["hosts"] hlen = len(hnames) cnt = 1 for x in range(0, hlen): tmp = str(hnames[x]) myglobalTopo.addHost(tmp, ip=Tools.makeIP(cnt), mac=Tools.makeMAC(cnt)) cnt = cnt + 1 my_swlist = [] for key, value in dict.items(data["switches"]): my_swlist.append(key) # Add to list of switches in topology cnt = 1 for value1, value2 in dict.items(data["switches"][key]): tmp = str(key) myglobalTopo.addSwitch(tmp, dpid=Tools.makeDPID(cnt)) cnt = cnt + 1 #hnames = data["hosts"] hnames = data["links"] hlen = len(hnames) for x in range(0, hlen): tmp = str(hnames[x][0]) tmp1 = str(hnames[x][1]) myglobalTopo.addLink(tmp, tmp1) print "Finished Loading Topology..." print "Creating Cluster ..." # start cluster
import time from mininet.topo import Topo from mininet.node import OVSSwitch from MaxiNet.Frontend import maxinet from 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.Cluster(minWorkers=2, maxWorkers=2) # start experiment with OVSSwitch on cluster exp = maxinet.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