Description
In this assignment, you will get familiar with the Packet Capture library (libpcap). This tutorial assumes background knowledge in networks and familiarity with the C programming language. For more information about the packet capture library, visit the following websites: https://linux.die.net/man/3/pcap and https://www.tcpdump.org. Using libpcap, we will capture packets right as they come off of the network card. 1. You are expected to (i) monitor the traffic live from a network interface (pcap_open_live) and (ii) read a pcap file (pcap_open_offline). 2. For this assignment, you will capture network traffic and you will process the incoming TCP and UDP packets. Do not use pcap_compile or pcap_setfilter. More specifically, you are expected to do the following: 1. Select the one interface that you wish to monitor or select the pcap file name. 2. Start capturing/reading packets. 3. Decode each received packet (i.e., is it a TCP or UDP packet?)1 . 4. Skip any packet that is not TCP or UDP. 5. Print the packet’s source and destination IP addresses. 6. Print the packet’s source and destination port numbers. 7. Print the packet’s protocol. 8. Print the packet’s TCP/UDP header length and TCP/UDP payload length in bytes. 9. Can you tell if an incoming TCP packet is a retransmission? If yes, how? If not, why? 10. Can you tell if an incoming UDP packet is a retransmission? If yes, how? If not, why? 11. In your program (when possible), mark each retransmitted packet as “Retransmitted”. 12. On exit, your program must print the following statistics: a. Total number of network flows captured2 . b. Number of TCP network flows captured. c. Number of UDP network flows captured. d. Total number of packets received (include the packets you skipped, that weren’t TCP or UDP packets.). 1 Do not forget to check if it runs over IPv4 or IPv6. 2 A network flow is defined by the 5-tuple {source IP address, source port, destination IP address, destination port, protocol}. e. Total number of TCP packets received. f. Total number of UDP packets received. g. Total bytes of TCP packets received. h. Total bytes of UDP packets received. Tool Specification Your tool will receive the following arguments from the command line upon execution. Options: Notes 1. The options defined in the “Tool specification” section must remain as-is. 2. If no appropriate option was given, your program has to print the appropriate error message. 3. You need to create a Makefile to compile your library and programs (you must submit it with your source code). 4. You are provided with a sample packet capture to test your program. Its duration is 5 minutes. 5. You need to create a README with your name, your AM and a short description (1-2 lines) of your implementation. 6. You must submit the following files: README, Makefile, monitor.c. 7. You should place all these files in a folder named _assign6 and then compress it as a .zip file. For example, if your login is 2020123456 the folder should be named 2020123456_assign6 you should commit 2020123456_assign6.zip. 8. Use the tab “Συζήτηση” in courses for questions. -i Network interface name (e.g., eth0) -r Packet capture file name (e.g., test.pcap) -h Help message