Project 1: Wiretap

Assigned: 9/17/09, Due: 10/2/09


Project Goal

Programs, tcpdump (http://www.tcpdump.org/) and Wireshark (http://www.wireshark.org/), allow sniffing and analyzing of packets being transmitted or received over a LAN. One prominent use of this information is in troubleshooting network configuration and reachability. In this project, we will provide you with data captured using these tools. Your task is to write the analysis routines similar to those provided by tcpdump and Wireshark. Your program must be written in C/C++ and should work on the Burrow or Sharkestra Linux machines.

Project Specification

Your program, wiretap, should take a file containing tcpdump data as its input and output the statistics detailed later in this document. Since this data is not in human-readable format, you will have to use the Packet Capture Library, libpcap.a, and the functions in its header file, pcap.h (found in /usr/include on the CS Linux machines) to read the data. When compiling your program, include the pcap library by using -lpcap as the first argument to your GNU compiler. For example, gcc -lpcap -o wiretap wiretap.c will compile a C program with the pcap library support. For C++, simply change the compiler from gcc to g++. The other steps you should follow are:

Packet format

Each packet in the file(s) provided to you is in tcpdump format. It contains a tcpdump-specific header, an Ethernet header, followed by network and transport layer headers and their contents. At the network layer, the captures will have IP and other protocols. TCP and UDP will both be present at the transport layer. We expect you to process Ethernet, IP, TCP, and UDP headers. The packets will also contain application data, but you do not need to process those headers. You will need to understand each of the header formats to accomplish this task. You are encouraged to reuse the structures from the relevant header files in the /usr/include/net and /usr/include/netinet directories on the CS Linux machines. These files contain structures used by the Linux operating system for actual packets. They can be used to greatly simplify the process of parsing the packets. However, you are still free to implement the structures on your own, if you wish.

Program output

The callback function should gather statistics from each packet to enable your program to print the following on standard out:

Test files

The following are two packet captures you should use for testing purposes.

Miscellaneous

Extra Credit

For 5% extra credit, infer flow information in your data. Specifically, for each combination seen of source and destination IP addresses and ports, and transport layer protocol, list the number of packets that traveled between them in each direction.

Deliverables and Grading

The grading will be based on the following three deliverables, all of which are due by 11:55pm on the due date: