22  WSN Exercises and Resources

Lab execution time can be estimated before starting runs:

\[ T_{\text{total}} = N_{\text{runs}} \times (t_{\text{setup}} + t_{\text{run}} + t_{\text{review}}) \]

Worked example: With 5 runs and per-run times of 4 min setup, 6 min execution, and 3 min review, total lab time is \(5\times(4+6+3)=65\) minutes. This prevents under-scoping and helps schedule complete experimental cycles.

In 60 Seconds

WSN lab exercises focus on three practical skills: calculating battery lifetime under duty cycling (a 2xAA node at 1% duty cycle lasts ~1.5 years), designing topologies that avoid the hotspot problem (deploy multiple sinks or use LEACH clustering), and comparing routing protocol energy efficiency (hierarchical saves 40-67% over flat routing at 500+ nodes).

Prerequisites: Complete the WSN series

Part of: Wireless Sensor Networks series

22.1 Learning Objectives

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

  • Calculate WSN battery lifetime under different duty cycling strategies
  • Design network topologies for real-world WSN deployment scenarios
  • Compare routing protocols by analyzing their energy efficiency and message overhead
  • Create deployment plans with cost analysis and energy budgets for WSN projects
Key Concepts
  • Core Concept: Fundamental principle underlying WSN Exercises and Resources — understanding this enables all downstream design decisions
  • Key Metric: Primary quantitative measure for evaluating WSN Exercises and Resources performance in real deployments
  • Trade-off: Central tension in WSN Exercises and Resources design — optimizing one parameter typically degrades another
  • Protocol/Algorithm: Standard approach or algorithm most commonly used in WSN Exercises and Resources implementations
  • Deployment Consideration: Practical factor that must be addressed when deploying WSN Exercises and Resources in production
  • Common Pattern: Recurring design pattern in WSN Exercises and Resources that solves the most frequent implementation challenges
  • Performance Benchmark: Reference values for WSN Exercises and Resources performance metrics that indicate healthy vs. problematic operation

22.2 MVU: Minimum Viable Understanding

If you only have 5 minutes, understand these three things:

  1. Duty cycling extends battery life by 100-600x – without it, batteries die in days instead of years
  2. The hotspot problem kills WSN deployments – nodes near the sink relay everyone’s traffic and die first
  3. Multiple sinks distribute relay load – the simplest architectural fix for network lifetime

Everything else in this chapter builds on applying these principles to real scenarios.

Wireless sensor networks are groups of small, battery-powered devices that cooperate to monitor their surroundings. Think of them as a team of tiny reporters spread across a field, a building, or even a forest, each measuring things like temperature, vibration, or motion and relaying their observations to a central point. Understanding WSNs is fundamental to many IoT applications.

Hey there, future network engineers! Sammy the Sensor has a challenge for you!

Imagine you’re building a sensor network to protect a nature reserve. Sammy and his friends (Lila the Light sensor, Max the Motion detector, and Bella the Battery monitor) need YOUR help figuring out:

  • How long will their batteries last? Bella says: “If I sleep most of the time and only wake up to check things, my battery lasts WAY longer – like years instead of days!”
  • Where should everyone stand? Max says: “If we all crowd near the ranger station, the sensors in the middle get tired carrying everyone’s messages!”
  • How should messages travel? Lila says: “Should everyone shout to the ranger station, or whisper to their neighbors who pass it along?”

Fun Challenge: Try Exercise 1 below and see if you can figure out how long a battery lasts. It is just division – battery size divided by how much power is used!

Scenario: Calculate network lifetime for a 50-node temperature monitoring WSN under three duty cycling strategies.

Given:

  • Battery: 2× AA (3,000 mAh at 3V)
  • Active current: 20 mA (sensing + radio)
  • Idle listening: 15 mA (radio on, not transmitting)
  • Sleep current: 1 µA (deep sleep mode)
  • Active period per cycle: 1 second (sample + transmit)

Strategy A: No Duty Cycling (Always-On Listening)

  • Radio stays in idle listening mode 24/7
  • Active 1 second every 60 seconds for transmission
  • Average current: 15 mA + (20-15) mA × (1/60) = 15.08 mA
  • Battery lifetime: 3,000 mAh / 15.08 mA = 199 hours = 8.3 days

Strategy B: Basic Duty Cycling (1% Active)

  • Active 1 second per 100 seconds, sleep otherwise
  • Average current: 0.01 × 20 mA + 0.99 × 0.001 mA = 0.20 + 0.001 = 0.201 mA
  • Battery lifetime: 3,000 mAh / 0.201 mA = 14,925 hours = 622 days (1.7 years)
  • Improvement: 622 / 8.3 = 75× longer than always-on

Strategy C: Aggressive Duty Cycling (0.1% Active)

  • Active 1 second per 1,000 seconds, sleep otherwise
  • Average current: 0.001 × 20 mA + 0.999 × 0.001 mA = 0.02 + 0.001 = 0.021 mA
  • Battery lifetime: 3,000 mAh / 0.021 mA = 142,857 hours = 5,952 days (16.3 years)
  • Improvement: 5,952 / 8.3 = 717× longer than always-on

Network-Level Analysis (First Node Death):

  • All nodes start with same battery
  • Hotspot nodes near sink relay 10× more traffic than edge nodes
  • Hotspot average current: 0.201 mA × 10 = 2.01 mA (forwarding neighbors’ data)
  • Hotspot lifetime: 3,000 / 2.01 = 1,493 hours = 62 days
  • Network fails at 62 days despite edge nodes at 90% battery

Solutions:

  1. Multiple sinks: Distribute relay load, extend to 200+ days
  2. Rotating cluster heads: Share hotspot burden, achieve near-ideal lifetime
  3. Solar-powered relays: Eliminate hotspot problem entirely
Learning Goal Exercise Type Tools Needed Time Required
Energy calculations Battery lifetime analysis Calculator, spreadsheet 30-60 min
Topology design Network layout planning Graph paper, NetworkX 1-2 hours
Protocol comparison Routing simulation NS-3, Cooja, or Python 2-4 hours
Deployment planning Cost and coverage analysis Spreadsheet, mapping tool 2-3 hours

Recommended exercise sequence for beginners:

  1. Exercise 1 (Energy): Build intuition about duty cycling impact
  2. Exercise 2 (Topology): Understand coverage vs. connectivity trade-offs
  3. Exercise 3 (Routing): Compare protocol energy efficiency quantitatively
  4. Exercise 4 (Deployment): Integrate all concepts into real-world plan

Tools by complexity:

  • Basic (no install): Spreadsheet, calculator, hand calculations
  • Intermediate: Python + NetworkX for graph modeling
  • Advanced: Cooja/Contiki or NS-3 for packet-level simulation

Grading rubric (educational):

  • Correct calculations (40%): Battery lifetime, sensor count, coverage percentage
  • Design justification (30%): Why this topology? Why this protocol?
  • Trade-off analysis (20%): Energy vs. latency, cost vs. reliability
  • Presentation (10%): Clear diagrams, organized report
Common Mistake: Forgetting the Hotspot Problem in Exercises

Misconception: “If I calculate average battery lifetime across all nodes, that’s the network lifetime.”

Reality: In N-to-1 convergecast topologies, the network dies when the first hotspot node fails, not when the average node fails. Edge nodes may have 95% battery remaining when the network becomes disconnected.

Exercise pitfall example:

  • Student calculates: 200 nodes × 1-year average lifetime = “Network lasts 1 year”
  • Reality: Hotspot nodes (5% of network) fail at 2 months
  • Network unusable at 2 months despite avg 90% battery

Correct approach for exercises:

  1. Identify hotspot nodes (within 2 hops of sink)
  2. Calculate relay burden (how much neighbor traffic they forward)
  3. Compute hotspot lifetime separately
  4. Network lifetime = min(hotspot lifetime), not average

Quantification:

  • Edge node (5 hops from sink): Transmits own data only
  • Hotspot node (1 hop from sink): Relays for ~50 nodes behind it
  • Hotspot transmissions: 1 (own) + 50 (relay) = 51× more traffic
  • Hotspot energy: 51× edge node consumption
  • Hotspot lifetime: edge lifetime / 51 = 1 year / 51 = 7 days

Solutions to include in exercises:

  • Deploy 3-5 sinks → distributes hotspot load
  • Rotate cluster heads → shares burden across all nodes
  • Mains-powered relays → eliminates hotspot battery constraint
  • Mobile sink → moves periodically, rotating hotspot location

Grading: Deduct points if student reports “network lifetime” without analyzing hotspot problem. Real deployments fail this way constantly.

Common Pitfalls

Relying on theoretical models without profiling actual behavior leads to designs that miss performance targets by 2-10×. Always measure the dominant bottleneck in your specific deployment environment — hardware variability, interference, and load patterns routinely differ from textbook assumptions.

Optimizing one parameter in isolation (latency, throughput, energy) without considering impact on others creates systems that excel on benchmarks but fail in production. Document the top three trade-offs before finalizing any design decision and verify with realistic workloads.

Most field failures come from edge cases that work in the lab: intermittent connectivity, partial node failure, clock drift, and buffer overflow under peak load. Explicitly design and test failure handling before deployment — retrofitting error recovery after deployment costs 5-10× more than building it in.

22.3 Summary

This chapter provided hands-on exercises and worked examples for WSN analysis and design:

  • Battery Lifetime Calculation: Duty cycling transforms node lifetime from days (15 mA idle listening) to years (0.2 mA at 1% duty cycle), a 75-717× improvement depending on aggressiveness
  • Hotspot Problem: In N-to-1 convergecast networks, nodes near the sink relay all neighbors’ traffic and deplete 10-100× faster than edge nodes; network lifetime equals the first hotspot node death, not the average
  • Topology Design Trade-offs: Star topology is simple and low-energy but limited by gateway range; mesh provides redundancy but introduces routing overhead and relay energy costs; cluster-tree balances both
  • Routing Protocol Comparison: Hierarchical protocols (LEACH) save 40-67% energy over flat flooding at 500+ nodes by limiting long-distance transmissions
  • Deployment Planning: Practical sizing follows: sensor count = area ÷ (spacing²); gateways = sensor count ÷ 50-100; total cost must include hardware, installation labor, connectivity, and maintenance (typically 40-60% above hardware alone)
  • Data Aggregation Bugs: A common implementation error is double-counting the cluster head’s reading, inflating reported averages by approximately 10% in 10-node clusters

Apply these skills in the practice exercises above to build confidence before tackling real WSN deployment projects.

WSN Deep Dives:

Wireless Technologies:

Architecture Context:

IoT Products:

Learning Hubs:

22.4 Interactive Quiz: Test Your Understanding

Test your knowledge of wireless sensor networks with this interactive auto-grading quiz.


22.5 Practice Exercises

Test your understanding of Wireless Sensor Networks with these hands-on exercises.

Objective: Calculate and compare network lifetime under different duty cycling strategies.

Scenario: You’re deploying a 50-node agricultural WSN. Each node has a 2000 mAh battery and consumes: - Active (sensing + transmitting): 20 mA for 1 second - Idle listening: 15 mA - Sleep mode: 0.01 mA

Tasks:

  1. Calculate battery lifetime for a node that transmits every 60 seconds without duty cycling (radio stays in idle listening mode)
  2. Calculate lifetime with 1% duty cycle (active 1 second per 100 seconds, sleep otherwise)
  3. Determine how long the network maintains 100% coverage (First Node Death metric)
  4. Calculate lifetime extension if hotspot nodes near the sink are replaced with solar-powered nodes

Expected Outcome:

  • Understand the dramatic impact of duty cycling on battery life (days vs years)
  • Recognize the hotspot problem and its effect on network lifetime
  • Be able to perform basic WSN energy calculations

Solution Hints:

  • Without duty cycling: Average current = 15 mA (idle) + (20 mA × 1s / 60s) ≈ 15.3 mA
  • With duty cycling: Average current = (20 mA × 1s / 100s) + (0.01 mA × 99s / 100s) ≈ 0.21 mA
  • Lifetime = Battery capacity / Average current
  • Hotspot nodes relay traffic, consuming ~5-10× more energy than edge nodes
Quick Check: Battery Lifetime Fundamentals

A sensor node uses 15 mA in idle listening mode continuously (no sleep). With a 2000 mAh battery, approximately how long will it last?

  1. About 5 days
  2. About 55 days
  3. About 1 year
  4. About 5 years

a) About 5 days. Battery life = 2000 mAh / 15 mA = 133 hours = approximately 5.5 days. This demonstrates why idle listening (radio always on) is devastating to battery life – duty cycling is essential to achieve multi-year operation.

Objective: Design and simulate different WSN topologies for a real-world scenario.

Scenario: Smart building with 100 temperature/humidity sensors across 3 floors (200m × 50m per floor). Sensors have 50m communication range, 10m sensing range. Gateway located on ground floor center.

Tasks:

  1. Calculate minimum number of sensors needed for full coverage (every point within 10m of a sensor)
  2. Design three topologies: (a) Star with multiple gateways, (b) Mesh network, (c) Cluster-tree
  3. For each topology, calculate: average hop count to gateway, number of relay nodes, maximum node degree
  4. Use a network simulator (e.g., Cooja, ns-3, or simple Python script) to model packet delivery under 10% link failure rate
  5. Compare energy consumption: count total transmissions per data collection round

Expected Outcome:

  • Understand trade-offs between topologies (complexity vs. reliability vs. energy)
  • Gain hands-on experience with network simulation tools
  • Learn to calculate coverage and connectivity metrics

Tools: Python + NetworkX library for graph modeling, or Cooja/Contiki for WSN simulation

Solution Approach:

  • Coverage: Area / (π × Rs²) with overlap factor ≈ 1.2-1.5
  • Star: Simple but limited by gateway range, needs multiple gateways
  • Mesh: Most reliable but highest energy cost due to route discovery
  • Cluster-tree: Good balance, 20-30 nodes per cluster recommended

Objective: Compare energy efficiency of different routing protocols through analysis and simulation.

Scenario: 100-node WSN with single sink. Compare flooding, geographic routing, and LEACH clustering.

Tasks:

  1. Analyze message overhead for each protocol when 10 nodes simultaneously send data to sink
  2. Calculate energy consumption: assume 1 unit energy per transmission, 0.5 units per reception
  3. Identify bottleneck nodes (hotspots) in each protocol
  4. Simulate 100 rounds of data collection and plot: (a) Total network energy, (b) First node death time, (c) Average latency
  5. Propose a hybrid protocol combining best features of each

Expected Outcome:

  • Understand routing protocol behavior in multi-hop networks
  • Learn to identify and analyze hotspot problems
  • Develop protocol comparison and optimization skills

Implementation:

# Pseudocode for routing comparison
def flooding(nodes, source, sink):
    messages = 0
    for node in nodes:
        if node.has_data:
            messages += broadcast_to_neighbors(node)
    return messages

def geographic_routing(nodes, source, sink):
    current = source
    hops = 0
    while current != sink:
        next_node = get_closest_to_sink(current.neighbors, sink)
        transmit(current, next_node)
        current = next_node
        hops += 1
    return hops

# Compare total transmissions and energy

Objective: Design a complete WSN deployment with cost analysis and energy planning.

Scenario: Precision agriculture for 100-hectare vineyard. Monitor soil moisture, temperature, and humidity. Data collection every 10 minutes. 3-year battery lifetime required.

Tasks:

  1. Calculate sensor density: nodes per hectare based on 50m sensing range
  2. Select hardware: Arduino + LoRa ($35/node) or ESP32 + Wi-Fi ($25/node + gateway costs)
  3. Design network topology and calculate infrastructure needs (gateways, routers)
  4. Create energy budget: calculate required battery capacity for 3-year lifetime with 1% duty cycle
  5. Calculate total deployment cost: sensors, gateways, installation, connectivity (cellular/Wi-Fi), maintenance
  6. Create deployment map showing node placement, cluster heads, and gateway positions

Expected Outcome:

  • Learn to translate requirements into WSN design specifications
  • Understand cost-performance trade-offs in real deployments
  • Gain experience with hardware selection and energy planning

Deliverable: 1-page deployment plan with: - Network diagram - Bill of materials (BOM) with costs - Energy budget spreadsheet - Installation timeline


22.6 Academic Resource: Smart Grid Power Distribution WSN

Smart grid power distribution wireless sensor network showing a central power generation facility (factory with smokestacks) connected via high-voltage transmission lines to multiple electrical substations (transmission towers), which then distribute power to residential homes (yellow houses) across the service area - wireless sensor links (white lines) form a mesh network connecting all elements for real-time monitoring of power flow, fault detection, and demand response - illustrating how WSN enables the smart grid vision of bidirectional power and information flow

Smart grid power distribution network showing sensor nodes at substations and homes connected via mesh wireless links

Source: NPTEL Internet of Things Course, IIT Kharagpur

This diagram demonstrates a real-world WSN deployment for smart grid power distribution:

  • Generation Layer: Power plant with environmental monitoring sensors
  • Transmission Layer: High-voltage substations with fault detection sensors
  • Distribution Layer: Residential endpoints with smart meters and demand sensors
  • Communication Mesh: Wireless links providing redundant paths for reliable data delivery

Key WSN Design Considerations Illustrated:

Layer Sensors Communication Data Rate
Generation Temperature, emissions, output Wired/Fiber High (1 kbps+)
Transmission Current, voltage, faults LoRa/Cellular Medium (100 bps)
Distribution Smart meters, demand Zigbee/Wi-SUN Low (10 bps)

22.7 Test Your Understanding

Test Your Understanding

Question 1: A WSN node has a 3000 mAh battery and consumes 0.3 mA on average with duty cycling enabled. What is the approximate battery lifetime?

  1. 10 days
  2. 100 days
  3. 416 days (about 14 months)
  4. 1000 days

c) 416 days (about 14 months). Battery life = 3000 mAh / 0.3 mA = 10,000 hours = 416 days. This demonstrates how effective duty cycling is at extending battery life from days to over a year.

Question 2: In a 100-node WSN with a single sink, nodes near the sink die 10x faster than edge nodes. What is the most effective architectural solution?

  1. Use larger batteries for nodes near the sink
  2. Increase transmission power so edge nodes can reach the sink directly
  3. Deploy multiple sinks to distribute the relay traffic load
  4. Reduce the sensing frequency of all nodes equally

c) Deploy multiple sinks to distribute the relay traffic load. The hotspot problem is caused by many-to-one traffic patterns where inner nodes relay traffic for all outer nodes. Adding sinks distributes this burden. Larger batteries only delay the problem, higher power increases all energy consumption, and reduced sensing does not fix the load imbalance.

Question 3: Which routing protocol comparison approach gives the most realistic energy efficiency results?

  1. Counting only transmission energy per packet
  2. Measuring total network energy over multiple data collection rounds
  3. Comparing theoretical throughput from protocol specifications
  4. Testing with a single source-destination pair

b) Measuring total network energy over multiple data collection rounds. Real WSN energy consumption includes routing overhead, relay traffic, idle listening, and retransmissions – not just per-packet transmission cost. Multiple rounds reveal hotspot problems and cumulative effects that single-round tests miss.

22.8 Knowledge Check

22.9 What’s Next?

Topic Chapter Description
WSN Tracking WSN Tracking Fundamentals Object and target tracking in wireless sensor networks
WSN Coverage WSN Coverage Coverage algorithms and deployment strategies
WSN Review WSN Overview Review Comprehensive reference and assessment