Homework Assignment: Understanding ICMP and Raw Sockets
Course: Network Security and Programming
Due Date: January 27 2025 @ 11:59pm Gradescope.
Objective
The purpose of this assignment is to deepen your understanding of network protocols, specifically the Internet Control Message Protocol (ICMP), and how raw sockets are used to interact directly with network layers. This assignment is strictly for educational purposes and emphasizes ethical considerations. You will implement a simplified ICMP echo request sender in C and analyze its behavior in a controlled lab environment.
Background
ICMP is a fundamental protocol used in network diagnostics (e.g., ping). It operates at the network layer and is used to communicate error messages or perform network tests. Raw sockets allow low-level access to network protocols, enabling the creation of custom packets.
An ICMP flooding attack, often referred to as a “Ping Flood,” is an example of misuse of ICMP. For this assignment, you will simulate the mechanics of sending multiple ICMP packets to understand the protocol and analyze network traffic. You are not allowed to target real systems outside the controlled lab environment you create.
Task Details
- Setup:
- Use a virtual environment (Kali Linux running in virtual box, VMware or QUEMU). This environment is isolated and configured for safe experimentation.
- Use the target IP address:
127.0.0.1(localhost).
- Implementation:
- Write a C program that:
- Uses raw sockets to send ICMP Echo Request packets (type 8, code 0).
- Constructs the ICMP header manually, including:
- Type (8 for Echo Request)
- Code (0 for Echo Request)
- Checksum (calculated dynamically)
- Identifier and Sequence Number
- Generates random source IP addresses for each packet.
- Sends multiple ICMP packets in a loop (e.g., 100 packets).
- Include appropriate error checking for socket creation and packet sending.
- Write a C program that:
- Analysis:
- Use Wireshark or tcpdump to capture and analyze the packets generated by your program.
- Verify that the packets are properly constructed and reaching the target IP address.
- Submission:
- Submit the following to Gradescope:
- Your C source code. Upload your file called (main.c)
- The Wireshark capture file (in
.pcapformat) showing the ICMP packets sent by your program.
- Submit the following to Gradescope:
Guidelines
- Language: Use C for this assignment.
- AI Assistants: Feel free to use any AI tools you would like.
- Safety: Do not run your program outside the controlled environment. Misuse of this code in real-world systems is strictly prohibited and may result in disciplinary action.