def emptyNet(): net = Mininet(controller=RemoteController, switch=OVSKernelSwitch) c1 = net.addController('c1', controller=RemoteController, ip="192.168.200.22", port=6633) c2 = net.addController('c2', controller=RemoteController, ip="127.0.0.1", port=6633) h1 = net.addHost( 'h1', ip='10.0.0.1' ) h2 = net.addHost( 'h2', ip='10.0.0.2' ) h3 = net.addHost( 'h3', ip='10.0.0.3' ) h4 = net.addHost( 'h4', ip='10.0.0.4' ) s1 = net.addSwitch( 's1' ) s2 = net.addSwitch( 's2' ) s1.linkTo( h1 ) s1.linkTo( h2 ) s1.linkTo( s2 ) s2.linkTo( h3 ) s2.linkTo( h4 ) net.build() c1.start() c2.start() s1.start([c1,c2]) s2.start([c1,c2]) net.start() net.staticArp() CLI( net ) net.stop()
def emptyNet(): net = Mininet(controller = RemoteController, switch = OVSKernelSwitch) #add Controller c1 = net.addController('c1', controller = RemoteController, ip = "127.0.0.1", port = 6633) #tt #add Host h1 = net.addHost('h1', ip = '10.0.0.1', mac = '00:00:00:00:00:01') h2 = net.addHost('h2', ip = '10.0.0.2', mac = '00:00:00:00:00:02') #h3 = net.addHost('h3', ip = '10.0.0.3') #add Switch s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') #add Link s1.linkTo(h1) s2.linkTo(h2) s1.linkTo(s2) #s1.linkTo(h3) net.build() c1.start() s1.start([c1]) s2.start([c1]) net.start() net.staticArp() print s1.cmd('ovs-vsctl set Bridge s1 protocols=OpenFlow13') print s2.cmd('ovs-vsctl set Bridge s2 protocols=OpenFlow13') CLI(net) net.stop()
def main(): g = read_topology() switch_data = switch_data_generator(g) topo = create_network(switch_data) mininet_controller = Ryu('ruy_controller', 'RuyController.py') switch = partial(OVSSwitch, protocols='OpenFlow13') net = Mininet(topo=topo, switch=switch, build=True, controller=mininet_controller) net.staticArp() config_file_path = 'config' pickle.dump(switch_data, open(config_file_path, 'w')) net.start() sleep(1.5) host = net.hosts[0] latency = defaultdict(dict) x = [] y = [] for dst in net.hosts: if dst != host: s = host.cmd('ping -c 1 %s' % dst.IP()) time = s.split()[13].split('=')[1] start = host.name[2:] end = dst.name[2:] x.append(end) y.append(time) latency[start][end] = time print(start + ' -> ' + end + ' time : ' + time + ' ms') net.stop() data = [go.Bar(x=x, y=y)] py.offline.plot(data, filename='basic-bar.html')
def run(): net = Mininet(autoSetMacs=True, cleanup=True) # Create the network switches s1, s2, s3 = [net.addSwitch(s) for s in 's1', 's2', 's3'] h1, h2, h3, h4, h5, h6 = [net.addHost(h) for h in 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'] # Tell mininet to use a remote controller located at 127.0.0.1:6653 c1 = RemoteController('c1', ip='127.0.0.1', port=6633) net.addController(c1) # Add link between switches. Each link has a delay of 5ms and 10Mbps bandwidth net.addLink(s1, s2) net.addLink(s2, s3) net.addLink(s3, s1) # Add link between a host and a switch for (h, s) in [(h1, s1), (h3, s2), (h5, s3)]: net.addLink(h, s) for (h, s) in [(h2, s1), (h4, s2), (h6, s3)]: net.addLink(h, s) # Start each switch and assign it to the remote controller for s in [s1, s2, s3]: s.start([c1]) net.staticArp() net.start() CLI(net)
def subnet1(): net = Mininet(controller=RemoteController, switch=OVSKernelSwitch) c1 = net.addController('c1', controller=RemoteController, ip="10.0.0.1", port=6633) c4 = net.addController('c4', controller=RemoteController, ip="10.0.0.4", port=6633) h31 = net.addHost('h11', ip='10.3.1.1') h32 = net.addHost('h12', ip='10.3.1.2') s31.addSwitch('s31') s31.linkTo(h31) s31.linkTo(h32) net.build() c1.start() c4.start() s31.start([c4, c1]) net.start() net.staticArp() CLI(net) net.stop()
def myNet(): MultiSwitch13 = partial( MultiSwitch, protocols='OpenFlow13' ) #tree_topo = TreeTopo(depth=3,fanout=2) tree_topo = SingleSwitchTopo(n=14) net = Mininet(controller=RemoteController, topo=tree_topo, switch=MultiSwitch13, build=False, autoSetMacs=True) info( '*** Adding controllers\n') #c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1", port=6633) c1 = net.addController('c1', controller=RemoteController, ip="192.168.1.1", port=6633) c2 = net.addController('c2', controller=RemoteController, ip="192.168.1.2", port=6633) c3 = net.addController('c3', controller=RemoteController, ip="192.168.1.3", port=6633) # info( '*** Add hosts\n') # h1 = net.addHost( 'h1', ip='10.0.0.1' ) # h2 = net.addHost( 'h2', ip='10.0.0.2' ) # h3 = net.addHost( 'h3', ip='10.0.0.3' ) # h4 = net.addHost( 'h4', ip='10.0.0.4' ) # info( '*** Add switches\n') # s1 = net.addSwitch( 's1', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s2 = net.addSwitch( 's2', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s3 = net.addSwitch( 's3', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s4 = net.addSwitch( 's4', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # info( '*** Add links\n') # s1.linkTo( h1 ) # s1.linkTo( s2 ) # s2.linkTo( h2 ) # s2.linkTo( s3 ) # s3.linkTo( h3 ) # s3.linkTo( s4 ) # s4.linkTo( h4 ) info( '*** Starting network\n') net.build() info( '*** Starting controllers\n') c1.start() c2.start() c3.start() # info( '*** Starting switches\n') # s1.start([c1,c2,c3]) # s2.start([c1,c2,c3]) # s3.start([c1,c2,c3]) # s4.start([c1,c2,c3]) net.start() net.staticArp() # i = 0; # while i < 10: # h1, h2 = random.choice(net.hosts), random.choice(net.hosts) # print h1.IP(), "-->", h2.IP() # sent, received, rttmin, rttavg, rttmax, rttdev = ping(h1, h2) # print received,"/",sent # i = i + 1 # sleep(1) CLI( net ) net.stop()
def main(): topo = PyRouterTopo(args) net = Mininet(topo=topo, link=TCLink, autoSetMacs=True, cleanup=True, listenPort=10001, controller=RemoteController) mb = net.get('mb') mb.setIP('0.0.0.0') # don't set an IP address on middlebox net.staticArp() start_webservers(net) net.interact()
def runMultiLink(): "Create and run multiple link network" topo = simpleMultiLinkTopo( n=5 ) net = Mininet( topo=topo, switch=OVSSwitch, controller=None, autoSetMacs=True, autoStaticArp=True ) net.addController(RemoteController( 'c0', ip='192.168.12.50' )) net.staticArp() net.start() CLI( net ) net.stop()
def main(): topo = PyRouterTopo(args) net = Mininet(topo=topo, link=TCLink, cleanup=True, autoSetMacs=True, controller=None) setup_addressing(net) net.staticArp() net.interact()
def start(controllers=[{'ip': '127.0.0.1', 'port': 6633}]): # Set up logging lg.setLogLevel('info') lg.setLogLevel('output') net = Mininet(switch=OVSSwitch, controller=None, autoStaticArp=True, listenPort=6634) for indx, ctl in enumerate(controllers): print("Adding controller", (1 + indx)) net.addController(('c%d' % indx), controller=RemoteController, ip=ctl['ip'], port=ctl['port']) # Add hosts h1 = net.addHost('h1') h2 = net.addHost('h2') #physical_intf = 'eth1' #Add switch that accepts only OpenFlow 1.0 s1 = net.addSwitch('s1', dpid='00:00:00:00:00:00:00:01', protocols='OpenFlow10') #Will accept both OpenFlow 1.0 and 1.3 #s2 = net.addSwitch('s2', dpid='00:00:00:00:00:00:00:02', protocols='OpenFlow10,OpenFlow13') #Will accept all protocols support by openvswitch #s3 = net.addSwitch('s2', dpid='00:00:00:00:00:00:00:02') # Connect physical interface #print "Adding physical hosts to mininet network..." #_intf1 = Intf( physical_intf, node=s1, port=1 ) net.addLink(h1, s1) net.addLink(h2, s1) # Start the network and prime other ARP caches net.start() net.staticArp() # Enter CLI mode output("Network ready\n") output("Getting results...") time.sleep(60) process_results() #output("Press Ctrl-d or type exit to quit\n") net.stop()
def __init__(self): info("Criando uma rede personalizada") # Initialize topology Topo.__init__(self) info("*** Using Openflow 1.3 \n") protocols = "OpenFlow13" # inicia a criação da rede net = Mininet(switch=OVSSwitch) info("*** Creating (reference) controllers\n") # cria o controlador que será utilizado na rede c1 = net.addController('c1', controller=RemoteController, ip='127.0.0.1', port=6633) info("*** Criando os switches\n") s1 = net.addSwitch('s1', protocols=protocols) s2 = net.addSwitch('s2', protocols=protocols) info("*** Criando os hosts\n") # cria os hosts 1 e 2 h1 = net.addHost(name='h1', ip='10.0.0.1', mac='00:00:00:00:00:01', defaultHost='') h2 = net.addHost(name='h2', ip='10.0.0.2', mac='00:00:00:00:00:02', defaultHost='') info("*** Creating links\n") # adiciona a conexao entre o host 1 e o switch 1 net.addLink(h1, s1) # adiciona a conexao entre o switch 1 e o switch 2 net.addLink(s1, s2) # adiciona a conexao entre o host 2 e o switch 2 net.addLink(h2, s2) info("*** Criando a rede\n") net.build() # inicia o controlador da rede s1.start([c1]) # incializa a rede net.start() net.staticArp() # inicia o CLI do Mininet CLI(net) net.stop()
def start(controllers=[{'ip':'127.0.0.1', 'port': 6633}]): # Set up logging lg.setLogLevel('info') lg.setLogLevel('output') net = Mininet(switch=OVSSwitch, controller=None, autoStaticArp=True, listenPort=6634) for indx, ctl in enumerate(controllers): print("Adding controller", (1+indx)) net.addController(('c%d' % indx), controller=RemoteController, ip=ctl['ip'], port=ctl['port']) # Add hosts h1 = net.addHost('h1') h2 = net.addHost('h2') #physical_intf = 'eth1' #Add switch that accepts only OpenFlow 1.0 s1 = net.addSwitch('s1', dpid='00:00:00:00:00:00:00:01', protocols='OpenFlow10') #Will accept both OpenFlow 1.0 and 1.3 #s2 = net.addSwitch('s2', dpid='00:00:00:00:00:00:00:02', protocols='OpenFlow10,OpenFlow13') #Will accept all protocols support by openvswitch #s3 = net.addSwitch('s2', dpid='00:00:00:00:00:00:00:02') # Connect physical interface #print "Adding physical hosts to mininet network..." #_intf1 = Intf( physical_intf, node=s1, port=1 ) net.addLink(h1, s1) net.addLink(h2, s1) # Start the network and prime other ARP caches net.start() net.staticArp() # Enter CLI mode output("Network ready\n") output("Getting results...") time.sleep(60) process_results() #output("Press Ctrl-d or type exit to quit\n") net.stop()
def main(): setLogLevel('info') tp = MyTopo() net = Mininet(tp, controller=RemoteController(ip='127.0.0.1', name='RyuController'), autoStaticArp=True) net.addNAT().configDefault() net.start() dumpNodeConnections(net.hosts) net.staticArp() # Not needed if autoStaticArp=True CLI(net) net.stop()
def emptyNet(): net = Mininet(controller=RemoteController, switch=OVSKernelSwitch, build=False, listenPort=6633) c1 = net.addController('c1', controller=RemoteController, defaultIP="127.0.0.1", port=6633) s1 = net.addSwitch( 's1', protocols = 'OpenFlow13' ) s2 = net.addSwitch( 's2', protocols = 'OpenFlow13' ) s3 = net.addSwitch( 's3', protocols = 'OpenFlow13' ) s4 = net.addSwitch( 's4', protocols = 'OpenFlow13' ) h1 = net.addHost( 'h1', ip='10.0.0.1/24', mac = '00:00:00:00:00:01' ) h2 = net.addHost( 'h2', ip='30.0.0.42/24', mac = '00:00:00:00:00:42' ) l1 = net.addHost( 'l1', ip='10.0.0.11/24', mac = '00:00:00:00:00:11' ) l2 = net.addHost( 'l2', ip='20.0.0.41/24', mac = '00:00:00:00:00:41' ) n1 = net.addHost( 'n1', ip='20.0.0.21/24', mac = '00:00:00:00:00:21' ) n2 = net.addHost( 'n2', ip='20.0.0.31/24', mac = '00:00:00:00:00:31' ) s1_h1 = net.addLink(s1,h1) s1_l1 = net.addLink(s1,l1) s1_l12 = net.addLink(s1,l1) s1_s3 = net.addLink(s1,s3) s1_s4 = net.addLink(s1,s4) s4_n2 = net.addLink(s4,n2) s4_n22 = net.addLink(s4,n2) s4_s2 = net.addLink(s4,s2) s3_n1 = net.addLink(s3,n1) s3_n12 = net.addLink(s3,n1) s3_s2 = net.addLink(s3,s2) s2_l2 = net.addLink(s2,l2) s2_l22 = net.addLink(s2,l2) s2_h2 = net.addLink(s2,h2) net.build() c1.start() s1.start([c1]) s2.start([c1]) s3.start([c1]) s4.start([c1]) net.start() net.staticArp() CLI( net ) net.stop()
class MininetRunner: def __init__(self, topo_file): topo = NetworkTopo(topo_file) self.net = Mininet(topo=topo, controller=None) self.net.addController(controller=P4Controller, switches=self.net.switches) self.start() time.sleep(1) """ Execute any commands provided in the topology.json file on each Mininet host """ for host_name, host_info in topo.topo['hosts'].items(): h = self.net.get(host_name) if "commands" in host_info: for cmd in host_info["commands"]: h.cmd(cmd) self.net.staticArp() CLI(self.net) # stop right after the CLI is exited self.net.stop() def start(self): "Start controller and switches." if not self.net.built: self.net.build() info('*** Starting %s switches\n' % len(self.net.switches)) for switch in self.net.switches: info(switch.name + ' ') switch.start(self.net.controllers) started = {} for swclass, switches in groupby( sorted(self.net.switches, key=lambda s: str(type(s))), type): switches = tuple(switches) if hasattr(swclass, 'batchStartup'): success = swclass.batchStartup(switches) started.update({s: s for s in success}) info('\n') info('*** Starting controller\n') for controller in self.net.controllers: info(controller.name + ' ') controller.start() info('\n') if self.net.waitConn: self.net.waitConnected()
def simpleTest(): "Create and test a simple network" topo = RouterStarTopo() net = Mininet(topo) net.staticArp() net.start() #topo.setIp(net) #net.get('h2').cmd('bash proxy/set_nat.sh') topo.disable_offload(net) topo.set_macs(net) print "Dumping host connections" dumpNodeConnections(net.hosts) CLI(net) print "Testing network connectivity" net.stop()
def run_test(self, params): """ Run test using provided scenario.\n Creates Mininet network and pushes traffic between hosts.\n :param scenario: :param tool: """ self.cleanup_mn_env() # load topo from XML and parse it to Mininet topology abstraction topo = TestTopo(SCENARIOS_DIR + params.scenario + ".xml") # check if params contain remote controller IP and port, if not: use default OVS controller # TODO: OVSController is not working yet if params.controller_ip is not None and params.controller_port is not None: ctrl = partial(RemoteController, ip=params.controller_ip, port=params.controller_port) else: ctrl = partial(OVSController) self.logger.info('Running default OVS Controller..') # create Mininet network net = Mininet(topo=topo, controller=ctrl, link=TCLink) # host=CPULimitedHost) self.logger.info("Starting network..") net.start() # no need to run ARP broadcast in network net.staticArp() # net.pingAll() logs_dir = util.prepare_logs_dir(params.scenario) retcode = self.push_traffic(net, logs_dir, params.iterations) # CLI ( net ) self.logger.info("Stopping network..") net.stop() self.clear_test(retcode, logs_dir) return retcode
def monitorTest(): topo = SDNProjectTopo() net = Mininet(topo=topo, link=TCLink, controller=partial(RemoteController, ip='127.0.0.1', port=6633)) hosts = net.hosts net.start() net.staticArp() dumpNodeConnections(net.hosts) net.pingAll() # for h in hosts: # print h.cmd('cat ./con_python/output_txt/output_link_length.txt') # print h.cmd('pwd') # print h.cmd('iperf -s &') CLI(net) net.stop()
def main(): num_hosts = int(args.num_hosts) result = os.system( "p4c --target bmv2 --arch v1model --p4runtime-files firmeware.p4info.txt " + args.p4_file) p4_file = args.p4_file.split('/')[-1] json_file = p4_file.split('.')[0] + ".json" # json_file = "/home/hpdn/Downloads/p4-researching-master/src/fundamental/learning-switch/basic_tutorial_switch.json" topo = SingleSwitchTopo("simple_switch_grpc", json_file, num_hosts) net = Mininet(topo=topo, host=P4Host, switch=P4GrpcSwitch, link=TCLink, controller=None) net.start() interfaces = get_all_virtual_interfaces() for i in interfaces: if i != "": os.system("ip link set {} mtu 1600 > /dev/null".format(i)) os.system( 'ethtool --offload {} rx off tx off > /dev/null'.format(i)) net.staticArp() if result != 0: print "Error while compiling!" exit() switch_running = "simple_switch_grpc" in (p.name() for p in psutil.process_iter()) if switch_running == False: print "The switch didnt start correctly! Check the path to your P4 file!!" exit() print "Starting mininet!" CLI(net)
def start(ip="127.0.0.1",port="6633",app="Netgaze"): net = Mininet(switch=ClickKernelSwitch) net.addController('c0') h1 = net.addHost('h1', ip='144.0.3.0') h2 = net.addHost('h2', ip='132.0.2.0') sw = net.addSwitch("click") sw.linkAs(h1, "h1") sw.linkAs(h2, "h2") net.start() net.staticArp() output("Network ready\n") time.sleep(3) # Enter CLI mode output("Press Ctrl-d or type exit to quit\n") lg.setLogLevel('info') CLI(net) lg.setLogLevel('output') net.stop()
def start_mininet(graph, n_ctrl): #Initialisation setLogLevel('info') net = Mininet() h = dict() nodes = list() s = dict() c = list() #Creating and adding controllers for i in range(1, n_ctrl+1): c.append(net.addController('c'+str(i), controller=RemoteController, ip="172.17.0." + str(i+1), port=6653)) #Creating hosts and switches and connecting one host with each switch for node in graph.nodes(): h[node] = net.addHost('h' + str(node)) nodes.append(h[node]) s[node] = net.addSwitch('s' + str(node)) s[node].linkTo(h[node]) #Creating links for e in graph.edges(): s[e[0]].linkTo(s[e[1]]) net.build() #Starting controllers for ctrl in c: ctrl.start() #Assigning controllers to switches for node in graph.nodes(): s[node].start(c) net.start() net.staticArp() CLI(net)
def simpleTest(): topo = LinearTopo(k=4) topo.createTopo() topo.createLink() #use=LinearTopo.DPIDS(4) net = Mininet(topo, link=TCLink, controller=None, autoSetMacs=True, autoStaticArp=True) ryu_ctrl = RemoteController(name='c1', ip='127.0.0.1', port=6633, protocols="OpenFlow13") net.addController(ryu_ctrl) print "addcontroller" #net.get('ES1').start([ryu_ctrl]) net.start() net.staticArp() #net.cli() dumpNodeConnections(net.hosts) CLI(net) net.stop()
def subnet1(): net = Mininet(controller=RemoteController, switch=OVSKernelSwitch) c1 = net.addController('c1', controller=RemoteController, ip="10.0.0.1", port=6633) c3 = net.addController('c3', controller=RemoteController, ip="10.0.0.3", port=6633) h21 = net.addHost('h11', ip='10.2.1.1') h22 = net.addHost('h12', ip='10.2.1.2') s21.addSwitch('s21') s21.linkTo(h21) s21.linkTo(h22) net.build() c1.start() c3.start() s21.start([c3,c1]) net.start() net.staticArp() CLI(net) net.stop()
def run(): topo = FatTree(6) net = Mininet(topo=topo, link=TCLink, controller=None) net.start() # sleep(5) # Mininet API for the experiment # sysctl -w net.ipv4.neigh.default.gc_thresh1=4098 # increase the arp table cache print("ARP TABLES") net.staticArp() ft = FatTreeConverted.from_mininet(net) rules, s_d = ft.getRules() ovs_rules = ft.getOVSRules(rules=rules) for switch in net.switches: print(switch.name) rl = ovs_rules[switch.name] for r in rl: cmd = "bash -c 'ovs-ofctl add-flow {} {}'".format(switch.name, r) print(switch.name, cmd) switch.cmd(cmd) print() print(ovs_rules) # Run the CLI for s, d in s_d: print(s, d) ploss = net.ping([net.getNodeByName(s), net.getNodeByName(d)]) if ploss > 0: print(s, d, "PACKET LOSS!") break print(ploss) results = iperf(net, s_d) print(results) CLI(net) net.stop()
def subnet1(): net = Mininet(controller=RemoteController, switch=OVSKernelSwitch) c1 = net.addController('c1', controller=RemoteController, ip="10.0.0.1", port=6633) c2 = net.addController('c2', controller=RemoteController, ip="10.0.0.2", port=6633) h11 = net.addHost('h11', ip='10.1.1.1') h12 = net.addHost('h12', ip='10.1.1.2') h13 = net.addHost('h13', ip='10.1.2.3') h14 = net.addHost('h14', ip='10.1.2.4') s11.addSwitch('s11') s12.addSwitch('s12') s11.linkTo(h11) s11.linkTo(h12) s11.linkTo(s12) s12.linkTo(h13) s12.lonkTo(h14) net.build() c1.start() c2.start() s11.start([c2, c1]) s12.start([c2, c2]) net.start() net.staticArp() CLI(net) net.stop()
def test_wget(ip="127.0.0.1",port="6633"): net = Mininet(switch=ClickKernelSwitch, controller=lambda n: RemoteController(n, defaultIP=ip, port=int(port))) net.addController('c0') h1 = net.addHost('h1', ip='144.0.3.0') h2 = net.addHost('h2', ip='132.0.2.0') sw = net.addSwitch("click") sw.linkAs(h1, "h1") sw.linkAs(h2, "h2") net.start() net.staticArp() output("Network ready\n") time.sleep(3) # Run a simple file transfer test output(h1.cmd("./serve.sh")) output(h2.cmd("wget 144.0.3.0")) time.sleep(1) net.stop()
def exampleNet(): IP_PREFIX='192.168.137.' MININET_VM_IP=IP_PREFIX+'110' CONTROLLER_IP=IP_PREFIX+'110' #MANAGER_IP=IP_PREFIX+'100' H1_VM_IP=IP_PREFIX+'10' H2_VM_IP=IP_PREFIX+'20' H3_VM_IP=IP_PREFIX+'30' #intfName = 'eth1' #_intf = Intf( intfName, node=s1 ) net = Mininet( topo=None, controller=None, build=False) net.addController( 'c0', controller=RemoteController, ip=CONTROLLER_IP, port=6633 ) # Add hosts and switches h1 = net.addHost( 'h1', ip='10.0.0.1', mac='00:00:00:00:00:01') h2 = net.addHost( 'h2', ip='10.0.0.2', mac='00:00:00:00:00:02' ) h3 = net.addHost( 'h3', ip='10.0.0.3', mac='00:00:00:00:00:03' ) h4 = net.addHost( 'h4', ip='10.0.0.4' ) h5 = net.addHost( 'h5', ip='10.0.0.5' ) h6 = net.addHost( 'h6', ip='10.0.0.6' ) s1 = net.addSwitch( 's1', protocols='OpenFlow10' ) s2 = net.addSwitch( 's2', protocols='OpenFlow10' ) s3 = net.addSwitch( 's3', protocols='OpenFlow10' ) s4 = net.addSwitch( 's4', protocols='OpenFlow10' ) s5 = net.addSwitch( 's5', protocols='OpenFlow10' ) s6 = net.addSwitch( 's6', protocols='OpenFlow10' ) s7 = net.addSwitch( 's7', protocols='OpenFlow10' ) # Add links net.addLink( s1, s5 ) net.addLink( s1, s2 ) net.addLink( s2, s4 ) net.addLink( s2, s3 ) net.addLink( s2, s7 ) net.addLink( s3, s4 ) net.addLink( s3, s6 ) net.addLink( s4, s5 ) net.addLink( s4, s7 ) net.addLink( s6, s7 ) net.addLink( h1, s1 ) net.addLink( h2, s2 ) net.addLink( h3, s4 ) net.addLink( h4, s4 ) net.addLink( h5, s2 ) net.addLink( h6, s3 ) ## Configure GRE tunnel ## # Delete old tunnel if still exists s1.cmd('ip tun del s1-gre1') s2.cmd('ip tun del s2-gre1') s4.cmd('ip tun del s4-gre1') # Create GRE tunnels print "Creating GRE tunnels..." s1.cmd('ip li ad s1-gre1 type gretap local '+MININET_VM_IP+' remote '+H1_VM_IP+' ttl 64') s1.cmd('ip li se dev s1-gre1 up') Intf( 's1-gre1', node=s1 ) s2.cmd('ip li ad s2-gre1 type gretap local '+MININET_VM_IP+' remote '+H2_VM_IP+' ttl 64') s2.cmd('ip li se dev s2-gre1 up') Intf( 's2-gre1', node=s2 ) s4.cmd('ip li ad s4-gre1 type gretap local '+MININET_VM_IP+' remote '+H3_VM_IP+' ttl 64') s4.cmd('ip li se dev s4-gre1 up') Intf( 's4-gre1', node=s4 ) net.start() print "Configuring ARP entries..." net.staticArp() s1.cmd('sudo ovs-ofctl add-flow s1 priority=65535,tcp,in_port=3,nw_src=10.0.0.0/8,nw_dst=10.0.0.0/8,tp_dst=80,actions=output:4') s4.cmd('sudo ovs-ofctl add-flow s4 priority=65535,tcp,in_port=5,actions=output:3') CLI( net ) net.stop()
class GenericMiddleBoxTopology(object): """ This class creates a basic experminet topology containing traffic sources and targets as well as intermediate middlebox machines. The number of hosts per type can be defined in the constructor. Management network: 10.0.0.0/8 User data network: 20.0.0.0/8 client1 -- -- mb1 -- -- target1 | | | | | -- s1 -- s3 -- s2 -- | | | | | client2 -- -- mb2 -- -- target2 """ def __init__(self, source_instances=2, target_instances=1, mbox_instances=2): self.source_instances = source_instances self.target_instances = target_instances self.mbox_instances = mbox_instances # bring up Mininet self.net = Mininet( host=CPULimitedHost, link=TCLink, autoSetMacs=True) # topology elements self.controllers = [] self.switches = [] self.middlebox_hosts = [] self.source_hosts = [] self.target_hosts = [] # single pointers to nw components self.control_switch = None self.source_switch = None self.target_switch = None self.default_controller = None self.data_controller = None # do network setup self.setup_controllers() self.setup_switches() self.setup_hosts() def start_network(self): # run the network self.net.staticArp() #self.net.start() # build network self.net.build() # start controllers self.data_controller.start() self.default_controller.start() # start switches and assign controller self.control_switch.start([self.default_controller]) self.source_switch.start([self.data_controller]) self.target_switch.start([self.data_controller]) # additional start tasks self.config_middlebox_hosts() self.run_middlebox_hosts() self.run_target_hosts() time.sleep(5) # give servers some time to come up self.run_source_hosts() def test_network(self): # debugging print "### Dumping host connections" dumpNodeConnections(self.net.hosts) if PARAMS.duration < 0: # only test if we are in CLI mode (save time) print "### Testing middlebox replica connectivity" if self.net.ping(hosts=self.middlebox_hosts) < 0.1: print "### OK" def enter_cli(self): # enter user interface CLI(self.net) self.net.stop() def setup_controllers(self): # default controller for managemen switch c1 = self.net.addController("c1", port=6634) self.default_controller = c1 self.controllers.append(c1) # custom controller for user traffic management c2 = self.net.addController( "c2", controller=RemoteController, ip='127.0.0.1', port=6633) self.data_controller = c2 self.controllers.append(c2) def setup_switches(self): # management switch s = self.net.addSwitch("s1") self.switches.append(s) self.control_switch = s # source switch s = self.net.addSwitch("s2") self.switches.append(s) self.source_switch = s # target switch s = self.net.addSwitch("s3") self.switches.append(s) self.target_switch = s def setup_hosts(self): """ basic host setup """ global PARAMS # middlebox hosts for i in range(0, self.mbox_instances): # we assume a max of 16 MBs in all experiments # all these MBs together use max 50% of CPU mb = self.net.addHost( "mb%d" % (i + 1), cpu=float(PARAMS.cpumb)/float(PARAMS.maxnumbermb)) self.middlebox_hosts.append(mb) # management plane links cdl = int(PARAMS.controldelay) if cdl > 0: self.net.addLink(mb, self.control_switch, delay="%dms" % cdl, bw=1000) else: self.net.addLink(mb, self.control_switch, bw=1000) # data plane links self.net.addLink(mb, self.source_switch, bw=1000) self.net.addLink(mb, self.target_switch, bw=1000) # source hosts for i in range(0, self.source_instances): sh = self.net.addHost( "source%d" % (i + 1), ip="20.0.0.%d" % (i + 1), cpu=float(PARAMS.cpusource)) self.source_hosts.append(sh) self.net.addLink(sh, self.source_switch, bw=1000) # target hosts for i in range(0, self.target_instances): th = self.net.addHost( "target%d" % (i + 1), ip="20.0.1.%d" % (i + 1), cpu=float(PARAMS.cputarget)) self.target_hosts.append(th) self.net.addLink(th, self.target_switch, bw=1000) def config_middlebox_hosts(self): """ additional runtime configurations of MB hosts """ for mb in self.middlebox_hosts: config_bridge(mb) def run_middlebox_hosts(self): """ run NF functionality inside MB hosts """ pass def run_target_hosts(self): """ run server functionality in target hosts """ for th in self.target_hosts: # start target.py on each target machine p = USER_BASE_PORT for sh in self.source_hosts: # start target.py for each source host once on each target host #th.cmd("./target.py %d > log/target_%s_%s.log 2>&1 &" # % (p, th.name, sh.name)) # one port for each source th.cmd("iperf -s -p %d > log/target_%s_%s.log 2>&1 &" % (p, th.name, sh.name)) # one port for each source p += 1 def run_source_hosts(self): """ run client functionality in source hosts """ th = self.target_hosts[0] p = USER_BASE_PORT for sh in self.source_hosts: # start source.py on source hosts and connect to first target host #sh.cmd("./source.py %s %d %s > log/source_%s.log 2>&1 &" # % (th.IP(), p, PARAMS.srclambda, sh.name)) sh.cmd("iperf -c %s -p %d -t 120 -i 10 > log/source_%s.log 2>&1 &" % (th.IP(), p, sh.name)) #print("./source.py %s %d %s > log/source_%s.log 2>&1 &" # % (th.IP(), p, PARAMS.srclambda, sh.name)) p += 1 def stop_topo(self): """ Do cleanup tasks. """ pass
def emptyNet(): net = Mininet(controller=RemoteController, switch=OVSKernelSwitch) c1 = net.addController('c1', controller=RemoteController, ip="192.168.64.3", port=6634) c2 = net.addController('c2', controller=RemoteController, ip="127.0.0.1", port=6633) # h1 = net.addHost( 'h1', ip='10.0.0.1', mac='00:00:00:00:00:01' ) # h2 = net.addHost( 'h2', ip='10.0.0.2', mac='00:00:00:00:00:02' ) ''' # For 4 host four switch Topology h1 = net.addHost('h1', ip='10.0.0.1') h2 = net.addHost('h2', ip='10.0.0.2') h3 = net.addHost( 'h3', ip='10.0.0.3' ) h4 = net.addHost( 'h4', ip='10.0.0.4' ) s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') s3 = net.addSwitch('s3') s4 = net.addSwitch('s4') s1.linkTo( h1 ) s2.linkTo( h2 ) s3.linkTo( h3 ) s4.linkTo( h4 ) s1.linkTo(s2) s2.linkTo(s3) s3.linkTo(s4) #s4.linkTo(s1) net.build() c1.start() c2.start() s1.start([c1, c2]) s2.start([c1, c2]) s3.start([c1, c2]) s4.start([c1, c2]) ''' # For 2 host 2 switch Topology h1 = net.addHost('h1', ip='10.0.0.1') h2 = net.addHost('h2', ip='10.0.0.2') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') s1.linkTo(h1) s2.linkTo(h2) s1.linkTo(s2) net.build() c1.start() c2.start() s1.start([c1, c2]) s2.start([c1, c2]) net.start() net.staticArp() CLI(net) net.stop()
# add hosts cn = self.addHost('cn') mn = self.addHost('mn') # add links self.addLink(sw3, sw2) # sw3-port1 == sw2-port1 self.addLink(sw3, sw1) # sw3-port2 == sw1-port1 self.addLink(sw3, cn) # sw3-port3 == cn self.addLink(sw2, mn) # sw2-port2 == mn self.addLink(sw1, mn) # sw1-port2 == mn if __name__ == '__main__': cleanup() topo6 = Test(3) net = Mininet(topo=topo6, switch=POFSwitch) net.addController('c0', controller=RemoteController, ip='192.168.109.111', port=CONTROLLER_LISTEN_PORT) setLogLevel('info') net.start() net.staticArp() print "Dumping host connections ..." dumpNodeConnections(net.hosts) dumpNodeConnections(net.switches) CLI(net) net.stop()
def start(stype, ip, port, numserv, numclient, dummyIP, numtests, delay): app='FreneticApp' # Initialize network net = Mininet(switch=switchTypes[stype], controller=lambda name: RemoteController(name, defaultIP=ip, port=int(port)), xterms=False ) print "Creating topology..." net = createNetwork(net, numserv, numclient) print "Starting network..." net.start() print "Configuring network..." net = configure(net) ## Prime all hosts ARP caches if STATIC_ARP: net.staticArp() netElems = {} for h in net.hosts: netElems[h.name] = h if DEBUG: print "=== " + h.name + " Connections ===" print h.connection for s in net.switches: netElems[s.name] = s if DEBUG: print "=== " + s.name + " Connections ===" print s.connection for c in net.controllers: netElems[c.name] = c output(" *** Network Initialized in %s seconds***\n\n" % str(time.time()-START_TIME)) # Wait for switch to register with controller time.sleep(3) # Run Test Harness yes = ['Y', 'y', 'yes', 'Yes', ''] no = ['N', 'n', 'no', 'No', 'NO'] print 'Waiting for controller: (Enter to continue) ', l = sys.stdin.readline() # Wait for prompt to continue # time.sleep(3) # Wait for controller to register # print 'Running intra-server pings...' # intraServerPing(net) print 'Start mongoose servers? [Y (default) / n ] ', l = sys.stdin.readline().strip() if l in no: print 'Not running mongoose servers' elif l in yes: runServers(net) else: print 'Unknown answer: ', l sys.exit(0) # print 'Writing intra-server pings to initialize switch entries' # CLIfile = 'LB.cli' # intraServerPing(net, CLIfile) print 'Automatic clients? [Y (default) / n ] ', l = sys.stdin.readline().strip() if l in no: print 'Not running automatic client wgets' # CLI(net, script=CLIfile) elif l in yes: # CLI(net, script=CLIfile) print 'Randomize client IPs? [Y (default) / n ] ', l = sys.stdin.readline().strip() if l in no: runClients(net, dummyIP=dummyIP, numtests=numtests, delay=delay) elif l in yes: runRandomClients(net, dummyIP=dummyIP, numtests=numtests, delay=delay) else: print 'Unknown answer: ', l sys.exit(0) else: print 'Unknown answer: ', l sys.exit(0) # Enter CLI mode for any finishing touches you might want to test output("*** Press ctrl-d or type exit to quit ***\n") # Change verbosity so that the output of CLI commands will display lg.setLogLevel('info') CLI(net) lg.setLogLevel('output') # All done, cleanup # netElems['h1'].cmd('sudo killall wbox dhclient') net.stop() os.system('sudo killall wget') os.system('sudo killall python') os.system('sudo killall mongoose') os.system('sudo killall /home/mininet/noxcore/build/src/.libs/lt-nox_core')
def simpleTest(): global switches, hosts, net, num_switches "Create and test a simple network" if (int(sys.argv[2]) % 2 == 1): topo = CustomTopo() with open("mini_topo", 'w') as f: pickle.dump(topo, f) print "Topo dumped successfully!!" else: with open("mini_topo", 'r') as f: topo = pickle.load(f) with open("global.pkl", 'r') as f: switches, hosts, topology, num_switches = pickle.load(f) net = Mininet(topo=topo, controller=None) for switch in switches: for intf in net.get(switch).intfList(): port = net.get(switch).ports[intf] print intf, switch, port path = sys.argv[1] # print "Dumping host connections" dumpNodeConnections(net.hosts) try: net.start() # Manually set switches to use OF1.3 and a custom controller of choice ind = 0 for switch in switches: ind += 1 net.get(switch).cmd('ovs-vsctl set bridge %s \ protocols=OpenFlow13' % (switch)) #net.get(switch).cmd('ovs-vsctl set bridge %s stp-enable=true' % switch) #net.get(switch).cmd('ovs-vsctl set-controller %s \ #tcp:127.0.0.1:6634 connection-mode=out-of-band' % (switch)) if (ind % 2 == 0): net.get(switch).cmd('ovs-vsctl set-controller %s \ tcp:127.0.0.1:6634 connection-mode=out-of-band' % (switch)) else: net.get(switch).cmd('ovs-vsctl set-controller %s \ tcp:127.0.0.1:6636 connection-mode=out-of-band' % (switch)) time.sleep(0.5) print "Switch Connected to controller!" #net.waitConnected() net.staticArp() for host in hosts: net.get(host).cmd("route add default gw %s" % ('10.0.0.2')) net.get(host).cmd("iperf -s -u -D -p %d &" % (6000 + int(str(switch)[1:]))) # time.sleep(0.1) net.get(host).cmd("iperf -s -D -p %d &" % (5000 + int(str(switch)[1:]))) net.get(host).cmd("sudo ITGRecv &") net.get(host).cmd("ruby -run -e httpd . -p 8080 &") #print "Started service in this host!!" #time.sleep(0.1) #CLI(net) print("All switches connected to all controllers!") flow_thread_log = DataLog(path) tcp = TCPTraffic() udp = UDPTraffic() ping = PingTraffic() voip = VoIPTraffic() dns = DNSTraffic() http = HttpTraffic() flow_thread_log.daemon = True tcp.daemon = True udp.daemon = True ping.daemon = True voip.daemon = True dns.daemon = True http.daemon = True tcp.start() udp.start() ping.start() voip.start() dns.start() #http.start() flow_thread_log.start() print "Starting the traffic now.." t = 0 time_out = 25 while t < time_out and (tcp.over or udp.over or ping.over or http.over or voip.over or dns.over): time.sleep(0.1) # (comment 1) t += 0.1 if (t < time_out): print("Operations completed before 20 seconds, terminating") else: print "Terminating the traffic after 20 seconds" #while(True): #net.pingAll() #time.sleep(1) finally: net.stop()
def emptyNet(): os.system('sudo mn -c') HostNumber = 122 net = Mininet(controller=RemoteController, switch=OVSKernelSwitch) c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1") c2 = net.addController('c2', controller=RemoteController, ip="127.0.0.2") host = [0] * HostNumber for i in range(1, HostNumber + 1): if i < 10: mac = '00:00:00:00:00:0%s' % str(i) ip = '10.0.0.%s' % str(i) host[i - 1] = net.addHost('h%s' % str(i), ip=ip, mac=mac) elif i < 100: mac = '00:00:00:00:00:%s' % str(i) ip = '10.0.0.%s' % str(i) host[i - 1] = net.addHost('h%s' % str(i), ip=ip, mac=mac) else: x = i i = i - 100 if i < 10: i = "0" + str(i) mac = '00:00:00:00:01:%s' % str(i) ip = '10.0.0.1%s' % str(i) host[x - 1] = net.addHost('h%s' % str(x), ip=ip, mac=mac) server = [0] * 1 server[0] = net.addHost('server', ip='10.0.0.199', mac='00:00:00:00:01:99') switch = [0] * 11 for i in range(1, 12): # x = i + 1 if i < 10: dpid = '000000000000010%s' % str(i) else: dpid = '00000000000001%s' % str(i) switch[i - 1] = net.addSwitch('s%s' % str(i), dpid=dpid) linkopts = dict(cls=TCLink, bw=1000, delay='5ms') #1Gb ingresslinks = dict(cls=TCLink, bw=100, delay='5ms') #800Mb = 100MByte print 'bulding links for edge switches from S1 to S4.' net.addLink(switch[0], switch[4], **linkopts) net.addLink(switch[1], switch[5], **linkopts) net.addLink(switch[2], switch[6], **linkopts) net.addLink(switch[3], switch[7], **linkopts) net.addLink(switch[4], switch[5], **linkopts) net.addLink(switch[4], switch[8], **linkopts) net.addLink(switch[4], switch[10], **linkopts) net.addLink(switch[5], switch[6], **linkopts) net.addLink(switch[6], switch[7], **linkopts) net.addLink(switch[7], switch[8], **linkopts) net.addLink(switch[7], switch[10], **linkopts) net.addLink(switch[8], switch[9], **linkopts) net.addLink(switch[9], switch[10], **linkopts) print 'bulding links between hosts and edge switches.' for i in range(0, 4): if i == 0: for x in range(0, 30): net.addLink(switch[i], host[x], **ingresslinks) elif i == 1: for x in range(30, 60): net.addLink(switch[i], host[x], **ingresslinks) elif i == 2: for x in range(60, 90): net.addLink(switch[i], host[x], **ingresslinks) elif i == 3: for x in range(90, 122): net.addLink(switch[i], host[x], **ingresslinks) else: pass net.addLink(switch[10], server[0], **linkopts) net.build() c1.start() c2.start() #c1.cmd("tcpdump -i any -nn port 6633 -U -w mylog &") for i in range(0, 11): if i < 4: switch[i].start([c1, c2]) else: switch[i].start([c1]) #net.start() enableSTP() net.staticArp() info('*** Starting the simulation in 10 Seconds ***\n') info('*** Run the ryu Controller now ***\n') time.sleep(30) info('\n*** Starting web server ***\n') server = net.get('server') #os.system('sudo tcpdump -i lo -w ryu-local.cap &') #os.system('sudo tcpdump -i any tcp -w TCP.pcap &') #server.cmdPrint('python -m SimpleHTTPServer 80 &') server.cmdPrint('iperf -s -p 80 -i 3 > server.text &') #net.pingAll() out = 0 while out <= 1: for i in range(1, 123): host = net.get('h%s' % str(i)) host.cmd('ping -c 1 10.0.0.199') out += 1 t_end = time.time() + 1 while time.time() < t_end: pass finish_time = 0 start_time = time.time() while finish_time < 40: # Training time to gather the information threads = [] for i in range(121, HostNumber + 1): t = threading.Thread(target=Training, args=( net, i, HostNumber, )) t.setDaemon(True) threads.append(t) t.start() for th in threads: th.join() #time.sleep(0.5) finish_time = time.time() - start_time for i in range(1, HostNumber + 1): t = threading.Thread(target=Training, args=( net, i, HostNumber, )) t.setDaemon(True) threads.append(t) t.start() for th in threads: th.join() #os.system('sudo tcpdump dst 10.0.0.199 -w TCP.pcap &') last = 0.0 pkts = [] packets = [] global Pkt_number global FPkt_number readpkt = rdpcap("/home/abdullah/Desktop/Dataset/TCP/1.pcap") for H in range(1, 123): host = net.get('h%s' % str(H)) host.cmdPrint('sudo tcpdump -i h%s-eth0 dst 10.0.0.199 -w h%s.pcap &' % (str(H), str(H))) server.cmd('sudo tcpdump -i server-eth0 dst 10.0.0.199 -w server.pcap &') for pkt in readpkt: if pkt[TCP] and pkt[TCP].flags & 2 and pkt[ IP].dst == "71.126.222.64" and not pkt[TCP].flags & 12: packets.append(pkt) num = len(packets) / float( 350) # 200 is the number of sent packets every attack round avg = len(packets) / float(num) threads = [] while last < len(packets): pkts = packets[int(last):int(last + avg)] wrpcap("/home/abdullah/ryu/ryu/app/pkts.pcap", pkts) for i in range(HostNumber, 0, -1): t = threading.Thread(target=Attack, args=( net, i, HostNumber, )) t.setDaemon(True) t.start() if i < 121: threads.append(t) for th in threads: th.join() last += avg print 'finish_time = ', finish_time print "\nthe benign packt number", Pkt_number print "\n the malicious packt number", FPkt_number CLI(net) net.stop()
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') # Change port and IP accordingly (c0 is Local controller, rest are Global controllers) c1 = net.addController(name='c1', controller=InbandController, ip='10.0.0.1', protocol='tcp', port=6653) c0 = net.addController(name='c0', controller=RemoteController, ip='0.0.0.0', protocol='tcp', port=6653) c3 = net.addController(name='c3', controller=InbandController, ip='10.0.0.3', protocol='tcp', port=6653) c2 = net.addController(name='c2', controller=InbandController, ip='10.0.0.2', protocol='tcp', port=6653) info('*** Adding controller\n') info('*** Add switches\n') s14 = net.addSwitch('s14', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s50 = net.addSwitch('s50', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s72 = net.addSwitch('s72', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s91 = net.addSwitch('s91', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s80 = net.addSwitch('s80', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s65 = net.addSwitch('s65', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s92 = net.addSwitch('s92', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s81 = net.addSwitch('s81', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s90 = net.addSwitch('s90', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s47 = net.addSwitch('s47', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s82 = net.addSwitch('s82', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s16 = net.addSwitch('s16', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s83 = net.addSwitch('s83', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s66 = net.addSwitch('s66', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s33 = net.addSwitch('s33', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s95 = net.addSwitch('s95', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s54 = net.addSwitch('s54', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s58 = net.addSwitch('s58', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s32 = net.addSwitch('s32', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s51 = net.addSwitch('s51', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s17 = net.addSwitch('s17', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s26 = net.addSwitch('s26', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s84 = net.addSwitch('s84', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s52 = net.addSwitch('s52', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s18 = net.addSwitch('s18', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s27 = net.addSwitch('s27', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s88 = net.addSwitch('s88', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s53 = net.addSwitch('s53', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s34 = net.addSwitch('s34', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s87 = net.addSwitch('s87', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s74 = net.addSwitch('s74', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s68 = net.addSwitch('s68', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s57 = net.addSwitch('s57', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s69 = net.addSwitch('s69', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s35 = net.addSwitch('s35', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s93 = net.addSwitch('s93', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s70 = net.addSwitch('s70', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s62 = net.addSwitch('s62', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s89 = net.addSwitch('s89', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s41 = net.addSwitch('s41', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s71 = net.addSwitch('s71', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s75 = net.addSwitch('s75', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s37 = net.addSwitch('s37', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s2 = net.addSwitch('s2', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s76 = net.addSwitch('s76', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s3 = net.addSwitch('s3', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s85 = net.addSwitch('s85', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s38 = net.addSwitch('s38', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s11 = net.addSwitch('s11', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s77 = net.addSwitch('s77', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s39 = net.addSwitch('s39', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s45 = net.addSwitch('s45', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s8 = net.addSwitch('s8', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s73 = net.addSwitch('s73', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s42 = net.addSwitch('s42', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s21 = net.addSwitch('s21', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s4 = net.addSwitch('s4', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s13 = net.addSwitch('s13', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s43 = net.addSwitch('s43', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s20 = net.addSwitch('s20', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s36 = net.addSwitch('s36', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s9 = net.addSwitch('s9', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s44 = net.addSwitch('s44', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s59 = net.addSwitch('s59', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s10 = net.addSwitch('s10', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s55 = net.addSwitch('s55', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s5 = net.addSwitch('s5', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s49 = net.addSwitch('s49', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s28 = net.addSwitch('s28', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s48 = net.addSwitch('s48', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s67 = net.addSwitch('s67', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s6 = net.addSwitch('s6', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s22 = net.addSwitch('s22', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s1 = net.addSwitch('s1', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s60 = net.addSwitch('s60', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s86 = net.addSwitch('s86', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s7 = net.addSwitch('s7', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s40 = net.addSwitch('s40', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s19 = net.addSwitch('s19', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s23 = net.addSwitch('s23', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s46 = net.addSwitch('s46', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s61 = net.addSwitch('s61', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s78 = net.addSwitch('s78', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s96 = net.addSwitch('s96', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s24 = net.addSwitch('s24', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s12 = net.addSwitch('s12', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s29 = net.addSwitch('s29', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s79 = net.addSwitch('s79', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s15 = net.addSwitch('s15', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s30 = net.addSwitch('s30', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s63 = net.addSwitch('s63', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s94 = net.addSwitch('s94', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s56 = net.addSwitch('s56', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s25 = net.addSwitch('s25', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s31 = net.addSwitch('s31', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s64 = net.addSwitch('s64', cls=OVSSwitch, inband=True, protocols='OpenFlow13') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) # Add in link options for different experiments linkopts = dict(bw=1000) info('*** Add links\n') net.addLink(s1, h1, cls=TCLink, **linkopts) #s1 Perth: 5 single switches attached net.addLink(s74, h2, cls=TCLink, **linkopts) net.addLink(s54, h3, cls=TCLink, **linkopts) net.addLink(s1, s3, cls=TCLink, **linkopts) net.addLink(s1, s2, cls=TCLink, **linkopts) net.addLink(s1, s4, cls=TCLink, **linkopts) net.addLink(s4, s5, cls=TCLink, **linkopts) net.addLink(s5, s6, cls=TCLink, **linkopts) net.addLink(s6, s7, cls=TCLink, **linkopts) net.addLink(s7, s4, cls=TCLink, **linkopts) net.addLink(s7, s8, cls=TCLink, **linkopts) net.addLink(s6, s9, cls=TCLink, **linkopts) net.addLink(s9, s8, cls=TCLink, **linkopts) net.addLink(s8, s11, cls=TCLink, **linkopts) net.addLink(s9, s10, cls=TCLink, **linkopts) net.addLink(s8, s12, cls=TCLink, **linkopts) net.addLink(s11, s13, cls=TCLink, **linkopts) net.addLink(s12, s14, cls=TCLink, **linkopts) net.addLink(s14, s15, cls=TCLink, **linkopts) net.addLink(s6, s16, cls=TCLink, **linkopts) net.addLink(s16, s17, cls=TCLink, **linkopts) net.addLink(s17, s18, cls=TCLink, **linkopts) net.addLink(s14, s19, cls=TCLink, **linkopts) net.addLink(s14, s21, cls=TCLink, **linkopts) net.addLink(s10, s20, cls=TCLink, **linkopts) net.addLink(s20, s25, cls=TCLink, **linkopts) net.addLink(s20, s26, cls=TCLink, **linkopts) net.addLink(s26, s25, cls=TCLink, **linkopts) net.addLink(s25, s24, cls=TCLink, **linkopts) net.addLink(s26, s27, cls=TCLink, **linkopts) net.addLink(s20, s23, cls=TCLink, **linkopts) net.addLink(s20, s22, cls=TCLink, **linkopts) net.addLink(s20, s28, cls=TCLink, **linkopts) net.addLink(s28, s29, cls=TCLink, **linkopts) net.addLink(s29, s30, cls=TCLink, **linkopts) net.addLink(s30, s31, cls=TCLink, **linkopts) net.addLink(s31, s32, cls=TCLink, **linkopts) net.addLink(s30, s32, cls=TCLink, **linkopts) net.addLink(s32, s33, cls=TCLink, **linkopts) net.addLink(s32, s34, cls=TCLink, **linkopts) net.addLink(s32, s35, cls=TCLink, **linkopts) net.addLink(s32, s36, cls=TCLink, **linkopts) net.addLink(s32, s37, cls=TCLink, **linkopts) net.addLink(s32, s38, cls=TCLink, **linkopts) net.addLink(s32, s40, cls=TCLink, **linkopts) net.addLink(s32, s39, cls=TCLink, **linkopts) net.addLink(s32, s41, cls=TCLink, **linkopts) net.addLink(s28, s41, cls=TCLink, **linkopts) net.addLink(s41, s42, cls=TCLink, **linkopts) net.addLink(s41, s43, cls=TCLink, **linkopts) net.addLink(s41, s44, cls=TCLink, **linkopts) net.addLink(s41, s45, cls=TCLink, **linkopts) net.addLink(s41, s46, cls=TCLink, **linkopts) net.addLink(s27, s47, cls=TCLink, **linkopts) net.addLink(s47, s48, cls=TCLink, **linkopts) net.addLink(s48, s52, cls=TCLink, **linkopts) net.addLink(s52, s49, cls=TCLink, **linkopts) net.addLink(s52, s51, cls=TCLink, **linkopts) net.addLink(s47, s50, cls=TCLink, **linkopts) net.addLink(s47, s53, cls=TCLink, **linkopts) net.addLink(s47, s54, cls=TCLink, **linkopts) net.addLink(s54, s56, cls=TCLink, **linkopts) net.addLink(s54, s55, cls=TCLink, **linkopts) net.addLink(s54, s57, cls=TCLink, **linkopts) net.addLink(s20, s54, cls=TCLink, **linkopts) net.addLink(s55, s60, cls=TCLink, **linkopts) net.addLink(s60, s58, cls=TCLink, **linkopts) net.addLink(s55, s59, cls=TCLink, **linkopts) net.addLink(s58, s63, cls=TCLink, **linkopts) net.addLink(s58, s65, cls=TCLink, **linkopts) net.addLink(s55, s58, cls=TCLink, **linkopts) net.addLink(s58, s62, cls=TCLink, **linkopts) net.addLink(s58, s61, cls=TCLink, **linkopts) net.addLink(s32, s66, cls=TCLink, **linkopts) net.addLink(s32, s67, cls=TCLink, **linkopts) net.addLink(s66, s67, cls=TCLink, **linkopts) net.addLink(s67, s68, cls=TCLink, **linkopts) net.addLink(s67, s69, cls=TCLink, **linkopts) net.addLink(s67, s70, cls=TCLink, **linkopts) net.addLink(s67, s71, cls=TCLink, **linkopts) net.addLink(s67, s72, cls=TCLink, **linkopts) net.addLink(s74, s75, cls=TCLink, **linkopts) net.addLink(s74, s73, cls=TCLink, **linkopts) net.addLink(s74, s76, cls=TCLink, **linkopts) net.addLink(s74, s77, cls=TCLink, **linkopts) net.addLink(s74, s82, cls=TCLink, **linkopts) net.addLink(s82, s81, cls=TCLink, **linkopts) net.addLink(s82, s80, cls=TCLink, **linkopts) net.addLink(s82, s78, cls=TCLink, **linkopts) net.addLink(s82, s79, cls=TCLink, **linkopts) net.addLink(s82, s83, cls=TCLink, **linkopts) net.addLink(s83, s92, cls=TCLink, **linkopts) net.addLink(s83, s93, cls=TCLink, **linkopts) net.addLink(s83, s94, cls=TCLink, **linkopts) net.addLink(s94, s81, cls=TCLink, **linkopts) net.addLink(s83, s89, cls=TCLink, **linkopts) net.addLink(s83, s88, cls=TCLink, **linkopts) net.addLink(s83, s87, cls=TCLink, **linkopts) net.addLink(s83, s86, cls=TCLink, **linkopts) net.addLink(s83, s84, cls=TCLink, **linkopts) net.addLink(s84, s90, cls=TCLink, **linkopts) net.addLink(s90, s85, cls=TCLink, **linkopts) net.addLink(s90, s91, cls=TCLink, **linkopts) net.addLink(s58, s83, cls=TCLink, **linkopts) net.addLink(s67, s58, cls=TCLink, **linkopts) net.addLink(s67, s83, cls=TCLink, **linkopts) net.addLink(s1, s32, cls=TCLink, **linkopts) net.addLink(s17, s20, cls=TCLink, **linkopts) net.addLink(s54, s96, cls=TCLink, **linkopts) net.addLink(s54, s95, cls=TCLink, **linkopts) net.addLink(s29, s62, cls=TCLink, **linkopts) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s14').start([c0]) net.get('s50').start([c0]) net.get('s72').start([c0]) net.get('s91').start([c0]) net.get('s80').start([c0]) net.get('s65').start([c0]) net.get('s92').start([c0]) net.get('s81').start([c0]) net.get('s90').start([c0]) net.get('s47').start([c0]) net.get('s82').start([c0]) net.get('s16').start([c0]) net.get('s83').start([c0]) net.get('s66').start([c0]) net.get('s33').start([c0]) net.get('s95').start([c0]) net.get('s54').start([c0, c3]) net.get('s58').start([c0]) net.get('s32').start([c0]) net.get('s51').start([c0]) net.get('s17').start([c0]) net.get('s26').start([c0]) net.get('s84').start([c0]) net.get('s52').start([c0]) net.get('s18').start([c0]) net.get('s27').start([c0]) net.get('s88').start([c0]) net.get('s53').start([c0]) net.get('s34').start([c0]) net.get('s87').start([c0]) net.get('s74').start([c0, c2]) net.get('s68').start([c0]) net.get('s57').start([c0]) net.get('s69').start([c0]) net.get('s35').start([c0]) net.get('s93').start([c0]) net.get('s70').start([c0]) net.get('s62').start([c0]) net.get('s89').start([c0]) net.get('s41').start([c0]) net.get('s71').start([c0]) net.get('s75').start([c0]) net.get('s37').start([c0]) net.get('s2').start([c0]) net.get('s76').start([c0]) net.get('s3').start([c0]) net.get('s85').start([c0]) net.get('s38').start([c0]) net.get('s11').start([c0]) net.get('s77').start([c0]) net.get('s39').start([c0]) net.get('s45').start([c0]) net.get('s8').start([c0]) net.get('s73').start([c0]) net.get('s42').start([c0]) net.get('s21').start([c0]) net.get('s4').start([c0]) net.get('s13').start([c0]) net.get('s43').start([c0]) net.get('s20').start([c0]) net.get('s36').start([c0]) net.get('s9').start([c0]) net.get('s44').start([c0]) net.get('s59').start([c0]) net.get('s10').start([c0]) net.get('s55').start([c0]) net.get('s5').start([c0]) net.get('s49').start([c0]) net.get('s28').start([c0]) net.get('s48').start([c0]) net.get('s67').start([c0]) net.get('s6').start([c0]) net.get('s22').start([c0]) net.get('s1').start([c0, c1]) net.get('s60').start([c0]) net.get('s86').start([c0]) net.get('s7').start([c0]) net.get('s40').start([c0]) net.get('s19').start([c0]) net.get('s23').start([c0]) net.get('s46').start([c0]) net.get('s61').start([c0]) net.get('s78').start([c0]) net.get('s96').start([c0]) net.get('s24').start([c0]) net.get('s12').start([c0]) net.get('s29').start([c0]) net.get('s79').start([c0]) net.get('s15').start([c0]) net.get('s30').start([c0]) net.get('s63').start([c0]) net.get('s94').start([c0]) net.get('s56').start([c0]) net.get('s25').start([c0]) net.get('s31').start([c0]) net.get('s64').start([c0]) info('*** Post configure switches and hosts\n') s1.cmd('ifconfig s1 10.0.0.21 up') s74.cmd('ifconfig s74 10.0.0.60 up') s54.cmd('ifconfig s54 10.0.0.42 up') s54.cmd('route add 10.0.0.3 dev s54') s74.cmd('route add 10.0.0.2 dev s74') s1.cmd('route add 10.0.0.1 dev s1') rootdir = '/sys/class/net' h1.cmd('ifconfig h1-eth0 mtu 10000') h2.cmd('ifconfig h2-eth0 mtu 10000') h3.cmd('ifconfig h3-eth0 mtu 10000') for switch in net.switches: for subdir, dirs, files in os.walk(rootdir): for dir in dirs: if (str(switch) == dir.split("-")[0]): switch.cmd('ifconfig ' + dir + ' mtu 10000') net.staticArp() #time.sleep(30) info("Starting Global Controller") #h1.cmd('cd ../controllers_used_in_labs/floodlight_global') #h1.cmd('java -jar target/floodlight.jar &') info("C1 started") #h2.cmd('cd ../controllers_used_in_labs/floodlight_global2') #h2.cmd('java -jar target/floodlight.jar &') info("C2 started") #h3.cmd('cd ../controllers_used_in_labs/floodlight_global3') #h3.cmd('java -jar target/floodlight.jar &') info("C3 started") CLI(net) #info("Stopping Network") net.stop()
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') # Change port and IP accordingly (c0 is Local controller, rest are Global controllers) c1 = net.addController(name='c1', controller=InbandController, ip='10.0.0.1', protocol='tcp', port=6653) c0 = net.addController(name='c0', controller=RemoteController, ip='0.0.0.0', protocol='tcp', port=6653) c3 = net.addController(name='c3', controller=InbandController, ip='10.0.0.3', protocol='tcp', port=6653) c2 = net.addController(name='c2', controller=InbandController, ip='10.0.0.2', protocol='tcp', port=6653) c4 = net.addController(name='c4', controller=InbandController, ip='10.0.0.4', protocol='tcp', port=6653) c5 = net.addController(name='c5', controller=InbandController, ip='10.0.0.5', protocol='tcp', port=6653) c6 = net.addController(name='c6', controller=InbandController, ip='10.0.0.6', protocol='tcp', port=6653) c7 = net.addController(name='c7', controller=InbandController, ip='10.0.0.7', protocol='tcp', port=6653) info('*** Add switches\n') s98 = net.addSwitch('s98', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s37 = net.addSwitch('s37', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s143 = net.addSwitch('s143', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s15 = net.addSwitch('s15', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s119 = net.addSwitch('s119', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s52 = net.addSwitch('s52', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s6 = net.addSwitch('s6', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s51 = net.addSwitch('s51', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s120 = net.addSwitch('s120', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s63 = net.addSwitch('s63', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s162 = net.addSwitch('s162', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s118 = net.addSwitch('s118', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s49 = net.addSwitch('s49', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s188 = net.addSwitch('s188', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s121 = net.addSwitch('s121', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s175 = net.addSwitch('s175', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s149 = net.addSwitch('s149', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s138 = net.addSwitch('s138', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s189 = net.addSwitch('s189', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s185 = net.addSwitch('s185', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s50 = net.addSwitch('s50', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s110 = net.addSwitch('s110', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s16 = net.addSwitch('s16', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s4 = net.addSwitch('s4', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s55 = net.addSwitch('s55', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s36 = net.addSwitch('s36', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s113 = net.addSwitch('s113', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s190 = net.addSwitch('s190', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s179 = net.addSwitch('s179', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s123 = net.addSwitch('s123', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s165 = net.addSwitch('s165', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s1 = net.addSwitch('s1', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s93 = net.addSwitch('s93', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s107 = net.addSwitch('s107', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s127 = net.addSwitch('s127', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s54 = net.addSwitch('s54', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s173 = net.addSwitch('s173', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s191 = net.addSwitch('s191', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s41 = net.addSwitch('s41', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s69 = net.addSwitch('s69', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s124 = net.addSwitch('s124', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s61 = net.addSwitch('s61', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s29 = net.addSwitch('s29', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s95 = net.addSwitch('s95', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s164 = net.addSwitch('s164', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s100 = net.addSwitch('s100', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s125 = net.addSwitch('s125', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s17 = net.addSwitch('s17', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s170 = net.addSwitch('s170', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s31 = net.addSwitch('s31', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s2 = net.addSwitch('s2', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s187 = net.addSwitch('s187', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s160 = net.addSwitch('s160', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s38 = net.addSwitch('s38', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s131 = net.addSwitch('s131', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s106 = net.addSwitch('s106', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s161 = net.addSwitch('s161', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s30 = net.addSwitch('s30', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s56 = net.addSwitch('s56', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s103 = net.addSwitch('s103', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s163 = net.addSwitch('s163', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s108 = net.addSwitch('s108', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s97 = net.addSwitch('s97', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s176 = net.addSwitch('s176', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s58 = net.addSwitch('s58', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s166 = net.addSwitch('s166', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s11 = net.addSwitch('s11', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s32 = net.addSwitch('s32', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s139 = net.addSwitch('s139', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s94 = net.addSwitch('s94', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s109 = net.addSwitch('s109', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s75 = net.addSwitch('s75', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s71 = net.addSwitch('s71', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s24 = net.addSwitch('s24', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s65 = net.addSwitch('s65', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s39 = net.addSwitch('s39', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s99 = net.addSwitch('s99', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s35 = net.addSwitch('s35', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s192 = net.addSwitch('s192', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s96 = net.addSwitch('s96', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s169 = net.addSwitch('s169', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s60 = net.addSwitch('s60', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s128 = net.addSwitch('s128', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s68 = net.addSwitch('s68', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s13 = net.addSwitch('s13', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s20 = net.addSwitch('s20', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s7 = net.addSwitch('s7', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s114 = net.addSwitch('s114', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s153 = net.addSwitch('s153', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s10 = net.addSwitch('s10', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s142 = net.addSwitch('s142', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s117 = net.addSwitch('s117', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s12 = net.addSwitch('s12', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s57 = net.addSwitch('s57', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s151 = net.addSwitch('s151', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s78 = net.addSwitch('s78', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s174 = net.addSwitch('s174', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s42 = net.addSwitch('s42', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s147 = net.addSwitch('s147', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s45 = net.addSwitch('s45', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s5 = net.addSwitch('s5', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s132 = net.addSwitch('s132', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s34 = net.addSwitch('s34', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s157 = net.addSwitch('s157', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s155 = net.addSwitch('s155', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s144 = net.addSwitch('s144', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s177 = net.addSwitch('s177', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s148 = net.addSwitch('s148', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s81 = net.addSwitch('s81', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s133 = net.addSwitch('s133', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s136 = net.addSwitch('s136', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s145 = net.addSwitch('s145', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s178 = net.addSwitch('s178', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s79 = net.addSwitch('s79', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s186 = net.addSwitch('s186', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s28 = net.addSwitch('s28', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s22 = net.addSwitch('s22', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s122 = net.addSwitch('s122', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s181 = net.addSwitch('s181', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s111 = net.addSwitch('s111', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s18 = net.addSwitch('s18', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s140 = net.addSwitch('s140', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s168 = net.addSwitch('s168', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s76 = net.addSwitch('s76', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s14 = net.addSwitch('s14', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s135 = net.addSwitch('s135', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s183 = net.addSwitch('s183', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s47 = net.addSwitch('s47', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s129 = net.addSwitch('s129', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s40 = net.addSwitch('s40', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s70 = net.addSwitch('s70', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s104 = net.addSwitch('s104', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s23 = net.addSwitch('s23', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s101 = net.addSwitch('s101', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s25 = net.addSwitch('s25', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s43 = net.addSwitch('s43', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s171 = net.addSwitch('s171', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s8 = net.addSwitch('s8', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s180 = net.addSwitch('s180', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s112 = net.addSwitch('s112', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s137 = net.addSwitch('s137', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s141 = net.addSwitch('s141', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s182 = net.addSwitch('s182', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s27 = net.addSwitch('s27', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s74 = net.addSwitch('s74', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s156 = net.addSwitch('s156', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s48 = net.addSwitch('s48', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s53 = net.addSwitch('s53', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s21 = net.addSwitch('s21', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s154 = net.addSwitch('s154', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s172 = net.addSwitch('s172', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s102 = net.addSwitch('s102', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s150 = net.addSwitch('s150', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s159 = net.addSwitch('s159', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s73 = net.addSwitch('s73', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s105 = net.addSwitch('s105', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s184 = net.addSwitch('s184', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s46 = net.addSwitch('s46', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s44 = net.addSwitch('s44', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s19 = net.addSwitch('s19', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s130 = net.addSwitch('s130', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s134 = net.addSwitch('s134', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s167 = net.addSwitch('s167', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s59 = net.addSwitch('s59', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s115 = net.addSwitch('s115', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s126 = net.addSwitch('s126', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s62 = net.addSwitch('s62', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s152 = net.addSwitch('s152', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s158 = net.addSwitch('s158', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s33 = net.addSwitch('s33', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s116 = net.addSwitch('s116', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s146 = net.addSwitch('s146', cls=OVSSwitch, inband=True, protocols='OpenFlow13') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None) h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None) h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None) linkopts = dict(delay='10ms', bw=1000) info('*** Add links\n') net.addLink(s51, h1) net.addLink(s71, h2) net.addLink(s139, h3) net.addLink(s7, h4) net.addLink(s14, h5) net.addLink(s30, h6) net.addLink(s39, h7) net.addLink(s2, s4) net.addLink(s1, s2) net.addLink(s4, s6) net.addLink(s4, s5) net.addLink(s5, s6) net.addLink(s7, s6) net.addLink(s4, s7) net.addLink(s7, s8) net.addLink(s6, s10) net.addLink(s5, s10) net.addLink(s10, s11) net.addLink(s11, s12) net.addLink(s12, s13) net.addLink(s14, s12) net.addLink(s14, s13) net.addLink(s14, s15) net.addLink(s13, s16) net.addLink(s11, s16) net.addLink(s17, s13) net.addLink(s17, s15) net.addLink(s14, s18) net.addLink(s19, s17) net.addLink(s19, s18) net.addLink(s19, s20) net.addLink(s20, s21) net.addLink(s20, s22) net.addLink(s20, s23) net.addLink(s24, s21) net.addLink(s24, s25) net.addLink(s25, s16) net.addLink(s24, s10) net.addLink(s25, s21) net.addLink(s27, s10) net.addLink(s27, s15) net.addLink(s28, s27) net.addLink(s28, s6) net.addLink(s28, s7) net.addLink(s28, s25) net.addLink(s32, s29) net.addLink(s32, s30) net.addLink(s32, s31) net.addLink(s29, s31) net.addLink(s31, s30) net.addLink(s29, s7) net.addLink(s30, s7) net.addLink(s33, s34) net.addLink(s34, s28) net.addLink(s33, s32) net.addLink(s33, s31) net.addLink(s33, s30) net.addLink(s33, s29) net.addLink(s31, s28) net.addLink(s34, s7) net.addLink(s34, s6) net.addLink(s34, s35) net.addLink(s33, s36) net.addLink(s35, s37) net.addLink(s35, s38) net.addLink(s37, s38) net.addLink(s38, s39) net.addLink(s38, s40) net.addLink(s40, s41) net.addLink(s41, s39) net.addLink(s39, s35) net.addLink(s21, s42) net.addLink(s42, s43) net.addLink(s43, s44) net.addLink(s42, s44) net.addLink(s44, s45) net.addLink(s43, s45) net.addLink(s45, s46) net.addLink(s43, s38) net.addLink(s44, s39) net.addLink(s39, s46) net.addLink(s35, s48) net.addLink(s35, s47) net.addLink(s51, s50) net.addLink(s51, s49) net.addLink(s49, s50) net.addLink(s52, s51) net.addLink(s52, s36) net.addLink(s55, s54) net.addLink(s53, s50) net.addLink(s53, s51) net.addLink(s54, s51) net.addLink(s54, s50) net.addLink(s51, s33) net.addLink(s36, s49) net.addLink(s56, s57) net.addLink(s56, s31) net.addLink(s57, s33) net.addLink(s56, s34) net.addLink(s59, s60) net.addLink(s60, s49) net.addLink(s58, s49) net.addLink(s56, s59) net.addLink(s63, s61) net.addLink(s63, s62) net.addLink(s61, s62) net.addLink(s50, s61) net.addLink(s50, s62) net.addLink(s50, s63) net.addLink(s49, s63) net.addLink(s49, s61) net.addLink(s60, s50) net.addLink(s65, s50) net.addLink(s68, s56) net.addLink(s68, s69) net.addLink(s69, s70) net.addLink(s70, s71) net.addLink(s71, s69) net.addLink(s69, s73) net.addLink(s73, s74) net.addLink(s75, s76) net.addLink(s75, s57) net.addLink(s76, s56) net.addLink(s74, s79) net.addLink(s74, s78) net.addLink(s79, s81) net.addLink(s78, s76) net.addLink(s79, s76) net.addLink(s81, s78) net.addLink(s17, s12) net.addLink(s33, s27) net.addLink(s62, s93) net.addLink(s65, s93) net.addLink(s63, s94) net.addLink(s62, s94) net.addLink(s94, s95) net.addLink(s95, s96) net.addLink(s98, s97) net.addLink(s97, s93) net.addLink(s99, s98) net.addLink(s98, s65) net.addLink(s97, s65) net.addLink(s81, s101) net.addLink(s99, s102) net.addLink(s102, s97) net.addLink(s102, s101) net.addLink(s101, s100) net.addLink(s102, s59) net.addLink(s101, s59) net.addLink(s100, s62) net.addLink(s100, s57) net.addLink(s56, s101) net.addLink(s57, s102) net.addLink(s56, s103) net.addLink(s97, s59) net.addLink(s98, s59) net.addLink(s59, s93) net.addLink(s59, s62) net.addLink(s101, s61) net.addLink(s105, s101) net.addLink(s104, s98) net.addLink(s104, s100) net.addLink(s104, s103) net.addLink(s103, s101) net.addLink(s103, s102) net.addLink(s103, s106) net.addLink(s106, s107) net.addLink(s107, s100) net.addLink(s81, s76) net.addLink(s106, s100) net.addLink(s106, s101) net.addLink(s101, s58) net.addLink(s101, s60) net.addLink(s104, s102) net.addLink(s104, s59) net.addLink(s65, s102) net.addLink(s108, s69) net.addLink(s109, s69) net.addLink(s110, s69) net.addLink(s111, s69) net.addLink(s112, s69) net.addLink(s113, s69) net.addLink(s114, s69) net.addLink(s115, s69) net.addLink(s116, s69) net.addLink(s117, s69) net.addLink(s118, s2) net.addLink(s119, s2) net.addLink(s120, s2) net.addLink(s121, s2) net.addLink(s122, s2) net.addLink(s123, s2) net.addLink(s124, s2) net.addLink(s125, s2) net.addLink(s126, s2) net.addLink(s127, s2) net.addLink(s128, s2) net.addLink(s129, s2) net.addLink(s130, s2) net.addLink(s134, s2) net.addLink(s131, s2) net.addLink(s132, s2) net.addLink(s133, s2) net.addLink(s135, s2) net.addLink(s136, s2) net.addLink(s137, s2) net.addLink(s138, s2) net.addLink(s155, s20) net.addLink(s154, s20) net.addLink(s153, s20) net.addLink(s152, s20) net.addLink(s151, s20) net.addLink(s150, s20) net.addLink(s149, s20) net.addLink(s148, s20) net.addLink(s147, s20) net.addLink(s146, s20) net.addLink(s145, s20) net.addLink(s144, s20) net.addLink(s143, s20) net.addLink(s142, s20) net.addLink(s141, s20) net.addLink(s140, s20) net.addLink(s139, s20) net.addLink(s156, s94) net.addLink(s157, s94) net.addLink(s158, s94) net.addLink(s159, s94) net.addLink(s185, s94) net.addLink(s184, s94) net.addLink(s183, s94) net.addLink(s182, s94) net.addLink(s181, s94) net.addLink(s165, s94) net.addLink(s164, s94) net.addLink(s163, s94) net.addLink(s162, s94) net.addLink(s161, s94) net.addLink(s160, s94) net.addLink(s192, s101) net.addLink(s191, s101) net.addLink(s190, s101) net.addLink(s189, s101) net.addLink(s188, s101) net.addLink(s187, s101) net.addLink(s186, s101) net.addLink(s54, s166) net.addLink(s54, s167) net.addLink(s54, s168) net.addLink(s54, s169) net.addLink(s54, s170) net.addLink(s54, s171) net.addLink(s54, s172) net.addLink(s54, s173) net.addLink(s54, s174) net.addLink(s54, s175) net.addLink(s54, s176) net.addLink(s54, s180) net.addLink(s54, s179) net.addLink(s54, s177) net.addLink(s54, s178) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s98').start([c0]) net.get('s37').start([c0]) net.get('s143').start([c0]) net.get('s15').start([c0]) net.get('s119').start([c0]) net.get('s52').start([c0]) net.get('s6').start([c0]) net.get('s51').start([c0, c1]) net.get('s120').start([c0]) net.get('s63').start([c0]) net.get('s162').start([c0]) net.get('s118').start([c0]) net.get('s49').start([c0]) net.get('s188').start([c0]) net.get('s121').start([c0]) net.get('s175').start([c0]) net.get('s149').start([c0]) net.get('s138').start([c0]) net.get('s189').start([c0]) net.get('s185').start([c0]) net.get('s50').start([c0]) net.get('s110').start([c0]) net.get('s16').start([c0]) net.get('s4').start([c0]) net.get('s55').start([c0]) net.get('s36').start([c0]) net.get('s113').start([c0]) net.get('s190').start([c0]) net.get('s179').start([c0]) net.get('s123').start([c0]) net.get('s165').start([c0]) net.get('s1').start([c0]) net.get('s93').start([c0]) net.get('s107').start([c0]) net.get('s127').start([c0]) net.get('s54').start([c0]) net.get('s173').start([c0]) net.get('s191').start([c0]) net.get('s41').start([c0]) net.get('s69').start([c0]) net.get('s124').start([c0]) net.get('s61').start([c0]) net.get('s29').start([c0]) net.get('s95').start([c0]) net.get('s164').start([c0]) net.get('s100').start([c0]) net.get('s125').start([c0]) net.get('s17').start([c0]) net.get('s170').start([c0]) net.get('s31').start([c0]) net.get('s2').start([c0]) net.get('s187').start([c0]) net.get('s160').start([c0]) net.get('s38').start([c0]) net.get('s131').start([c0]) net.get('s106').start([c0]) net.get('s161').start([c0]) net.get('s30').start([c0, c6]) net.get('s56').start([c0]) net.get('s103').start([c0]) net.get('s163').start([c0]) net.get('s108').start([c0]) net.get('s97').start([c0]) net.get('s176').start([c0]) net.get('s58').start([c0]) net.get('s166').start([c0]) net.get('s11').start([c0]) net.get('s32').start([c0]) net.get('s139').start([c0, c3]) net.get('s94').start([c0]) net.get('s109').start([c0]) net.get('s75').start([c0]) net.get('s71').start([c0, c2]) net.get('s24').start([c0]) net.get('s65').start([c0]) net.get('s39').start([c0, c7]) net.get('s99').start([c0]) net.get('s35').start([c0]) net.get('s192').start([c0]) net.get('s96').start([c0]) net.get('s169').start([c0]) net.get('s60').start([c0]) net.get('s128').start([c0]) net.get('s68').start([c0]) net.get('s13').start([c0]) net.get('s20').start([c0]) net.get('s7').start([c0, c4]) net.get('s114').start([c0]) net.get('s153').start([c0]) net.get('s10').start([c0]) net.get('s142').start([c0]) net.get('s117').start([c0]) net.get('s12').start([c0]) net.get('s57').start([c0]) net.get('s151').start([c0]) net.get('s78').start([c0]) net.get('s174').start([c0]) net.get('s42').start([c0]) net.get('s147').start([c0]) net.get('s45').start([c0]) net.get('s5').start([c0]) net.get('s132').start([c0]) net.get('s34').start([c0]) net.get('s157').start([c0]) net.get('s155').start([c0]) net.get('s144').start([c0]) net.get('s177').start([c0]) net.get('s148').start([c0]) net.get('s81').start([c0]) net.get('s133').start([c0]) net.get('s136').start([c0]) net.get('s145').start([c0]) net.get('s178').start([c0]) net.get('s79').start([c0]) net.get('s186').start([c0]) net.get('s28').start([c0]) net.get('s22').start([c0]) net.get('s122').start([c0]) net.get('s181').start([c0]) net.get('s111').start([c0]) net.get('s18').start([c0]) net.get('s140').start([c0]) net.get('s168').start([c0]) net.get('s76').start([c0]) net.get('s14').start([c0, c5]) net.get('s135').start([c0]) net.get('s183').start([c0]) net.get('s47').start([c0]) net.get('s129').start([c0]) net.get('s40').start([c0]) net.get('s70').start([c0]) net.get('s104').start([c0]) net.get('s23').start([c0]) net.get('s101').start([c0]) net.get('s25').start([c0]) net.get('s43').start([c0]) net.get('s171').start([c0]) net.get('s8').start([c0]) net.get('s180').start([c0]) net.get('s112').start([c0]) net.get('s137').start([c0]) net.get('s141').start([c0]) net.get('s182').start([c0]) net.get('s27').start([c0]) net.get('s74').start([c0]) net.get('s156').start([c0]) net.get('s48').start([c0]) net.get('s53').start([c0]) net.get('s21').start([c0]) net.get('s154').start([c0]) net.get('s172').start([c0]) net.get('s102').start([c0]) net.get('s150').start([c0]) net.get('s159').start([c0]) net.get('s73').start([c0]) net.get('s105').start([c0]) net.get('s184').start([c0]) net.get('s46').start([c0]) net.get('s44').start([c0]) net.get('s19').start([c0]) net.get('s130').start([c0]) net.get('s134').start([c0]) net.get('s167').start([c0]) net.get('s59').start([c0]) net.get('s115').start([c0]) net.get('s126').start([c0]) net.get('s62').start([c0]) net.get('s152').start([c0]) net.get('s158').start([c0]) net.get('s33').start([c0]) net.get('s116').start([c0]) net.get('s146').start([c0]) info('*** Post configure switches and hosts\n') s51.cmd('ifconfig s51 10.0.0.21 up') s71.cmd('ifconfig s71 10.0.0.81 up') s139.cmd('ifconfig s139 10.0.0.149 up') s7.cmd('ifconfig s7 10.0.0.27 up') s14.cmd('ifconfig s14 10.0.0.34 up') s30.cmd('ifconfig s30 10.0.0.40 up') s39.cmd('ifconfig s39 10.0.0.49 up') s51.cmd('route add 10.0.0.1 dev s51') s71.cmd('route add 10.0.0.2 dev s71') s139.cmd('route add 10.0.0.3 dev s139') s39.cmd('route add 10.0.0.7 dev s39') s30.cmd('route add 10.0.0.6 dev s30') s14.cmd('route add 10.0.0.5 dev s14') s7.cmd('route add 10.0.0.4 dev s7') rootdir = '/sys/class/net' h1.cmd('ifconfig h1-eth0 mtu 10000') h2.cmd('ifconfig h2-eth0 mtu 10000') h3.cmd('ifconfig h3-eth0 mtu 10000') h4.cmd('ifconfig h4-eth0 mtu 10000') h5.cmd('ifconfig h5-eth0 mtu 10000') h6.cmd('ifconfig h6-eth0 mtu 10000') h7.cmd('ifconfig h7-eth0 mtu 10000') for switch in net.switches: for subdir, dirs, files in os.walk(rootdir): for dir in dirs: if (str(switch) == dir.split("-")[0]): switch.cmd('ifconfig ' + dir + ' mtu 10000') net.staticArp() CLI(net) net.stop()
def exampleNet(): IP_PREFIX = '192.168.137.' MININET_VM_IP = IP_PREFIX + '110' CONTROLLER_IP = IP_PREFIX + '110' #MANAGER_IP=IP_PREFIX+'100' H1_VM_IP = IP_PREFIX + '10' H2_VM_IP = IP_PREFIX + '20' H3_VM_IP = IP_PREFIX + '30' #intfName = 'eth1' #_intf = Intf( intfName, node=s1 ) net = Mininet(topo=None, controller=None, build=False) net.addController('c0', controller=RemoteController, ip=CONTROLLER_IP, port=6633) # Add hosts and switches h1 = net.addHost('h1', ip='10.0.0.1', mac='00:00:00:00:00:01') h2 = net.addHost('h2', ip='10.0.0.2', mac='00:00:00:00:00:02') h3 = net.addHost('h3', ip='10.0.0.3', mac='00:00:00:00:00:03') h4 = net.addHost('h4', ip='10.0.0.4') h5 = net.addHost('h5', ip='10.0.0.5') h6 = net.addHost('h6', ip='10.0.0.6') s1 = net.addSwitch('s1', protocols='OpenFlow10') s2 = net.addSwitch('s2', protocols='OpenFlow10') s3 = net.addSwitch('s3', protocols='OpenFlow10') s4 = net.addSwitch('s4', protocols='OpenFlow10') s5 = net.addSwitch('s5', protocols='OpenFlow10') s6 = net.addSwitch('s6', protocols='OpenFlow10') s7 = net.addSwitch('s7', protocols='OpenFlow10') # Add links net.addLink(s1, s5) net.addLink(s1, s2) net.addLink(s2, s4) net.addLink(s2, s3) net.addLink(s2, s7) net.addLink(s3, s4) net.addLink(s3, s6) net.addLink(s4, s5) net.addLink(s4, s7) net.addLink(s6, s7) net.addLink(h1, s1) net.addLink(h2, s2) net.addLink(h3, s4) net.addLink(h4, s4) net.addLink(h5, s2) net.addLink(h6, s3) ## Configure GRE tunnel ## # Delete old tunnel if still exists s1.cmd('ip tun del s1-gre1') s2.cmd('ip tun del s2-gre1') s4.cmd('ip tun del s4-gre1') # Create GRE tunnels print "Creating GRE tunnels..." s1.cmd('ip li ad s1-gre1 type gretap local ' + MININET_VM_IP + ' remote ' + H1_VM_IP + ' ttl 64') s1.cmd('ip li se dev s1-gre1 up') Intf('s1-gre1', node=s1) s2.cmd('ip li ad s2-gre1 type gretap local ' + MININET_VM_IP + ' remote ' + H2_VM_IP + ' ttl 64') s2.cmd('ip li se dev s2-gre1 up') Intf('s2-gre1', node=s2) s4.cmd('ip li ad s4-gre1 type gretap local ' + MININET_VM_IP + ' remote ' + H3_VM_IP + ' ttl 64') s4.cmd('ip li se dev s4-gre1 up') Intf('s4-gre1', node=s4) net.start() print "Configuring ARP entries..." net.staticArp() s1.cmd( 'sudo ovs-ofctl add-flow s1 priority=65535,tcp,in_port=3,nw_src=10.0.0.0/8,nw_dst=10.0.0.0/8,tp_dst=80,actions=output:4' ) s4.cmd( 'sudo ovs-ofctl add-flow s4 priority=65535,tcp,in_port=5,actions=output:3' ) CLI(net) net.stop()
def start(nh=4, ns=1, stype = 'us', ip="127.0.0.1", port="6633", pi=5, fwd='lsw', val=2): init() passes = val # Initialize network noxfwd = {'lsw':'pyswitch', 'hub':'pyhub', 'fls':'sample_routing', 'adapt':'adaptive_routing'} noxapp = "FreneticApp" freneticapp = "benchmarks" freneticfun = "pc" args = [fwd] if GOPTS['remote']: net = Mininet( topo=LinearTopo(nh,ns), switch=switchTypes[stype], controller=lambda name: RemoteController(name, defaultIP=ip, port=int(port)), xterms=False, autoSetMacs=True) else: if GOPTS['nox']: noxapp = noxfwd[fwd] else: setup_env(freneticapp,args,freneticfun,fetch_subdirs(parent)) net = Mininet( topo=LinearTopo(nh,ns), switch=switchTypes[stype], controller=lambda name: NOX(name, noxapp), xterms=False, autoSetMacs=True) setNet(net) startNet() INIT = time.time() if not GOPTS['quiet']: output(" *** Network Initialized in %s seconds***\n" % str(INIT-GOPTS['start'])) if not(GOPTS['arp']): net.staticArp() if not GOPTS['quiet']: output(" *** Network Statically ARP'ed in %s seconds***\n" % str(time.time()-INIT)) netElems = {} netElems = buildNetElems(GOPTS['debug'],net) if GOPTS['agg']: p = {} if GOPTS['debug']: qopt = "" else: qopt = "-q " pcmd = 'sudo tshark -a duration:%s ' + qopt + '-i %s -z io,stat,0,' justhosts = map(lambda h:h.name, net.hosts) for s in net.switches: for swifname in s.connection.keys(): (h, hifname) = s.connection[swifname] [hostname,ifname] = hifname.split("-") if hostname in justhosts: cmd = pcmd % (str(nh*4),swifname) p[swifname] = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) if GOPTS['debug']: print "Beginning packet capture on interface %s..." % swifname # Change verbosity so that the output of CLI commands will display time.sleep(6) if GOPTS['debug']: output(netElems['s101'].cmd('dpctl show unix:/tmp/s101')) r = hostSweep(net, nh, ns, 0,passes) #r = net.pingall() # Despite the fact that the pings are blocking calls # which wait for a result, it seems that tshark needs # additional time to 'catch up' time.sleep(int(pi*1.5)) # Wait for capture processes to finish if GOPTS['agg']: for proc in p.values(): proc.wait() if not GOPTS['quiet']: lg.setLogLevel('output') if GOPTS['dump']: dumpFlows(stype,net) ### Stop controller, but wait to kill mininet if not GOPTS['remote']: netElems['c0'].stop() if GOPTS['agg']: # Grab network capture data total = 0 rexp = re.compile('000.000-[\s]+[\d]+[\s]+[\d]+', re.IGNORECASE) for (k,proc) in p.items(): out = proc.stdout.read() err = proc.stderr.read() if GOPTS['debug']: print k print err print out l = rexp.findall(out) for e in l: x = e.split() [n] = x[-1:] total += int(n) if not(GOPTS['quiet'] or GOPTS['agg']): if r == 0: output("## SUCCESS: No Lost Packets ##\n") else: output("## FAIL: %i Lost Packet(s) ##\n" % r) retcode = r elif GOPTS['agg']: output('\n###$%s$###\n' % total) retcode = total elif GOPTS['quiet']: retcode = r else: retcode = 0 return retcode
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') # Change port and IP accordingly (c0 is Local controller, rest are Global controllers) c1 = net.addController(name='c1', controller=InbandController, ip='10.0.0.1', protocol='tcp', port=6653) c2 = net.addController(name='c2', controller=InbandController, ip='10.0.0.2', protocol='tcp', port=6653) c3 = net.addController(name='c3', controller=InbandController, ip='10.0.0.3', protocol='tcp', port=6653) c0 = net.addController(name='c0', controller=RemoteController, ip='0.0.0.0', protocol='tcp', port=6653) info('*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s2 = net.addSwitch('s2', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s3 = net.addSwitch('s3', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s4 = net.addSwitch('s4', cls=OVSSwitch, inband=True, protocols='OpenFlow13') #Top 4 s5 = net.addSwitch('s5', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s6 = net.addSwitch('s6', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s7 = net.addSwitch('s7', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s8 = net.addSwitch('s8', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s9 = net.addSwitch('s9', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s10 = net.addSwitch('s10', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s11 = net.addSwitch('s11', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s12 = net.addSwitch('s12', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s13 = net.addSwitch('s13', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s14 = net.addSwitch('s14', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s15 = net.addSwitch('s15', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s16 = net.addSwitch('s16', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s17 = net.addSwitch('s17', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s18 = net.addSwitch('s18', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s19 = net.addSwitch('s19', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s20 = net.addSwitch('s20', cls=OVSSwitch, inband=True, protocols='OpenFlow13') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) # Add in link options for different experiments linkopts = dict(bw=1000) info('*** Add links\n') net.addLink(s1, h1, cls=TCLink, **linkopts) #s1 Perth: 5 single switches attached net.addLink(s20, h2, cls=TCLink, **linkopts) net.addLink(s7, h3, cls=TCLink, **linkopts) net.addLink(s1, s5, cls=TCLink, **linkopts) net.addLink(s1, s9, cls=TCLink, **linkopts) net.addLink(s1, s13, cls=TCLink, **linkopts) net.addLink(s1, s17, cls=TCLink, **linkopts) net.addLink(s2, s5, cls=TCLink, **linkopts) net.addLink(s2, s9, cls=TCLink, **linkopts) net.addLink(s2, s13, cls=TCLink, **linkopts) net.addLink(s2, s17, cls=TCLink, **linkopts) net.addLink(s3, s6, cls=TCLink, **linkopts) net.addLink(s3, s10, cls=TCLink, **linkopts) net.addLink(s3, s14, cls=TCLink, **linkopts) net.addLink(s3, s18, cls=TCLink, **linkopts) net.addLink(s4, s6, cls=TCLink, **linkopts) net.addLink(s4, s10, cls=TCLink, **linkopts) net.addLink(s4, s14, cls=TCLink, **linkopts) net.addLink(s4, s18, cls=TCLink, **linkopts) net.addLink(s5, s7, cls=TCLink, **linkopts) net.addLink(s5, s8, cls=TCLink, **linkopts) net.addLink(s6, s7, cls=TCLink, **linkopts) net.addLink(s6, s8, cls=TCLink, **linkopts) net.addLink(s9, s11, cls=TCLink, **linkopts) net.addLink(s9, s12, cls=TCLink, **linkopts) net.addLink(s10, s11, cls=TCLink, **linkopts) net.addLink(s10, s12, cls=TCLink, **linkopts) net.addLink(s13, s15, cls=TCLink, **linkopts) net.addLink(s13, s16, cls=TCLink, **linkopts) net.addLink(s14, s15, cls=TCLink, **linkopts) net.addLink(s14, s16, cls=TCLink, **linkopts) net.addLink(s17, s19, cls=TCLink, **linkopts) net.addLink(s17, s20, cls=TCLink, **linkopts) net.addLink(s18, s19, cls=TCLink, **linkopts) net.addLink(s18, s20, cls=TCLink, **linkopts) info('*** Starting network\n') net.build() info('*** Starting controllers\n') c0.start() c1.start() c2.start() c3.start() info('*** Starting switches\n') net.get('s1').start([c0, c1]) net.get('s2').start([c0]) net.get('s3').start([c0]) net.get('s4').start([c0]) net.get('s5').start([c0]) net.get('s6').start([c0]) net.get('s7').start([c0, c3]) net.get('s8').start([c0]) net.get('s9').start([c0]) net.get('s10').start([c0]) net.get('s11').start([c0]) net.get('s12').start([c0]) net.get('s13').start([c0]) net.get('s14').start([c0]) net.get('s15').start([c0]) net.get('s16').start([c0]) net.get('s17').start([c0]) net.get('s18').start([c0]) net.get('s19').start([c0]) net.get('s20').start([c0, c2]) info('*** Post configure switches and hosts\n') s1.cmd('ifconfig s1 10.0.0.21 up') s7.cmd('ifconfig s7 10.0.0.28 up') s20.cmd('ifconfig s20 10.0.0.40 up') s7.cmd('route add 10.0.0.3 dev s7') s1.cmd('route add 10.0.0.1 dev s1') s20.cmd('route add 10.0.0.2 dev s20') rootdir = '/sys/class/net' h1.cmd('ifconfig h1-eth0 mtu 10000') h2.cmd('ifconfig h2-eth0 mtu 10000') h3.cmd('ifconfig h3-eth0 mtu 10000') for switch in net.switches: for subdir, dirs, files in os.walk(rootdir): for dir in dirs: if (str(switch) == dir.split("-")[0]): switch.cmd('ifconfig ' + dir + ' mtu 65000') net.staticArp() #time.sleep(15) info("Starting Global Controller") #h1.cmd('cd ../controllers_used_in_labs/floodlight_global') #h1.cmd('java -jar target/floodlight.jar &') info("C1 started") #h2.cmd('cd ../controllers_used_in_labs/floodlight_global2') #h2.cmd('java -jar target/floodlight.jar &') info("C2 started") #h3.cmd('cd ../controllers_used_in_labs/floodlight_global3') #h3.cmd('java -jar target/floodlight.jar &') info("C3 started") CLI(net) #info("Stopping Network") net.stop()
def main(): topo = PyRouterTopo(args) net = Mininet(topo=topo, link=TCLink, cleanup=True, autoSetMacs=True) setup_addressing(net) net.staticArp() net.interact()
def run(): # Construct the network with cpu limited hosts and shaped links net = Mininet(link=TCLink, autoStaticArp=True, autoSetMacs=True, cleanup=True) swlinks, hostlinks, swes, hnums = process_graph_file("g.graph") # Create the network switches sw = list() # sw[i] is 'si', e.g. sw[1] is 's1', sw[0] is not used sw.append(None) # let sw[0] = None for i in range(1, sorted(swes)[-1] + 1): if i in swes: s = net.addSwitch('s%s' % i) # dpid='000000000000ff0%s' % i sw.append(s) else: sw.append(None) # Create network hosts # h1, h2 = [net.addHost(h) for h in ['h1', 'h2']] hosts = list() hosts.append(None) # let hosts[0] = None for i in range(1, sorted(hnums)[-1] + 1): if i in hnums: h = net.addHost('h%s' % i) hosts.append(h) else: hosts.append(None) # Tell mininet to use a remote controller located at 127.0.0.1:6653 c1 = RemoteController('c1', ip='127.0.0.1', port=6653) # c1 = OVSController('c1') net.addController(c1) # Simple topology for testing # net.addLink(h1, sw[1], bw=10) # net.addLink(h2, sw[2], bw=10) # net.addLink(sw[1], sw[2], bw=10) # Add link between switches # for (s1, s2) in [(sw[1], sw[2]), (sw[1], sw[5]), (sw[1], sw[6]), (sw[2], sw[3]), (sw[3], sw[4]), (sw[4], sw[8]), (sw[5], sw[7]), (sw[6], sw[7]), (sw[7], sw[8])]: # s1_num = int(s1.name[1]) # s2_num = int(s2.name[1]) # print("s%d, s%d" % (s1_num, s2_num)) # # link with a delay of 5ms and 15Mbps bandwidth; s1-eth3 connects to s3, s3-eth1 connects to s1, etc. # net.addLink(s1, s2, port1=s2_num, port2=s1_num, bw=15) # delay='5ms' for (s1_num, s2_num, bandwidth) in swlinks: print("s%d, s%d" % (s1_num, s2_num)) # link with a delay of 5ms and 15Mbps bandwidth; s1-eth3 connects to s3, s3-eth1 connects to s1, etc. net.addLink(sw[s1_num], sw[s2_num], port1=s2_num, port2=s1_num, bw=bandwidth) # delay='5ms' for (h_num, s_num, bandwidth) in hostlinks: print("h%d, s%d" % (h_num, s_num)) net.addLink(hosts[h_num], sw[s_num], bw=bandwidth) # Add link between a host and a switch # for (h, s) in [(h1, sw[0]), (h2, sw[7])]: # h_num = int(h.name[1]) # s_num = int(s.name[1]) # print("h%d, s%d" % (h_num, s_num)) # net.addLink(h, s, bw=10) # Start each switch and assign it to the controller for i in range(1, len(sw)): # omit sw[0] if sw[i] is not None: sw[i].start([c1]) net.staticArp( ) # add all-pairs ARP entries to eliminate the need to handle broadcast net.start() # print "Network connectivity" # dumpNetConnections(net) # net.pingAll() # print(sw[5].intfs) # print node dict {port# : intf object} # print(h1.IP(h1.intfs[3])) # print IP associated with a specific interface of h1 # print(sw[5].ports) # print node dict {intf object : port#} CLI(net) # open command-line interface # Start iperf server (-s) in h1 # h1.cmd('iperf -s &') # Run a iperf client on h2 and print the throughput # result = h2.cmd('iperf -yc -c ' + h1.IP() + ' -t 2').split(",")[-1] # test for 2 sec, parse the csv row to get the last item (bandwidth in bps) # print "Throughput between h1<-->h2: " + str(float(result)/1000000.0) + "Mbps" net.stop()
def myNetwork(): net = Mininet(topo=None, build=False) info('*** Adding controller\n') # Change port and IP accordingly (c0 is Local controller, rest are Global controllers) c1 = net.addController(name='c1', controller=InbandController, ip='10.0.0.1', protocol='tcp', port=6653) c0 = net.addController(name='c0', controller=RemoteController, ip='0.0.0.0', protocol='tcp', port=6653) c3 = net.addController(name='c3', controller=InbandController, ip='10.0.0.3', protocol='tcp', port=6653) c2 = net.addController(name='c2', controller=InbandController, ip='10.0.0.2', protocol='tcp', port=6653) c4 = net.addController(name='c4', controller=InbandController, ip='10.0.0.4', protocol='tcp', port=6653) c5 = net.addController(name='c5', controller=InbandController, ip='10.0.0.5', protocol='tcp', port=6653) c6 = net.addController(name='c6', controller=InbandController, ip='10.0.0.6', protocol='tcp', port=6653) c7 = net.addController(name='c7', controller=InbandController, ip='10.0.0.7', protocol='tcp', port=6653) info('*** Adding controller\n') info('*** Add switches\n') s14 = net.addSwitch('s14', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s50 = net.addSwitch('s50', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s72 = net.addSwitch('s72', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s91 = net.addSwitch('s91', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s80 = net.addSwitch('s80', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s65 = net.addSwitch('s65', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s92 = net.addSwitch('s92', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s81 = net.addSwitch('s81', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s90 = net.addSwitch('s90', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s47 = net.addSwitch('s47', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s82 = net.addSwitch('s82', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s16 = net.addSwitch('s16', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s83 = net.addSwitch('s83', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s66 = net.addSwitch('s66', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s33 = net.addSwitch('s33', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s95 = net.addSwitch('s95', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s54 = net.addSwitch('s54', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s58 = net.addSwitch('s58', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s32 = net.addSwitch('s32', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s51 = net.addSwitch('s51', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s17 = net.addSwitch('s17', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s26 = net.addSwitch('s26', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s84 = net.addSwitch('s84', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s52 = net.addSwitch('s52', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s18 = net.addSwitch('s18', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s27 = net.addSwitch('s27', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s88 = net.addSwitch('s88', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s53 = net.addSwitch('s53', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s34 = net.addSwitch('s34', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s87 = net.addSwitch('s87', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s74 = net.addSwitch('s74', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s68 = net.addSwitch('s68', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s57 = net.addSwitch('s57', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s69 = net.addSwitch('s69', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s35 = net.addSwitch('s35', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s93 = net.addSwitch('s93', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s70 = net.addSwitch('s70', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s62 = net.addSwitch('s62', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s89 = net.addSwitch('s89', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s41 = net.addSwitch('s41', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s71 = net.addSwitch('s71', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s75 = net.addSwitch('s75', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s37 = net.addSwitch('s37', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s2 = net.addSwitch('s2', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s76 = net.addSwitch('s76', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s3 = net.addSwitch('s3', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s85 = net.addSwitch('s85', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s38 = net.addSwitch('s38', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s11 = net.addSwitch('s11', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s77 = net.addSwitch('s77', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s39 = net.addSwitch('s39', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s45 = net.addSwitch('s45', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s8 = net.addSwitch('s8', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s73 = net.addSwitch('s73', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s42 = net.addSwitch('s42', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s21 = net.addSwitch('s21', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s4 = net.addSwitch('s4', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s13 = net.addSwitch('s13', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s43 = net.addSwitch('s43', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s20 = net.addSwitch('s20', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s36 = net.addSwitch('s36', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s9 = net.addSwitch('s9', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s44 = net.addSwitch('s44', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s59 = net.addSwitch('s59', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s10 = net.addSwitch('s10', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s55 = net.addSwitch('s55', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s5 = net.addSwitch('s5', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s49 = net.addSwitch('s49', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s28 = net.addSwitch('s28', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s48 = net.addSwitch('s48', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s67 = net.addSwitch('s67', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s6 = net.addSwitch('s6', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s22 = net.addSwitch('s22', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s1 = net.addSwitch('s1', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s60 = net.addSwitch('s60', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s86 = net.addSwitch('s86', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s7 = net.addSwitch('s7', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s40 = net.addSwitch('s40', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s19 = net.addSwitch('s19', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s23 = net.addSwitch('s23', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s46 = net.addSwitch('s46', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s61 = net.addSwitch('s61', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s78 = net.addSwitch('s78', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s96 = net.addSwitch('s96', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s24 = net.addSwitch('s24', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s12 = net.addSwitch('s12', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s29 = net.addSwitch('s29', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s79 = net.addSwitch('s79', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s15 = net.addSwitch('s15', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s30 = net.addSwitch('s30', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s63 = net.addSwitch('s63', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s94 = net.addSwitch('s94', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s56 = net.addSwitch('s56', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s25 = net.addSwitch('s25', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s31 = net.addSwitch('s31', cls=OVSSwitch, inband=True, protocols='OpenFlow13') s64 = net.addSwitch('s64', cls=OVSSwitch, inband=True, protocols='OpenFlow13') info('*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None) h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None) h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None) # Add in link options for different experiments linkopts = dict(delay='10ms', bw=1000) info('*** Add links\n') net.addLink(s1, h1) #s1 Perth: 5 single switches attached net.addLink(s74, h2) net.addLink(s54, h3) net.addLink(s7, h4) net.addLink(s14, h5) net.addLink(s30, h6) net.addLink(s39, h7) net.addLink(s1, s3) net.addLink(s1, s2) net.addLink(s1, s4) net.addLink(s4, s5) net.addLink(s5, s6) net.addLink(s6, s7) net.addLink(s7, s4) net.addLink(s7, s8) net.addLink(s6, s9) net.addLink(s9, s8) net.addLink(s8, s11) net.addLink(s9, s10) net.addLink(s8, s12) net.addLink(s11, s13) net.addLink(s12, s14) net.addLink(s14, s15) net.addLink(s6, s16) net.addLink(s16, s17) net.addLink(s17, s18) net.addLink(s14, s19) net.addLink(s14, s21) net.addLink(s10, s20) net.addLink(s20, s25) net.addLink(s20, s26) net.addLink(s26, s25) net.addLink(s25, s24) net.addLink(s26, s27) net.addLink(s20, s23) net.addLink(s20, s22) net.addLink(s20, s28) net.addLink(s28, s29) net.addLink(s29, s30) net.addLink(s30, s31) net.addLink(s31, s32) net.addLink(s30, s32) net.addLink(s32, s33) net.addLink(s32, s34) net.addLink(s32, s35) net.addLink(s32, s36) net.addLink(s32, s37) net.addLink(s32, s38) net.addLink(s32, s40) net.addLink(s32, s39) net.addLink(s32, s41) net.addLink(s28, s41) net.addLink(s41, s42) net.addLink(s41, s43) net.addLink(s41, s44) net.addLink(s41, s45) net.addLink(s41, s46) net.addLink(s27, s47) net.addLink(s47, s48) net.addLink(s48, s52) net.addLink(s52, s49) net.addLink(s52, s51) net.addLink(s47, s50) net.addLink(s47, s53) net.addLink(s47, s54) net.addLink(s54, s56) net.addLink(s54, s55) net.addLink(s54, s57) net.addLink(s20, s54) net.addLink(s55, s60) net.addLink(s60, s58) net.addLink(s55, s59) net.addLink(s58, s63) net.addLink(s58, s65) net.addLink(s55, s58) net.addLink(s58, s62) net.addLink(s58, s61) net.addLink(s32, s66) net.addLink(s32, s67) net.addLink(s66, s67) net.addLink(s67, s68) net.addLink(s67, s69) net.addLink(s67, s70) net.addLink(s67, s71) net.addLink(s67, s72) net.addLink(s74, s75) net.addLink(s74, s73) net.addLink(s74, s76) net.addLink(s74, s77) net.addLink(s74, s82) net.addLink(s82, s81) net.addLink(s82, s80) net.addLink(s82, s78) net.addLink(s82, s79) net.addLink(s82, s83) net.addLink(s83, s92) net.addLink(s83, s93) net.addLink(s83, s94) net.addLink(s94, s81) net.addLink(s83, s89) net.addLink(s83, s88) net.addLink(s83, s87) net.addLink(s83, s86) net.addLink(s83, s84) net.addLink(s84, s90) net.addLink(s90, s85) net.addLink(s90, s91) net.addLink(s58, s83) net.addLink(s67, s58) net.addLink(s67, s83) net.addLink(s1, s32) net.addLink(s17, s20) net.addLink(s54, s96) net.addLink(s54, s95) net.addLink(s29, s62) info('*** Starting network\n') net.build() info('*** Starting controllers\n') for controller in net.controllers: controller.start() info('*** Starting switches\n') net.get('s14').start([c0, c5]) net.get('s50').start([c0]) net.get('s72').start([c0]) net.get('s91').start([c0]) net.get('s80').start([c0]) net.get('s65').start([c0]) net.get('s92').start([c0]) net.get('s81').start([c0]) net.get('s90').start([c0]) net.get('s47').start([c0]) net.get('s82').start([c0]) net.get('s16').start([c0]) net.get('s83').start([c0]) net.get('s66').start([c0]) net.get('s33').start([c0]) net.get('s95').start([c0]) net.get('s54').start([c0, c3]) net.get('s58').start([c0]) net.get('s32').start([c0]) net.get('s51').start([c0]) net.get('s17').start([c0]) net.get('s26').start([c0]) net.get('s84').start([c0]) net.get('s52').start([c0]) net.get('s18').start([c0]) net.get('s27').start([c0]) net.get('s88').start([c0]) net.get('s53').start([c0]) net.get('s34').start([c0]) net.get('s87').start([c0]) net.get('s74').start([c0, c2]) net.get('s68').start([c0]) net.get('s57').start([c0]) net.get('s69').start([c0]) net.get('s35').start([c0]) net.get('s93').start([c0]) net.get('s70').start([c0]) net.get('s62').start([c0]) net.get('s89').start([c0]) net.get('s41').start([c0]) net.get('s71').start([c0]) net.get('s75').start([c0]) net.get('s37').start([c0]) net.get('s2').start([c0]) net.get('s76').start([c0]) net.get('s3').start([c0]) net.get('s85').start([c0]) net.get('s38').start([c0]) net.get('s11').start([c0]) net.get('s77').start([c0]) net.get('s39').start([c0, c7]) net.get('s45').start([c0]) net.get('s8').start([c0]) net.get('s73').start([c0]) net.get('s42').start([c0]) net.get('s21').start([c0]) net.get('s4').start([c0]) net.get('s13').start([c0]) net.get('s43').start([c0]) net.get('s20').start([c0]) net.get('s36').start([c0]) net.get('s9').start([c0]) net.get('s44').start([c0]) net.get('s59').start([c0]) net.get('s10').start([c0]) net.get('s55').start([c0]) net.get('s5').start([c0]) net.get('s49').start([c0]) net.get('s28').start([c0]) net.get('s48').start([c0]) net.get('s67').start([c0]) net.get('s6').start([c0]) net.get('s22').start([c0]) net.get('s1').start([c0, c1]) net.get('s60').start([c0]) net.get('s86').start([c0]) net.get('s7').start([c0, c4]) net.get('s40').start([c0]) net.get('s19').start([c0]) net.get('s23').start([c0]) net.get('s46').start([c0]) net.get('s61').start([c0]) net.get('s78').start([c0]) net.get('s96').start([c0]) net.get('s24').start([c0]) net.get('s12').start([c0]) net.get('s29').start([c0]) net.get('s79').start([c0]) net.get('s15').start([c0]) net.get('s30').start([c0, c6]) net.get('s63').start([c0]) net.get('s94').start([c0]) net.get('s56').start([c0]) net.get('s25').start([c0]) net.get('s31').start([c0]) net.get('s64').start([c0]) info('*** Post configure switches and hosts\n') s1.cmd('ifconfig s1 10.0.0.21 up') s74.cmd('ifconfig s74 10.0.0.60 up') s54.cmd('ifconfig s54 10.0.0.42 up') s7.cmd('ifconfig s7 10.0.0.27 up') s14.cmd('ifconfig s14 10.0.0.34 up') s30.cmd('ifconfig s30 10.0.0.40 up') s39.cmd('ifconfig s39 10.0.0.49 up') s54.cmd('route add 10.0.0.3 dev s54') s74.cmd('route add 10.0.0.2 dev s74') s1.cmd('route add 10.0.0.1 dev s1') s39.cmd('route add 10.0.0.7 dev s39') s30.cmd('route add 10.0.0.6 dev s30') s14.cmd('route add 10.0.0.5 dev s14') s7.cmd('route add 10.0.0.4 dev s7') rootdir = '/sys/class/net' h1.cmd('ifconfig h1-eth0 mtu 10000') h2.cmd('ifconfig h2-eth0 mtu 10000') h3.cmd('ifconfig h3-eth0 mtu 10000') h4.cmd('ifconfig h4-eth0 mtu 10000') h5.cmd('ifconfig h5-eth0 mtu 10000') h6.cmd('ifconfig h6-eth0 mtu 10000') h7.cmd('ifconfig h7-eth0 mtu 10000') for switch in net.switches: for subdir, dirs, files in os.walk(rootdir): for dir in dirs: if (str(switch) == dir.split("-")[0]): switch.cmd('ifconfig ' + dir + ' mtu 10000') net.staticArp() #time.sleep(30) info("Starting Global Controller") #h1.cmd('cd ../controllers_used_in_labs/floodlight_global') #h1.cmd('java -jar target/floodlight.jar &') info("C1 started") #h2.cmd('cd ../controllers_used_in_labs/floodlight_global2') #h2.cmd('java -jar target/floodlight.jar &') info("C2 started") #h3.cmd('cd ../controllers_used_in_labs/floodlight_global3') #h3.cmd('java -jar target/floodlight.jar &') info("C3 started") CLI(net) #info("Stopping Network") net.stop()
def myNet(): MultiSwitch13 = partial(MultiSwitch, protocols='OpenFlow13') #tree_topo = TreeTopo(depth=3,fanout=2) tree_topo = SingleSwitchTopo(n=3) net = Mininet(controller=RemoteController, topo=tree_topo, switch=MultiSwitch13, build=False, autoSetMacs=True) info('*** Adding controllers\n') #c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1", port=6633) c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1", port=6633) # c2 = net.addController('c2', controller=RemoteController, ip="192.168.56.101", port=6633) # c3 = net.addController('c3', controller=RemoteController, ip="192.168.56.103", port=6633) # info( '*** Add hosts\n') # h1 = net.addHost( 'h1', ip='10.0.0.1' ) # h2 = net.addHost( 'h2', ip='10.0.0.2' ) # h3 = net.addHost( 'h3', ip='10.0.0.3' ) # h4 = net.addHost( 'h4', ip='10.0.0.4' ) # info( '*** Add switches\n') # s1 = net.addSwitch( 's1', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s2 = net.addSwitch( 's2', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s3 = net.addSwitch( 's3', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # s4 = net.addSwitch( 's4', cls=OVSKernelSwitch, protocols='OpenFlow13' ) # info( '*** Add links\n') # s1.linkTo( h1 ) # s1.linkTo( s2 ) # s2.linkTo( h2 ) # s2.linkTo( s3 ) # s3.linkTo( h3 ) # s3.linkTo( s4 ) # s4.linkTo( h4 ) info('*** Starting network\n') net.build() info('*** Starting controllers\n') c1.start() # c2.start() # c3.start() # info( '*** Starting switches\n') # s1.start([c1,c2,c3]) # s2.start([c1,c2,c3]) # s3.start([c1,c2,c3]) # s4.start([c1,c2,c3]) net.start() net.staticArp() # i = 0; # while i < 10: # h1, h2 = random.choice(net.hosts), random.choice(net.hosts) # print h1.IP(), "-->", h2.IP() # sent, received, rttmin, rttavg, rttmax, rttdev = ping(h1, h2) # print received,"/",sent # i = i + 1 # sleep(1) CLI(net) net.stop()