本文整理汇总了Python中mininet.net.Mininet.meshRouting方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.meshRouting方法的具体用法?Python Mininet.meshRouting怎么用?Python Mininet.meshRouting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.meshRouting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import meshRouting [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 meshRouting [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()
示例3: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import meshRouting [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()