Network Traffic Generator

Network Traffic Generator — User Manual

How to Use

Our NTG support path complete and syntax complete. Thus, you can use tab and arrow keys to type the command.

Syntax complete after typing fl. complete1 Can view supported command by tab. complete2 Can use arrow-down and enter to select the flow command. complete3 Path complete after --config and one space. complete4 Still have path complete after the dir flow_exp/ was typed. complete5

If your’e configuration file and command are correct, NTG will start generate flows as below: success1 However, If you have syntax error or configuration file error, it will show some error words as below:

error1 error1

Notice

  • Our NTG do not support experiment interrupt. Thus, if you want to interrupt one running experiment, it will immediately shut down the NTG as below:    interrupt1

How to use NTG in Mininet

Pre-request

  • You must have installed Mininet, Ryu, and NDTwin.
  • You must have downloaded NTG and move those files and directories into folders with Mininet topology file written in python.
  • You must modify the NTG.yaml’s host_file into ./setting/Mininet.yaml and parameters in ./setting/Mininet.yaml.

Demonstrating Mininet topology

The code below is the snippet of testbed_topo.py in our NTG. If you want to use you’re own topology, please follow the step below to change you’re topology code.

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.node import RemoteController

# ===============
#   Skip codes
# ===============

if __name__ == "__main__":
  topo = MyTopo()
  net = Mininet(
        topo=topo,
        controller=RemoteController,
        switch=OVSKernelSwitch,
        link=TCLink,
        autoSetMacs=True,
    )
  # ===============
  #   Skip codes
  # ===============
  net.start()
  # ===============
  #   Skip codes
  # ===============
  CLI(net)

Start Up Process

  1. Modify the topology python code to import network_traffic_generator.py and replace Mininet’s CLI to our NTG’s CLI.
from mininet.topo import Topo
from mininet.net import Mininet
# from mininet.cli import CLI
from mininet.node import RemoteController

# ===============
#   Skip codes
# ===============

if __name__ == "__main__":
  topo = MyTopo()
  net = Mininet(
        topo=topo,
        controller=RemoteController,
        switch=OVSKernelSwitch,
        link=TCLink,
        autoSetMacs=True,
    )
  # ===============
  #   Skip codes
  # ===============
  net.start()
  # ===============
  #   Skip codes
  # ===============
  #   CLI(net)
  command_line(net,config_file_path="NTG.yaml")
  1. Start the Ryu Controller in the first terminal.
ryu-manager intelligent_router.py ryu.app.rest_topology ryu.app.ofctl_rest --ofp-tcp-listen-port 6633 --observe-link

ryu

  1. Start the topology in the second terminal.
sudo ./testbed_topo.py
# Or you're custom topology.

# if unable to run testbed_topo.py
chmod +x ./testbed_topo.py

mininet

  1. Since NTG need some topology information from NDTwin, you need to wait for the Ryu Controller to install all flow rules into switches.

mininet1

  1. Only when the terminal of Ryu Controller shows all-destination paths installed. can you start the NDTwin. Typically, you need to wait about 1 minutes

start_trigger

  1. Start the NDTwin in the third terminal.
sudo -E bin/ndtwin_kernel --loglevel info

ndtwin

  1. Now, you can start using NTG

mininet2

How to use NTG in Hardware

Pre-request

  • You must have installed Ryu, and NDTwin.

  • You must have downloaded NTG.

  • You must modify the NTG.yaml’s host_file into ./setting/Hardware.yaml and parameters in ./setting/Hardware.yaml.

  • For hardware testbed, we use master and worker architecture to generate flows. Thus, you need to prepare some machines running in Linux and install python libraries as below and move network_traffic_generator_worker_node.py into those machines:

    • fastapi
    • uvicorn (used to start the API server)
    • pydantic
    • loguru
    • orjson (required by ORJSONResponse)
pip install --upgrade pip
pip install fastapi "uvicorn[standard]" pydantic loguru orjson

  Also, you need to make sure NTG can connect to those worker nodes.

Start Up Process

  1. Start the Ryu Controller
ryu-manager intelligent_router.py ryu.app.rest_topology ryu.app.ofctl_rest --ofp-tcp-listen-port 6633 --observe-link
  1. Start the NDTwin
sudo -E bin/ndtwin_kernel --loglevel info
  1. Start the NTG
python network_traffic_generator.py
  1. Manually Start worker node API servers on machines if the worker nodes do not start up correctly.
uvicorn network_traffic_generator_worker_node:app --host 0.0.0.0 --port 8000
  1. Now, you can use NTG to generate flows.

Tips

  • Ensure all data.worker_node_server URLs in Hardware.yaml are reachable and the servers are running.
  • Keep flow_distance_probability and flow_type_probability values normalized (sum to 1.0) for each section.
  • Validate parameter names and formats in flow_parameters to match the selected types.
  • For multiple consecutive experiments, the tool resets internal state after completion.
  • For one experiment, it will be ended only when all of flows, exclude flows with unlimited duration, are fininshed.

Troubleshooting

  • If flows do not start: 
    • Confirm API servers are up, ports opened, and the interactive_commands.py process can reach them.
    • It may due to the CPU resources are not enough for you’re flow configurations. Please lower the flow numbers or parameters to fix the question.
    • Since every iperf process will open one file and the number of opening file may be limited, the machine would be unable to run new iperf process when you have generated a huge amount of flows. Thus, you can change the ulimits -n or ulimits -u to a higher values to solve the problem.
  • If Nornir inventory errors occur: double-check that groups is a YAML list and host keys/fields are correctly indented.
  • If uvicorn fails to start: verify your virtualenv and ensure uvicorn is installed (pip install uvicorn fastapi).