本文整理汇总了Python中mininet.node.Controller.start方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.start方法的具体用法?Python Controller.start怎么用?Python Controller.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Controller
的用法示例。
在下文中一共展示了Controller.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: emptyNet
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def emptyNet():
net = Mininet(topo=None, build=False)
c0 = Controller('c0', inNamespace=False)
h1 = Host('h1')
h2 = Host('h2')
#intf1 = Intf("h1-eth1")
#intf2 = Intf("h2-eth1")
s1 = OVSSwitch('br0', inNamespace=False)
Link(h1, s1)
Link(h2, s1)
c0.start()
s1.start([c0])
net.start()
#s1.cmd('ovs-vsctl set bridge br0 protocols=OpenFlow13')
CLI(net)
net.stop()
h1.stop()
h2.stop()
s1.stop()
c0.stop()
示例2: topology
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def topology():
"Create a network."
net = Mininet( link=TCLink, switch=OVSSwitch )
c0 = Controller( 'c0', port=6634 )
c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
net.addController(c0)
net.addController(c1)
print "*** Creating nodes"
s0 = net.addSwitch('s0')
ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
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' )
h1 = net.addHost('h0', ip='192.168.0.5')
h2 = net.addHost('h1', ip='192.168.0.6')
print "*** Adding Link"
net.addLink(sta1, ap1, bw=10, loss=0)
net.addLink(sta2, ap1, bw=10, loss=0)
net.addLink(sta3, ap2, bw=10, loss=0)
net.addLink(sta4, ap2, bw=10, loss=0)
net.addLink(ap1, s0)
net.addLink(ap2, s0)
net.addLink(h1, s0)
net.addLink(h2, s0)
net.build()
c0.start()
c1.start()
ap1.start( [c0] )
ap2.start( [c0] )
#nat0.start( [c0] )
s0.start([c1])
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例3: emptyNet
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=Controller)
info( '*** Adding controller\n' )
ctrlRemote = RemoteController( 'c0', ip=ipControladorOF )
net.addController(ctrlRemote)
info('--> remote IP controller - c0:' + ctrlRemote.IP() +'\n')
#ctrlLocal = RemoteController('c1', port=6633, ip="127.0.0.1")
ctrlLocal = Controller('c1', port=6634)
net.addController(ctrlLocal)
info('--> local IP controller - c1:' + ctrlLocal.IP() +'\n')
info( '*** Adding hosts\n' )
lanH1 = net.addHost('h1', ip='10.0.0.1')
lanH2 = net.addHost('h2', ip='10.0.0.2')
lanIDS = net.addHost('h3', ip='10.0.0.3')
lanRouter = net.addHost('h4')
wanH1 = net.addHost('h5', ip='192.168.0.5')
wanH2 = net.addHost('h6', ip='192.168.0.6')
info( '*** Adding switch\n' )
lanSw = net.addSwitch('s1')
wanSw = net.addSwitch('s2')
info( '*** Creating links\n' )
net.addLink(lanH1, lanSw)
net.addLink(lanH2, lanSw)
net.addLink(lanIDS, lanSw)
net.addLink(lanRouter, lanSw)
net.addLink(lanRouter, wanSw)
net.addLink(wanH1, wanSw)
net.addLink(wanH2, wanSw)
info( '*** Starting network\n')
net.start()
info('*** Starting controllers and switches')
#link remote controller to s0 internal network swith
ctrlRemote.start()
#use remote controller
lanSw.start([ctrlRemote])
#use local controller
#info('\n\n\n************ using local controller for swLAN')
#lanSw.start([ctrlLocal])
#start local controller to switch from s1 external network
ctrlLocal.start()
wanSw.start([ctrlLocal])
info( '*** Executing hosts scripts\n')
execCmds(net)
sleep(5) # wai 5 seconds to start IDS!
#log tests in files, the name of file and directory will be composed by date/time of start execution of test
hst1 = net.getNodeByName('h1')
hst1.cmdPrint('mkdir /var/log/tcpdump/'+date)
arquivo = open('/var/log/tcpdump/'+date+'/teste.txt', 'w')
textoTeste = """
Test -
\n Begin at:\n
"""
data = datetime.datetime.now()
textoTeste=textoTeste+"%s/%s/%s as %s:%s:%s:%s\n"%(data.year,data.month,data.day,data.hour,data.minute,data.second,data.microsecond)
arquivo.write(textoTeste)
### Tests
#
# Start the testes here!
#
# Select the test to run. For that uncomment the line of the desired test.
info( '*** Executing Tests\n')
textoTeste = textoTeste =teste1(net)
#textoTeste = testeIperf(net)
#textoTeste = testeIDSWakeupExternoInterno(net)
#textoTeste = testeDDoSExtInt(net)
#textoTeste = testeDDoSIntExt(net)
#textoTeste = testeDDoSIntInt(net)
# record attack test!
textoTeste = textoTeste+"""
put comment of test here
"""
arquivo.write(textoTeste)
### end of test!
# register the time that test was finished
#.........这里部分代码省略.........
示例4: start
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def start(self):
Controller.start(self)
sleep(1)
示例5: topology
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def topology():
"Create a network."
net = Mininet( link=TCLink, switch=OVSSwitch )
#create local controller for APs
c0 = Controller( 'c0', port=6634 )
#create controller for s0 (Ryuretic)
c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
net.addController(c0)
net.addController(c1)
print "*** Creating nodes"
s0 = net.addSwitch('s0')
ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
###########
ap3 = net.addBaseStation( 'ap3', ssid="ssid_ap3", mode="g", channel="10" )
sta1 = net.addStation( 'sta1', ip='192.168.0.1/24',
defaultRoute='via 192.168.0.224' )
sta2 = net.addStation( 'sta2', ip='192.168.0.2/24',
defaultRoute='via 192.168.0.224' )
sta3 = net.addStation( 'sta3', ip='192.168.0.3/24',
defaultRoute='via 192.168.0.224' )
sta4 = net.addStation( 'sta4', ip='192.168.0.4/24',
defaultRoute='via 192.168.0.224' )
#############
sta5 = net.addStation( 'sta5', ip='10.0.0.2/24', defaultRoute='via 10.0.0.22' )
sta6 = net.addStation( 'sta6', ip='10.0.0.3/24', defaultRoute='via 10.0.0.22')
#############
h1 = net.addHost('h1', ip='192.168.0.5', defaultRoute='via 192.168.0.224')
h2 = net.addHost('h2', ip='192.168.0.6', defaultRoute='via 192.168.0.224')
print "*** Adding Link"
net.addLink(sta1, ap1, bw=10, loss=0)
net.addLink(sta2, ap1, bw=10, loss=0)
net.addLink(sta3, ap2, bw=10, loss=0)
net.addLink(sta4, ap2, bw=10, loss=0)
###############
net.addLink(sta5, ap3, bw=10, loss=0)
net.addLink(sta6, ap3, bw=10, loss=0)
net.addLink(ap1, s0)
net.addLink(ap2, s0)
net.addLink(h1, s0)
net.addLink(h2, s0)
######
##############################################################
#Add NAT granting access to Internet
nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224',
subnet='192.168.0.0/24', inNamespace=False)
net.addLink(nat, s0)
##############################################################
#Create RAP
nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.22',
subnet='10.0.0.0/24', inNameSpace=False,
inetIntf='nat1-eth0', localIntf='nat1-eth1',
defaultRoute='via 192.168.0.224')
net.addLink(nat1,s0)
net.addLink(ap3, nat1)
###############################################################
net.build()
c0.start()
c1.start()
ap1.start( [c0] )
ap2.start( [c0] )
ap3.start( [c0] )
s0.start( [c1] )
nat1.setIP('10.0.0.22/8', intf='nat1-eth1')
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例6: topology
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def topology():
"Create a network."
net = Mininet( link=TCLink, switch=OVSSwitch )
#create local controller for APs
c0 = Controller( 'c0', port=6634 )
#create controller for s0 (Ryuretic)
#c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
net.addController(c0)
#net.addController(c1)
print "*** Creating nodes"
s0 = net.addSwitch('s0')
################## Create Rogue APs ###############################
ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5",
position='10,30,0', range='20' )
ap3 = net.addBaseStation( 'ap3', ssid="ssid_ap3", mode="g", channel="10",
position='50,30,0', range='20')
################ Create Rogue Stations #############################
sta1 = net.addStation( 'sta1', ip='192.168.0.11/24', mac='AA:BB:BB:BB:BB:01',
defaultRoute='via 192.168.0.224', position='10,40,0' )
sta2 = net.addStation( 'sta2', ip='192.168.0.12/24', mac='AA:BB:BB:BB:BB:02',
defaultRoute='via 192.168.0.224', position='15,30,0' )
sta3 = net.addStation( 'sta3', ip='192.168.0.13/24', mac='AA:BB:BB:BB:BB:03',
defaultRoute='via 192.168.0.224', position='15,35,0' )
sta4 = net.addStation( 'sta4', ip='10.0.0.1/24', mac='AA:BB:BB:BB:BB:11',
defaultRoute='via 10.0.0.22', position='50,20,0' )
sta5 = net.addStation( 'sta5', ip='10.0.0.2/24', mac='AA:BB:BB:BB:BB:12',
defaultRoute='via 10.0.0.22', position='55,15,0' )
sta6 = net.addStation( 'sta6', ip='10.0.0.3/24', mac='AA:BB:BB:BB:BB:13',
defaultRoute='via 10.0.0.22', position='45,125,0' )
################## Create Hosts ####################################
h1 = net.addHost('h1', ip='192.168.0.1', mac='AA:AA:AA:AA:AA:01',
defaultRoute='via 192.168.0.224')
h2 = net.addHost('h2', ip='192.168.0.2', mac='AA:AA:AA:AA:AA:02',
defaultRoute='via 192.168.0.224')
h3 = net.addHost('h3', ip='192.168.0.3', mac='AA:AA:AA:AA:AA:03',
defaultRoute='via 192.168.0.224')
h4 = net.addHost('h4', ip='192.168.0.4', mac='AA:AA:AA:AA:AA:04',
defaultRoute='via 192.168.0.224')
h5 = net.addHost('h5', ip='192.168.0.5', mac='AA:AA:AA:AA:AA:05',
defaultRoute='via 192.168.0.224')
h6 = net.addHost('h6', ip='192.168.0.6', mac='AA:AA:AA:AA:AA:06',
defaultRoute='via 192.168.0.224')
################## Wireless AP Interface #############################
print "*** Adding Link"
net.addLink(sta1, ap1, bw=10, loss=5)
net.addLink(sta2, ap1, bw=10, loss=5)
net.addLink(sta3, ap1, bw=10, loss=5)
##################### NAT1 Interface ###############################
net.addLink(sta4, ap3, bw=10, delay=5, loss=5)
net.addLink(sta5, ap3, bw=10, loss=5)
net.addLink(sta6, ap3, bw=10, loss=5)
##################### Link devices to Switch ########################
net.addLink(ap1, s0)
net.addLink(h1, s0)
net.addLink(h2, s0)
net.addLink(h3, s0)
net.addLink(h4, s0)
net.addLink(h5, s0)
net.addLink(h6, s0)
###################### Create NAT for Internet #######################
nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224', mac='AA:AA:AA:AA:AA:AA',
subnet='192.168.0.0/24', inNamespace=False)
net.addLink(nat, s0)
########################### Create RAP ########################
nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.22', mac='AA:CC:CC:CC:CC:CC',
subnet='10.0.0.0/24', inNameSpace=False,
inetIntf='nat1-eth0', localIntf='nat1-eth1',
defaultRoute='via 192.168.0.224')
net.addLink(nat1,s0)
net.addLink(ap3, nat1, bw=100)
######################### Build Topology ##########################
net.build()
######################### Start Topology ##########################
c0.start()
#c1.start()
ap1.start( [c0] )
ap3.start( [c0] )
s0.start( [c0] )
######################## Add RAP Interface ##########################
nat1.setIP('10.0.0.22/8', intf='nat1-eth1')
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
示例7: Host
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
#!/usr/bin/python
from mininet.topo import Topo
from mininet.node import Host, OVSSwitch, Controller
from mininet.link import Link
h1 = Host('h1')
h2 = Host('h2')
s1 = OVSSwitch('s1', inNamespace=False)
c0 = Controller('c0', inNamespace=False)
Link(h1,s1)
Link(h2,s1)
h1.setIP('10.1/8')
h2.setIP('10.2/8')
c0.start()
s1.start([c0])
print h1.cmd('ping -c1', h2.IP())
s1.stop()
c0.stop()
示例8: topology
# 需要导入模块: from mininet.node import Controller [as 别名]
# 或者: from mininet.node.Controller import start [as 别名]
def topology():
"Create a network."
net = Mininet( link=TCLink, switch=OVSSwitch )
c0 = Controller( 'c0', port=6634 )
c1 = RemoteController( 'c1', ip='127.0.0.1', port=6633 )
net.addController(c0)
net.addController(c1)
print "*** Creating nodes"
s0 = net.addSwitch('s0')
ap1 = net.addBaseStation( 'ap1', ssid="ssid_ap1", mode="g", channel="5" )
ap2 = net.addBaseStation( 'ap2', ssid="ssid_ap2", mode="g", channel="1" )
sta1 = net.addStation( 'sta1', ip='192.168.0.1/24', defaultRoute='via 192.168.0.224' )
sta2 = net.addStation( 'sta2', ip='192.168.0.2/24', defaultRoute='via 192.168.0.224' )
sta3 = net.addStation( 'sta3', ip='192.168.0.3/24', defaultRoute='via 192.168.0.224' )
sta4 = net.addStation( 'sta4', ip='192.168.0.4/24', defaultRoute='via 192.168.0.224' )
h1 = net.addHost('h1', ip='192.168.0.5', defaultRoute='via 192.168.0.224')
h2 = net.addHost('h2', ip='192.168.0.6', defaultRoute='via 192.168.0.224')
print "*** Adding Link"
net.addLink(sta1, ap1, bw=10, loss=0)
net.addLink(sta2, ap1, bw=10, loss=0)
net.addLink(sta3, ap2, bw=10, loss=0)
net.addLink(sta4, ap2, bw=10, loss=0)
net.addLink(ap1, s0)
net.addLink(ap2, s0)
net.addLink(h1, s0)
net.addLink(h2, s0)
##############################################################
#nat = net.addNAT('nat', ip=natIP, inNamespace=False)
nat = net.addHost( 'nat', cls=NAT, ip='192.168.0.224', subnet='192.168.0.0/24', inNamespace=False)
net.addLink(nat, s0)
##############################################################
## s2 = net.addSwitch('s2')
## nat1=net.addHost('nat1', cls=NAT, ip='192.168.0.220',
## subnet='10.0.0.0/24',
## inetIntf='nat1-eth0', localIntf='nat1-eth1',
## **hostConfig)
## net.addLink(nat1, s0)
## natParams = {'ip' : '10.0.0.1/24'}
## net.addLink(s2, nat1, intfName1='nat1-eth1', params1=natParams)
##
## h3 = net.addHost('h3', ip='10.0.0.2', defaultRoute = 'via 10.0.0.1')
## h4 = net.addHost('h4', ip='10.0.0.3', defaultRoute = 'via 10.0.0.1')
## h5 = net.addHost('h5', ip='10.0.0.4', defaultRoute = 'via 10.0.0.1')
## net.addLink(h3, s2)
## net.addLink(h4, s2)
## net.addLink(h5, s2)
net.build()
c0.start()
c1.start()
ap1.start( [c0] )
ap2.start( [c0] )
s0.start([c1])
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()