-
Notifications
You must be signed in to change notification settings - Fork 8
About Lab 2: Traffic capture
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.
This is how to send traffic to two ports.
This is how to listen to ping requests and replies separately using the tap.
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.)
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]
.
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
The interfaces must be up in order to listen on them.
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()
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