A Java-based network routing simulation that implements the Link State Routing Protocol. This project demonstrates how routers in a network discover their neighbors, build routing tables, and forward messages using the shortest path algorithm.
This project simulates a network of routers that can:
- Discover and maintain information about their neighbors
- Build and update routing tables using the Link State Routing Protocol
- Forward messages between routers using the optimal path
- Handle communication across different subnets through gateway routers
The simulation consists of several key components:
-
Routers: Each router has:
- A unique IP address
- A subnet mask
- A routing table
- A link state database
- Information about its neighbors and connection latencies
-
Network: The network class manages:
- Router connections
- Message delivery between routers
- Network topology
-
Message Types:
- Link State Messages: Used for router discovery and topology updates
- Data Messages: Used for actual data transmission between routers
The project implements two main algorithms:
-
Link State Routing Protocol:
- Each router broadcasts information about its directly connected neighbors
- Routers maintain a database of the entire network topology
- Uses Dijkstra's algorithm to calculate the shortest path to all destinations
-
Dijkstra's Shortest Path Algorithm:
- Used to calculate the optimal routes in the network
- Considers link latencies as edge weights
- Updates routing tables with the best paths to each destination
- Java Development Kit (JDK) 8 or higher
- Compile the Java files:
javac *.java- Run the main program:
java MainThe simulation will:
- Create a network with multiple routers
- Establish connections between routers
- Initialize routing tables
- Run the Link State Routing Protocol
- Display the final routing tables
- Demonstrate message routing between routers
The default simulation creates a network with:
- Subnet 192.168.1.0/24: Routers A, B, and C
- Subnet 192.168.2.0/24: Routers D and E
- Various connections with different latencies
- Gateway routers connecting the subnets
Main.java: Entry point and network setupRouter.java: Router implementation and routing logicNetwork.java: Network topology and message deliveryRoutingTable.java: Routing table managementLinkState.java: Link state informationMessage.java: Message handling and types
- Dynamic routing table updates
- Cross-subnet communication
- Latency-based path selection
- Message forwarding with hop limits
- Network topology visualization
- Gateway router functionality