标签:过程 int gre soft sign switch loss inf star
In this assignment, your task is to create a simple tree topology. You will assume each level i.e., core, aggregation, edge and host to be composed of a single layer of switches/hosts with a configurable fanout value (k) looks like:
代码:
# CustomTopo.py ‘‘‘ Coursera: - Software Defined Networking (SDN) course -- Module 3 Programming Assignment Professor: Nick Feamster Teaching Assistant: Muhammad Shahbaz ‘‘‘ from mininet.topo import Topo from mininet.net import Mininet from mininet.node import CPULimitedHost from mininet.link import TCLink from mininet.util import irange,dumpNodeConnections from mininet.log import setLogLevel class CustomTopo(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() ) } def simpleTest(): "Create and test a simple network" linkopts1 = dict(bw=10, delay=‘3ms‘, use_htb=True) linkopts2 = dict(bw=8, delay=‘4ms‘, loss=1, max_queue_size=900, ) linkopts3 = dict(bw=6, delay=‘5ms‘, loss=1, max_queue_size=800) topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=2) net = Mininet(topo, host=CPULimitedHost, link=TCLink) net.start() print "Dumping host connections" dumpNodeConnections(net.hosts) print "Testing network connectivity" net.pingAll() net.stop() if __name__ == ‘__main__‘: # Tell mininet to print useful information setLogLevel(‘info‘) simpleTest()
在mininet虚拟机上执行下面操作即可创建自定义的网络拓扑。函数simpleTest()创建网络并进行了简单的ping测试,从屏幕输出可以看到创建的过程。
mininet@mininet-vm:~/mininet$ sudo python CustomTopo.py
标签:过程 int gre soft sign switch loss inf star
原文地址:http://www.cnblogs.com/soul-stone/p/7955562.html