Example 2 mininet wifi - nps-ros2/mininet_testbed GitHub Wiki

Circle 10

Scenario definition

This example examines network flows of ten robots where each robot is communicating to the next in a circle. Topics flow one to one, not one to many as is done in example1.

Rather than using the miniedit GUI, it was much simpler to create the circle_10.py network configuration from a copy of example1_mod.py by:

  • Adding stations using addStation.
  • Adding links using addLink.
  • Changing the x, y station position values so that the robots are arranged somewhat circularly.

Here is the resulting circle_10.py file:

#!/usr/bin/python

from mininet.log import setLogLevel, info
from mn_wifi.net import Mininet_wifi
from mn_wifi.node import Station, OVSKernelAP
from mn_wifi.cli import CLI
from mn_wifi.link import wmediumd, adhoc
from mn_wifi.wmediumdConnector import interference
from subprocess import call


def myNetwork():

    net = Mininet_wifi(topo=None,
                       build=False,
                       link=wmediumd,
                       wmediumd_mode=interference,
                       ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    info( '*** Add switches/APs\n')

    info( '*** Add hosts/stations\n')
    R01 = net.addStation('R01', ip='10.0.0.1', position='2.0,1.0,0')
    R02 = net.addStation('R02', ip='10.0.0.2', position='3.0,1.0,0')
    R03 = net.addStation('R03', ip='10.0.0.3', position='4.0,1.0,0')
    R04 = net.addStation('R04', ip='10.0.0.4', position='5.0,2.0,0')
    R05 = net.addStation('R05', ip='10.0.0.5', position='5.0,3.0,0')
    R06 = net.addStation('R06', ip='10.0.0.6', position='4.0,4.0,0')
    R07 = net.addStation('R07', ip='10.0.0.7', position='3.0,4.0,0')
    R08 = net.addStation('R08', ip='10.0.0.8', position='2.0,4.0,0')
    R09 = net.addStation('R09', ip='10.0.0.9', position='1.0,3.0,0')
    R10 = net.addStation('R10', ip='10.0.0.10', position='1.0,2.0,0')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info( '*** Add links\n')
    net.addLink(R01, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R01-wlan0')
    net.addLink(R02, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R02-wlan0')
    net.addLink(R03, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R03-wlan0')
    net.addLink(R04, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R04-wlan0')
    net.addLink(R05, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R05-wlan0')
    net.addLink(R06, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R06-wlan0')
    net.addLink(R07, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R07-wlan0')
    net.addLink(R08, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R08-wlan0')
    net.addLink(R09, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R09-wlan0')
    net.addLink(R10, cls=adhoc, ssid='new-ssid', mode='g', channel=1, intf='R10-wlan0')

    net.plotGraph(min_x=0, min_y=0, max_x=6, max_y=5)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches/APs\n')

    info( '*** Post configure nodes\n')

#    CLI(net)
#    net.stop()

    return net


if __name__ == '__main__':
    setLogLevel( 'info' )
    myNetwork()

Here is the circle_10.csv file defining the publisher, sbscriber, and robot attributes that establish the circle of network communication:

# Publisher, Role, Topic, Frequency, Size, History, Depth, Reliability, Durability
Publisher, R01_role, R01_to_R02, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R02_role, R02_to_R03, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R03_role, R03_to_R04, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R04_role, R04_to_R05, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R05_role, R05_to_R06, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R06_role, R06_to_R07, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R07_role, R07_to_R08, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R08_role, R08_to_R09, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R09_role, R09_to_R10, 2, 40, keep_last, 0, best_effort, volatile
Publisher, R10_role, R10_to_R01, 2, 40, keep_last, 0, best_effort, volatile

# Subscriber, Role, Topic, History, Depth, Reliability, Durability
Subscriber, R01_role, R10_to_R01, keep_last, 0, best_effort, volatile
Subscriber, R02_role, R01_to_R02, keep_last, 0, best_effort, volatile
Subscriber, R03_role, R02_to_R03, keep_last, 0, best_effort, volatile
Subscriber, R04_role, R03_to_R04, keep_last, 0, best_effort, volatile
Subscriber, R05_role, R04_to_R05, keep_last, 0, best_effort, volatile
Subscriber, R06_role, R05_to_R06, keep_last, 0, best_effort, volatile
Subscriber, R07_role, R06_to_R07, keep_last, 0, best_effort, volatile
Subscriber, R08_role, R07_to_R08, keep_last, 0, best_effort, volatile
Subscriber, R09_role, R08_to_R09, keep_last, 0, best_effort, volatile
Subscriber, R10_role, R09_to_R10, keep_last, 0, best_effort, volatile

# Robot, Name, Role
Robot, R01, R01_role
Robot, R02, R02_role
Robot, R03, R03_role
Robot, R04, R04_role
Robot, R05, R05_role
Robot, R06, R06_role
Robot, R07, R07_role
Robot, R08, R08_role
Robot, R09, R09_role
Robot, R10, R10_role

Run

cd ~/gits/mininet_testbed
./mininet_runner.bash ~/gits/mininet_testbed/scenarios/circle_10.csv _mininet_test_circle_10

We run the testbed for about one hour before stopping it with Ctrl-D.

Plot

Here we run the testbed for about one hour

 cd ~/gits/mininet_testbed
./plot_analytics.py _mininet_test_circle_10 circle_10 -b 60 -w circle_10

We use the -b option to get a bar period of one minute to average out points in the latency graph.

Latency points:

plots/circle_10_latency_points.png

Throughput:

plots/circle_10_throughput.png

Latency:

plots/circle_10_latency.png

Loss:

plots/circle_10_loss.png