本文整理汇总了Python中mininet.net.Mininet.addAP方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.addAP方法的具体用法?Python Mininet.addAP怎么用?Python Mininet.addAP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.addAP方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addAP [as 别名]
def main():
net = Mininet()
net.addController('c0', controller=RemoteController, ip="127.0.0.1", port=6633)
sw0 = net.addSwitch('sw0', ip=None)
ap0 = net.addAP('ap0', ip=None)
mininet.ns3.setMobilityModel(ap0, None)
mininet.ns3.setPosition(ap0, 0, 0, 0)
ap1 = net.addAP('ap1', ip=None)
mininet.ns3.setMobilityModel(ap1, None)
mininet.ns3.setPosition(ap1, 10, 10, 0)
sta0 = net.addStation('sta0', ip="10.0.0.1")
mininet.ns3.setMobilityModel(sta0, None)
mininet.ns3.setVelocity(sta0, 0, 5, 0)
sta1 = net.addStation('sta1', ip="10.0.0.2")
mininet.ns3.setMobilityModel(sta1, None)
mininet.ns3.setVelocity(sta1, 5, 0, 0)
wifi = WifiSegment(standard=ns.wifi.WIFI_PHY_STANDARD_80211g)
wifi.addAp(ap0, channelNumber=11, ssid="opennet_0")
wifi.addAp(ap1, channelNumber=11, ssid="opennet_1")
wifi.addSta(sta0, channelNumber=11, ssid="opennet_0")
wifi.addSta(sta1, channelNumber=11, ssid="opennet_1")
net.addLink(sw0, ap0)
net.addLink(sw0, ap1)
net.start()
mininet.ns3.start()
sta0.cmdPrint('ping -c2 ' + sta1.IP())
sta1.cmdPrint('ping -c2 ' + sta0.IP())
CLI(net)
mininet.ns3.stop()
mininet.ns3.clear()
net.stop()
示例2: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addAP [as 别名]
def main():
net = Mininet()
net.addController("c0", controller=RemoteController, ip="127.0.0.1", port=6633)
wifi = WifiSegment()
# About AP
ap0 = net.addAP("ap0")
mininet.ns3.setMobilityModel(ap0, None)
mininet.ns3.setPosition(ap0, 0, 0, 0)
wifi.addAp(ap0, channelNumber=6, ssid="opennet_ap")
# Check mininet.node.AP
if isinstance(ap0, mininet.node.AP):
print("I'm a AP")
# About Station
sta0 = net.addStation("sta0")
mininet.ns3.setMobilityModel(sta0, None)
mininet.ns3.setPosition(sta0, 0, 0, 0)
wifi.addSta(sta0, channelNumber=6, ssid="opennet_ap")
# Check mininet.node.Station
if isinstance(sta0, mininet.node.Station):
print("I'm a station")
print("APs list: {0}\nSTAs list: {1}\n".format(wifi.aps, wifi.stas))
# About OVSSwitch
s0 = net.addSwitch("s0")
# About Host
h0 = net.addHost("h0", ip="1.1.1.1")
# Ignore warning message: "defaultIntf: warning: h0 has no interfaces"
net.addLink(s0, h0)
print("Switches list: {0}\nHosts list: {1}\n".format(net.switches, net.hosts))
mininet.ns3.start()
net.start()
mininet.ns3.stop()
net.stop()
示例3: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addAP [as 别名]
def main():
net = Mininet()
net.addController('c0', controller=RemoteController, ip="127.0.0.1", port=6633)
natIP="10.0.0.220"
cpu = 0.1
wifi = WifiSegment(standard=ns.wifi.WIFI_PHY_STANDARD_80211g)
#Added for NAT
hostConfig = {'cpu': cpu, 'defaultRoute': 'via ' + natIP }
print("Building Switch")
# About OVSSwitch
s0 = net.addSwitch('s0', ip=None)
print ("Building APs")
# About AP
ap0 = net.addAP('ap0', ip=None)
mininet.ns3.setMobilityModel(ap0, None)
mininet.ns3.setPosition(ap0, 10, 0, 20)
ap1 = net.addAP('ap1', ip=None)
mininet.ns3.setMobilityModel(ap1, None)
mininet.ns3.setPosition(ap1, 10, 10, 0)
# Check mininet.node.AP
if isinstance(ap0, mininet.node.AP):
print("I'm AP 2")
if isinstance(ap1, mininet.node.AP):
print("I'm AP 1")
print("Building Hosts")
# About Host
#h0 = net.addHost('h0', ip="10.1.1.1")
h0 = net.addHost('h0', mac='00:00:00:00:00:01', ip="10.0.0.1", **hostConfig)
h1 = net.addHost('h1', mac='00:00:00:00:00:02', ip="10.0.0.2", **hostConfig)
print "Building Stations"
# About Station
## sta0 = net.addStation('sta0', ip="10.1.1.5", **hostConfig)
sta0 = net.addStation('sta0', ip='192.168.1.100/24',
defaultRoute='via 192.168.1.1')
mininet.ns3.setMobilityModel(sta0, None)
mininet.ns3.setPosition(sta0, 10, 0, 20)
## sta1 = net.addStation('sta1', ip="10.1.1.6", **hostConfig)
sta1 = net.addStation('sta1', ip='192.168.1.101/24',
defaultRoute='via 192.168.1.1')
mininet.ns3.setMobilityModel(sta1, None)
mininet.ns3.setPosition(sta1, 10, 0, 15)
## sta2 = net.addStation('sta2', ip="10.1.1.7", **hostConfig)
sta2 = net.addStation('sta2', ip='192.168.1.102/24',
defaultRoute='via 192.168.1.1')
mininet.ns3.setMobilityModel(sta2, None)
mininet.ns3.setPosition(sta2, 10, 0, 25)
## sta3 = net.addStation('sta3', ip="10.1.1.8", **hostConfig)
sta3 = net.addStation('sta3', ip='192.168.2.100/24',
defaultRoute='via 192.168.2.1')
mininet.ns3.setMobilityModel(sta3, None)
mininet.ns3.setPosition(sta3, 10, 10, 0)
sta4 = net.addStation('sta4', ip='192.168.2.101/24',
defaultRoute='via 192.168.2.1')
mininet.ns3.setMobilityModel(sta4, None)
mininet.ns3.setPosition(sta4, 10, 10, 5)
sta5 = net.addStation('sta5', ip='192.168.2.102/24',
defaultRoute='via 192.168.2.1')
mininet.ns3.setMobilityModel(sta5, None)
mininet.ns3.setPosition(sta5, 10, 10, 10)
#Check mininet.node.Station
if isinstance(sta0, mininet.node.Station):
print("I'm station 0")
if isinstance(sta1, mininet.node.Station):
print("I'm station 1")
if isinstance(sta2, mininet.node.Station):
print("I'm station 2")
if isinstance(sta3, mininet.node.Station):
print("I'm station 3")
if isinstance(sta4, mininet.node.Station):
print("I'm station 4")
if isinstance(sta5, mininet.node.Station):
print("I'm station 5")
print("****Preparing to list devices***")
print("APs list: {0}\nSTAs list: {1}\n".format(wifi.aps, wifi.stas))
wifi.addAp(ap0, channelNumber=6, ssid="opennet_0")
wifi.addSta(sta0, channelNumber=6, ssid="opennet_0")
wifi.addSta(sta1, channelNumber=6, ssid="opennet_0")
wifi.addSta(sta2, channelNumber=6, ssid="opennet_0")
wifi.addAp(ap1, channelNumber=11, ssid="opennet_1")
wifi.addSta(sta3, channelNumber=11, ssid="opennet_1")
wifi.addSta(sta4, channelNumber=11, ssid="opennet_1")
wifi.addSta(sta5, channelNumber=11, ssid="opennet_1")
#Building NATs
print("Building NAT")
#.........这里部分代码省略.........
示例4: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addAP [as 别名]
def main():
net = Mininet()
net.addController('c0', controller=RemoteController, ip="127.0.0.1", port=6633)
wifi = WifiSegment()
print "Building APs"
# About AP
ap0 = net.addAP('ap0', ip="10.1.1.3")
mininet.ns3.setMobilityModel(ap0, None)
mininet.ns3.setPosition(ap0, 0, 0, 0)
wifi.addAp(ap0, channelNumber=11, ssid="opennet_ap")
ap1 = net.addAP('ap1', ip="10.1.1.4")
mininet.ns3.setMobilityModel(ap1, None)
mininet.ns3.setPosition(ap1, 10, 10, 10)
wifi.addAp(ap1, channelNumber=1, ssid="opennet_ap2")
# Check mininet.node.AP
if isinstance(ap0, mininet.node.AP):
print("I'm an AP")
if isinstance(ap1, mininet.node.AP):
print("I'm an AP also")
print "Building Stations"
# About Station
sta0 = net.addStation('sta0', ip="10.1.2.1")
mininet.ns3.setMobilityModel(sta0, None)
mininet.ns3.setPosition(sta0, 0, 0, 0)
wifi.addSta(sta0, channelNumber=11, ssid="opennet_ap")
sta1 = net.addStation('sta1', ip="10.1.2.2")
mininet.ns3.setMobilityModel(sta1, None)
mininet.ns3.setPosition(sta1, 0, 0, 5)
wifi.addSta(sta1, channelNumber=11, ssid="opennet_ap")
sta2 = net.addStation('sta2', ip="10.1.2.3")
mininet.ns3.setMobilityModel(sta2, None)
mininet.ns3.setPosition(sta2, 0, 5, 0)
wifi.addSta(sta2, channelNumber=11, ssid="opennet_ap")
sta3 = net.addStation('sta3', ip="10.1.3.1")
mininet.ns3.setMobilityModel(sta3, None)
mininet.ns3.setPosition(sta3, 10, 10, 10)
wifi.addSta(sta3, channelNumber=1, ssid="opennet_ap2")
#Check mininet.node.Station
if isinstance(sta0, mininet.node.Station):
print("I'm a station")
if isinstance(sta1, mininet.node.Station):
print("I'm a station also")
print("****Preparing to list devices***")
print("APs list: {0}\nSTAs list: {1}\n".format(wifi.aps, wifi.stas))
print("Building Switch")
# About OVSSwitch
s0 = net.addSwitch('s0')
print("Building Hosts")
# About Host
h0 = net.addHost('h0', ip="10.1.1.1")
h1 = net.addHost('h1', ip="10.1.1.2")
print("Building Links")
# Ignore warning message: "defaultIntf: warning: h0 has no interfaces"
net.addLink(s0, h0)
net.addLink(s0, h1)
net.addLink(s0, ap0)
net.addLink(s0, ap1)
print("Switches list: {0}\nHosts list: {1}\n".format(net.switches, net.hosts))
info('***Starting Network***\n')
mininet.ns3.start()
net.start()
info( 'Testing network connectivity\n' )
h0.cmdPrint( 'ping 10.1.1.2 -c3' )
sta0.cmdPrint('ping -c2 ' + sta3.IP())
sta1.cmdPrint('ping -c2 ' + sta3.IP())
CLI(net)
mininet.ns3.stop()
net.stop()
示例5: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addAP [as 别名]
def main():
net = Mininet()
net.addController('c0', controller=RemoteController, ip="127.0.0.1", port=6633)
wifi = WifiSegment(standard=ns.wifi.WIFI_PHY_STANDARD_80211g)
print("Building Switch")
# About OVSSwitch
s0 = net.addSwitch('s0', ip=None)
print("Building Hosts")
# About Host
h0 = net.addHost('h0', ip="10.1.1.1")
h1 = net.addHost('h1', ip="10.1.1.2")
print ("Building APs")
# About AP
ap0 = net.addAP('ap0', ip=None)
mininet.ns3.setMobilityModel(ap0, None)
mininet.ns3.setPosition(ap0, 10, 0, 20)
ap1 = net.addAP('ap1', ip=None)
mininet.ns3.setMobilityModel(ap1, None)
mininet.ns3.setPosition(ap1, 10, 10, 0)
# Check mininet.node.AP
if isinstance(ap0, mininet.node.AP):
print("I'm AP 2")
if isinstance(ap1, mininet.node.AP):
print("I'm AP 1")
print "Building Stations"
# About Station
sta0 = net.addStation('sta0', ip="10.1.1.5")
mininet.ns3.setMobilityModel(sta0, None)
mininet.ns3.setPosition(sta0, 10, 0, 20)
sta1 = net.addStation('sta1', ip="10.1.1.6")
mininet.ns3.setMobilityModel(sta1, None)
mininet.ns3.setPosition(sta1, 10, 0, 15)
sta2 = net.addStation('sta2', ip="10.1.1.7")
mininet.ns3.setMobilityModel(sta2, None)
mininet.ns3.setPosition(sta2, 10, 0, 25)
sta3 = net.addStation('sta3', ip="10.1.1.8")
mininet.ns3.setMobilityModel(sta3, None)
mininet.ns3.setPosition(sta3, 10, 10, 0)
#Check mininet.node.Station
if isinstance(sta0, mininet.node.Station):
print("I'm station 0")
if isinstance(sta1, mininet.node.Station):
print("I'm station 1")
if isinstance(sta2, mininet.node.Station):
print("I'm station 2")
if isinstance(sta3, mininet.node.Station):
print("I'm station 3")
print("****Preparing to list devices***")
print("APs list: {0}\nSTAs list: {1}\n".format(wifi.aps, wifi.stas))
print("Building Links")
# Ignore warning message: "defaultIntf: warning: h0 has no interfaces"
net.addLink(s0, h0)
net.addLink(s0, h1)
wifi.addAp(ap0, channelNumber=6, ssid="opennet_0")
wifi.addSta(sta0, channelNumber=6, ssid="opennet_0")
wifi.addSta(sta1, channelNumber=6, ssid="opennet_0")
wifi.addSta(sta2, channelNumber=6, ssid="opennet_0")
wifi.addAp(ap1, channelNumber=11, ssid="opennet_1")
wifi.addSta(sta3, channelNumber=11, ssid="opennet_1")
net.addLink(s0, ap0)
net.addLink(s0, ap1)
print("Switches list: {0}\nHosts list: {1}\n".format(net.switches, net.hosts))
info('***Starting Network***\n')
mininet.ns3.start()
net.start()
info( 'Testing network connectivity\n' )
print ( '\n\nTesting h0 -> h1 \n\n' )
h0.cmdPrint( 'ping 10.1.1.2 -c2' )
print ( '\n\nTesting h0 -> sta0 \n\n')
h0.cmdPrint( 'ping 10.1.1.5 -c2' )
print ( '\n\nTesting h0 -> sta1 \n\n')
h0.cmdPrint( 'ping 10.1.1.6 -c2' )
print ( '\n\nTesting h0 -> sta2 \n\n')
h0.cmdPrint( 'ping 10.1.1.7 -c2' )
print ( '\n\nTesting h0 -> sta3 \n\n')
#.........这里部分代码省略.........