89  Ad Hoc Production

In 60 Seconds

Production ad-hoc networks use a four-layer architecture: topology discovery, link quality assessment (classifying links as Excellent/Good/Fair/Poor based on PDR, RSSI, and latency), multi-path routing for redundancy, and continuous performance monitoring. Routing strategy selection depends on priority: shortest path for latency, energy-aware for battery longevity.

Minimum Viable Understanding
  • Production ad-hoc networks use a four-layer architecture: topology discovery, link quality assessment, multi-path routing, and performance monitoring.
  • Link quality is classified into four tiers (Excellent/Good/Fair/Poor) based on PDR, RSSI, and latency thresholds to drive routing decisions.
  • Routing strategy selection depends on application needs: shortest path for low latency, load balanced for even wear, energy-aware for longevity, QoS-aware for reliability.

Max the Microcontroller was in charge of managing the Smart Farm’s wireless network, and he had FOUR important jobs:

Job 1 – Finding Neighbors: “First, I figure out who can hear who,” Max explained. “Sammy the Sensor can talk to Lila the LED because they’re close, but not to Bella the Battery across the barn.”

Job 2 – Checking Signal Quality: “Then I rate each connection. Sammy to Lila? EXCELLENT – crystal clear! Sammy to the faraway weather station? POOR – like trying to whisper across a football field.”

Job 3 – Planning Routes: “I figure out multiple paths for messages. If the main road is busy, I have a back road ready. It’s like having GPS suggest three routes to grandma’s house!”

Job 4 – Watching Everything: Lila added, “Max also watches for trouble. If one sensor is doing ALL the work passing messages, Max reroutes traffic so nobody burns out.”

Bella smiled: “It’s like being the world’s best traffic controller – keeping data flowing smoothly across the whole farm!”

89.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Build Production Frameworks: Implement comprehensive multi-hop ad-hoc network management systems
  • Assess Link Quality: Design link quality classification and monitoring for dynamic networks
  • Implement Multi-Path Routing: Create load-balanced routing across multiple paths
  • Monitor Network Performance: Build real-time topology discovery and health monitoring
  • Handle Network Dynamics: Manage link state changes and routing table updates
  • Deploy Production Systems: Apply the framework to real-world IoT deployments

89.2 Prerequisites

Required Chapters:

Technical Background:

  • Self-organizing networks
  • MANET concepts
  • Reactive vs proactive routing

Ad-hoc Routing Protocols:

Protocol Type Overhead Latency Best For
AODV Reactive Low High Dynamic
DSR Reactive Low High Small networks
OLSR Proactive High Low Static
DSDV Proactive High Low Stable

Estimated Time: 45 minutes

This chapter is implementation-heavy. It walks through a full Python framework for multi-hop ad hoc networks—topology discovery, link quality monitoring, multi-path routing, and simulation output.

It is designed to come after you are comfortable with the conceptual material from:

  • adhoc-fundamentals.qmd – why ad hoc networks exist, basic routing ideas, and limitations.
  • multi-hop-fundamentals.qmd – how multi-hop forwarding, path length, and connectivity work.
  • adhoc-hybrid-zrp.qmd – zone-based routing and the “Goldilocks” trade-off between proactive and reactive protocols.

If you are new to ad hoc networking:

  • Skim the code examples to see what a production-style toolkit might look like.
  • Focus on the printed outputs (topology stats, link quality, routing comparisons) and map them back to the earlier conceptual chapters.
  • Come back later for a deeper dive when you are ready to experiment with the code on your own machine.

Key Concepts

  • Production Ad Hoc Network: Deployment-ready ad hoc network implementation meeting reliability, scalability, and maintainability requirements
  • Routing Protocol Selection Framework: Systematic approach selecting DSDV, DSR, AODV, or ZRP based on deployment characteristics
  • Network Management in Ad Hoc: Monitoring, fault detection, and configuration management without centralized infrastructure
  • Security Architecture: Ad hoc security requirements: authentication, encryption, intrusion detection without a central authority
  • Scalability Analysis: How routing overhead, convergence time, and routing table size grow with network size
  • Fault Tolerance Design: Designing for node failure, link failure, and network partition without service interruption
  • Deployment Checklist: Pre-deployment verification of routing configuration, security settings, and channel planning
  • Monitoring Without Infrastructure: Distributed monitoring using gossip protocols, network tomography, and probe-based measurement

89.3 Introduction

Production ad-hoc networks require robust management systems that go beyond simple routing protocols. Real-world IoT deployments face challenges including variable link quality, node mobility, battery constraints, and the need for continuous monitoring. This chapter provides a comprehensive production-ready Python framework that addresses these challenges through modular, extensible components.

The framework consists of four key layers:

  1. Topology Discovery Layer - Dynamic neighbor discovery, link tracking, and topology event monitoring
  2. Link Quality Assessment Layer - PDR, RSSI, latency measurement with quality classification
  3. Multi-Path Routing Layer - K-shortest paths, multiple routing metrics, and path selection strategies
  4. Performance Monitoring Layer - Network statistics, bottleneck detection, and health monitoring

89.4 Production Framework: Advanced Multi-Hop Network Management

Estimated Time: ~25 min | Difficulty: Advanced | Unit: P04.C06.U01

This section provides a comprehensive production-ready Python framework for managing multi-hop ad-hoc networks in real-world IoT deployments. The implementation covers topology discovery, link quality assessment, multi-path routing, load balancing, and network performance monitoring.

89.4.1 Enumerations and Type Definitions

89.4.2 Core Data Structures

89.4.3 Main Classes

89.4.4 Comprehensive Examples

89.4.4.1 Example 1: Complete Network Topology Management

Output:

=== Ad-Hoc Network Topology Management ===

Network created: 20 nodes

Discovering neighbors based on transmission range (100m)...

Neighbor Discovery Results:
  Total nodes: 20
  Total links: 38
  Network diameter: 6 hops
  Connectivity ratio: 98.4%

Neighbor statistics:
  Average neighbors per node: 3.8
  Min neighbors: 1
  Max neighbors: 8

  Most connected: node_12 (8 neighbors)
  Least connected: node_17 (1 neighbors)

--- Simulating Topology Change ---
Moving node_05 to new location...
  Neighbors before move: 4
  Neighbors after move: 2
  Neighbor change: -2

Topology events recorded: 78

89.4.4.2 Example 2: Link Quality Estimation and Monitoring

Output:

=== Link Quality Estimation ===

Simulating excellent link: node_00-node_01
  PDR: 94.0%
  Quality: EXCELLENT
  Latency: 10.2 +/- 1.9 ms
  RSSI: -55.3 dBm
  Stability score: 0.921
  Predicted stability (30s): 0.915

Simulating good link: node_02-node_03
  PDR: 81.0%
  Quality: GOOD
  Latency: 24.8 +/- 7.6 ms
  RSSI: -70.2 dBm
  Stability score: 0.762
  Predicted stability (30s): 0.754

Simulating poor link: node_04-node_05
  PDR: 44.0%
  Quality: POOR
  Latency: 59.3 +/- 19.2 ms
  RSSI: -87.8 dBm
  Stability score: 0.312
  Predicted stability (30s): 0.298

89.4.4.3 Example 3: Multi-Path Routing with K-Shortest Paths

Output:

=== Multi-Path Routing ===

Computing multiple paths: node_00 -> node_15

Found 3 disjoint paths:

Path 1 (path_1):
  Hops: node_00 -> node_03 -> node_07 -> node_12 -> node_15
  Hop count: 4
  Cost: 4.00
  State: ACTIVE

Path 2 (path_2):
  Hops: node_00 -> node_02 -> node_06 -> node_11 -> node_14 -> node_15
  Hop count: 5
  Cost: 5.00
  State: ACTIVE

Path 3 (path_3):
  Hops: node_00 -> node_01 -> node_05 -> node_09 -> node_13 -> node_15
  Hop count: 5
  Cost: 5.00
  State: ACTIVE

=== Routing Strategy Comparison ===

SHORTEST_PATH:
  Path usage distribution:
    path_1: 50 packets (100%)

LOAD_BALANCED:
  Path usage distribution:
    path_1: 17 packets (34%)
    path_2: 17 packets (34%)
    path_3: 16 packets (32%)

ENERGY_AWARE:
  Path usage distribution:
    path_1: 24 packets (48%)
    path_2: 15 packets (30%)
    path_3: 11 packets (22%)

Final path delivery ratios:
  path_1: 91.0% (141/155)
  path_2: 87.5% (28/32)
  path_3: 92.6% (25/27)

89.4.4.4 Example 4: Network Performance Monitoring

Output:

=== Network Performance Monitoring ===

Simulating network traffic...

Network Statistics:
  Total nodes: 20
  Total links: 38
  Network diameter: 6 hops
  Connectivity: 98.4%
  Average battery: 84.3%
  Average latency: 48.7 ms
  Max latency: 92.3 ms

Bottleneck nodes detected: 3
  High-traffic nodes:
    node_12: 48 forwarded, 92.3% forwarding ratio
    node_07: 35 forwarded, 87.5% forwarding ratio
    node_03: 29 forwarded, 82.9% forwarding ratio

Top 5 nodes by packet forwarding:
  node_12: 48 packets forwarded, 8 neighbors, 78.3% battery
  node_07: 35 packets forwarded, 6 neighbors, 81.7% battery
  node_03: 29 packets forwarded, 5 neighbors, 88.2% battery
  node_06: 22 packets forwarded, 4 neighbors, 92.1% battery
  node_11: 18 packets forwarded, 3 neighbors, 85.9% battery

89.4.4.5 Example 5: Energy-Aware Routing

Output:

=== Energy-Aware Routing Comparison ===

Testing Shortest Path strategy...
  Packets delivered: 489
  Min battery: 42.3%
  Avg battery: 87.6%
  Battery std dev: 18.7%
  Dead nodes: 0

Testing Energy-Aware strategy...
  Packets delivered: 487
  Min battery: 71.8%
  Avg battery: 89.2%
  Battery std dev: 9.3%
  Dead nodes: 0

=== Comparison ===
Energy-Aware vs Shortest Path:
  Min battery improvement: +29.5%
  Avg battery improvement: +1.6%
  Battery balance (lower std is better): +9.4%

89.4.4.6 Example 6: Integrated Network Simulation

Output:

=== Integrated Multi-Hop Network Simulation ===

Creating 25-node ad-hoc network...
Measuring link quality...

Network initialized:
  Nodes: 25
  Links: 52
  Diameter: 5 hops
  Connectivity: 99.7%

============================================================
Period 1
============================================================

Network Performance:
  Avg battery: 98.2%
  Avg latency: 47.3 ms
  Topology events: 105

Network Health:
  Bottleneck nodes: 2
  Failing links: 3

============================================================
Period 2
============================================================

  Warning: Node failure detected!
  Removed wsn_10 from network

Network Performance:
  Avg battery: 96.5%
  Avg latency: 49.1 ms
  Topology events: 116

Network Health:
  Bottleneck nodes: 3
  Failing links: 4

============================================================
Period 3
============================================================

Network Performance:
  Avg battery: 94.7%
  Avg latency: 50.8 ms
  Topology events: 116

Network Health:
  Bottleneck nodes: 3
  Failing links: 5

============================================================
Simulation Complete
============================================================

=== Final Network State ===

Topology:
  Active nodes: 24
  Active links: 48
  Network diameter: 6 hops
  Connectivity: 98.9%

Performance:
  Average latency: 49.1 ms
  Max latency: 87.6 ms
  Average battery: 94.7%

Traffic Statistics:
  Total sent: 289
  Total received: 266
  Total dropped: 23
  Network PDR: 92.0%

89.5 Framework Summary

This production framework provides comprehensive multi-hop ad-hoc network management:

Topology Management:

  • Dynamic neighbor discovery
  • Link tracking and maintenance
  • Topology event monitoring
  • Network diameter and connectivity metrics

Link Quality Assessment:

  • PDR, latency, jitter, RSSI tracking
  • Quality classification (Excellent/Good/Fair/Poor)
  • Stability scoring and prediction
  • Windowed metric estimation

Multi-Path Routing:

  • K-shortest paths algorithm (Yen’s variant)
  • Multiple routing metrics (hop count, latency, reliability, energy, composite)
  • Path disjointness for redundancy
  • Route cost calculation

Routing Strategies:

  • Shortest path (minimum hops)
  • Load balanced (distribute traffic)
  • Energy-aware (extend lifetime)
  • QoS-aware (maximize delivery ratio)

Network Monitoring:

  • Per-node statistics (forwarding, battery, energy)
  • Network-wide metrics (latency, connectivity, diameter)
  • Bottleneck detection
  • Failing link identification

The framework enables production-ready multi-hop ad-hoc networks with advanced routing, quality monitoring, and performance optimization.

Scenario: Factory deployment shows 25% packet loss on “GOOD” classified links. Calculate adjusted RSSI/PDR thresholds.

Given:

  • Current thresholds: GOOD = 70-90% PDR, -70 to -80 dBm RSSI
  • Observed: Links at -78 dBm showing 65% PDR (below 70% threshold)
  • Factory has metal structures causing multipath fading

Steps:

  1. Measure RSSI-PDR correlation:
    • Collect 1000 samples across factory
    • Find 70% PDR occurs at -72 dBm (not -70 dBm standard)
  2. Adjust thresholds for environment:
    • EXCELLENT: >90% PDR, >-65 dBm (was -70)
    • GOOD: 70-90% PDR, -65 to -75 dBm (was -70 to -80)
    • FAIR: 50-70% PDR, -75 to -85 dBm (was -80 to -90)

Result: Re-classification reduces packet loss from 25% to 8% by avoiding marginally-viable links.

Key Insight: Default thresholds assume free-space propagation. Industrial environments need 5-10 dB margin for metal/multipath effects.

Application Priority Strategy Trade-off
Minimum latency Shortest path Uneven battery drain
Maximum lifetime Energy-aware +30% latency
Highest reliability QoS-aware Higher overhead
Even node wear Load balanced +20% latency

Example: Medical alert system → QoS-aware (reliability over efficiency) Example: Environmental monitoring → Energy-aware (2-year battery requirement)

Common Mistake: Static Link Quality Thresholds

The Mistake: Using fixed RSSI/PDR thresholds across all environments, leading to misclassification in industrial/urban settings.

Impact: Links classified “GOOD” actually have 50-60% PDR due to interference, causing retransmissions and application timeouts.

Solution: Calibrate thresholds during site survey. Measure actual RSSI-PDR correlation in deployment environment. Adjust thresholds ±5-10 dB based on measurements.

Validation: Deploy 5-10 nodes, collect 500+ samples, recalculate thresholds before full deployment.

Common Pitfalls

Simulation defaults for routing protocols (update intervals, cache timeouts, zone radii) are tuned for generic scenarios, not production deployments. Production networks require parameter tuning based on actual node density, mobility patterns, and traffic loads. Document parameter choices and their rationale.

Traditional PKI requires a trusted central authority. In ad hoc networks, no always-available authority exists. Production deployments need distributed trust establishment (web of trust, threshold cryptography, or pre-distributed certificates) to authenticate nodes without central infrastructure.

Ad hoc networks are vulnerable to routing disruption by malicious nodes advertising false routes or consuming all bandwidth. Production deployments need intrusion detection and rate limiting for routing control traffic. Resource exhaustion from a compromised node can collapse the entire network’s routing.

Lab experiments with 10-20 nodes do not reveal scalability problems that emerge at 100+ nodes. Routing overhead, convergence time, and routing table size scale non-linearly. Always prototype with target scale or use analytical models to predict production performance before full deployment.

89.6 Summary

This chapter provided a production-ready framework for managing multi-hop ad-hoc networks in IoT deployments.

Key Takeaways:

  1. Modular Architecture: The four-layer design (topology, quality, routing, monitoring) enables independent component development and testing

  2. Link Quality Classification: PDR, RSSI, and latency thresholds classify links as Excellent (>90% PDR), Good (70-90%), Fair (50-70%), or Poor (<50%)

RSSI (Received Signal Strength Indicator) uses dBm where more negative = weaker. Path loss follows \(RSSI = P_{tx} - 10n\log_{10}(d) + X\) where \(n \approx 2-4\) (environment factor), \(d\) is distance. Worked example: Transmit power \(P_{tx} = 0\) dBm (1 mW), distance \(d=50m\), \(n=3\) (factory): \(RSSI = 0 - 10(3)\log_{10}(50) \approx 0 - 51 = -51\) dBm. At 100m: \(RSSI \approx -60\) dBm (9dB weaker). The EXCELLENT threshold (-70 dBm) means signals can travel \(\approx 215m\) with \(n=3\) factory propagation. GOOD threshold (-80 dBm) supports \(\approx 460m\).

  1. Multi-Path Redundancy: K-shortest paths with disjoint routes provide failover capability and load distribution options

  2. Routing Strategy Selection: Choose based on application needs:

    • Shortest path for low latency
    • Load balanced for even wear
    • Energy-aware for network longevity
    • QoS-aware for delivery reliability
  3. Continuous Monitoring: Real-time bottleneck detection and health monitoring prevent unexpected failures

Production ad-hoc network framework architecture showing four layered processing stages connected by vertical arrows: Topology Discovery Layer (Neighbor Discovery discovers links, Link Tracking monitors connections, Topology Events records changes), Link Quality Assessment Layer (PDR Measurement, RSSI Monitoring, and Latency Tracking all feed into Quality Classification for link evaluation), Multi-Path Routing Layer (K-Shortest Paths algorithm calculates Route Metrics which feeds Routing Strategy for path selection), and Performance Monitoring Layer (Network Statistics enables both Bottleneck Detection and Health Monitoring), with feedback arrow from Performance Monitoring back to Topology Discovery for continuous network optimization
Figure 89.1: Production framework architecture with four layers: Topology Discovery (neighbor discovery, link tracking, topology events), Link Quality Assessment (PDR/RSSI/latency measurements feeding quality classification), Multi-Path Routing (K-shortest paths algorithm with route metrics driving routing strategy), and Performance Monitoring (network statistics enabling bottleneck detection and health monitoring with feedback to discovery layer)
Test Your Understanding

Question 1: A 20-node ad-hoc network has three paths from source to gateway. Path A has 3 hops with nodes at 40% battery, Path B has 4 hops with nodes at 80% battery, and Path C has 5 hops with nodes at 95% battery. Which routing strategy would maximize network lifetime?

  1. Shortest-path routing via Path A (fewest hops)
  2. Load-balanced routing distributing traffic equally across all three paths
  3. Energy-aware routing that favors paths with higher battery nodes
  4. QoS-aware routing that selects the path with lowest latency

c) Energy-aware routing directs more traffic to paths with abundant battery reserves (Paths B and C), preventing the low-battery nodes on Path A from depleting prematurely. Shortest-path routing would drain Path A’s 40% battery nodes first, causing network partition while other nodes retain 80-95% capacity.

Question 2: In the link quality classification system, a link with 85% PDR, -73 dBm RSSI, and 30ms latency would be classified as:

  1. EXCELLENT (>90% PDR, >-70 dBm)
  2. GOOD (70-90% PDR, -70 to -80 dBm)
  3. FAIR (50-70% PDR, -80 to -90 dBm)
  4. POOR (<50% PDR, <-90 dBm)

b) GOOD – The PDR of 85% falls in the 70-90% range, the RSSI of -73 dBm is between -70 and -80 dBm, and the 30ms latency is within the 20-50ms band. All three metrics consistently place this link in the GOOD tier.

Question 3: Why does the production framework use K-shortest paths with disjoint routes rather than simply finding the single best path?

  1. K-shortest paths are computationally simpler to calculate
  2. Disjoint paths ensure that a single link failure does not disable all backup routes simultaneously
  3. Multiple paths always have lower total latency than a single path
  4. K-shortest paths eliminate the need for link quality monitoring

b) Disjoint paths ensure failover resilience. If backup paths share links with the primary path, a single link failure could disable both primary and backup simultaneously. Node-disjoint or link-disjoint paths guarantee independent failure domains, enabling true redundancy.

89.7 Knowledge Check

89.8 What’s Next

If you want to… Read this
Review all ad hoc concepts Ad Hoc Networks Review
Study ad hoc labs and quiz Ad Hoc Networks: Labs and Quiz
Learn about production assessment Ad Hoc Production Assessment
Explore DTN for challenging environments DTN Store-Carry-Forward
Apply concepts to UAV networks UAV Network Fundamentals