本文整理汇总了Python中mininet.net.Mininet.addStation方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.addStation方法的具体用法?Python Mininet.addStation怎么用?Python Mininet.addStation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.addStation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
image = 'shub1905/chaos:hostapd_latest'
image2 = 'shub1905/ubuntu:updated_wpa'
cmd = '/bin/ash'
cmd2 = '/bin/bash'
print "*** Creating nodes"
sta1 = net.addStation( 'sta1', ip='10.0.0.1', passwd='123456789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 )
sta2 = net.addStation( 'sta2', ip='10.0.0.2', passwd='12346789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 )
sta3 = net.addStation( 'sta3', ip='10.0.0.3', passwd='123456789a', encrypt='wpa2', cls=Docker, dimage=image2, dcmd=cmd2 )
# sta1 = net.addStation( 'sta1', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
# sta2 = net.addStation( 'sta2', passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5", passwd='123456789a', encrypt='wpa2' ) #encrypt=(wpa,wpa2,wep)
c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )
print "*** Associating Stations"
net.addLink(sta1, ap1)
net.addLink(sta2, ap1)
net.addLink(sta3, ap1)
print "*** Starting network"
net.build()
c0.start()
ap1.start( [c0] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例2: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1', wlans=3 ) # 3 wlan added
sta2 = net.addStation( 'sta2' ) # 1 wlan added
ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel=5 ) # 1 wlan added
c0 = net.addController('c0', controller=Controller)
print "*** Associating..."
net.addLink(ap1, sta1)
net.addHoc(sta1, ssid='adhoc1', mode='g')
net.addHoc(sta2, ssid='adhoc1', mode='g')
print "*** Starting network"
net.build()
c0.start()
ap1.start( [c0] )
print "***Addressing..."
sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
sta2.setIP('192.168.10.2/24', intf="sta2-wlan0")
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例3: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1', ip="192.168.0.1/24" )
sta2 = net.addStation( 'sta2', ip="192.168.0.2/24" )
sta3 = net.addStation( 'sta3', ip="192.168.0.3/24" )
sta4 = net.addStation( 'sta4', ip="192.168.0.4/24" )
ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel="1" )
ap2 = net.addBaseStation( 'ap2', ssid="ssid_2", mode="b", channel="6" )
c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6653 )
print "*** Adding Link"
net.addLink(ap1, ap2) #wired connection
net.addLink(sta1, ap1)
net.addLink(sta2, ap1)
net.addLink(sta3, ap2)
net.addLink(sta4, ap2)
print "*** Starting network"
net.build()
c0.start()
ap1.start( [c0] )
ap2.start( [c0] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例4: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [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()
示例5: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller )
info( '*** Adding controller\n' )
net.addController( 'c0' )
image = 'ubuntu'
cmd = '/bin/bash'
print "*** Creating nodes"
ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5", passwd='123456789a', encrypt='wpa2')
sta1 = net.addStation( 'sta1', passwd='123456789a', encrypt='wpa2')
sta2 = net.addStation( 'sta2', passwd='123456789ab', encrypt='wpa2')
sta3 = net.addStation( 'sta3', passwd='123456789a', encrypt='wpa2')
h1 = net.addHost('h1', cls=Docker, dimage=image, dcmd=cmd)
h2 = net.addHost('h2', cls=Docker, dimage=image, dcmd=cmd)
h3 = net.addHost('h3')
h4 = net.addHost('h4', cls=Docker, dimage=image, dcmd=cmd)
c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633)
s1 = net.addSwitch( 's1')
s2 = net.addSwitch( 's2')
print "*** Associating Stations"
net.addLink(sta1, ap1)
net.addLink(sta2, ap1)
net.addLink(sta3, ap1)
net.addLink(h1, ap1)
net.addLink(h2, ap1)
net.addLink(h3, ap1)
net.addLink(ap1, s1)
net.addLink(s1, s2)
net.addLink(s2, h4)
print "*** Starting network"
net.build()
c0.start()
ap1.start( [c0] )
s1.start( [c0] )
s2.start( [c0] )
print "*** Running CLI"
CLI(net)
print "*** Stopping network"
net.stop()
system('sudo mn -c')
system('docker stop $(docker ps -aq);docker rm $(docker ps -aq)')
示例6: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1' )
sta2 = net.addStation( 'sta2', wlans=1, mac='00:02:00:00:00:02', ip='10.0.0.2/8' )
sta3 = net.addStation( 'sta3', wlans=1, mac='00:02:00:00:00:03', ip='10.0.0.3/8' )
sta4 = net.addStation( 'sta4', wlans=1, mac='00:02:00:00:00:04', ip='10.0.0.4/8' )
c5 = net.addController( 'c5', ip='127.0.0.1', port=6633 )
h7 = net.addHost( 'h7', mac='00:00:00:00:00:07', ip='10.0.0.7/8' )
print "*** Creating links"
net.addLink(sta4, ap1)
net.addLink(sta3, ap1)
net.addLink(sta2, ap1)
net.addLink(ap1, h7)
print "*** Starting network"
net.build()
c5.start()
ap1.start( [c5] )
ap1.cmd("iw dev ap1-wlan0 interface add vwlan1 type managed")
ap1.cmd("iw dev ap1-wlan0 interface add vwlan2 type managed")
ap1.cmd("ifconfig vwlan1 hw ether 00:00:00:aa:bb:11")
ap1.cmd("ifconfig vwlan2 hw ether 00:00:00:aa:bb:22")
ap1.cmd("ifconfig vwlan1 up")
ap1.cmd("ifconfig vwlan2 up")
ap1.cmd("ovs-vsctl add-port ap1 vwlan1")
ap1.cmd("ovs-vsctl add-port ap1 vwlan2")
ap1.cmd("echo -e 'interface=vwlan1\ndriver=nl80211\nssid=vwlan1\nhw_mode=g\nchannel=1\nwme_enabled=1\nwmm_enabled=1' > vwlan1.conf")
ap1.cmd("hostapd -B vwlan1.conf &")
ap1.cmd("echo -e 'interface=vwlan2\ndriver=nl80211\nssid=vwlan2\nhw_mode=g\nchannel=1\nwme_enabled=1\nwmm_enabled=1' > vwlan2.conf")
ap1.cmd("hostapd -B vwlan2.conf &")
sta2.cmd("ifconfig sta2-wlan0 down")
sta2.cmd("iwconfig sta2-wlan0 essid 'vwlan1'")
sta2.cmd("ifconfig sta2-wlan0 up")
sta3.cmd("ifconfig sta3-wlan0 down")
sta3.cmd("iwconfig sta3-wlan0 essid 'vwlan2'")
sta3.cmd("ifconfig sta3-wlan0 up")
### after the above setting, sta2( sta3, or sta4) can ping h7. sta2 can also ping sta3/sta4.
#the following rule can block sta2 from communicating with other host or station
ap1.cmd("ovs-ofctl add-flow ap1 priority=65535,ip,nw_dst=10.0.0.2,actions=drop")
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例7: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)
print "*** Creating nodes"
sta1 = net.addStation("sta1", mac="00:00:00:00:00:02", ip="10.0.0.2/8", speed=1)
sta2 = net.addStation("sta2", mac="00:00:00:00:00:03", ip="10.0.0.3/8", speed=3)
ap1 = net.addBaseStation("ap1", ssid="new-ssid", mode="g", channel="1", position="50,50,0")
c1 = net.addController("c1", controller=Controller)
print "*** Starting network"
net.build()
c1.start()
ap1.start([c1])
"""uncomment to plot graph"""
net.plotGraph(max_x=100, max_y=100)
getTrace(sta1, "examples/replaying/replayingMobility/node1.dat")
getTrace(sta2, "examples/replaying/replayingMobility/node2.dat")
replayingMobility()
print "*** Running CLI"
CLI(net)
print "*** Stopping network"
net.stop()
示例8: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( wirelessRadios=6, controller=RemoteController, link=TCLink, switch=OVBaseStation )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1' )
sta2 = net.addStation( 'sta2' )
bs1 = net.addBaseStation( 'bs1' )
c0 = net.addController('c0', controller=OVSController, port=6633 )
print "*** Adding Link"
net.addLink(sta1, bs1)
net.addLink(sta2, bs1)
print "*** Starting network"
net.build()
c0.start()
bs1.start( [c0] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例9: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
c1 = net.addController( 'c1', controller=Controller )
print "*** adding Link"
net.addLink(sta1, ap1)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
"""uncomment to plot graph"""
net.plotGraph(max_x=100, max_y=100)
getTrace(sta1, 'examples/replaying/replayingBandwidth/throughputData.dat')
replayingBandwidth()
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例10: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='10,10,0' )
c1 = net.addController( 'c1', controller=Controller )
"""uncomment to plot graph"""
#net.plotGraph(max_x=60, max_y=60)
print "*** Associating and Creating links"
net.addLink(ap1, h1, 1, 0)
net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
"*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWaypoint, GaussMarkov ***"
net.startMobility(0, model='GaussMarkov', max_x=20, max_y=20, min_v=0.1, max_v=0.3)
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例11: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( wirelessRadios=3, controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
c1 = net.addController( 'c1', controller=Controller )
print "*** Creating links"
net.addLink(ap1, h1, 1, 0)
net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例12: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
#wirelessRadios = Number of STAs + APs
print "*** Creating nodes"
ap1 = net.addBaseStation( 'ap1', ssid="simplewifi", mode="g", channel="5" )
sta1 = net.addStation( 'sta1', ip='192.168.0.1/24' )
sta2 = net.addStation( 'sta2', ip='192.168.0.2/24' )
h3 = net.addHost( 'h3', ip='192.168.0.3/24' )
h4 = net.addHost( 'h4', ip='192.168.0.4/24' )
c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )
print "*** Adding Link"
net.addLink(sta1, ap1)
net.addLink(sta2, ap1)
net.addLink(h3, ap1)
net.addLink(h4, ap1)
print "*** Starting network"
net.build()
c0.start()
ap1.start( [c0] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例13: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)
print "*** Creating nodes"
h1 = net.addHost("h1", mac="00:00:00:00:00:01", ip="10.0.0.1/8")
sta1 = net.addStation("sta1", mac="00:00:00:00:00:02", ip="10.0.0.2/8", position="10,20,0")
sta2 = net.addStation("sta2", mac="00:00:00:00:00:03", ip="10.0.0.3/8", position="10,30,0")
ap1 = net.addBaseStation("ap1", ssid="new-ssid", mode="g", channel="1", position="15,30,0")
c1 = net.addController("c1", controller=Controller)
"""uncomment to plot graph"""
# net.plotGraph(max_x=60, max_y=60)
print "*** Creating links"
net.addLink(ap1, h1, 1, 0)
net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
print "*** Starting network"
net.build()
c1.start()
ap1.start([c1])
print "*** Running CLI"
CLI(net)
print "*** Stopping network"
net.stop()
示例14: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
c1 = net.addController( 'c1', controller=Controller )
"""uncomment to plot graph"""
#net.plotGraph(max_x=60, max_y=60)
print "*** Creating links"
net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例15: topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addStation [as 别名]
def topology():
"Create a network."
net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )
print "*** Creating nodes"
sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
c1 = net.addController( 'c1', controller=Controller )
print "*** Associating and Creating links"
net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
"""uncomment to plot graph"""
net.plotGraph(max_x=100, max_y=100)
"""Seed"""
net.seed(20)
"*** Available models: RandomWalk, TruncatedLevyWalk, RandomDirection, RandomWayPoint, GaussMarkov, ReferencePoint, TimeVariantCommunity ***"
net.startMobility(startTime=0, model='RandomDirection', max_x=60, max_y=60, min_v=0.5, max_v=0.5)
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()