This program simulates IPv4 packet fragmentation and routes each fragment using Dijkstra's algorithm to find the shortest path through a network.
- Create and visualize network topologies (predefined or custom)
- Generate IPv4 packets with custom payload sizes
- Fragment packets based on MTU constraints
- Calculate shortest paths for each fragment using Dijkstra's algorithm
- Support for dynamic network topology changes between fragment transmissions
- Detailed display of fragmentation and routing information
src/main.c: Main program logic and workflowsrc/network.c&include/network.h: Network topology representation and managementsrc/ipv4.c&include/ipv4.h: IPv4 packet structures and fragmentation functionssrc/dijkstra.c&include/dijkstra.h: Implementation of Dijkstra's shortest path algorithmsrc/ui.c&include/ui.h: User interface functionsMakefile: Compilation instructions
Use the provided Makefile to compile the program:
make
This will create an executable named network_sim in the build directory.
Run the compiled program:
./build/network_sim
Follow the interactive prompts to:
- Choose or create a network topology
- Specify source and destination nodes
- Set MTU and payload size
- View the fragmentation results and routing paths
You can also run the application using Docker, which ensures consistent execution across different systems:
docker build -t ipv4-router .
docker run -it ipv4-router
The -it flags ensure you can interact with the program's interface.
- Represents the network as an adjacency matrix
- Supports directed graphs with weighted edges
- Allows dynamic modification of the topology
- Creates IPv4 packets with proper headers
- Fragments packets according to IPv4 standards
- Handles fragment offset calculation in 8-byte units
- Implements Dijkstra's algorithm for shortest path finding
- Constructs the complete path from source to destination
- Detects unreachable destinations
- Provides user interface for input and visualization
- Displays network topology in multiple formats
- Shows detailed information about packets and fragments
- Does not implement actual packet transmission
- Uses simplified addressing (node numbers instead of IP addresses)
- Does not handle IPv4 options
- Simplified checksum calculation
- Add fragment reassembly at the destination
- Implement actual network simulation with packet transmission
- Add support for network failures and fault tolerance
- Extend with alternative routing algorithms