A Rust-based network simulator is an educational tool that mimics packet transportation, routing, and other network behaviors, designed to help visualize and test network configurations and behaviors. The project includes a variety of features such as packet forwarding, static routing, error simulation, and a planned GUI for enhanced interactivity.
- Rust: Core language used for developing the simulator.
- Cargo: Rust's package manager and build tool.
- Egui: For handling terminal-based interaction and GUI.
- Multithreading: Multithreading supports sending responses to incoming packets or forwarding packets through the network.
- Synchronization (Mutex): Maintains atomicity and prevents race conditions with multithreading.
- Packet Simulation:
- Simulate the creation, forwarding, and modification of network packets.
- Include packet fragmentation and reassembly.
- Routing:
- Static routing tables to forward packets.
- Error Simulation:
- Simulate packet loss, corruption, retransmissions, and delays.
- Configurable bandwidth constraints on routers and switches.
- TTL (Time-To-Live): The TTL field in the packet header decreases as the packet travels through routers.
- TCP/IP Behavior Simulation: Support for simple behaviors of TCP/IP packets for testing.
- Network Graph: A graphical representation of the network showing devices, links, and packet flow.
- Animations: Visual animations of packets forwarded through the network.
- Interactive Nodes: Clickable network nodes (hosts, switches, routers) to inspect packet history and routing tables.
- Real-time Updates: Display packet state changes, routing updates, and error simulations in real-time.
- Packet:
- Represents a network packet with properties such as source/destination IP, source/destination MAC addresses, and data.
- Handles ARP requests and responses.
- Router:
- Static routing table.
- Will support dynamic routing protocols in future updates.
- Can forward packets based on the destination network.
- Switch:
- Maintains a CAM/MAC table (MAC → port).
- Can forward frames to the correct port.
- Host:
- Can generate packets.
- Maintains ARP table (IP → MAC).
- Sends/receives ARP requests.
- Device:
- Interface for hosts/routers/switches.
- Dynamic Routing: Implementation of routing protocols such as RIP and OSPF.
- Protocol Expansion: More complex protocol simulations like ICMP, ARP, and HTTP.
To get started with the simulator, clone the repository and compile the project:
git clone https://github.com/yashkukrecha/network-simulator.git
cd network-simulator
cargo runHave fun learning about networking! Here is a basic demonstration: