Example Scenarios - nps-ros2/ns3_testbed GitHub Wiki

See Setup for details on setting up and running these examples.

R1 to R2

This example shows latency over about 15 minutes for 500 byte traffic from R1 to R2 transmitted at 10 Hz.

Setup

Prepare scenario CSV file scenario1.csv in cd ~/gits/ns3_testbed/cpp_testbed_runner/build/cpp_testbed_runner as follows:

Publish,,,,,,,
Node,Subscription,Frequency,Size,History,Depth,Reliability,Durability
R1,odometry,10,500,keep_last,0,reliable,volatile
,,,,,,,
Subscribe,,,,,,,
Node,Subscription,History,Depth,Reliability,Durability,,
R2,odometry,keep_last,0,reliable,volatile,,

You may prepare this by exporting a spreadsheet. Here is an example:

Run

  • Start the Testbed Monitor:

    cd ~/gits/ns3_testbed/testbed_monitor
    ./testbed_monitor.py -o scenario1_data.csv
    
  • Start ns-3 to support two robots:

    cd ~/gits/ns3_testbed/ns3_programs/build
    ./ns3_mobility -c 2 -l 2
    
  • Start the two robots given the scenario1.csv scenario:

    sudo /bin/bash
    cd ~/gits/ns3_testbed/cpp_testbed_runner/build/cpp_testbed_runner
    ./testbed_runner -c 2 -i scenario1.csv -n -p
    
  • Allow the simulation to run, then stop the started programs.

Analysis

Create the plot from the generated scenario1_data.csv file:

cd ~/gits/ns3_testbed/testbed_monitor
./plot_analytics.py scenario1_data.csv -m 3 -w "Large Dataset"

Here is the output:

https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/large_dataset.csv.pdf

In looking at this, we make some observations:

  • Average latency is about 1 ms.
  • There appear to be three popular latency values: 0.7 ms, 0.9 ms, 1.1 ms.
  • There is jitter.
  • There is periodicity, possibly caused by active processes running in the background at scheduled intervals.

One Robot Talking to Four Robots

Setup

Scenario file scenario2.csv:

Publish,,,,,,,
Node,Subscription,Frequency,Size,History,Depth,Reliability,Durability
R1,odometry,10,500,keep_last,0,reliable,volatile
,,,,,,,
Subscribe,,,,,,,
Node,Subscription,History,Depth,Reliability,Durability,,
R2-5,odometry,keep_last,0,reliable,volatile,,

Run

  • Start the Testbed GUI using ./tg.py -o scenario2_data.csv
  • Start ns-3 to support five robots, 1 stationary, 4 mobile, with 2-meter mobility using ./ns3_mobility -s ns3_1_4.csv -c 5 -l 12
  • Start the five robots using ./testbed_runner -c 5 -i example_2_2_to_4.csv -n -p
  • Allow the simulation to run, then stop the started programs.

Anlysis

  • Create the plot using ./plot_latency.py -i ../testbed_gui/scenario2_data.csv -m 70 -w "Zhaolin's Setup".

Here is the output:

https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/zhaolin_10hz.csv.pdf

In looking at this we see about 1 ms latency for R2, about 12 ms for R3, 23 ms for R4, and 35 ms for R5. We see consistent latency for R2 with 10 to 20 ms variance for R3, R4, and R5.

Four Robots Talking to One Robot

Here is the setup:

Publish,,,,,,,
Node,Subscription,Frequency,Size,History,Depth,Reliability,Durability
R2-5,odometry,10,500,keep_last,0,reliable,volatile
,,,,,,,
Subscribe,,,,,,,
Node,Subscription,History,Depth,Reliability,Durability,,
R1,odometry,keep_last,0,reliable,volatile,,

Synchronized

Transmission is synchronized, so all robots attempt to transmit at 10 Hz at the same time.

After gathering data and then running ./plot_latency.py -i ../doc/plots/4_out_1_in.csv -m 15 "4 out 1 in simultaneous" -w we get this plot:

https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/4_out_1_in.csv.pdf

Staggered

With four robots transmitting at 10 Hz but staggered by 88 ms, after gathering data and then running ./plot_latency.py -i ../doc/plots/4_out_1_in_staggered.csv -m 4 "4 out 1 in staggered", we get this:

https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/4_out_1_in_staggered.csv.pdf

CSMA Instead of Wifi

We run ns3_csma instead of ns3_mobility to connect robots with CSMA (wired) instead of Wifi:

cd ~/gits/ns3_testbed/ns3_programs/build
./ns3_csma -c 5

4 out 1 in CSMA simultaneous: https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/4_out_1_in_csma.csv.pdf.

4 out 1 in CSMA staggered: https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/4_out_1_in_csma_staggered.csv.pdf.

CSMA Swarm of 25

25 out 1 in CSMA simultaneous: https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/25_out_1_in_csma.csv.pdf

25 out 1 in CSMA staggered: https://github.com/nps-ros2/ns3_testbed/blob/master/doc/plots/25_out_1_in_csma_staggered.csv.pdf