Compare mobile ad-hoc routing
Measure route discovery, control work, delivery and repair under matched dense, sparse and mobile scenarios.

Blueprint Bina: I want you to inspect the failed case and the record that explains the next decision.
Predict the reading, then compare it with the measurement.
Python 3 in your browser (JupyterLite)
Python · no installOpen the notebook in your browser and run each Python cell; no install or account is needed.
Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.
Steps
Step 1
- Do
- In the JupyterLite notebook, run the Step 1 cell to freeze the shared scenario.
- You will see
- Input: execute notebook step 1 with the record’s unchanged fixture, seed, and parameters. Observed: seed=42; square=100x100; radio uses Euclidean distance Observed: dense 30 30 0 6 30 30 Observed: sparse 15 15 0 6 30 30
- Why it matters
- Expected: STEP 1 scenario-contract ready from this deterministic notebook step. Interpretation: Matching the random field and workload isolates the routing choice. Warm-up and control-count boundaries must be stated before comparison. Action: Run python main.py and inspect step 1: freeze the shared scenario. Boundary: this local fixture is not a live device, network, or site measurement.

Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- In the JupyterLite notebook, run the Step 2 cell to inspect the seeded field (first six nodes).
- You will see
- Input: execute notebook step 2 with the record’s unchanged fixture, seed, and parameters. Observed: 0 63.9 2.5 3,4,9,20 Observed: 1 27.5 22.3 4,5,6,11,13,21,22,23,25,29 Observed: 2 73.6 67.7 7,10,14,15,18,19,27
- Why it matters
- Expected: STEP 2 topology measured from this deterministic notebook step. Interpretation: Radio range changes the graph itself. The seeded coordinates let another learner reproduce which relays can hear one another. Action: Run python main.py and inspect step 2: inspect the seeded field (first six nodes). Boundary: this local fixture is not a live device, network, or site measurement.

Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- In the JupyterLite notebook, run the Step 3 cell to send identical packets through the dense field.
- You will see
- Input: execute notebook step 3 with the record’s unchanged fixture, seed, and parameters. Observed: Flood 0-4-1-29 3 0 102 100% 30 Observed: AODV-style 0-4-1-29 3 20 18 100% 230 Observed: DSDV-style 0-4-1-29 3 1520 18 100% 30
- Why it matters
- Expected: STEP 3 dense comparison complete from this deterministic notebook step. Interpretation: DSR carries a source route while AODV-style forwarding uses a discovered path. DSDV pays for table formation before forwarding; flooding spends data copies. Action: Run python main.py and inspect step 3: send identical packets through the dense field. Boundary: this local fixture is not a live device, network, or site measurement.

Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- In the JupyterLite notebook, run the Step 4 cell to repeat with the legacy sparse scenario.
- You will see
- Input: execute notebook step 4 with the record’s unchanged fixture, seed, and parameters. Observed: Flood unreachable 0 0 6 0% None Observed: AODV-style unreachable 0 1 0 0% None Observed: DSDV-style unreachable 0 48 0 0% None
- Why it matters
- Expected: STEP 4 sparse comparison complete from this deterministic notebook step. Interpretation: A disconnected graph has no immediate route. A failed delivery is evidence about topology, not proof that a named protocol is broken. Action: Run python main.py and inspect step 4: repeat with the legacy sparse scenario. Boundary: this local fixture is not a live device, network, or site measurement.

Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- In the JupyterLite notebook, run the Step 5 cell to move for one second, invalidate, and rediscover.
- You will see
- Input: execute notebook step 5 with the record’s unchanged fixture, seed, and parameters. Observed: Max displacement <=10; broken cached edges=[] Observed: Cached route valid=True; rule: reject any missing edge Observed: Flood 0-4-1-29 3 0 96 100% 30
- Why it matters
- Expected: STEP 5 mobility rediscovery complete from this deterministic notebook step. Interpretation: Mobility can invalidate previously useful state. Rebuilding tables and rediscovering on the same moved graph makes the recovery comparison inspectable. Action: Run python main.py and inspect step 5: move for one second, invalidate, and rediscover. Boundary: this local fixture is not a live device, network, or site measurement.

Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- In the JupyterLite notebook, run the Step 6 cell to force a route error even if movement spared the route.
- You will see
- Input: execute notebook step 6 with the record’s unchanged fixture, seed, and parameters. Observed: Before=[0, 4, 1, 29] Observed: After link removal valid=False; rule: every edge must exist Observed: RERR emitted=1; expired at t=61: True; cache=None
- Why it matters
- Expected: STEP 6 failure handled from this deterministic notebook step. Interpretation: The host requires route errors, cache cleanup and recovery evidence. The forced missing edge and cache expiry show both ways a route stops being usable. Action: Run python main.py and inspect step 6: force a route error even if movement spared the route. Boundary: this local fixture is not a live device, network, or site measurement.

Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- In the JupyterLite notebook, run the Step 7 cell to vary load and repeat 30 seeds.
- You will see
- Input: execute notebook step 7 with the record’s unchanged fixture, seed, and parameters. Observed: Vary load and repeat 30 seeds Observed: 1 AODV-style 20 20.00 Observed: 1 DSDV-style 1520 1520.00
- Why it matters
- Expected: STEP 7 load-and-seed sensitivity measured from this deterministic notebook step. Interpretation: Control work per packet depends on workload. Thirty seeds expose topology sensitivity without claiming a radio-performance confidence interval. Action: Run python main.py and inspect step 7: vary load and repeat 30 seeds. Boundary: this local fixture is not a live device, network, or site measurement.

Step 7 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 8
- Do
- In the JupyterLite notebook, run the Step 8 cell to carry one packet across scheduled contacts.
- You will see
- Input: execute notebook step 8 with the record’s unchanged fixture, seed, and parameters. Observed: 5 3 0 None 2 3 Observed: 5 5 0 None 2 3 Observed: 10 3 0 None 2 3
- Why it matters
- Expected: STEP 8 DTN TTL-and-copy comparison complete from this deterministic notebook step. Interpretation: Store-and-forward needs contacts before expiry and enough copy budget. The same contact trace makes TTL and replication comparisons fair. Action: Run python main.py and inspect step 8: carry one packet across scheduled contacts. Boundary: this local fixture is not a live device, network, or site measurement.

Step 8 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 9
- Do
- In the JupyterLite notebook, run the Step 9 cell to validate the model before interpreting it.
- You will see
- Input: execute notebook step 9 with the record’s unchanged fixture, seed, and parameters. Observed: two nodes one hop: PASS; disconnected target: PASS Observed: same seed same coordinates: PASS; discovered edges exist: PASS Observed: No MAC contention, fading, queues, or measured battery model.
- Why it matters
- Expected: STEP 9 validation PASS from this deterministic notebook step. Interpretation: One-hop and disconnected cases catch graph mistakes. Passing them supports this small model, while testbed measurements are still needed for field conclusions. Action: Run python main.py and inspect step 9: validate the model before interpreting it. Boundary: this local fixture is not a live device, network, or site measurement.

Step 9 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
Which statement best describes why a team might choose DSR for an ad-hoc IoT deployment?
Return to the chapter’s knowledge checkA field team says DSR is working because one packet reached the gateway. What review evidence is still missing?
Return to the chapter’s knowledge check