def topology(): "Create a network." net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch ) staList = [] print "*** Creating nodes" for n in range(10): staList.append(n) staList[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) ) phyap1 = net.addPhysicalBaseStation( 'phyap1', ssid= 'SBRC16-MininetWiFi', mode= 'g', channel= '1', position='50,115,0', phywlan='wlan11' ) sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0') ap2 = net.addAccessPoint( 'ap2', ssid= 'ap2', mode= 'g', channel= '11', position='100,175,0' ) ap3 = net.addAccessPoint( 'ap3', ssid= 'ap3', mode= 'g', channel= '6', position='150,50,0' ) ap4 = net.addAccessPoint( 'ap4', ssid= 'ap4', mode= 'g', channel= '1', position='175,150,0' ) c1 = net.addController( 'c1', controller=Controller, port=6653 ) root = Node( 'root', inNamespace=False ) print "*** Configuring wifi nodes" net.configureWifiNodes() """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" for sta in staList: net.addMesh(sta, ssid='meshNet') net.addLink(phyap1, ap2) net.addLink(ap2, ap3) net.addLink(ap3, ap4) print "*** Starting network" net.build() c1.start() phyap1.start( [c1] ) ap2.start( [c1] ) ap3.start( [c1] ) ap4.start( [c1] ) ip = 201 for sta in staList: sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta) ip+=1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch ) sta = [] print "*** Creating nodes" for n in range(10): sta.append(n) sta[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) ) phyap1 = net.addPhysicalBaseStation( 'phyap1', ssid= 'SBRC16-MininetWiFi', mode= 'g', channel= '1', position='50,115,0', wlan='wlan11' ) sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0') ap2 = net.addBaseStation( 'ap2', ssid= 'ap2', mode= 'g', channel= '11', position='100,175,0' ) ap3 = net.addBaseStation( 'ap3', ssid= 'ap3', mode= 'g', channel= '6', position='150,50,0' ) ap4 = net.addBaseStation( 'ap4', ssid= 'ap4', mode= 'g', channel= '1', position='175,150,0' ) c1 = net.addController( 'c1', controller=Controller, port=6653 ) root = Node( 'root', inNamespace=False ) print "*** Creating links" for station in sta: net.addMesh(station, ssid='meshNet') """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" net.addLink(phyap1, ap2) net.addLink(ap2, ap3) net.addLink(ap3, ap4) print "*** Starting network" net.build() c1.start() phyap1.start( [c1] ) ap2.start( [c1] ) ap3.start( [c1] ) ap4.start( [c1] ) ip = 201 for station in sta: station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip)) ip+=1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): """Create a network. sta1 <--> sta2 <--> sta3""" print "*** Network creation" net = Mininet() print "*** Creating nodes" sta1 = net.addStation('sta1', range=50, position='10,10,0') sta2 = net.addStation('sta2', range=50, position='20,10,0') sta3 = net.addStation('sta3', range=50, position='30,10,0') print "*** Configure wmediumd" # This should be done right after the station has been initialized sta1.wmediumdIface = DynamicWmediumdIntfRef(sta1) sta2.wmediumdIface = DynamicWmediumdIntfRef(sta2) sta3.wmediumdIface = DynamicWmediumdIntfRef(sta3) intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface] links = [ WmediumdSNRLink(sta1.wmediumdIface, sta2.wmediumdIface, 15), WmediumdSNRLink(sta2.wmediumdIface, sta1.wmediumdIface, 15), WmediumdSNRLink(sta2.wmediumdIface, sta3.wmediumdIface, 15), WmediumdSNRLink(sta3.wmediumdIface, sta2.wmediumdIface, 15) ] WmediumdStarter.initialize(intfrefs, links, with_server=True) print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Start wmediumd" WmediumdStarter.start() print "*** Plotting graph ***" net.plotGraph(max_x=200, max_y=200) print "*** Enabling Mesh Routing ***" net.meshRouting('custom') print "*** Creating links" net.addMesh(sta1, ssid='adNet') net.addMesh(sta2, ssid='adNet') net.addMesh(sta3, ssid='adNet') print "*** Starting network" net.start() print "\n\n\n" print "*** Pinging sta2" sta1.cmdPrint('ping -c 1 10.0.0.2') print "*** Update wmediumd" WmediumdServerConn.connect() # Required when the position of the nodes are previously defined. Useful to set channel params. net.autoAssociation() CLI(net) print "*** Stopping network" net.stop() print "*** Stopping wmediumd" WmediumdServerConn.disconnect() WmediumdStarter.stop()
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch) print "*** Creating nodes" car = [] stas = [] for x in range(0, 10): car.append(x) stas.append(x) for x in range(0, 10): car[x] = net.addCar('car%s' % (x), wlans=1, ip='10.0.0.%s/8' % (x + 1), mode='b', max_x=40, max_y=40, range=1000) rsu10 = net.addAccessPoint('rsu10', ssid='rsu10', mode='g', channel='1', position='3500,2500,0', range=500) rsu11 = net.addAccessPoint('rsu11', ssid='rsu11', mode='g', channel='6', position='3000,2500,0', range=500) rsu12 = net.addAccessPoint('rsu12', ssid='rsu12', mode='g', channel='11', position='2500,3000,0', range=500) rsu13 = net.addAccessPoint('rsu13', ssid='rsu13', mode='g', channel='11', position='4000,3000,0', range=500) rsu14 = net.addAccessPoint('rsu14', ssid='rsu14', mode='g', channel='11', position='4500,3000,0', range=500) c1 = net.addController('c1', controller=Controller, ip='127.0.0.1', port=6633) print "*** Configuring wifi nodes" net.configureWifiNodes() net.meshRouting('custom') net.addLink(rsu10, rsu11) net.addLink(rsu11, rsu12) net.addLink(rsu12, rsu13) net.addLink(rsu13, rsu14) """Available Options: sumo, sumo-gui""" # Put your sumocfg file in /mininet/sumo/data net.useExternalProgram('sumo-gui', config_file='map.sumocfg') print "*** Starting network" net.build() c1.start() rsu10.start([c1]) rsu11.start([c1]) rsu12.start([c1]) rsu13.start([c1]) rsu14.start([c1]) i = 201 for sw in net.vehicles: sw.start([c1]) os.system('ifconfig %s 10.0.0.%s' % (sw, i)) i += 1 i = 1 j = 2 for c in car: c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, i)) c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i)) c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j) i += 2 j += 2 i = 1 j = 2 for v in net.vehiclesSTA: v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j)) v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i)) v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') i += 1 j += 2 for v1 in net.vehiclesSTA: i = 1 j = 1 for v2 in net.vehiclesSTA: if v1 != v2: v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i)) i += 1 j += 2 print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def topology(): global car1_new global car2_new global car3_new global car4_new car1_new = '' car2_new = '' car3_new = '' car4_new = '' "Create a network." net = Mininet(controller=RemoteController, link=TCLink, switch=OVSKernelSwitch) print "*** Creating nodes" car = [] stas = [] for x in range(0, 4): car.append(x) stas.append(x) for x in range(0, 4): min = random.randint(20, 40) max = random.randint(40, 60) car[x] = net.addCar('car%s' % (x + 1), wlans=1, ip='10.0.0.%s/8' % (x + 1), min_speed=min, max_speed=max, range=100) rsu11 = net.addAccessPoint('RSU11', ssid='RSU11', mode='g', channel='1', range=200, ip='192.168.0.11') rsu12 = net.addAccessPoint('RSU12', ssid='RSU12', mode='g', channel='6', range=200, ip='192.168.0.12') rsu13 = net.addAccessPoint('RSU13', ssid='RSU13', mode='g', channel='11', range=200, ip='192.168.0.13') rsu14 = net.addAccessPoint('RSU14', ssid='RSU14', mode='g', channel='1', range=200, ip='192.168.0.14') rsu15 = net.addAccessPoint('RSU15', ssid='RSU15', mode='g', channel='6', range=200, ip='192.168.0.15') c1 = net.addController('c1', controller=RemoteController, ip='192.168.56.107') print "*** Configuring wifi nodes" net.configureWifiNodes() net.meshRouting('custom') print "*** Associating and Creating links" net.addLink(rsu11, rsu12, bw=0.7, loss=2, delay='25ms') net.addLink(rsu12, rsu15, bw=1, loss=3, delay='10ms') net.addLink(rsu13, rsu15, bw=1, loss=2, delay='10ms') net.addLink(rsu13, rsu14, bw=5, loss=2, delay='5ms') net.addLink(rsu11, rsu14, bw=0.7, loss=8, delay='25ms') net.addLink(rsu11, rsu13, bw=0.7, loss=2, delay='25ms') net.addLink(rsu12, rsu14, bw=0.7, loss=8, delay='25ms') net.addLink(rsu11, rsu15, bw=0.7, loss=5, delay='25ms') net.addLink(rsu14, rsu15, bw=0.7, loss=6, delay='25ms') net.addLink(rsu12, rsu13, bw=5, loss=3, delay='5ms') print "*** Starting network" net.build() c1.start() rsu11.start([c1]) rsu12.start([c1]) rsu13.start([c1]) rsu14.start([c1]) rsu15.start([c1]) i = 201 for sw in net.vehicles: sw.start([c1]) os.system('ifconfig %s 10.0.0.%s' % (sw, i)) i += 1 """uncomment to plot graph""" net.plotGraph(max_x=1000, max_y=1000) """Number of Roads""" net.roads(6) """Start Mobility""" net.startMobility(startTime=0) i = 1 j = 2 k = 1 for c in car: c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, k)) c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i)) c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j) i += 2 j += 2 k += 1 i = 1 j = 2 for v in net.vehiclesSTA: v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j)) v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i)) v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') i += 1 j += 2 for v1 in net.vehiclesSTA: i = 1 j = 1 for v2 in net.vehiclesSTA: if v1 != v2: v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i)) i += 1 j += 2 car1 = car[0] car2 = car[1] car3 = car[2] car4 = car[3] output(car1, car2, car3, car4) print "*** Running CLI" cmdcli = CLI(net) #cmdcli.do_px("print car1.cmd('iwconfig > 1234_py_test.txt')") #CLI( net ) print "*** Stopping network" net.stop()
def topology(): """Create a network. sta1 <--> sta2 <--> sta3""" print "*** Network creation" net = Mininet() print "*** Creating nodes" sta1 = net.addStation('sta1', range=200) sta2 = net.addStation('sta2', range=200) sta3 = net.addStation('sta3', range=200) print "*** Configure wmediumd" # This should be done right after the station has been initialized sta1.wmediumdIface = DynamicWmediumdIntfRef(sta1) sta2.wmediumdIface = DynamicWmediumdIntfRef(sta2) sta3.wmediumdIface = DynamicWmediumdIntfRef(sta3) intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface] links = [ WmediumdLink(sta1wlan0, sta2wlan0, 15), WmediumdLink(sta2wlan0, sta1wlan0, 15), WmediumdLink(sta2wlan0, sta3wlan0, 15), WmediumdLink(sta3wlan0, sta2wlan0, 15) ] WmediumdConn.set_wmediumd_data(intfrefs, links, with_server=True) WmediumdConn.connect_wmediumd_on_startup() print "*** Configuring wifi nodes" net.configureWifiNodes() net.plotGraph(max_x=240, max_y=240) net.meshRouting('custom') net.seed(20) print "*** Creating links" net.addMesh(sta1, ssid='adNet') net.addMesh(sta2, ssid='adNet') net.addMesh(sta3, ssid='adNet') print "*** Starting network" net.start() print "\n\n\n" print "*** Pinging sta2" sta1.cmdPrint('ping -c 1 10.0.0.2') print "*** Setting up the mobility model" net.startMobility(startTime=0, model='RandomDirection', max_x=220, max_y=220, min_v=0.1, max_v=0.2) print "*** Update wmediumd" WmediumdServerConn.connect() CLI(net) print "*** Stopping network" net.stop() print "*** Stopping wmediumd" WmediumdServerConn.disconnect() WmediumdConn.disconnect_wmediumd()
def topology(): "Create a network." net = Mininet(controller=RemoteController, link=TCLink, accessPoint=UserAP) staList = [] internetIface = 'eth0' usbDongleIface = 'wlan11' print "*** Creating nodes" for n in range(10): staList.append(n) staList[n] = net.addStation('sta%s' % (n + 1), wlans=2, mac='00:00:00:00:00:%s' % (n + 1), ip='192.168.0.%s/24' % (n + 1)) phyap1 = net.addPhysicalBaseStation('phyap1', protocols='OpenFlow13', ssid='Sigcomm-2016-Mininet-WiFi', mode='g', channel='1', position='50,115,0', phywlan=usbDongleIface) ap2 = net.addAccessPoint('ap2', protocols='OpenFlow13', ssid='ap-ssid2', mode='g', channel='11', position='100,175,0') ap3 = net.addAccessPoint('ap3', protocols='OpenFlow13', ssid='ap-ssid3', mode='g', channel='6', position='150,115,0') ap4 = net.addAccessPoint('ap4', protocols='OpenFlow13', ssid='ap-ssid4', mode='g', channel='11', position='100,55,0') c5 = net.addController('c5', controller=RemoteController, port=6653) sta11 = net.addStation('sta11', ip='10.0.0.111/8', position='60,100,0') h12 = net.addHost('h12', ip='10.0.0.109/8') root = net.addHost('root', ip='10.0.0.254/8', inNamespace=False) print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Creating links" for sta in staList: net.addMesh(sta, ssid='meshNet') """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" net.addLink(phyap1, ap2) net.addLink(ap2, ap3) net.addLink(sta11, ap2) net.addLink(ap3, ap4) net.addLink(ap4, phyap1) net.addLink(root, ap3) net.addLink(phyap1, h12) print "*** Starting network" net.build() c5.start() phyap1.start([c5]) ap2.start([c5]) ap3.start([c5]) ap4.start([c5]) time.sleep(2) """output=all,flood""" ap3.cmd( 'dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100') ap3.cmd( 'dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100,meter:1 apply:output=flood' ) phyap1.cmd( 'dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=2,ip_dst=10.0.0.109,eth_type=0x800,ip_proto=6,tcp_dst=80 apply:set_field=tcp_dst:80,set_field=ip_dst:10.0.0.111,output=5' ) phyap1.cmd( 'dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=1,eth_type=0x800,ip_proto=6,tcp_src=80 apply:set_field=ip_src:10.0.0.109,output=2' ) fixNetworkManager(root, 'root-eth0') startNAT(root, internetIface) sta11.cmd('ip route add default via 10.0.0.254') sta11.cmd('pushd /home/fontes; python3 -m http.server 80 &') ip = 201 for sta in staList: sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta) sta.cmd('ip route add default via 10.0.0.254') ip += 1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=200, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch) print "*** Creating nodes" car = [] stas = [] for x in range(0, 10): car.append(x) stas.append(x) for x in range(0, 10): min = random.randint(1, 10) max = random.randint(11, 30) car[x] = net.addCar('car%s' % (x + 1), wlans=1, ip='10.0.0.%s/8' % (x + 1), min_speed=min, max_speed=max, range=50) rsu11 = net.addAccessPoint('RSU11', ssid='RSU11', mode='g', channel='1', range=100) rsu12 = net.addAccessPoint('RSU12', ssid='RSU12', mode='g', channel='6', range=100) rsu13 = net.addAccessPoint('RSU13', ssid='RSU13', mode='g', channel='11', range=100) rsu14 = net.addAccessPoint('RSU14', ssid='RSU14', mode='g', channel='11', range=100) c1 = net.addController('c1', controller=Controller) print "*** Configuring wifi nodes" net.configureWifiNodes() net.meshRouting('custom') print "*** Associating and Creating links" net.addLink(rsu11, rsu12) net.addLink(rsu11, rsu13) net.addLink(rsu11, rsu14) print "*** Starting network" net.build() c1.start() rsu11.start([c1]) rsu12.start([c1]) rsu13.start([c1]) rsu14.start([c1]) i = 201 for sw in net.vehicles: sw.start([c1]) os.system('ifconfig %s 10.0.0.%s' % (sw, i)) i += 1 """uncomment to plot graph""" net.plotGraph(max_x=500, max_y=500) """Number of Roads""" net.roads(20) """Start Mobility""" net.startMobility(startTime=0) i = 1 j = 2 k = 1 for c in car: c.cmd('ifconfig %s-wlan0 192.168.0.%s/24 up' % (c, k)) c.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (c, i)) c.cmd('ip route add 10.0.0.0/8 via 192.168.1.%s' % j) i += 2 j += 2 k += 1 i = 1 j = 2 for v in net.vehiclesSTA: v.cmd('ifconfig %s-eth0 192.168.1.%s/24 up' % (v, j)) v.cmd('ifconfig %s-mp0 10.0.0.%s/24 up' % (v, i)) v.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward') i += 1 j += 2 for v1 in net.vehiclesSTA: i = 1 j = 1 for v2 in net.vehiclesSTA: if v1 != v2: v1.cmd('route add -host 192.168.1.%s gw 10.0.0.%s' % (j, i)) i += 1 j += 2 print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet(controller=RemoteController, link=TCLink, switch=UserSwitch) staList = [] print "*** Creating nodes" for n in range(10): staList.append(n) staList[n] = net.addStation('sta%s' % (n + 1), wlans=2, mac='00:00:00:00:00:%s' % (n + 1), ip='192.168.0.%s/24' % (n + 1)) phyap1 = net.addPhysicalBaseStation('phyap1', protocols='OpenFlow13', ssid='ap-ssid1', mode='g', channel='1', position='50,115,0', phywlan='wlan1') ap2 = net.addBaseStation('ap2', protocols='OpenFlow13', ssid='ap-ssid2', mode='g', channel='11', position='100,175,0') ap3 = net.addBaseStation('ap3', protocols='OpenFlow13', ssid='ap-ssid3', mode='g', channel='6', position='150,115,0') ap4 = net.addBaseStation('ap4', protocols='OpenFlow13', ssid='ap-ssid4', mode='g', channel='6', position='100,55,0') sta11 = net.addStation('sta11', ip='10.0.0.111/8', position='120,200,0') c1 = net.addController('c1', controller=RemoteController, port=6653) root = Node('root', inNamespace=False) print "*** Creating links" for sta in staList: net.addMesh(sta, ssid='meshNet') """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" net.addLink(phyap1, ap2) net.addLink(ap2, ap3) net.addLink(sta11, ap2) net.addLink(ap3, ap4) net.addLink(ap4, phyap1) link = net.addLink(root, ap3) link.intf1.setIP('10.254', 8) """Adding datapath""" net.addOfDataPath('ap3', 'wlan0') print "*** Starting network" net.build() c1.start() phyap1.start([c1]) ap2.start([c1]) ap3.start([c1]) ap4.start([c1]) time.sleep(2) """output=all,flood""" ap3.cmd( 'dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100') ap3.cmd( 'dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100, meter:1 apply:output=flood' ) startNAT(root) sta11.cmd('ip route add default via 10.0.0.254') sta11.cmd('pushd /homt/alpha; python3 -m http.server 80 &') ip = 201 for sta in staList: sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta) sta.cmd('ip route add default via 10.0.0.254') ip += 1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet( controller=RemoteController, link=TCLink, switch=UserSwitch ) staList = [] internetIface = 'eth0' usbDongleIface = 'wlan0' print "*** Creating nodes" for n in range(10): staList.append(n) staList[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) ) phyap1 = net.addPhysicalBaseStation( 'phyap1', protocols='OpenFlow13', ssid='Sigcomm-2016-Mininet-WiFi', mode= 'g', channel= '1', position='50,115,0', phywlan=usbDongleIface ) ap2 = net.addBaseStation( 'ap2', protocols='OpenFlow13', ssid='ap-ssid2', mode= 'g', channel= '11', position='100,175,0' ) ap3 = net.addBaseStation( 'ap3', protocols='OpenFlow13', ssid='ap-ssid3', mode= 'g', channel= '6', position='150,115,0' ) ap4 = net.addBaseStation( 'ap4', protocols='OpenFlow13', ssid='ap-ssid4', mode= 'g', channel= '11', position='100,55,0' ) c5 = net.addController( 'c5', controller=RemoteController, port=6653 ) sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='60,100,0') h12 = net.addHost( 'h12', ip='10.0.0.109/8') root = net.addHost( 'root', ip='10.0.0.254/8', inNamespace=False ) print "*** Creating links" for sta in staList: net.addMesh(sta, ssid='meshNet') """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" net.addLink(phyap1, ap2) net.addLink(ap2, ap3) net.addLink(sta11, ap2) net.addLink(ap3, ap4) net.addLink(ap4, phyap1) net.addLink(root, ap3) net.addLink(phyap1, h12) print "*** Starting network" net.build() c5.start() phyap1.start( [c5] ) ap2.start( [c5] ) ap3.start( [c5] ) ap4.start( [c5] ) time.sleep(2) """output=all,flood""" ap3.cmd('dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100') ap3.cmd('dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100,meter:1 apply:output=flood') phyap1.cmd('dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=2,ip_dst=10.0.0.109,eth_type=0x800,ip_proto=6,tcp_dst=80 apply:set_field=tcp_dst:80,set_field=ip_dst:10.0.0.111,output=5') phyap1.cmd('dpctl unix:/tmp/phyap1 flow-mod table=0,cmd=add in_port=1,eth_type=0x800,ip_proto=6,tcp_src=80 apply:set_field=ip_src:10.0.0.109,output=2') fixNetworkManager( root, 'root-eth0' ) startNAT(root, internetIface) sta11.cmd('ip route add default via 10.0.0.254') sta11.cmd('pushd /home/fontes; python3 -m http.server 80 &') ip = 201 for sta in staList: sta.setIP('10.0.0.%s/8' % ip, intf="%s-wlan1" % sta) sta.cmd('ip route add default via 10.0.0.254') ip+=1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=200, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet( controller=RemoteController, link=TCLink, switch=UserSwitch ) sta = [] print "*** Creating nodes" for n in range(10): sta.append(n) sta[n] = net.addStation( 'sta%s' % (n+1), wlans=2, mac='00:00:00:00:00:%s' % (n+1), ip='192.168.0.%s/24' % (n+1) ) phyap1 = net.addPhysicalBaseStation( 'phyap1', protocols='OpenFlow13', ssid= 'ap-ssid1', mode= 'g', channel= '1', position='50,115,0', wlan='wlan11' ) ap2 = net.addBaseStation( 'ap2', protocols='OpenFlow13', ssid= 'ap-ssid2', mode= 'g', channel= '11', position='100,175,0' ) ap3 = net.addBaseStation( 'ap3', protocols='OpenFlow13', ssid= 'ap-ssid3', mode= 'g', channel= '6', position='150,115,0' ) ap4 = net.addBaseStation( 'ap4', protocols='OpenFlow13', ssid= 'ap-ssid4', mode= 'g', channel= '6', position='100,55,0' ) sta11 = net.addStation( 'sta11', ip='10.0.0.111/8', position='120,200,0') c1 = net.addController( 'c1', controller=RemoteController, port=6653 ) root = Node( 'root', inNamespace=False ) print "*** Creating links" for station in sta: net.addMesh(station, ssid='meshNet') """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" net.addLink(phyap1, ap2) net.addLink(ap2, ap3) net.addLink(sta11, ap2) net.addLink(ap3, ap4) net.addLink(ap4, phyap1) link = net.addLink( root, ap3 ) link.intf1.setIP( '10.254', 8 ) """Adding datapath""" net.addOfDataPath('ap3', 'wlan0') print "*** Starting network" net.build() c1.start() phyap1.start( [c1] ) ap2.start( [c1] ) ap3.start( [c1] ) ap4.start( [c1] ) time.sleep(2) """output=all,flood""" ap3.cmd('dpctl unix:/tmp/ap3 meter-mod cmd=add,flags=1,meter=1 drop:rate=100') ap3.cmd('dpctl unix:/tmp/ap3 flow-mod table=0,cmd=add in_port=4,eth_type=0x800,ip_dst=10.0.0.100, meter:1 apply:output=flood') startNAT( root ) sta11.cmd('ip route add default via 10.0.0.254') sta11.cmd('pushd /homt/alpha; python3 -m http.server 80 &') ip = 201 for station in sta: station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip)) station.cmd('ip route add default via 10.0.0.254') ip+=1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI( net ) print "*** Stopping network" net.stop()
def topology(): "Create a network." net = Mininet(controller=RemoteController, link=TCLink, switch=OVSKernelSwitch) sta = [] print "*** Creating nodes" for n in range(10): sta.append(n) sta[n] = net.addStation('sta%s' % (n + 1), wlans=2, mac='00:00:00:00:00:%s' % (n + 1), ip='192.168.0.%s/24' % (n + 1)) phyap1 = net.addPhysicalBaseStation('phyap1', ssid='ap-ssid1', mode='g', channel='1', position='50,115,0', wlan='wlan11') ap2 = net.addBaseStation('ap2', ssid='ap-ssid2', mode='g', channel='11', position='100,175,0') c1 = net.addController('c1', controller=Controller, port=6653) root = Node('root', inNamespace=False) print "*** Creating links" for station in sta: net.addMesh(station, ssid='meshNet') """uncomment to plot graph""" net.plotGraph(max_x=240, max_y=240) """Routing""" net.meshRouting('custom') """Seed""" net.seed(20) print "*** Associating and Creating links" net.addLink(phyap1, ap2) print "*** Starting network" net.build() c1.start() phyap1.start([c1]) ap2.start([c1]) ip = 201 for station in sta: station.cmd('ifconfig %s-wlan1 10.0.0.%s/8' % (station, ip)) ip += 1 "*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***" net.startMobility(startTime=0, model='RandomWalk', max_x=200, max_y=220, min_v=0.1, max_v=0.2) print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop()