A visual and interactive simulation of the Distance Vector Routing (DVR) protocol, built using Kotlin and Jetpack Compose for Desktop. This application serves as an educational tool to understand how DVR works by allowing users to visualize the network topology, observe the step-by-step convergence process, manage network links dynamically, and find the shortest paths based on the calculated routing tables.
Distance.Vector.Routing.Simulation.Video.mp4
- ✅ Interactive Graph Visualization: Displays network nodes and edges with associated costs using Jetpack Compose Canvas.
- 🖱️ Node & Edge Selection: Click on nodes or edges to highlight them and view specific details (like a node's routing table).
- 🔗 Dynamic Link Management:
- ➕ Add new bidirectional links (edges) between nodes with specified costs.
- ➖ Remove existing links.
- ✏️ Update the cost (weight) of existing links.
- ⏯️ Step-by-Step Simulation: Manually advance the DVR algorithm one step at a time to observe how routing tables are exchanged and updated (Bellman-Ford logic).
- 🚀 Auto-Step Simulation: Automatically run simulation steps with visual feedback until convergence is reached. Includes pause functionality.
- Visual DVR Exchange: See symbolic "packets" representing distance vector advertisements travel along the links during simulation steps.
- 📊 Routing Table Display: View the current routing table (
Destination,Cost,Next Hop) for any selected node, updating in real-time as the simulation progresses. Shortest Path Finding: Calculate and visualize the shortest path between any two nodes based on the current state of the converged (or partially converged) routing tables. Path is highlighted on the graph. - 🏁 Convergence Detection: The simulation clearly indicates when the DVR algorithm has stabilized and all routing tables are consistent.
- 🎨 Clear Visual Feedback: Utilizes distinct colors and highlights for selections, active advertisements, calculated paths, and simulation status messages.
- 🔄 Reset Functionality: Easily reset the entire simulation back to its initial network topology and state.
- Language: Kotlin
- UI Framework: Jetpack Compose for Desktop
- Asynchronous Operations: Kotlin Coroutines (for smooth animations and non-blocking simulation steps)
- Build System: Gradle
- JDK: Java Development Kit version 11 or higher. (Ensure
JAVA_HOMEis set correctly). - Gradle: Usually bundled with IntelliJ IDEA or installable separately. The project includes a Gradle wrapper (
gradlew). - IDE (Recommended): IntelliJ IDEA (Community or Ultimate) for the best Kotlin and Compose development experience.
-
Clone the repository:
git clone https://github.com/rezaul-web/Distance-Vector-Routing-Protocol-Simulation.git cd Distance-Vector-Routing-Protocol-Simulation -
Open in IntelliJ IDEA:
- Launch IntelliJ IDEA.
- Select
File>Open...and navigate to the clonedDistance-Vector-Routing-Protocol-Simulationdirectory. - Trust the project if prompted.
- Allow IntelliJ to import the Gradle project and download dependencies (this might take a few minutes).
-
Build the Project:
- Use the IDE:
Build>Build Project(or pressCtrl+F9/Cmd+F9). - Alternatively, via terminal:
./gradlew build # On Linux/macOS gradlew.bat build # On Windows
- Use the IDE:
-
From IntelliJ IDEA (Recommended):
- Find the
Main.ktfile (likely insrc/main/kotlin/). - Locate the
mainfunction within the file. - Click the green
▶️ icon in the gutter next to themainfunction. - Select "Run 'MainKt'".
- Find the
-
From the Command Line (using Gradle):
./gradlew run # On Linux/macOS gradlew.bat run # On Windows
The application window is divided into the main visualization canvas on the left and control panels/table display on the right.
-
🖱️ Canvas Interaction:
- View: Observe the network graph (nodes and links with costs).
- Select Node: Click directly on a node circle. It will be highlighted (e.g., Magenta), and its routing table will appear in the bottom-right panel.
- Select Edge: Click near the line representing a link. It will be highlighted (e.g., Orange).
- Deselect: Click on any empty space in the canvas area.
-
🔗 Link Management (Bottom Left):
- Input
Node 1 ID,Node 2 ID, andCost. - Add: Creates a link if valid and non-existent.
- Remove: Deletes the specified link.
- Update Cost: Modifies the cost of an existing link.
- Note: Changes reset the convergence state and require re-running the simulation.
- Input
-
⚙️ Simulation Controls (Top Right):
-
Step: Executes one full round of DVR updates across all nodes. Visualize the DV exchange animations. Disabled when converged or during auto-step.
-
Auto Step / Pause: Starts/stops automatic execution of steps with delays until convergence.
-
Reset Sim: Returns the network to its initial configuration and clears all calculated data.
-
Enter
Source IDandDest ID. -
Show Path: Uses the current routing tables to trace and highlight the calculated shortest path on the canvas (Nodes: Green/Orange, Edges: Red). Visual feedback indicates if a path exists based on the current table state.
-
-
📊 Routing Table Display (Bottom Right):
- Shows the table for the currently selected node (
Destination,Cost,Next Hop). - Updates dynamically after each simulation step if changes occur for the selected node.
INFindicates an unreachable destination.
- Shows the table for the currently selected node (
-
💬 Status Messages:
- Look below the "Find Path" section for feedback on actions (link added/removed, step completed, convergence reached, path found, errors, etc.).
- Initialization: Starts with a base network topology. Each node initializes its table: 0 cost to itself, direct link cost to neighbors, and infinity (
INF) to others. - Bellman-Ford Logic (Core of DVR): In each
Step, nodes exchange their distance vectors with neighbors. When nodeAreceives a vector from neighborB:- For every destination
DinB's vector,AcalculatesCost(A, D) = Cost(A, B) + Cost(B, D). - If this calculated cost is less than
A's current known cost toD,Aupdates its table: sets the new lower cost and setsNext HopforDtoB.
- For every destination
- Visualization: The simulation animates this exchange and highlights table changes.
- Convergence: The process repeats until no node updates its table during a full step, meaning the shortest paths (according to DVR) have been found.
- Path Tracing: The "Show Path" function iteratively looks up the
Next Hopin each node's table, starting from the source, until the destination is reached.
(Note: This simulation demonstrates the core DVR principle. It may not implement advanced optimizations like Split Horizon or Poison Reverse unless explicitly coded.)
Contributions are welcome! If you find bugs, have suggestions for improvements, or want to add new features:
- Open an Issue: Describe the bug or feature suggestion clearly in the repository's "Issues" tab.
- Fork & Pull Request: Fork the repository, make your changes on a separate branch, and submit a pull request detailing your changes.
This project is licensed under the MIT License. See the LICENSE file for full details.