【Mininet】Mininet设置带宽之简单性能测试

实验参考:

Mininet设置带宽之简单性能测试

实验步骤:

1. 进入mininet/custom目录下,通过vi mymininet1.py创建脚本并添加内容(本实验通过python脚本自定义拓扑,创建包含一个交换机、四个主机的网络拓扑):

#!/usr/bin/python
 
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
 
class SingleSwitchTopo(Topo):
    "Single switch connected to n hosts."
    def __init__(self, n=2, **opts):
        Topo.__init__(self, **opts)
        switch = self.addSwitch('s1')
        for h in range(n):
            #Each host gets 50%/n of system CPU
            host = self.addHost('h%s' % (h + 1), cpu=.5/n)
            #10 Mbps, 5ms delay, 0% Loss, 1000 packet queue
            self.addLink(host, switch, bw=10, delay='5ms', loss=0, max_queue_size=1000, use_htb=True)
 
def perfTest():
    "Create network and run simple performance test"
    topo = SingleSwitchTopo(n=4)
    net = Mininet(topo=topo,host=CPULimitedHost, link=TCLink)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing network connectivity"
    net.pingAll()
    print "Testing bandwidth between h1 and h4"
    h1, h4 = net.get('h1', 'h4')
    net.iperf((h1, h4))
    net.stop()
 
if __name__=='__main__':
    setLogLevel('info')
    perfTest()

2. 修改文件权限并将其执行:

 

实验结论:

通过python脚本创建Mininet脚本,对设备链路间的带宽、延迟、丢包率等(如:bw=10, delay='5ms', loss=0, max_queue_size=1000, use_htb=True)进行设置 ,对设备有一个限制作用,且通过iperf来进行测试主机间的性能。

猜你喜欢

转载自www.cnblogs.com/ptolemy/p/11255970.html
今日推荐