Skip to content

About Lab 2: Traffic capture

noaz edited this page Oct 6, 2017 · 1 revision

Use OSNT to generate traffic, and capture it with two different methods.
You will need to write code for capturing traffic in the Notebook template. The code for generating traffic is already included. After each experiment check that the traffic is captured correctly in L50Lab2/ so that you can process it later if necessary.

The NetFPGA card requires rebooting on first power-on, to load bitfiles correctly.

About Experiments 1-4

This is how to send traffic to two ports.

twoports

About Experiment 5

This is how to listen to ping requests and replies separately using the tap.

ping

B. DAG

The driver must be loaded using dagload.
dagsnap is the capture tool. There cannot be more than one capture process running at the same time, or a Device or resource busy will show. pkill dagsnap if there are any. (This may happen if code exits due to an error before it kills the capture process.)

Usage

dagsnap -d0 -o <output file name>
This runs until it is killed.

Eg Scripting a capture in Python

cmd = shlex.split('dagsnap -d0 -o output.erf')
p = Popen(cmd)
sleep(2) # ensure that process is ready to capture
# send traffic #
sleep(2) # ensure that process has finished capturing
p.kill()

The Popen module allows us to spawn a child process. For more information, read Python docs on the Popen constructor and Popen objects.

dagsnap produces .erf files. These can be viewed using Wireshark or converted to plaintext using tshark -r file.erf [Optional: -V].

Functions in L50/Jupyter/useful/useful2.1.py

gettimes(exp)
Input: experiment name, eg. 'expB1'
Output: list of timestamps in seconds as strings

getdiff(exp)
Input: experiment name
Output: list of timestamp differences in nanoseconds

C. tcpdump

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

Usage

tcpdump -i <interface> -w <output file name> Similarly to dagsnap, this runs until it is killed.
NB. Furthermore, the capture file will not be recorded correctly unless it is killed.

Eg Scripting a capture in Python

cmd=shlex.split('tcpdump -i eth0 -w bla.pcap')
p = Popen(cmd)
sleep(2) # ensure that process is ready to capture
# send traffic #
sleep(2) # ensure that process has finished capturing
p.terminate()

Functions in L50/Jupyter/useful/useful2.2.py

gettimes(exp)
Input: experiment name, eg. 'exp2a'
Output: list of timestamps in seconds as strings

getrtt(fname)
Input: filename
Prints examples of RTTs.
Output: list of RTTs in microseconds.

getdiff(exp)
Input: experiment name
Output: list of timestamp differences in milliseconds