Mininet Experimental measurement of path loss rate

Source: Internet
Author: User
Tags flock python script

Reference: Loss rate based on mininet measurement path

Remember when we used a Python script to write a topology, we could set the loss rate of the link, and now we're going to test the loss rate by experimenting.

Experiment Introduction

In this environment, H0 sends packets to H1, because the connection loss rate is set in the Mininet script, some packets are lost during transmission, and the purpose of this experiment is to show how to calculate the path loss rate (H0-S0-S1-H1) through the controller. This assumes that the controller knows the network topology beforehand, so I do not show the code that discovers the network and other related code. The controller sends Flow_stats_request to S0 and S1, and when the controller receives response from S0, the number of packets for a particular stream is saved in Input_pkts, and when the controller receives S1 from response, The number of packets received for a particular stream is saved in Output_pkts, and the difference is the number of packets lost.

Setting up the Environment 1. Writing a Python script
    • Create a new file mymininet.py under the Mininet directory.
touch test.pyvim test.py
    • Edit the file mymininet.py as follows:
#!/usr/bin/python from mininet.net import mininetfrom mininet.node import nodefrom mininet.link import Tclinkfrom mininet . log import Setloglevel, infofrom threading import timerfrom mininet.util import quietrunfrom time import sleep def mynet    (cname= ' controller ', cargs= '-v ptcp: '): "Create network from scratch using Open vSwitch."     Info ("* * * * * Creating nodes\n") Controller = node (' C0 ', innamespace=false) switch = node (' S0 ', innamespace=false) switch1 = node (' s1 ', innamespace=false) H0 = node (' H0 ') h1 = node (' h1 ') info ("* * * Creating links\n ") Linkopts0=dict (bw=100, delay= ' 1ms ', loss=0) linkopts1=dict (bw=100, delay= ' 1ms ', loss=10) Link0=tclink (H0, SW Itch, **linkopts0) Link1 = tclink (switch, switch1, **linkopts1) link2 = Tclink (H1, Switch1, **LINKOPTS0) # Print LINK0.INTF1, LINK0.INTF2 link0.intf2.setMAC ("0:0:0:0:0:1") Link1.intf1.setMAC ("0:0:0:0:0:2") link1.intf2.se TMAC ("0:1:0:0:0:1") Link2.intf2.setMAC ("0:1:0:0: 0:2 ") info (" * * * Configuring Hosts\n ") H0.setip (' 192.168.123.1/24 ') h1.setip (' 192.168.123.2/24 ') Info ("* * * * Starting network using Open vswitch\n") switch.cmd (' Ovs-vsctl del-br dp0 ') switch.cmd (' Ovs-vsctl add  -BR dp0 ') switch1.cmd (' Ovs-vsctl del-br dp1 ') switch1.cmd (' Ovs-vsctl add-br dp1 ') controller.cmd (CNAME + ') ' + Cargs + ' & ') for intf in Switch.intfs.values (): Print intf print switch.cmd (' Ovs-vsctl ad D-port dp0%s '% intf) for intf in Switch1.intfs.values (): Print intf print switch1.cmd (' Ovs-vsctl add- Port dp1%s '% intf) # note:controller and switch is in root namespace, and we # can connect via loopback inte Rface switch.cmd (' ovs-vsctl set-controller dp0 tcp:10.0.0.13:6633 ') switch1.cmd (' Ovs-vsctl set-controller dp1 TCP  : 10.0.0.13:6633 ') info (' * * * waiting for switch to connect to controller ') while ' is_connected ' is not in Quietrun (    ' Ovs-vsctl show '):    Sleep (1) info ('. ') info (' \ n ') #info ("Running test\n") h0.cmdprint (' ping-q 0x64-c ' + H1. IP ()) sleep (1) info ("* * * stopping network\n") controller.cmd (' Kill% ' + CNAME) switch.cmd (' Ovs-vs CTL del-br dp0 ') Switch.deleteintfs () switch1.cmd (' Ovs-vsctl del-br dp1 ') switch1.deleteintfs () info (' \ n ') if __name__ = = ' __main__ ': setloglevel (' info ') info (' * * * * Scratch network Demo (kernel datapath) \ n ') mininet     . Init () mynet ()
2. Write Pox script
    • Create a new file flow_stats.py under the Pox directory.
    • Edit the file flow_stats.py as follows:
#This file is part of pox.## POX are free software:you can redistribute it and/or modify# it under the terms of the GNU Ge Neral public License as published by# the free software Foundation, either version 3 of the License, or# (at your option) Any later version.## POX are distributed in the hope so it'll be useful,# if without any WARRANTY; Without even the implied warranty of# merchantability or FITNESS for A particular PURPOSE.  See the# GNU General public License-details.## you should has received a copy of the GNU General public license# Along with POX. If not, see 
3. Run the script flow_stats.py.
/pox.py flow_stats

4. Run the script mymininet.py.
chmod +x mymininet.py./mymininet.py

Controller not connected up, do not know why ...

Mininet Experimental measurement of path loss rate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.