A simplified software implementation of an IPv4 router in C, capable of forwarding IP packets, handling ARP requests/replies, and sending ICMP error messages.
The project simulates the essential mechanisms of network routing and packet processing at the data link and network layers.
This router operates as an intermediary node in a local network, processing Ethernet frames, managing routing and ARP tables, and generating ICMP messages for error handling.
It models real-world routing behavior, including checksum validation, TTL management, and forwarding logic.
Language: C
Focus: Low-level networking, ARP and ICMP protocols, routing tables, binary search optimization
- Packet processing loop
- Receives and parses Ethernet frames
- Handles IP and ARP packets separately
- Routing
- Reads and sorts routing tables using merge sort
- Implements binary search to find the best route match
- Decrements TTL and recomputes IP checksums before forwarding
- ARP Table
- Parses entries from
arp_table.txt - Looks up MAC addresses for next hops
- Adds new entries dynamically upon receiving ARP replies
- Parses entries from
- ICMP Handling
- Sends ICMP Echo Reply, Time Exceeded, and Destination Unreachable packets
- Automatically swaps headers and recomputes checksums
- Error Checking
- Verifies Ethernet frame length and IP checksum validity
- Ignores packets not addressed to the router or broadcast
- Ethernet II (MAC addressing, Ethertype filtering)
- IPv4 (header parsing, TTL, checksum)
- ARP (request/reply handling and caching)
- ICMP (echo, unreachable, time exceeded)
- Implemented layer-2 and layer-3 networking logic from scratch
- Gained practical understanding of ARP resolution, ICMP messaging, and routing
- Applied checksum computation, TTL management, and packet encapsulation
- Practiced binary search and merge sort optimizations for routing performance