TL;DR Use D-ITG to generate traffic of your choice.
To define a topology in Mininet -
You can use the MininetEdit.py application in mininet/examples/miniedit.py
folder. This will create a .py file defining the topology. You could have also written the same code to create the topology, the MininetEdit application is just a GUI to make it easy.
A sample topology definition looks something like this -
(I have created a simple network with 2 hosts h1, h2
connected to a switch s1
)
#!/usr/bin/python
from mininet.net import Mininet
... #More import calls
def myNetwork(net):
info( '*** Add switches\n')
s1 = net.addSwitch('s1')
info( '*** Add hosts\n')
h1 = net.addHost('h1',ip='10.0.0.1',defaultRoute=None)
h2 = net.addHost('h2',ip='10.0.0.2',defaultRoute=None)
info( '*** Add links\n')
net.addLink(h1, s1,bw=200,delay='0ms',loss=0,max_queue_size=1000)
net.addLink(h2, s1,bw=200,delay='0ms',loss=0,max_queue_size=1000)
return net
You can set the maximum link rate / bandwitdh in the MininetEdit app, or change the bw parameter in the addLink function in the code file manually.
If you want to generate some real traffic on this mininet topology, use D-ITG. This is a simple tool that will allow you to generate traffic with different distributions, inter-arrival times, packet sizes, etc.,
So if you want to generate constant rate traffic of say rate KB/s from host h1
to h2
, you can follow these steps -
Run xterm h1
from mininet instance
Run the following command on the terminal of h1
ITGSend -a <ip_of_h2> -T UDP -C <rate> -c <packet_size>
You can refer the D-ITG manual for more.