minnet sample

简介: 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...

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

 

目录
相关文章
|
3月前
|
机器学习/深度学习 计算机视觉 Python
output
【9月更文挑战第14天】
33 1
|
API 数据格式
TensorFlow2._:model.summary() Output Shape为multiple解决方法
TensorFlow2._:model.summary() Output Shape为multiple解决方法
281 0
TensorFlow2._:model.summary() Output Shape为multiple解决方法
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
517 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决h5py\_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
成功解决h5py\_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
成功解决h5py\_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
成功解决 File "h5py\h5t.pxd", line 14, in init h5py._conv (D:\Build\h5py\h5py-2.7.0\h5py\_conv.c:7539)
成功解决 File "h5py\h5t.pxd", line 14, in init h5py._conv (D:\Build\h5py\h5py-2.7.0\h5py\_conv.c:7539)
成功解决 File "h5py\h5t.pxd", line 14, in init h5py._conv (D:\Build\h5py\h5py-2.7.0\h5py\_conv.c:7539)
成功解决\h5py\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float
成功解决\h5py\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float
|
jenkins 持续交付
成功解决c:\jenkins\workspace\mxnet-tag\mxnet\src\operator\tensor\./matrix_op-inl.h:189: Using target_sha
成功解决c:\jenkins\workspace\mxnet-tag\mxnet\src\operator\tensor\./matrix_op-inl.h:189: Using target_sha
成功解决linear_model\stochastic_gradient.py:128: FutureWarning: max_iter and tol parameters have been ad
成功解决linear_model\stochastic_gradient.py:128: FutureWarning: max_iter and tol parameters have been ad
|
BI
Five Steps to Becoming a Better Data Analyst
In this post, a data analyst from wangjubao.com, a leading data-marketing firm in China, shares some advice on making better data insights.
1899 0
Five Steps to Becoming a Better Data Analyst