def topology(): """Create a network. sta1 <--> sta2 <--> sta3""" print "*** Network creation" net = Mininet() print "*** Configure wmediumd" sta1wlan0 = StaticWmediumdIntfRef('sta1', 'sta1-wlan0', '02:00:00:00:00:00') sta2wlan0 = StaticWmediumdIntfRef('sta2', 'sta2-wlan0', '02:00:00:00:01:00') sta3wlan0 = StaticWmediumdIntfRef('sta3', 'sta3-wlan0', '02:00:00:00:02:00') intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0] links = [ WmediumdLink(sta1wlan0, sta2wlan0, 15), WmediumdLink(sta2wlan0, sta1wlan0, 15), WmediumdLink(sta2wlan0, sta3wlan0, 15), WmediumdLink(sta3wlan0, sta2wlan0, 15) ] WmediumdConn.set_wmediumd_data(intfrefs, links) WmediumdConn.connect_wmediumd_on_startup() print "*** Creating nodes" sta1 = net.addStation('sta1') sta2 = net.addStation('sta2') sta3 = net.addStation('sta3') print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Creating links" net.addHoc(sta1, ssid='adNet') net.addHoc(sta2, ssid='adNet') net.addHoc(sta3, ssid='adNet') print "*** Starting network" net.start() print "*** Running CLI" CLI(net) print "*** Stopping wmediumd" WmediumdConn.disconnect_wmediumd() 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') sta2 = net.addStation('sta2') sta3 = net.addStation('sta3') print "*** Configure wmediumd" # This should be done right after the station has been initialized sta1wlan0 = DynamicWmediumdIntfRef(sta1) sta2wlan0 = DynamicWmediumdIntfRef(sta2) sta3wlan0 = DynamicWmediumdIntfRef(sta3) intfrefs = [sta1wlan0, sta2wlan0, sta3wlan0] links = [ WmediumdLink(sta1wlan0, sta2wlan0, 15), WmediumdLink(sta2wlan0, sta1wlan0, 15), WmediumdLink(sta2wlan0, sta3wlan0, 15), WmediumdLink(sta3wlan0, sta2wlan0, 15)] WmediumdConn.set_wmediumd_data(intfrefs, links) WmediumdConn.connect_wmediumd_on_startup() print "*** Configuring wifi nodes" net.configureWifiNodes() print "*** Creating links" net.addHoc(sta1, ssid='adNet') net.addHoc(sta2, ssid='adNet') net.addHoc(sta3, ssid='adNet') print "*** Starting network" net.start() print "*** Running CLI" CLI(net) print "*** Stopping wmediumd" WmediumdConn.disconnect_wmediumd() 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. 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 = [ 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() 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 preivously defined. Useful to set channel params. net.autoAssociation() CLI(net) print "*** Stopping network" net.stop() print "*** Stopping wmediumd" WmediumdServerConn.disconnect() WmediumdConn.disconnect_wmediumd()