Python Mininet wifi自定义拓扑
起初,我想创建一个复杂的拓扑结构(更多交换机相互连接),但即使是这个简单的拓扑结构也不起作用。我无法获得工作连接,例如“h1 ping h2” 以下是拓扑结构: 他是应该创建等效拓扑的脚本:Python Mininet wifi自定义拓扑,python,wifi,sdn,mininet,topology,Python,Wifi,Sdn,Mininet,Topology,起初,我想创建一个复杂的拓扑结构(更多交换机相互连接),但即使是这个简单的拓扑结构也不起作用。我无法获得工作连接,例如“h1 ping h2” 以下是拓扑结构: 他是应该创建等效拓扑的脚本: !/usr/bin/python """ Setting the position of Nodes (only for Stations and Access Points) and providing mobility. """ from mininet.net import Mininet f
!/usr/bin/python
"""
Setting the position of Nodes (only for Stations and Access Points) and providing mobility.
"""
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSKernelAP
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, accessPoint=OVSKernelAP )
print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
h2 = net.addHost( 'h2', mac='00:00:00:00:00:11', ip='10.0.1.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='50,50,0' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='40,50,0')
sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', position='20,50,0' )
ap1 = net.addAccessPoint( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '5', position='25,50,0', range='35' )
ap2 = net.addAccessPoint( 'ap2', ssid= 'new-ssid', mode= 'g', channel= '5', position='75,50,0', range='35' )
c1 = net.addController( 'c1' )
s1 = net.addSwitch('s1')
#net.runAlternativeModule('../module/mac80211_hwsim.ko')
print "*** Configuring wifi nodes"
net.configureWifiNodes()
print "*** Associating and Creating links"
net.addLink(ap1, s1)
net.addLink(ap2, s1)
net.addLink(s1, c1)
#net.addLink(ap1, ap2)
net.addLink(s1, h1)
net.addLink(s1, h2)
net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
net.addLink(ap1, sta3)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
ap2.start( [c1] )
"""uncomment to plot graph"""
net.plotGraph(max_x=100, max_y=100)
net.startMobility(startTime=0)
net.mobility(sta1, 'start', time=1, position='0.0,50.0,0.0')
net.mobility(sta1, 'stop', time=30, position='100.0,50.0,0.0')
net.stopMobility(stopTime=31)
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
topology()
如前所述,我甚至无法ping h1和h2:(
我甚至尝试使用RemoteController,但得到了同样的结果。
你知道什么是错的吗?< /P> < P> <强>请考虑下面的变化:< /强>
from mininet.node import Controller, RemoteController, OVSKernelAP, OVSSwitch
net = Mininet( controller=Controller, link=TCLink, accessPoint=OVSKernelAP, switch=OVSSwitch )
c1 = net.addController( 'c1', controller=Controller )
s3 = net.addSwitch('s3')
删除:net.addLink(s1,c1)
添加:s3.启动([c1])
请注意,如果将AP和开关都设置为相同的ID(例如S1、AP1),默认情况下它们将具有相同的DPID。因此,我必须将S1重命名为S3。另一方面,当您添加节点时,可以将DPID定义为参数。
< P> <强>请考虑以下更改:< /强>from mininet.node import Controller, RemoteController, OVSKernelAP, OVSSwitch
net = Mininet( controller=Controller, link=TCLink, accessPoint=OVSKernelAP, switch=OVSSwitch )
c1 = net.addController( 'c1', controller=Controller )
s3 = net.addSwitch('s3')
删除:net.addLink(s1,c1)
添加:s3.启动([c1])
请注意,如果您使用相同的ID(例如s1、ap1)设置ap和交换机,则默认情况下它们将具有相同的DPID。因此,我必须将s1重命名为s3。另一方面,您可以在添加节点时将DPID定义为参数,无论是否需要