Project 2: TCP-based traceroute
Type of Project: Individual
Language: C/C++, Java, Python, or another language
Points: 30 points
Submission Guidelines: Submit through ELC. Submit ONLY the source code (zip or tar.gz file). Automate the build process. For example, include a “Makefile” for C/C++ code, a pom.xml for Java code, a setup.py for Python code, etc. Make sure to name the output executable as “tcp_traceroute”. All files need to be under the same main directory (i.e., do not create subdirectories under “LastNameFirstName-tcp_traceroute”).
NOTE: project submissions that do not follow the guidelines risk to receive 0 points.
Project Description: In this project, you are asked to use raw sockets to write a simple traceroute-like program. This program increases the value of TTL in an IP datagram (referred to as an IP packet) it has crafted to carry a TCP segment. In a TCP segment, all flags in the header except PUSH must be off. TCP payload carries nothing but a string “CSCI6760-f19”. When making a such packet, the program needs to calculate and fill in correct IP header checksum and TCP checksum.
One can run your program using the following command:
# ./tcp_traceroute <DEST_IP> <TCP_PORT>
# ./tcp_traceroute 126.96.36.199 80
The output should look like something below:
1 188.8.131.52 0.355 ms 0.444 ms 0.479 ms
2 184.108.40.206 0.437 ms 0.463 ms 0.534 ms
3 220.127.116.11 0.507 ms 0.614 ms 0.756 ms
4 18.104.22.168 0.580 ms 0.899 ms 1.226 ms
5 22.214.171.124 2.561 ms 2.281 ms 2.052 ms
6 126.96.36.199 4.046 ms 4.474 ms 4.331 ms
7 188.8.131.52 4.346 ms 4.147 ms 17.470 ms
8 184.108.40.206 5.487 ms 5.364 ms 4.814 ms
9 220.127.116.11 5.295 ms 6.790 ms 7.464 ms
The TTL must start from 1 and go to a maximum of 30. For each TTL, the round trip time needs to be measured for 3 times. That means, your program will send out 3 packets with TTL 1, 3 packets with TTL 2, etc. To each packet you have sent, an ICMP response will be sent back, indicating expiration of TTL (often carried in a “Time Exceeded” ICMP packet). By timing the difference between when a packet is sent out and when a corresponding ICMP response arrives, you can further calculate time variations for a particular TTL.
Your code must appropriately handle response packets delivered from the network. Refer to RFC 792 on how to interpret ICMP messages, such as “Port Unreachable” and “Host Unreachable”. When TTL is raised above a certain point, your packets get close to the destination. TCP protocol and firewall settings might affect what responses your program receives. If your packet hits an open (LISTEN) port on the destination end host, your program may receive a TCP RST (reset) packet. Also, note that firewall on destination network might be configured to drop outgoing ICMP TTL expired traffic, and/or incoming TCP non-ACK traffic.
Packet loss might happen to a trace probing packet or the response packet during transfer in the network. You should use a timer and set a timeout interval to 1 second. If your program does not receive an ICMP “Time Exceeded” or a TCP RST packet before getting a timeout, you can assume the response packet is lost.
TESTING YOUR CODE
You should test your code in multiple scenarios. Find some IP addresses to which the routes are stable and compare your results with the output of “traceroute” (use the -T and -p and -n options).
MAILING LIST: If you have questions about the project, the best place to ask is on eLC, or to talk to me after class or during an office hour.
I will run your progarm on 5 different combinations of <DEST_IP> and <TCP_PORT>. You will get 4 points for each test that produces an acceptable output (as compared to traceroute and my own implementation of the program).