当前位置:文库下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > mininet 简单的自定义拓扑
免费下载此文档侵权投诉

mininet 简单的自定义拓扑

# CustomTopo.py

'''

Coursera:

- Software Defined Networking (SDN) course

-- Module 3 Programming Assignment

Professor: Nick Feamster

Teaching Assistant: Muhammad Shahbaz

'''

frommininet.topo import Topo

from http://www.hjavira.net import Mininet

frommininet.node import CPULimitedHost

frommininet.link import TCLink

frommininet.util import irange,dumpNodeConnections

from mininet.log import setLogLevel

classCustomTopo(Topo):

"Simple Data Center Topology"

"linkopts - (1:c1, 2:aggregation, 3: edge) parameters"

"fanout - number of child switch per parent switch"

def __init__(self, linkopts1, linkopts2, linkopts3, fanout=2, **opts):

# Initialize topology and default options

Topo.__init__(self, **opts)

# Add your logic here ...

self.fanout = fanout

core = self.addSwitch('c1')

for i in irange(1, fanout):

aggregation = self.addSwitch('a%s' %i)

self.addLink(core, aggregation, **linkopts1)

for j in irange(1, fanout):

edge = self.addSwitch('e%s' %(fanout*(i-1)+j))

self.addLink(aggregation, edge, **linkopts2)

for k in irange(1, fanout):

host = self.addHost('h%s' %((fanout*(fanout*(i-1)+j-1))+k))

self.addLink(edge, host, **linkopts3)

topos = { 'custom': ( lambda: CustomTopo() ) }

defsimpleTest():

"Create and test a simple network"

linkopts1 = dict(bw=10, delay='3ms', use_htb=True)

第1页

免费下载Word文档免费下载:mininet 简单的自定义拓扑

(下载1-7页,共7页)

我要评论

返回顶部