Skip to content
DhyeyTandelPublic

About

In-process Python simulator for reliable transport and distance-vector routing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

MiniNet Protocol Simulator (mininet-sim)

MiniNet is a from-scratch, in-process network protocol simulator written in Python. It models a lossy, delayed physical medium using asyncio and runs a custom reliable transport protocol (Go-Back-N ARQ) layered on top of a dynamic Distance Vector routing protocol (Bellman-Ford style with poison reverse).

This simulator does not use real OS sockets; instead, it implements a simulated link layer, allowing deterministic injection of packet loss, latency, and packet corruption for testing protocol convergence and reliable transport characteristics.


Architecture Diagram

                 +--------------------------------------------+
                 |                 CLI Group                  |
                 |      (run-topology, show-routes, send)      |
                 +----------------------+---------------------+
                                        | (Local TCP Control Socket)
                                        v
                 +--------------------------------------------+
                 |              NetworkSimulator              |
                 |    - Manages nodes & physical connections  |
                 |    - Models dynamic link loss & latency    |
                 +----------+----------------------+----------+
                            |                      |
                            v                      v
                 +--------------------+  +--------------------+
                 |      SimNode       |  |      SimNode       |
                 |       ("N1")       |  |       ("N4")       |
                 | +----------------+ |  | +----------------+ |
                 | |   GBNSender    | |  | |   GBNSender    | |
                 | +----------------+ |  | +----------------+ |
                 | |  GBNReceiver   | |  | |  GBNReceiver   | |
                 | +----------------+ |  | +----------------+ |
                 | |  RoutingNode   | |  | |  RoutingNode   | |
                 | +----------------+ |  | +----------------+ |
                 +----------+---------+  +----------^---------+
                            |                       |
                            +---[ VirtualLink ]-----+
                                 (Loss & Latency)

Headline Results

  1. High Packet Loss Tolerance: Reliably sustains error-free, byte-for-byte identical 50KB transfers over a 3-hop routed network even at 20% packet loss on data links and 10% packet loss on ACK links.
  2. Swift Convergence: A 3-hop linear topology ($N_1 - N_2 - N_3 - N_4$) with a 2.0-second broadcast interval converges completely within 2.12 seconds (second update cycle).
  3. Advanced Retransmit Control: Successfully triggers Fast Retransmit upon the 3rd duplicate ACK (4th consecutive receipt) and applies Exponential Backoff on consecutive timeouts, doubling the retransmit timer up to a capped $4\times$ multiplier.

Installation

  1. Clone the repository:

    git clone https://github.com/DhyeyTandel/MiniNET.git
    cd MiniNET
  2. Set up virtual environment and install in editable mode:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -e ".[test,dev]"

CLI Usage Guide

The CLI is registered under the mininet command.

1. Zero-Configuration End-to-End Demo

Run the zero-config demo which sets up a 4-node line topology with 10% packet loss on links, displays table convergence, and runs a reliable GBN transfer over 3 hops.

mininet demo

Output:

1. Starting 4-node line topology with 10% loss rates on all links...
Awaiting routing table convergence...

Routing converged in 2.12 seconds!
      Routing Table for N1       
┏━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━┓
┃ Destination ┃ Cost ┃ Next Hop ┃
┡━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━┩
│ N1          │ 0.0  │ N1       │
│ N2          │ 1.0  │ N2       │
│ N3          │ 2.0  │ N2       │
│ N4          │ 3.0  │ N2       │
└─────────────┴──────┴──────────┘
...
2. Initiating GBN reliable file transfer from N1 to N4 (3-hop routed transfer)...
Received Stream: 'Hello World! This message has been sent reliably over a 3-hop virtual network with 10% packet loss on every hop, utilizing Bellman-Ford Distance Vector routing and sliding window Go-Back-N reliable transport protocol.'

Success: Stream verification passed (byte-for-byte identical)!

Transfer Performance Stats:
Bytes Transmitted:   217 bytes
Timeout Retransmits: 0
Fast Retransmits:    0
Elapsed GBN Time:    0.0245 seconds

2. Start a Running Network Daemon

Load a topology definition JSON file to run the network and daemon control server:

mininet run-topology examples/four_node.json

3. Inject Link Loss Dynamically

In a separate terminal, inject packet loss on a specific link:

mininet inject-loss --link N1 N2 --rate 0.25

4. Inspect Live Routing Tables

View the routing tables of all running nodes (add --watch to monitor live updates):

mininet show-routes

5. Transfer Data

Send text or files between nodes in the running network:

mininet send --from N1 --to N4 --data "This is reliable transport data"

Development

Use the included Makefile targets to build, test, and check code style:

  • Run test suite: make test
  • Run test suite with coverage report: make test-cov
  • Lint code with Ruff: make lint
  • Run the demo: make demo

License

This project is licensed under the MIT License. See LICENSE for details.

About

In-process Python simulator for reliable transport and distance-vector routing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages