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 installMeasure route discovery, control work, delivery and repair under matched dense, sparse and mobile scenarios.
Open 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
- Run python main.py and inspect step 1: freeze the shared scenario.
- You will see
- seed=42; square=100x100; radio uses Euclidean distance; case nodes radio speed_limit packets interval_s warmup_s. STEP 1 scenario-contract ready
- Why it matters
- Matching the random field and workload isolates the routing choice. Warm-up and control-count boundaries must be stated before comparison.

Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- Run python main.py and inspect step 2: inspect the seeded field (first six nodes).
- You will see
- node x y neighbours; 0 63.9 2.5 3,4,9,20. STEP 2 topology measured
- Why it matters
- Radio range changes the graph itself. The seeded coordinates let another learner reproduce which relays can hear one another.

Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- Run python main.py and inspect step 3: send identical packets through the dense field.
- You will see
- protocol route hops ctrl data_tx delivery first_ms; Flood 0-4-1-29 3 0 102 100% 30. STEP 3 dense comparison complete
- Why it matters
- DSR carries a source route while AODV-style forwarding uses a discovered path. DSDV pays for table formation before forwarding; flooding spends data copies.

Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- Run python main.py and inspect step 4: repeat with the legacy sparse scenario.
- You will see
- protocol route hops ctrl data_tx delivery first_ms; Flood unreachable 0 0 6 0% None. STEP 4 sparse comparison complete
- Why it matters
- A disconnected graph has no immediate route. A failed delivery is evidence about topology, not proof that a named protocol is broken.

Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- Run python main.py and inspect step 5: move for one second, invalidate, and rediscover.
- You will see
- Max displacement <=10; broken cached edges=[]; Cached route valid=True; rule: reject any missing edge. STEP 5 mobility rediscovery complete
- Why it matters
- Mobility can invalidate previously useful state. Rebuilding tables and rediscovering on the same moved graph makes the recovery comparison inspectable.

Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- Run python main.py and inspect step 6: force a route error even if movement spared the route.
- You will see
- Before=[0, 4, 1, 29]; After link removal valid=False; rule: every edge must exist. STEP 6 failure handled
- Why it matters
- 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.

Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- Run python main.py and inspect step 7: vary load and repeat 30 seeds.
- You will see
- packets protocol controls controls/packet; 1 AODV-style 20 20.00. STEP 7 load-and-seed sensitivity measured
- Why it matters
- Control work per packet depends on workload. Thirty seeds expose topology sensitivity without claiming a radio-performance confidence interval.

Step 7 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 8
- Do
- Run python main.py and inspect step 8: carry one packet across scheduled contacts.
- You will see
- TTL copies delivery delay_s tx peak_buffer; 5 3 0 None 2 3. STEP 8 DTN TTL-and-copy comparison complete
- Why it matters
- Store-and-forward needs contacts before expiry and enough copy budget. The same contact trace makes TTL and replication comparisons fair.

Step 8 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 9
- Do
- Run python main.py and inspect step 9: validate the model before interpreting it.
- You will see
- two nodes one hop: PASS; disconnected target: PASS; same seed same coordinates: PASS; discovered edges exist: PASS. STEP 9 validation PASS
- Why it matters
- One-hop and disconnected cases catch graph mistakes. Passing them supports this small model, while testbed measurements are still needed for field conclusions.

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