Skip to content

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., your practice guide

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 install

Measure route discovery, control work, delivery and repair under matched dense, sparse and mobile scenarios.

Tier 2 · Web · paste-in setup · No account

Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 148.0.7778.96; captureSource playwright:jupyterlite. Date: 2026-09-10.

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.

Open in your browser (new tab)

Steps

Screens captured against Python 3 in your browser (JupyterLite) Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 148.0.7778.96; captureSource playwright:jupyterlite on 2026-09-10; the tool may have moved on — the text steps are the contract.

  1. 1 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.
    JupyterLite step 1 showing the executed Python and its observed result.
    Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  2. 2 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.
    JupyterLite step 2 showing the executed Python and its observed result.
    Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  3. 3 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.
    JupyterLite step 3 showing the executed Python and its observed result.
    Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  4. 4 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.
    JupyterLite step 4 showing the executed Python and its observed result.
    Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  5. 5 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.
    JupyterLite step 5 showing the executed Python and its observed result.
    Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  6. 6 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.
    JupyterLite step 6 showing the executed Python and its observed result.
    Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  7. 7 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.
    JupyterLite step 7 showing the executed Python and its observed result.
    Step 7 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  8. 8 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.
    JupyterLite step 8 showing the executed Python and its observed result.
    Step 8 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  9. 9 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.
    JupyterLite step 9 showing the executed Python and its observed result.
    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.

  1. Which statement best describes why a team might choose DSR for an ad-hoc IoT deployment?

    Return to the chapter’s knowledge check
  2. A 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

Caution

Use fictional inputs. This deterministic teaching model omits real radio interference and hardware timing; its counts explain this scenario, not field performance.

Return to DSR Reactive Routing · Browse Labs