本文整理汇总了Python中mininet.topo.Topo类的典型用法代码示例。如果您正苦于以下问题:Python Topo类的具体用法?Python Topo怎么用?Python Topo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Topo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, n=2, **opts):
Topo.__init__(self, **opts)
# Add hosts and switches
h1 = self.addHost('h1')
h2 = self.addHost('h2')
I1 = self.addSwitch('I1', dpid=toID('00:00:00:00:00:01'))
s2 = self.addSwitch('s2', dpid=toID('00:00:00:00:00:02'))
s3 = self.addSwitch('s3', dpid=toID('00:00:00:00:00:03'))
s4 = self.addSwitch('s4', dpid=toID('00:00:00:00:00:04'))
s5 = self.addSwitch('s5', dpid=toID('00:00:00:00:00:05'))
s6 = self.addSwitch('s6', dpid=toID('00:00:00:00:00:06'))
s7 = self.addSwitch('s7', dpid=toID('00:00:00:00:00:07'))
s8 = self.addSwitch('s8', dpid=toID('00:00:00:00:00:09'))
s9 = self.addSwitch('s9', dpid=toID('00:00:00:00:00:09'))
E2 = self.addSwitch('E2', dpid=toID('00:00:00:00:00:10'))
# links Add
self.addLink(I1, h1)#, 2, 1, intfName1 = 'eth0-h1')
self.addLink(E2, h2)#, 2, 1, intfName1 = 'eth0-h2')
self.addLink(I1, s2)
self.addLink(s2, s3)
self.addLink(s3, s4)
self.addLink(s4, s5)
self.addLink(s5, s6)
self.addLink(s6, s7)
self.addLink(s7, s8)
self.addLink(s8, s9)
self.addLink(s9, E2)
示例2: __init__
def __init__( self, snum, hnum ):
Topo.__init__( self )
swi = {}
hos = {}
# print "reached 1"
snum = int(snum)
hnum = int(hnum)
for x in xrange(snum):
s = self.addSwitch("s" +str(x+1))
swi[x+1]= s
# print "reached 2 "
for x in xrange(hnum):
h = self.addHost("h" +str(x+1))
hos[x+1]= h
# print "reached 3"
for x in xrange(snum):
for y in xrange(x):
self.addLink(swi[x+1],swi[y+1])
# print "reached 4"
sph = hnum/snum
sin = swi.keys()
skey = sin*int(hnum/snum)
# print skey
tmp = sin[:(hnum%snum)]
# print tmp
skey = skey + tmp
skey.sort()
# print skey
i = 1
for x in skey:
self.addLink(swi[x], hos[i])
i = i+1
示例3: __init__
def __init__( self, **opts ):
"Create a topology."
# Initialize Topology
Topo.__init__( self, **opts )
# add nodes, switches first...
NewYork = self.addSwitch( 's0' )
Chicago = self.addSwitch( 's1' )
WashingtonDC = self.addSwitch( 's2' )
Seattle = self.addSwitch( 's3' )
Sunnyvale = self.addSwitch( 's4' )
LosAngeles = self.addSwitch( 's5' )
Denver = self.addSwitch( 's6' )
KansasCity = self.addSwitch( 's7' )
Houston = self.addSwitch( 's8' )
Atlanta = self.addSwitch( 's9' )
Indianapolis = self.addSwitch( 's10' )
# ... and now hosts
NewYork_host = self.addHost( 'h0' )
Chicago_host = self.addHost( 'h1' )
WashingtonDC_host = self.addHost( 'h2' )
Seattle_host = self.addHost( 'h3' )
Sunnyvale_host = self.addHost( 'h4' )
LosAngeles_host = self.addHost( 'h5' )
Denver_host = self.addHost( 'h6' )
KansasCity_host = self.addHost( 'h7' )
Houston_host = self.addHost( 'h8' )
Atlanta_host = self.addHost( 'h9' )
Indianapolis_host = self.addHost( 'h10' )
# add edges between switch and corresponding host
self.addLink( NewYork , NewYork_host )
self.addLink( Chicago , Chicago_host )
self.addLink( WashingtonDC , WashingtonDC_host )
self.addLink( Seattle , Seattle_host )
self.addLink( Sunnyvale , Sunnyvale_host )
self.addLink( LosAngeles , LosAngeles_host )
self.addLink( Denver , Denver_host )
self.addLink( KansasCity , KansasCity_host )
self.addLink( Houston , Houston_host )
self.addLink( Atlanta , Atlanta_host )
self.addLink( Indianapolis , Indianapolis_host )
# add edges between switches
self.addLink( NewYork , Chicago, bw=10, delay='5.82294818601ms')
self.addLink( NewYork , WashingtonDC, bw=10, delay='1.66933354639ms')
self.addLink( Chicago , Indianapolis, bw=10, delay='1.33817152535ms')
self.addLink( WashingtonDC , Atlanta, bw=10, delay='4.43098085052ms')
self.addLink( Seattle , Sunnyvale, bw=10, delay='5.78617273178ms')
self.addLink( Seattle , Denver, bw=10, delay='8.33987030826ms')
self.addLink( Sunnyvale , LosAngeles, bw=10, delay='2.55695492867ms')
self.addLink( Sunnyvale , Denver, bw=10, delay='7.64100479966ms')
self.addLink( LosAngeles , Houston, bw=10, delay='11.2143737889ms')
self.addLink( Denver , KansasCity, bw=10, delay='4.53199947571ms')
self.addLink( KansasCity , Houston, bw=10, delay='5.29499644815ms')
self.addLink( KansasCity , Indianapolis, bw=10, delay='3.7130222434ms')
self.addLink( Houston , Atlanta, bw=10, delay='5.73005892826ms')
self.addLink( Atlanta , Indianapolis, bw=10, delay='3.49428237002ms')
示例4: __init__
def __init__(self, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
# Add switch
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
s31 = self.addSwitch('s31')
s32 = self.addSwitch('s32')
s4 = self.addSwitch('s4')
s5 = self.addSwitch('s5')
s6 = self.addSwitch('s6')
s7 = self.addSwitch('s7')
# Add hosts
h1 = self.addHost('h1', mac='00:00:00:00:01:01', ip='10.0.1.1')
h5 = self.addHost('h5', mac='00:00:00:00:05:01', ip='10.0.5.1')
# Add link
self.addLink(s1, h1)
self.addLink(s5, h5)
self.addLink(s1, s2)
self.addLink(s2, s31)
self.addLink(s2, s32)
self.addLink(s31, s4)
self.addLink(s32, s4)
self.addLink(s4,s5)
self.addLink(s5,s6)
self.addLink(s4,s6)
self.addLink(s5,s7)
self.addLink(s7,s1)
示例5: __init__
def __init__(self, hosts=2, bwlimit=10, lat=0.1, **opts):
Topo.__init__(self, **opts)
tor = []
numLeafes = hosts
bw = bwlimit
s = 1
#bw = 10
for i in range(numLeafes):
h = self.addHost('h' + str(i + 1), mac=self.makeMAC(i),
ip="10.0.0." + str(i + 1))
sw = self.addSwitch('s' + str(s), dpid=self.makeDPID(s),
**dict(listenPort=(13000 + s - 1)))
s = s + 1
self.addLink(h, sw, bw=bw, delay=str(lat) + "ms")
tor.append(sw)
toDo = tor # nodes that have to be integrated into the tree
while len(toDo) > 1:
newToDo = []
for i in range(0, len(toDo), 2):
sw = self.addSwitch('s' + str(s), dpid=self.makeDPID(s),
**dict(listenPort=(13000 + s - 1)))
s = s + 1
newToDo.append(sw)
self.addLink(toDo[i], sw, bw=bw, delay=str(lat) + "ms")
if len(toDo) > (i + 1):
self.addLink(toDo[i + 1], sw, bw=bw, delay=str(lat) + "ms")
toDo = newToDo
bw = 1.0 * bw
示例6: __init__
def __init__(self):
"""Create custom topo."""
# Initialize topology
Topo.__init__(self)
# Add hosts and switches
host1 = self.addHost('h1', cls=VLANHost, vlan=200)
host2 = self.addHost('h2', cls=VLANHost, vlan=300)
host3 = self.addHost('h3', cls=VLANHost, vlan=200)
host4 = self.addHost('h4', cls=VLANHost, vlan=300)
host5 = self.addHost('h5', cls=VLANHost, vlan=200)
host6 = self.addHost('h6', cls=VLANHost, vlan=300)
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
s3 = self.addSwitch('s3')
self.addLink(s1, s2)
self.addLink(s2, host1)
self.addLink(s2, host2)
self.addLink(s2, host3)
self.addLink(s1, s3)
self.addLink(s3, host4)
self.addLink(s3, host5)
self.addLink(s3, host6)
示例7: __init__
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
emissor1 = self.addHost( 'h1' )
exibidor1000 = self.addHost( 'h2' )
servidor = self.addHost( 'h3' )
emissor2 = self.addHost( 'h4' )
exibidor1001 = self.addHost( 'h5' )
switch1 = self.addSwitch( 's1' )
switch2 = self.addSwitch( 's2' )
switch3 = self.addSwitch( 's3' )
switch4 = self.addSwitch( 's4' )
# Add links
self.addLink(emissor1, switch1)
self.addLink(exibidor1000, switch1)
self.addLink(switch1, switch4)
self.addLink(switch4, switch2)
self.addLink(switch2, servidor)
self.addLink(switch4, switch3)
self.addLink(switch3, emissor2)
self.addLink(exibidor1001, switch3)
示例8: __init__
def __init__(self, **opts):
Topo.__init__(self, **opts)
#make switchs
self.Iot_1 = self.addSwitch('Iot1')
self.Iot_2 = self.addSwitch('IoT2')
self.Iot_3 = self.addSwitch('IoT3')
self.Iot_left = self.addSwitch('Iot4')
self.Iot_right = self.addSwitch('Iot5')
#make host
self.H_1 = self.addHost('H1')
self.H_2 = self.addHost('H2')
#make link
#self.addLink(self.Iot_1,self.H_1,0,0)
#self.addLink(self.Iot_1,self.Iot_2,1,0)
#self.addLink(self.Iot_2,self.H_2,1,0)
#self.addLink(self.Iot_3,self.H_2,1,1)
#self.addLink(self.Iot_3,self.H_1,0,1)
self.addLink(self.Iot_left,self.H_1)
self.addLink(self.Iot_1,self.Iot_left)
self.addLink(self.Iot_1,self.Iot_2)
self.addLink(self.Iot_2,self.Iot_right)
self.addLink(self.Iot_3,self.Iot_right)
self.addLink(self.Iot_3,self.Iot_left)
self.addLink(self.Iot_right,self.H_2)
示例9: __init__
def __init__(self):
# Initialize topology
Topo.__init__(self)
# Create template host, switch, and link
hconfig = {'inNamespace': True}
link_config = {'bw': 100}
host_link_config = {}
# Create switch nodes
self.addSwitch('s1')
self.addSwitch('s2')
# Create host nodes
self.addHost('h1', **hconfig)
self.addHost('h2', **hconfig)
self.addHost('h3', **hconfig)
# Add switch links
self.addLink('s1', 's2', **link_config)
# Add host links
self.addLink('h1', 's1', **link_config)
self.addLink('h2', 's1', **link_config)
self.addLink('h3', 's2', **link_config)
示例10: __init__
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
Switch1 = self.addSwitch( 's1' )
Switch2 = self.addSwitch( 's2' )
Switch3 = self.addSwitch( 's3' )
Switch4 = self.addSwitch( 's4' )
Host11 = self.addHost( 'h1' )
Host12 = self.addHost( 'h2' )
Host21 = self.addHost( 'h3' )
Host22 = self.addHost( 'h4' )
Host23 = self.addHost( 'h5' )
Service1 = self.addHost( 'srvc1' )
# Add links
self.addLink( Host11, Switch1 )
self.addLink( Host12, Switch1 )
self.addLink( Host21, Switch2 )
self.addLink( Host22, Switch2 )
self.addLink( Host23, Switch2 )
self.addLink( Switch1, Switch2 )
self.addLink( Switch2, Switch4 )
self.addLink( Switch4, Switch3 )
self.addLink( Switch3, Switch1 )
self.addLink( Switch3, Service1 )
self.addLink( Switch4, Service1 )
示例11: __init__
def __init__( self, *args, **kwargs ):
Topo.__init__( self, *args, **kwargs )
# Describe Code
# Set up data plane switch - this is the emulated router dataplane
# Note: The controller needs to be configured with the specific driver that
# will be attached to this switch.
# IXP fabric
main_switch = self.addSwitch( 's1' )
# Add node for central Route Server"
route_server = self.addHost('x1', ip = '172.0.255.254/16', mac='08:00:27:89:3b:ff', inNamespace = False)
self.addLink(main_switch, route_server, 1)
# Add node for ARP Proxy"
arp_proxy = self.addHost('x2', ip = '172.0.255.253/16', mac='08:00:27:89:33:ff', inNamespace = False)
self.addLink(main_switch, arp_proxy, 2)
# Add Participants to the IXP
# Each participant consists of 1 quagga router PLUS
# 1 host per network advertised behind quagga
self.addParticipant(fabric=main_switch, name = 'a1', port = 3, mac = '08:00:27:89:3b:9f',
ip = '172.0.0.01/16', networks = ['100.0.0.0/24', '110.0.0.0/24'], AS = 100)
self.addParticipant(fabric=main_switch, name = 'b1', port = 4, mac = '08:00:27:92:18:1f',
ip = '172.0.0.11/16', networks = ['140.0.0.0/24', '150.0.0.0/24'], AS = 200)
self.addParticipant(fabric=main_switch, name = 'c1', port = 5, mac='08:00:27:54:56:ea',
ip = '172.0.0.21/16', networks = ['140.0.0.0/24', '150.0.0.0/24'], AS = 300)
self.addParticipant(fabric=main_switch, name = 'c2', port = 6, mac = '08:00:27:bd:f8:b2',
ip = '172.0.0.22/16', networks = ['140.0.0.0/24', '150.0.0.0/24'], AS = 300)
示例12: __init__
def __init__( self):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
host1 = self.addHost( 'h1', ip="10.0.1.2", defaultRoute = "via 10.0.1.1/24" )
host2 = self.addHost( 'h2', ip="10.0.1.3", defaultRoute = "via 10.0.1.1/24" )
host3 = self.addHost( 'h3', ip="10.0.2.2", defaultRoute = "via 10.0.2.1/24" )
host4 = self.addHost( 'h4', ip="10.0.2.3", defaultRoute = "via 10.0.2.1/24" )
host5 = self.addHost( 'h5', ip="10.0.2.4", defaultRoute = "via 10.0.2.1/24" )
switch1 = self.addSwitch( 's1')
switch2 = self.addSwitch( 's2')
# Add links
self.addLink( host1, switch1 )
self.addLink( host2, switch1 )
self.addLink( host3, switch2 )
self.addLink( host4, switch2 )
self.addLink( host5, switch2 )
self.addLink( switch1, switch2 )
示例13: __init__
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
host1 = self.addHost( 'h1' )
host2 = self.addHost( 'h2' )
host3 = self.addHost( 'h3' )
host4 = self.addHost( 'h4' )
host5 = self.addHost( 'h5' )
host6 = self.addHost( 'h6' )
switch1 = self.addSwitch( 's1' )
switch2 = self.addSwitch( 's2' )
switch3 = self.addSwitch( 's3' )
# Add links
self.addLink( host1, switch1, bw=100, delay='5ms' )
self.addLink( host2, switch1, bw=100, delay='5ms' )
self.addLink( host3, switch1, bw=100, delay='5ms' )
self.addLink( host4, switch1, bw=5, delay='10ms' )
self.addLink( host5, switch1, bw=5, delay='10ms' )
self.addLink( host6, switch1, bw=5, delay='10ms' )
self.addLink( switch1, switch2, delay='40ms' )
self.addLink( switch2, switch3, delay='40ms' )
示例14: __init__
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
leftHost = self.addHost( 'h1' )
leftHost1 = self.addHost( 'h2' )
centerHost = self.addHost( 'h3' )
centerHost1 = self.addHost( 'h4' )
rightHost = self.addHost( 'h5' )
rightHost1 = self.addHost( 'h6' )
leftSwitch = self.addSwitch( 's1' )
centerSwitch = self.addSwitch( 's2' )
rightSwitch = self.addSwitch( 's3' )
# Add links
self.addLink( leftHost, leftSwitch )
self.addLink( leftHost1, leftSwitch )
self.addLink( centerHost, centerSwitch)
self.addLink( centerHost1, centerSwitch)
self.addLink( rightHost, rightSwitch)
self.addLink( rightHost1, rightSwitch)
self.addLink( leftSwitch, centerSwitch )
self.addLink( rightSwitch, centerSwitch )
示例15: __init__
def __init__( self, enable_all = True ):
"Create custom topo."
Topo.__init__( self )
# h1 = self.addHost("h1")
# h2 = self.addHost("h2")
# h3 = self.addHost("h3",
# ip="172.31.3.100/24",
# defaultRoute="gw 172.31.3.1")
# h4 = self.addHost("h4",
# ip="172.31.4.100/24",
# defaultRoute="gw 172.31.4.1")
sA = self.addSwitch("s21")
sB = self.addSwitch("s22")
sC = self.addSwitch("s23")
sD = self.addSwitch("s24")
sE = self.addSwitch("s25")
sF = self.addSwitch("s26")
# self.addLink(h1, sA)
# self.addLink(h2, sB)
# self.addLink(h3, sC)
# self.addLink(h4, sD)
self.addLink(sA, sB)
self.addLink(sA, sC)
self.addLink(sB, sD)
self.addLink(sC, sE)
self.addLink(sD, sF)
self.addLink(sE, sF)