Simple performance test of mininet experiment setting bandwidth

write in front


Reference for this experiment

  • This experiment was written about Opendaylight, but it doesn't seem to have anything to do with ODL, and the local controller POX is used.
  • It is worth noting: After the experiment, be sure to use the mn -c command to clean up the process . Otherwise, problems such as ping failure between hosts and port occupation will be caused.
  • Although it was a simple experiment, I had a deeper understanding of the virtual controller and a deeper understanding of the word software in SDN by asking the teacher during the process .

Experimental ideas


  • Python script to implement custom topology
  • Set the bandwidth, delay and packet loss rate of the link
  • iperf tests bandwidth performance between hosts

In short, one script solves all problems. The core of this experiment is to read the script.

Experimental topology


Experimental procedure


1. Build the environment

  • Install mininet virtual machine

2. Create a script

  • Enter the mininet/custom directory, create the script mymininet.py and add the content:
#!/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()
  • This script has everything written, including the bandwidth settings of the link, the pingall command, and the iperf command. Just run the watch process.
  • Understanding the script is the key!

run script

python mymininet.py
或者
chmod +x mymininet.py #添加文件执行属性
./mymininet.py

Effect screenshot

Experiment Summary and Precautions


  • Create a Mininet script through a python script, set the bandwidth, delay, packet loss rate, etc. (bw=10, delay='5ms', loss=0, max_queue_size=1000, use_htb=True) between device links, and have A limiting role, and testing performance between hosts through iperf.
  • Note: mn -c cleans up the process .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325299450&siteId=291194637