Skip to content

About Lab 3: Traffic generation

noaz edited this page Oct 6, 2017 · 1 revision

Use three different methods to generate traffic, and capture all of them with the DAG card.

You will need to write code for generating traffic in the Notebook template. The code for capturing traffic is already included. There cannot be more than one capture process running at the same time on a DAG card, so pkill dagsnap if there are any. (This may happen if code exits due to an error before it kills the capture process.)

After each experiment check that the traffic is captured correctly in L50Lab3/ so that you can process it later if necessary.

About pcap files

pcap files are packet capture files, which are loaded into our traffic generation tool to be replayed. You can view the details of the pcap files by opening them in Wireshark. Prepared pcap files for all experiments are included in the L50 repo, but you can create some using python OSNT-SUME-live/projects/osnt/sw/host/app/pcap_gen.py -o <outputfile> -n <number of packets> -l <packet length> -s <source MAC> -d <destination MAC>. You can find the MAC of an interface using ifconfig <interface>.

Functions in useful3.py

getdeltas(fexp, num)
Input: exp = '[folder]/[experiment name]', eg. '3.1/exp1a'. num = number of packets sent
Output: list of inter-arrival times in microseconds (float)

1. OSNT

Optional: OSNT includes GUI tools, which you can use to check your setup if you wish. After loading the OSNT bitfile correctly and connecting your interfaces, on two Terminal windows cd OSNT-SUME-live/projects/osnt/sw/host/app/gui && python generator_gui.py and cd OSNT-SUME-live/projects/osnt/sw/host/app/gui && python generator_gui.py. Replay L50/pcap_files/lab3.1/512_nf1_nf2.pcap from Interface 1 in the generator, and check that it arrives on Interface 2 in the monitor.

In the experiment you will use the CLI tool instead, which includes both generation and capture. cd OSNT-SUME-live/projects/osnt/sw/host/app/cli && python osnt-tool-cmd.py <options>

Usage and examples

python osnt-tool-cmd.py -ifp0 <pcap file> -rpn0 <replay number> [Optional: -ipg0 <gap (ns)>] -run
NB. ipg in OSNT is the gap in nanoseconds between the start of one packet and the start of the next. If the supplied value is too small it is ignored; the default value is 0. For 10 Gigabit Ethernet, 10 bits travel in 1 ns.
NB. This command exits immediately, which may be before the packets have finished replaying. So you must sleep a certain amount of time before killing the capturing process.

Eg. Replay blah.pcap 10 times on nf0, at max speed.
python osnt-tool-cmd.py -ifp0 blah.pcap -rpn0 20 -run
Eg. Replay blah.pcap 20 times on nf1, with gap 100000 ns.
python osnt-tool-cmd.py -ifp1 blah.pcap -rpn1 20 -ipg1 100000 -run

2. tcpreplay

The interfaces must be up in order to send on them.

Usage and examples

tcpreplay -i <interface> -l <replay number> --preload-pcap [Optional: -t] [Optional: -p <packets/sec>] blah.pcap
NB -t means max speed and is not to be used in conjuction with -p.

Eg. Replay blah.pcap 10 times on nic0, at max speed.
tcpreplay -i nic0 -l 10 --preload-pcap -t blah.pcap
Eg. Replay blah.pcap 20 times on nic1, at 20000 packets/sec.
tcpreplay -i nic1 -l 20 --preload-pcap -p 20000 blah.pcap

3. MoonGen

MoonGen takes a script as its argument, whose entry point is the function master which specifies how packets are to be sent. There is a prepared script /root/L50/Jupyter/useful/generator.lua to use for this experiment. You can learn how to write your own scripts here.

Usage and examples

moongen/build/MoonGen L50/Jupyter/useful/generator.lua <number of ports> <rate (Mbits/sec)> <iterations> <packet size (bytes)>
NB. Each iteration is 100 packets. You can change this in generator.lua.
NB. To send as fast as possible, set rate as 10000 or above.
NB. You can send on 1 port (0) or 2 ports (0 and 1).

Eg. Send 1000 512B packets as fast as possible on 1 port.
moongen/build/MoonGen L50/Jupyter/useful/generator.lua 1 10000 10 512
Eg. Send 10000 512B packets at rate 10 Mbits/sec on 2 ports.
moongen/build/MoonGen L50/Jupyter/useful/generator.lua 2 10 100 512