本文整理汇总了Python中mininet.net.Mininet.addController方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.addController方法的具体用法?Python Mininet.addController怎么用?Python Mininet.addController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.addController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RunTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def RunTest():
"""TOPO"""
topo = FatTreeTopo()
topo.topoCreate(4,4,2,2,2)
CONTROLLER_NAME = topo.crtlname
CONTROLLER_IP = topo.crtlip
CONTROLLER_PORT = topo.crtlport
net = Mininet(topo=topo,build= False,link=TCLink, controller=None)
time.sleep(1)
net.addController( CONTROLLER_NAME,controller=RemoteController,
ip=CONTROLLER_IP,
port=CONTROLLER_PORT)
net.start()
dumpNodeConnections(net.hosts)
net.pingAll()
h1 = net.get('h000')
h16 = net.get('h311')
h2 = net.get('h001')
h1.popen('iperf -s -u -i 1')
h16.popen('iperf -s -u -i 1')
h2.cmdPrint('iperf -c '+ h1.IP() + ' -u -t 10 -i 1 -b 100m')
h2.cmdPrint('iperf -c '+ h16.IP() + ' -u -t 10 -i 1 -b 100m')
CLI(net)
net.stop()
示例2: myNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def myNet():
MultiSwitch13 = partial( MultiSwitch, protocols='OpenFlow13' )
#tree_topo = TreeTopo(depth=3,fanout=2)
tree_topo = SingleSwitchTopo(n=14)
net = Mininet(controller=RemoteController, topo=tree_topo, switch=MultiSwitch13, build=False, autoSetMacs=True)
info( '*** Adding controllers\n')
#c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.1", port=6633)
c1 = net.addController('c1', controller=RemoteController, ip="192.168.1.1", port=6633)
c2 = net.addController('c2', controller=RemoteController, ip="192.168.1.2", port=6633)
c3 = net.addController('c3', controller=RemoteController, ip="192.168.1.3", port=6633)
# info( '*** Add hosts\n')
# h1 = net.addHost( 'h1', ip='10.0.0.1' )
# h2 = net.addHost( 'h2', ip='10.0.0.2' )
# h3 = net.addHost( 'h3', ip='10.0.0.3' )
# h4 = net.addHost( 'h4', ip='10.0.0.4' )
# info( '*** Add switches\n')
# s1 = net.addSwitch( 's1', cls=OVSKernelSwitch, protocols='OpenFlow13' )
# s2 = net.addSwitch( 's2', cls=OVSKernelSwitch, protocols='OpenFlow13' )
# s3 = net.addSwitch( 's3', cls=OVSKernelSwitch, protocols='OpenFlow13' )
# s4 = net.addSwitch( 's4', cls=OVSKernelSwitch, protocols='OpenFlow13' )
# info( '*** Add links\n')
# s1.linkTo( h1 )
# s1.linkTo( s2 )
# s2.linkTo( h2 )
# s2.linkTo( s3 )
# s3.linkTo( h3 )
# s3.linkTo( s4 )
# s4.linkTo( h4 )
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
c1.start()
c2.start()
c3.start()
# info( '*** Starting switches\n')
# s1.start([c1,c2,c3])
# s2.start([c1,c2,c3])
# s3.start([c1,c2,c3])
# s4.start([c1,c2,c3])
net.start()
net.staticArp()
# i = 0;
# while i < 10:
# h1, h2 = random.choice(net.hosts), random.choice(net.hosts)
# print h1.IP(), "-->", h2.IP()
# sent, received, rttmin, rttavg, rttmax, rttdev = ping(h1, h2)
# print received,"/",sent
# i = i + 1
# sleep(1)
CLI( net )
net.stop()
示例3: run
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def run():
"Create control and data networks, and invoke the CLI"
info( '* Creating Control Network\n' )
ctopo = ControlNetwork( n=4, dataController=DataController )
cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', controller=None )
info( '* Adding Control Network Controller\n')
cnet.addController( 'cc0', controller=Controller )
info( '* Starting Control Network\n')
cnet.start()
info( '* Creating Data Network\n' )
topo = TreeTopo( depth=2, fanout=2 )
# UserSwitch so we can easily test failover
sw = partial( UserSwitch, opts='--inactivity-probe=1 --max-backoff=1' )
net = Mininet( topo=topo, switch=sw, controller=None )
info( '* Adding Controllers to Data Network\n' )
for host in cnet.hosts:
if isinstance(host, Controller):
net.addController( host )
info( '* Starting Data Network\n')
net.start()
mn = MininetFacade( net, cnet=cnet )
CLI( mn )
info( '* Stopping Data Network\n' )
net.stop()
info( '* Stopping Control Network\n' )
cnet.stop()
示例4: createTopo
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def createTopo( ):
"Simple topology example."
net = Mininet( controller=RemoteController)
info( '*** Adding controller\n' )
net.addController( 'c0', controller=RemoteController,ip="127.0.0.1",port=6633 )
# Add hosts and switches
leftHost = net.addHost( 'h1' )
rightHost = net.addHost( 'h2' )
leftSwitch = net.addSwitch( 's3' )
rightSwitch = net.addSwitch( 's4' )
centerSwitchl = net.addSwitch( 's5' )
centerSwitchr = net.addSwitch( 's6' )
# Add links
net.addLink( leftHost, leftSwitch )
net.addLink( leftSwitch, centerSwitchl )
net.addLink( centerSwitchl, centerSwitchr )
net.addLink( centerSwitchr, rightSwitch)
linkOpts = {'bw':10};
net.addLink( rightSwitch, rightHost, cls=TCLink, **linkOpts)
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
示例5: build
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def build( self ):
"Build network based on our topology."
net = Mininet(controller=RemoteController, topo=None )
# Make controller
net.addController( 'c0' )
# Make nodes
for widget in self.widgetToItem:
name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
nodeNum = int( name[ 1: ] )
if 'Switch' in tags:
net.addSwitch( name )
elif 'Host' in tags:
net.addHost( name, ip=ipStr( nodeNum ) )
else:
raise Exception( "Cannot create mystery node: " + name )
# Make links
for link in self.links.values():
( src, dst ) = link
srcName, dstName = src[ 'text' ], dst[ 'text' ]
src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
src.linkTo( dst )
# Build network (we have to do this separately at the moment )
net.build()
return net
示例6: emptyNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=RemoteController )
info( '*** Adding controller\n' )
net.addController( 'c0',ip='127.0.0.1',port=6633 )
info( '*** Adding hosts\n' )
Host_1 = net.addHost('Host_1', ip='10.0.1.10/24',defaultRoute='via 10.0.1.1',mac='00:00:00:00:00:01')
Host_2 = net.addHost('Host_2', ip='10.0.2.10/24',defaultRoute='via 10.0.2.1',mac='00:00:00:00:00:02')
Host_3 = net.addHost('Host_3', ip='10.0.3.10/24',defaultRoute='via 10.0.3.1',mac='00:00:00:00:00:03')
Host_4 = net.addHost('Host_4', ip='192.168.0.22/24',defaultRoute='via 192.168.0.1',mac='00:00:00:00:00:04')
info( '*** Adding switch\n' )
Device_1 = net.addSwitch( 's1' )
Device_2 = net.addSwitch( 's2' )
info( '*** Creating links\n' )
net.addLink( Host_1, Device_1 )
net.addLink( Host_2, Device_1 )
net.addLink( Host_3, Device_1 )
net.addLink( Host_4, Device_2 )
net.addLink( Device_1, Device_2 )
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
示例7: ONOSCluster
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
class ONOSCluster( Controller ):
# TODO
n = 3
def start( self ):
ctopo = ControlNetwork( n=self.n, dataController=ONOS )
self.cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', controller=None )
self.cnet.addController( 'cc0', controller=Controller )
self.cnet.start()
self.ctrls = []
for host in self.cnet.hosts:
if isinstance( host, Controller ):
self.ctrls.append( host )
host.start()
def stop( self ):
for host in self.cnet.hosts:
if isinstance( host, Controller ):
host.stop()
self.cnet.stop()
def clist( self ):
"Return list of Controller proxies for this ONOS cluster"
print 'controllers:', self.ctrls
return self.ctrls
示例8: createTopo
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def createTopo():
logging.debug("LV1 Create HugeTopo")
topo = HugeTopo()
topo.createTopo()
topo.createLink()
# TODO add multiple controller here
logging.debug("LV1 Start Mininet")
CONTROLLER_IP = "127.0.0.1"
CONTROLLER_PORT = 6633
c0 = Controller('c0', port=6633)
c1 = Controller('c1', port=6634)
c2 = Controller('c2', port=6635)
c3 = Controller('c3', port=6636)
c5 = RemoteController('c2', ip='127.0.0.1')
net = Mininet(topo=topo, link=TCLink, controller=POX)
for c in [c0, c1, c2, c3 ]:
net.addController(c)
net.start()
logger.debug("LV1 dumpNode")
enableSTP()
dumpNodeConnections(net.hosts)
#pingTest(net)
#iperfTest(net, topo)
CLI(net)
p = pexpect.spawn( 'controller test' )
# but first a simple ping test
p.sendline( 'xterm c0' )
net.stop()
示例9: emptyNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=Controller )
info( '*** Adding controller\n' )
net.addController( 'c0' )
info( '*** Adding hosts\n' )
h1 = net.addHost( 'h1', ip='10.0.0.1' )
h2 = net.addHost( 'h2', ip='10.0.0.2' )
info( '*** Adding switch\n' )
s3 = net.addSwitch( 's3' )
info( '*** Creating links\n' )
h1.linkTo( s3 )
h2.linkTo( s3 )
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
示例10: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def main(argv):
global _remControl
global _controllers
remote_ip = '127.0.0.1'
lan = 2
try:
opts, args = getopt(argv[1:], 'r:l:', ['remote-ip=','lan='])
except GetoptError as err:
print err.msg, err.opt
exit(1);
print opts
print args
for opt, arg in opts:
if opt in ('-r', '--remote-ip'):
remote_ip = arg
if opt in ('-l', '--lan'):
lan = int(arg)
_remControl = RemoteController('Remote Controller', ip=remote_ip)
_controllers['remote'] = _remControl
topo = HomeTopo(ethHosts=lan)
net = Mininet(topo=topo, switch=MultiController, host=CPULimitedHost,
link=TCLink, autoPinCpus=True, build=False)
net.addController(_controller)
net.build()
topo.routerSetup(net)
net.start()
dumpNodeConnections(net.hosts)
CLI( net )
net.stop()
示例11: emptyNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=RemoteController )
info( '*** Adding controller\n' )
net.addController( 'c1',controller=RemoteController,ip="192.168.1.38",port=6653 )
info( '*** Adding hosts\n' )
h3 = net.addHost( 'h3', ip = "10.0.0.3" )
h4 = net.addHost( 'h4', ip = "10.0.0.4" )
info( '*** Adding switch\n' )
s2 = net.addSwitch( 's2' ,mac="00:00:00:00:00:02" )
info( '*** Creating links\n' )
net.addLink( h3, s2 )
net.addLink( h4, s2 )
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
示例12: createStaticRouterNetwork
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def createStaticRouterNetwork():
info( '*** Creating network for Static Router Example\n' )
# Create an empty network.
net = Mininet(controller=RemoteController, switch=OVSKernelSwitch)
net.addController('c0')
# Creating nodes in the network.
h0 = net.addHost('h0')
s0 = net.addSwitch('s0')
h1 = net.addHost('h1')
s1 = net.addSwitch('s1')
# Creating links between nodes in network.
h0int, s0int = createLink(h0, s0)
h1int, s1int = createLink(h1, s1)
s0pint, s1pint = createLink(s0, s1)
# Configuration of IP addresses in interfaces
s0.setIP(s0int, '192.168.1.1', 26)
h0.setIP(h0int, '192.168.1.2', 26)
s1.setIP(s1int, '192.168.1.65', 26)
h1.setIP(h1int, '192.168.1.66', 26)
s0.setIP(s0pint, '192.168.1.129', 26)
s1.setIP(s1pint, '192.168.1.130', 26)
info( '*** Network state:\n' )
for node in s0, s1, h0, h1:
info( str( node ) + '\n' )
# Start command line
net.start()
CLI(net)
net.stop()
示例13: net
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def net():
'''Create a simulated network'''
net = Mininet(controller=lambda a: RemoteController(a,ip='127.0.0.1'))
info('*** Adding controller\n')
# currently, we do not add a controller to this network.
net.addController('c0')
info('*** Adding hosts\n')
# this is a host that is in the external network
h1 = net.addHost('h1', ip='10.0.0.1')
h2 = net.addHost('h2', ip='10.0.0.1')
info('*** Adding switches\n')
inst1 = net.addSwitch('inst1', dpid=int2dpid(11))
inst2 = net.addSwitch('inst2', dpid=int2dpid(12))
lb = net.addSwitch('lb', dpid=int2dpid(1))
info('*** Creating links\n')
net.addLink(h1, inst1)
net.addLink(h2, inst2)
net.addLink(inst1, lb)
net.addLink(inst2, lb)
info('*** Starting network\n')
net.start()
info('*** Running CLI\n')
CLI(net)
info('*** Stopping network\n')
net.stop()
示例14: emptyNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
"[h1]<---wifi-network-a--->[s3]<---wifi-network-b--->[h2]"
" ^ ^ ^ ^ "
" Sta Ap Ap Sta "
net = Mininet()
info( '*** Adding controller\n' )
net.addController( 'c0', controller=RemoteController, ip="127.0.0.1", port=6633 )
info( '*** Adding hosts\n' )
h1 = net.addHost( 'h1', ip='10.0.0.1' )
h2 = net.addHost( 'h2', ip='10.0.0.2' )
info( '*** Adding switch\n' )
s3 = net.addSwitch( 's3' )
info( '*** Creating links\n' )
WIFIApStaLink( s3, h1, ssid="wifi-network-a" ) # line modified
WIFIApStaLink( s3, h2, ssid="wifi-network-b" ) # line modified
info( '*** Starting network\n')
net.start()
mininet.ns3.start() # line added
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
mininet.ns3.stop()
mininet.ns3.clear() # line added
net.stop()
示例15: MyTopo
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addController [as 别名]
class MyTopo(object):
def __init__(self, cname='onos', cips=['10.0.3.1']):
# Create network with multiple controllers
self.net = Mininet(controller=RemoteController, switch=OVSKernelSwitch,
build=False, autoSetMacs=True)
# Add controllers with input IPs to the network
ctrls = [RemoteController(cname, cip, 6633) for cip in cips]
for ctrl in ctrls:
print ctrl.ip
self.net.addController(ctrl)
# Add components
self.s1 = self.net.addSwitch('s1', dpid='00000000000000a1')
h1 = self.net.addHost('h1', ip='10.0.0.11/24', mac='00:00:00:00:00:01')
# Add links
self.net.addLink(h1, self.s1)
def run(self):
self.net.build()
self.net.start()
self.s1.cmd('ovs-vsctl set bridge s1 protocols=OpenFlow13')
self.s1.cmd('ovs-vsctl add-port s1 vxlan1')
self.s1.cmd('ovs-vsctl set interface vxlan1 type=vxlan option:remote_ip=45.55.19.146 option:key=flow')
CLI(self.net)
self.net.stop()