本文整理汇总了Python中mininet.topo.Topo.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Topo.__init__方法的具体用法?Python Topo.__init__怎么用?Python Topo.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.topo.Topo
的用法示例。
在下文中一共展示了Topo.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, sw_path, json_path, nb_hosts, nb_switches, links, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
for i in xrange(nb_switches):
switch = self.addSwitch('s%d' % (i + 1),
sw_path = sw_path,
json_path = json_path,
thrift_port = _THRIFT_BASE_PORT + i,
pcap_dump = False, #True,
device_id = i)
for h in xrange(nb_hosts):
ip = "10.0.{0}.10".format(h + 1)
mac = "00:04:00:00:00:{0:02d}".format(h + 1)
host = self.addHost('h%d' % (h + 1), ip=ip, mac=mac)
for a, b in links:
self.addLink(a, b)
示例2: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, sw_path, json_path, nb_hosts, nb_switches, links, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
for i in xrange(nb_switches):
switch = self.addSwitch('s%d' % (i + 1),
sw_path = sw_path,
json_path = json_path,
thrift_port = _THRIFT_BASE_PORT + i,
pcap_dump = True,
device_id = i)
for h in xrange(nb_hosts):
host = self.addHost('h%d' % (h + 1))
for a, b in links:
self.addLink(a, b)
示例3: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, sw_path, json_path, nb_hosts, nb_switches, links, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
for i in xrange(nb_switches):
self.addSwitch('s%d' % (i + 1),
sw_path = sw_path,
json_path = json_path,
thrift_port = _THRIFT_BASE_PORT + i,
pcap_dump = True,
device_id = i)
for h in xrange(nb_hosts):
self.addHost('h%d' % (h + 1), ip="10.0.0.%d" % (h + 1),
mac="00:00:00:00:00:0%d" % (h+1))
for a, b in links:
self.addLink(a, b)
示例4: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
# public zone
sw1 = self.addSwitch( 's1' )
h1 = self.addHost( 'h1', ip='100.0.0.10/24' )
h2 = self.addHost( 'h2', ip='100.0.0.11/24' )
fw1 = self.addSwitch( 's2' )
# public link
self.addLink( h1, sw1 )
self.addLink( h2, sw1 )
示例5: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, sw_path, json_path, log_file,
thrift_port, pcap_dump, n, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
switch = self.addSwitch('s1',
sw_path = sw_path,
json_path = json_path,
log_console = True,
log_file = log_file,
thrift_port = thrift_port,
enable_debugger = True,
pcap_dump = pcap_dump)
for h in xrange(n):
host = self.addHost('h%d' % (h + 1),
ip = "10.0.%d.10/24" % h,
mac = '00:04:00:00:00:%02x' %h)
print "Adding host", str(host)
self.addLink(host, switch)
示例6: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, params):
Topo.__init__(self)
self.params = params
self.total_switches = self.params["num_switches"]
self.switch_names = []
# Add switches and hosts under them
for i in xrange(self.params["num_switches"]):
curr_switch = self.addSwitch("s" + str(i+1), protocols="OpenFlow14")
self.switch_names.append(curr_switch)
for j in xrange(self.params["num_hosts_per_switch"]):
curr_switch_host = self.addHost("h" + str(i+1) + str(j+1))
self.addLink(curr_switch, curr_switch_host)
# Add links between switches
if self.params["num_switches"] > 1:
for i in xrange(self.params["num_switches"] - 1):
self.addLink(self.switch_names[i], self.switch_names[i+1])
# Form a ring only when there are more than two switches
if self.params["num_switches"] > 2:
self.addLink(self.switch_names[0], self.switch_names[-1])
示例7: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
leftHost = self.addHost( 'h1' )
rightHost = self.addHost( 'h2' )
leftSwitch = self.addSwitch( 's3' )
rightSwitch = self.addSwitch( 's4' )
# Add links
self.addLink( leftHost, leftSwitch )
self.addLink( leftSwitch, rightSwitch )
self.addLink( rightSwitch, rightHost )
示例8: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, sw_path, json_path, nb_hosts, nb_switches, links, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
for i in xrange(nb_switches):
thrift_port = _THRIFT_BASE_PORT+i
self.addSwitch('s%d' % (i + 1), # dpid = str('0x'+i), # add dpid
sw_path = sw_path,
json_path = json_path,
thrift_port = thrift_port,
pcap_dump = True,
device_id = i)
for h in xrange(nb_hosts):
hi = self.addHost('h%d' % (h + 1))
hosts.append(hi)
示例9: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self):
# Init Topo
Topo.__init__(self)
# Add hosts and switches
self.h1 = self.addHost( 'h1' )
self.h2 = self.addHost( 'h2' )
self.h3 = self.addHost( 'h3' )
self.h4 = self.addHost( 'h4' )
self.h5 = self.addHost( 'h5' )
self.h6 = self.addHost( 'h6' )
self.s1 = self.addSwitch( 's1' )
self.s2 = self.addSwitch( 's2' )
# Add links
self.addLink(self.h1, self.s1, bw=10, max_queue_size=1000)
self.addLink(self.h2, self.s1, bw=10, max_queue_size=1000)
self.addLink(self.h3, self.s1, bw=10, max_queue_size=1000)
self.addLink(self.s2, self.h4, bw=10, max_queue_size=1000)
self.addLink(self.s2, self.h5, bw=10, max_queue_size=1000)
self.addLink(self.s2, self.h6, bw=10, max_queue_size=1000)
self.addLink(self.s1, self.s2, bw=10, max_queue_size=1000)
示例10: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__( self, n, dataController=DataController, **kwargs ):
"""n: number of data network controller nodes
dataController: class for data network controllers"""
Topo.__init__( self, **kwargs )
# Connect everything to a single switch
cs0 = self.addSwitch( 'cs0' )
# Add hosts which will serve as data network controllers
for i in range( 0, n ):
c = self.addHost( 'c%s' % i, cls=dataController,
inNamespace=True )
self.addLink( c, cs0 )
# Connect switch to root namespace so that data network
# switches will be able to talk to us
root = self.addHost( 'root', inNamespace=False )
self.addLink( root, cs0 )
# Make it Happen!!
示例11: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__( self, N, **params ):
# Initialize topology
Topo.__init__( self, **params )
# Create switches and hosts
hosts = [ self.addHost( 'h%s' % h )
for h in irange( 1, N ) ]
switches = [ self.addSwitch( 's%s' % s )
for s in irange( 1, N - 1 ) ]
# Wire up switches
last = None
for switch in switches:
if last:
self.addLink( last, switch )
last = switch
# Wire up hosts
self.addLink( hosts[ 0 ], switches[ 0 ] )
for host, switch in zip( hosts[ 1: ], switches ):
self.addLink( host, switch )
示例12: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self):
# Initialize topology and default options
Topo.__init__(self)
s1 = self.addSwitch('s1',dpid='0000000000000001')
s2a = self.addSwitch('s2a',dpid='000000000000002a')
s2b = self.addSwitch('s2b',dpid='000000000000002b')
s2c = self.addSwitch('s2c',dpid='000000000000002c')
s3 = self.addSwitch('s3',dpid='0000000000000003')
self.addLink(s1, s2a)
self.addLink(s1, s2b)
self.addLink(s2b, s2c)
self.addLink(s3, s2a)
self.addLink(s3, s2c)
host_1 = self.addHost('h1',ip='10.0.0.1',mac='10:00:00:00:00:01')
host_2 = self.addHost('h2',ip='10.0.0.2',mac='10:00:00:00:00:02')
self.addLink(host_1, s1)
self.addLink(host_2, s3)
示例13: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__(self, k=4):
super(FattreeTopo, self).__init__()
self.size = k
Topo.__init__(self)
self._build()
示例14: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__( self ):
Topo.__init__( self )
h1 = self.addHost('h1')
h2 = self.addHost('h2')
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
s3 = self.addSwitch('s3')
s4 = self.addSwitch('s4')
self.addLink(s1,h1)
self.addLink(s4,h2)
self.addLink(s1,s2)
self.addLink(s1,s3)
self.addLink(s2,s4)
self.addLink(s3,s4)
示例15: __init__
# 需要导入模块: from mininet.topo import Topo [as 别名]
# 或者: from mininet.topo.Topo import __init__ [as 别名]
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
# public zone
sw1 = self.addSwitch( 's1' )
h1 = self.addHost( 'h1', ip='100.0.0.10/24' )
h2 = self.addHost( 'h2', ip='100.0.0.11/24' )
# firewall
fw1 = self.addSwitch( 's2' )
# private
sw3 = self.addSwitch( 's3' )
h3 = self.addHost( 'h3', ip='100.0.0.50/24' )
h4 = self.addHost( 'h4', ip='100.0.0.51/24' )
# public link
self.addLink( h1, sw1 )
self.addLink( h2, sw1 )
# middle public
self.addLink( fw1, sw1 )
self.addLink( fw1, sw3 )
# private link
self.addLink( sw3, h3 )
self.addLink( sw3, h4 )