本文整理汇总了Python中mininet.net.Mininet.addMesh方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.addMesh方法的具体用法?Python Mininet.addMesh怎么用?Python Mininet.addMesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.addMesh方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addMesh [as 别名]
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()
示例2: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addMesh [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
car = []
for x in range(0,20):
car.append(x)
for x in range(0,20):
car[x] = net.addVehicle( 'car%s' % x, wlans=2, ip='10.0.0.%s/8' % (x+1) )
bs1 = net.addBaseStation( 'BS1', ssid= 'new-ssid1', mode= 'g', channel= '1' )
bs2 = net.addBaseStation( 'BS2', ssid= 'new-ssid2', mode= 'g', channel= '6' )
bs3 = net.addBaseStation( 'BS3', ssid= 'new-ssid3', mode= 'g', channel= '11' )
c1 = net.addController( 'c1', controller=Controller )
print "*** Associating and Creating links"
for x in range(0,20):
net.addMesh(car[x], ssid='mesh')
net.addLink(bs1, bs2)
net.addLink(bs1, bs3)
print "*** Starting network"
net.build()
c1.start()
bs1.start( [c1] )
bs2.start( [c1] )
bs3.start( [c1] )
"""Available Options: sumo, sumo-gui"""
#Put your sumocfg file in /mininet/sumo/data
net.useExternalProgram('sumo-gui', config_file='map.sumocfg')
"""Routing"""
#net.meshRouting('custom')
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例3: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addMesh [as 别名]
def topology():
"Create a network."
net = Mininet( )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1' )
sta2 = net.addStation( 'sta2' )
sta3 = net.addStation( 'sta3' )
print "*** Creating links"
net.addMesh(sta1, ssid='meshNet')
net.addMesh(sta2, ssid='meshNet')
net.addMesh(sta3, ssid='meshNet')
print "*** Starting network"
net.build()
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例4: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addMesh [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
car1 = net.addVehicle( 'car1', wlans=2, mac='00:00:00:00:00:01', ip='10.0.0.1/8', min_speed=1, max_speed=5 )
car2 = net.addVehicle( 'car2', wlans=2, mac='00:00:00:00:00:02', ip='10.0.0.2/8', min_speed=5, max_speed=10 )
car3 = net.addVehicle( 'car3', mac='00:00:00:00:00:03', ip='10.0.0.3/8', min_speed=10, max_speed=15 )
car4 = net.addVehicle( 'car4', mac='00:00:00:00:00:04', ip='10.0.0.4/8', min_speed=15, max_speed=20 )
car5 = net.addVehicle( 'car5', mac='00:00:00:00:00:05', ip='10.0.0.5/8', min_speed=15, max_speed=20 )
bs1 = net.addBaseStation( 'BS1', ssid= 'new-ssid1', mode= 'g', channel= '1' )
bs2 = net.addBaseStation( 'BS2', ssid= 'new-ssid2', mode= 'g', channel= '6' )
bs3 = net.addBaseStation( 'BS3', ssid= 'new-ssid3', mode= 'g', channel= '11' )
c1 = net.addController( 'c1', controller=Controller )
print "*** Associating and Creating links"
net.addMesh(car1, ssid='mesh')
net.addMesh(car2, ssid='mesh')
net.addMesh(car3, ssid='mesh')
net.addMesh(car4, ssid='mesh')
net.addMesh(car5, ssid='mesh')
net.addLink(bs1, bs2)
net.addLink(bs1, bs3)
print "*** Starting network"
net.build()
c1.start()
bs1.start( [c1] )
bs2.start( [c1] )
bs3.start( [c1] )
"""uncomment to plot graph"""
net.plotGraph(max_x=500, max_y=500)
"""Number of Roads"""
net.roads(4)
"""Seed"""
net.seed(20)
"""Start Mobility"""
net.startMobility(startTime=0)
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例5: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addMesh [as 别名]
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()
示例6: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addMesh [as 别名]
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()