53  Protocol Overhead and Encapsulation

53.1 Learning Objectives

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

  • Compare protocol overhead: Evaluate header sizes across different IoT protocols
  • Understand encapsulation: Explain the “Russian doll” model of protocol layering
  • Calculate efficiency: Determine bandwidth costs for different protocol stacks
  • Choose protocols: Select appropriate protocols based on overhead constraints

Prerequisites (Read These First): - Packet Anatomy - Headers, payloads, and trailers fundamentals - Frame Delimiters and Boundaries - Framing and MTU concepts - Error Detection - Checksums and CRC

Companion Chapters (Packet Structure Series): - Packet Structure Overview - Index of all packet structure topics

Networking Foundations: - Layered Models - OSI and TCP/IP encapsulation - Transport Protocols - TCP/UDP packet headers

Protocol-Specific Details: - MQTT - MQTT fixed/variable headers - CoAP - CoAP 4-byte header - LoRaWAN - LoRa MAC header - 6LoWPAN - IPv6 header compression

Design & Analysis: - Network Traffic Analysis - Wireshark packet inspection


53.2 Protocol Header Comparison

Time: ~12 min | Difficulty: Advanced | Unit: P02.C02.U04

Different IoT protocols have vastly different header sizes and overhead. Understanding this helps you choose the right protocol for bandwidth-constrained applications.

53.2.1 Real Protocol Headers Compared

Here’s how common IoT protocols stack up when sending a 10-byte sensor payload:

Protocol Header Size Trailer/FCS Total Overhead Total Packet Overhead %
LoRaWAN 13 bytes 4 bytes (MIC) 17 bytes 27 bytes 63%
CoAP/UDP/IPv6 4+8+40 bytes - 52 bytes 62 bytes 84%
MQTT/TCP/IPv6 2+20+40 bytes - 62 bytes 72 bytes 86%
BLE 10 bytes 3 bytes (CRC) 13 bytes 23 bytes 57%
Zigbee (802.15.4) 25 bytes 2 bytes (FCS) 27 bytes 37 bytes 73%
TCP/IPv4 20+20 bytes - 40 bytes 50 bytes 80%
UDP/IPv4 8+20 bytes - 28 bytes 38 bytes 74%

Key Insights:

  • MQTT over TCP/IPv6: 86% overhead for a 10-byte payload! (72 bytes total)
  • LoRaWAN: 63% overhead but optimized for long-range, low-power
  • BLE: Best overhead ratio (57%) for short-range applications
  • CoAP/UDP: Better than MQTT but still 84% overhead

53.2.2 Real-World Impact

For 1000 sensors sending 10 bytes every hour for a year:

Protocol Annual Data Volume @ $0.10/MB Backhaul Cost
Raw Data 88 MB $8.80
BLE 201 MB $20.10
LoRaWAN 237 MB $23.70
UDP/IPv4 333 MB $33.30
TCP/IPv4 438 MB $43.80
MQTT/TCP/IPv6 631 MB $63.10

Five vertical flowcharts comparing protocol overhead for 10-byte sensor payload. BLE (23 bytes total): Header 10 bytes (navy) to Payload 10 bytes 43% efficiency (teal) to CRC 3 bytes (orange), best for short-range low overhead. LoRaWAN (27 bytes): Header 13 bytes (navy) to Payload 10 bytes 37% efficiency (teal) to MIC 4 bytes (orange), best for long-range low power. UDP/IPv4 (38 bytes): IPv4 Header 20 bytes (navy) to UDP Header 8 bytes (navy) to Payload 10 bytes 26% efficiency (teal), best for real-time unreliable OK. TCP/IPv4 (50 bytes): IPv4 Header 20 bytes (navy) to TCP Header 20 bytes (navy) to Payload 10 bytes 20% efficiency (teal), best for reliability important. MQTT/TCP/IPv6 (72 bytes): IPv6 Header 40 bytes (navy) to TCP Header 20 bytes (navy) to MQTT Header 2 bytes (navy) to Payload 10 bytes 14% efficiency (teal), best for pub/sub internet-scale. Efficiency decreases dramatically with protocol stacking from 43% to 14%.

Five vertical flowcharts comparing protocol overhead for 10-byte sensor payload. BLE (23 bytes total): Header 10 bytes (navy) to Payload 10 bytes 43% efficiency (teal) to CRC 3 bytes (orange), best for short-range low overhead. LoRaWAN (27 bytes): Header 13 bytes (navy) to Payload 10 bytes 37% efficiency (teal) to MIC 4 bytes (orange), best for long-range low power. UDP/IPv4 (38 bytes): IPv4 Header 20 bytes (navy) to UDP Header 8 bytes (navy) to Payload 10 bytes 26% efficiency (teal), best for real-time unreliable OK. TCP/IPv4 (50 bytes): IPv4 Header 20 bytes (navy) to TCP Header 20 bytes (navy) to Payload 10 bytes 20% efficiency (teal), best for reliability important. MQTT/TCP/IPv6 (72 bytes): IPv6 Header 40 bytes (navy) to TCP Header 20 bytes (navy) to MQTT Header 2 bytes (navy) to Payload 10 bytes 14% efficiency (teal), best for pub/sub internet-scale. Efficiency decreases dramatically with protocol stacking from 43% to 14%.
Figure 53.1: Protocol header overhead comparison for a 10-byte payload. BLE has the best efficiency (43% payload), while MQTT over TCP/IPv6 has only 14% payload efficiency due to protocol stacking. LoRaWAN trades overhead for long-range capability. Choose protocols based on your bandwidth budget and range requirements.

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
graph LR
    subgraph BANDWIDTH["Annual Bandwidth Cost (10KB/day)"]
        direction TB
        B1["BLE: 23 bytes/msg<br/>201 MB/year<br/>$20"]
        B2["LoRaWAN: 27 bytes<br/>237 MB/year<br/>$24"]
        B3["UDP/IPv4: 38 bytes<br/>333 MB/year<br/>$33"]
        B4["TCP/IPv4: 50 bytes<br/>438 MB/year<br/>$44"]
        B5["MQTT/IPv6: 72 bytes<br/>631 MB/year<br/>$63"]
    end

    subgraph BATTERY["Battery Impact"]
        direction TB
        BAT1["BLE: 43% payload<br/>Most efficient<br/>5+ year battery"]
        BAT2["LoRaWAN: 37% payload<br/>Good range trade-off<br/>10+ year battery"]
        BAT3["UDP: 26% payload<br/>Moderate overhead<br/>Needs power source"]
        BAT4["TCP: 20% payload<br/>High overhead<br/>Mains powered"]
        BAT5["MQTT: 14% payload<br/>Worst efficiency<br/>Must be plugged in"]
    end

    B1 --> BAT1
    B2 --> BAT2
    B3 --> BAT3
    B4 --> BAT4
    B5 --> BAT5

    style B1 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style B2 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style B3 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
    style B4 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
    style B5 fill:#2C3E50,stroke:#E67E22,stroke-width:2px,color:#fff
    style BAT1 fill:#16A085,stroke:#2C3E50,stroke-width:1px,color:#fff
    style BAT2 fill:#16A085,stroke:#2C3E50,stroke-width:1px,color:#fff
    style BAT3 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
    style BAT4 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
    style BAT5 fill:#2C3E50,stroke:#E67E22,stroke-width:1px,color:#fff

Figure 53.2: Alternative view: Real-World Cost Impact - Instead of abstract byte counts, this diagram shows what protocol overhead means for your budget and deployment. Sending the same 10KB of sensor data daily costs $20/year with BLE but $63/year with MQTT over IPv6. Battery impact compounds the difference: BLE enables 5+ year battery life while MQTT practically requires mains power. Green protocols (BLE, LoRaWAN) are battery-friendly; orange protocols (UDP, TCP) need careful power planning; navy (MQTT/IPv6) requires constant power. Choose based on deployment constraints, not just features. {fig-alt=“Two-column comparison diagram showing bandwidth costs and battery impact for five protocols. Bandwidth Cost column: BLE 23 bytes per message at 201 MB per year costs $20 (teal), LoRaWAN 27 bytes at 237 MB costs $24 (teal), UDP/IPv4 38 bytes at 333 MB costs $33 (orange), TCP/IPv4 50 bytes at 438 MB costs $44 (orange), MQTT/IPv6 72 bytes at 631 MB costs $63 (navy). Battery Impact column: BLE 43% payload efficiency enables 5+ year battery (teal), LoRaWAN 37% efficiency offers good range trade-off with 10+ year battery (teal), UDP 26% efficiency needs power source (orange), TCP 20% efficiency requires mains power (orange), MQTT 14% efficiency worst case must be plugged in (navy). Arrows connect each protocol’s bandwidth to its battery impact.”}

53.3 Protocol Encapsulation: The Russian Doll Model

Time: ~10 min | Difficulty: Intermediate | Unit: P02.C02.U05

Each protocol layer wraps the data from the layer above, like Russian nesting dolls. Understanding this is key to:

  • Reading packet captures in Wireshark - see how protocols nest inside each other
  • Calculating MTU and overhead - know why large payloads get fragmented
  • Debugging network issues - identify which layer is causing problems
  • Designing efficient IoT protocols - minimize unnecessary wrapping

53.3.1 How Encapsulation Works

When you send data through a network, each layer adds its own header (and sometimes trailer) around the data from the layer above:

  1. Application Layer creates data (e.g., MQTT Publish message)
  2. Transport Layer wraps it with TCP/UDP header
  3. Network Layer wraps that with IP header
  4. Data Link Layer wraps everything with Ethernet header and trailer

Flowchart showing protocol encapsulation across four network layers. Application Layer (green): 100 bytes application data/MQTT Publish (teal). Transport Layer (blue): TCP Header 20 bytes (navy) wraps application data, total 120 bytes. Network Layer (yellow): IP Header 20 bytes (navy) wraps TCP segment, total 140 bytes. Data Link Layer (pink): Ethernet Header 14 bytes (navy) wraps IP packet, plus FCS 4 bytes (orange) trailer, total 158 bytes on wire. Arrows show nesting from inner to outer layers.

Flowchart showing protocol encapsulation across four network layers. Application Layer (green): 100 bytes application data/MQTT Publish (teal). Transport Layer (blue): TCP Header 20 bytes (navy) wraps application data, total 120 bytes. Network Layer (yellow): IP Header 20 bytes (navy) wraps TCP segment, total 140 bytes. Data Link Layer (pink): Ethernet Header 14 bytes (navy) wraps IP packet, plus FCS 4 bytes (orange) trailer, total 158 bytes on wire. Arrows show nesting from inner to outer layers.
Figure 53.3: Protocol encapsulation showing layered wrapping like Russian dolls. Application data (100 bytes) gets wrapped by TCP header (20 bytes), then IP header (20 bytes), then Ethernet header/trailer (18 bytes). Final packet is 158 bytes on wire - 58% overhead! Each layer adds routing, control, or error detection information.

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
graph LR
    subgraph SENSOR["Temperature Sensor"]
        S1["Read: 23.5C"]
        S2["MQTT Publish<br/>topic/temp"]
    end

    subgraph Wi-Fi["Wi-Fi Chip"]
        W1["Add TCP header<br/>Port 1883"]
        W2["Add IP header<br/>192.168.1.10"]
        W3["Add 802.11 frame<br/>MAC address"]
    end

    subgraph ROUTER["Home Router"]
        R1["Strip 802.11"]
        R2["Add Ethernet"]
        R3["Forward to ISP"]
    end

    subgraph CLOUD["Cloud Broker"]
        C1["Strip headers"]
        C2["Extract MQTT"]
        C3["Store: 23.5C"]
    end

    S1 --> S2
    S2 -->|"2 bytes"| W1
    W1 -->|"+20 bytes"| W2
    W2 -->|"+20 bytes"| W3
    W3 -->|"+34 bytes"| R1
    R1 --> R2 --> R3
    R3 --> C1 --> C2 --> C3

    style S1 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style S2 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style W1 fill:#2C3E50,stroke:#16A085,stroke-width:1px,color:#fff
    style W2 fill:#2C3E50,stroke:#16A085,stroke-width:1px,color:#fff
    style W3 fill:#2C3E50,stroke:#16A085,stroke-width:1px,color:#fff
    style R1 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
    style R2 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
    style R3 fill:#E67E22,stroke:#2C3E50,stroke-width:1px,color:#fff
    style C1 fill:#7F8C8D,stroke:#2C3E50,stroke-width:1px,color:#fff
    style C2 fill:#7F8C8D,stroke:#2C3E50,stroke-width:1px,color:#fff
    style C3 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff

Figure 53.4: Alternative view: Sensor Data Journey - Instead of abstract layers, this diagram traces a real temperature reading from sensor to cloud. The 2-byte temperature value (23.5C) gains 20 bytes at TCP, 20 more at IP, and 34 more for Wi-Fi framing. At the router, the Wi-Fi frame is stripped and replaced with Ethernet. At the cloud broker, all headers are stripped to recover the original 2-byte reading. This journey view helps students understand why overhead matters and where bytes get added/removed. {fig-alt=“Horizontal flow diagram showing sensor data journey through network. Temperature Sensor section (teal): Read 23.5C flows to MQTT Publish topic/temp (2 bytes). Wi-Fi Chip section (navy): Add TCP header Port 1883 (+20 bytes), Add IP header 192.168.1.10 (+20 bytes), Add 802.11 frame MAC address (+34 bytes). Home Router section (orange): Strip 802.11, Add Ethernet, Forward to ISP. Cloud Broker section (gray to teal): Strip headers, Extract MQTT, Store 23.5C. Arrows show data flow with byte counts indicating growing then shrinking packet size as headers are added then removed.”}

53.3.2 Overhead Calculation Example: Sending 1 Byte of Sensor Data

What happens when you send just 1 byte of temperature data through a standard network stack?

Layer Header/Trailer Size Running Total Purpose
Application (MQTT) ~2 bytes header 3 bytes MQTT packet type and flags
Transport (TCP) 20 bytes header 23 bytes Source/dest ports, sequence numbers, checksums
Network (IPv4) 20 bytes header 43 bytes Source/dest IP addresses, TTL, protocol
Data Link (Ethernet) 14+4 bytes header+FCS 61 bytes MAC addresses, frame type, error detection

Result: 1 byte of actual sensor data requires 61 bytes on the wire = 98% overhead!

This is why IoT protocols like CoAP/UDP and 6LoWPAN header compression matter so much for constrained networks.


53.3.3 Protocol Overhead Comparison for IoT

Different protocol stacks have dramatically different overhead. Here’s the minimum packet size for common IoT protocols:

Protocol Stack Minimum Packet Size Overhead for 1 Byte Best Use Case
Standard HTTP/TCP/IP ~500+ bytes 99.8% NOT suitable for IoT
MQTT/TCP/IPv4 ~62 bytes 98% Internet-scale pub/sub
CoAP/UDP/IPv4 ~52 bytes 98% Constrained RESTful
CoAP/UDP/6LoWPAN ~16 bytes 94% IPv6 over constrained networks
MQTT-SN ~7 bytes 86% Sensor networks, UDP-based
Raw IEEE 802.15.4 ~25 bytes 96% Low-power wireless (Zigbee, Thread)
BLE ~23 bytes 96% Short-range, low-power
LoRaWAN ~21 bytes 95% Long-range, low-power (10+ km)

Key Insights:

  • Standard web protocols (HTTP/TCP/IP) waste bandwidth with massive headers
  • CoAP over UDP reduces overhead by removing TCP complexity
  • 6LoWPAN compression reduces IPv6 headers from 40 bytes to ~2 bytes
  • MQTT-SN is optimized for sensor networks (UDP instead of TCP)
  • LoRaWAN minimizes overhead while maintaining security (encryption + MIC)

Why This Matters:

  1. Bandwidth costs: Cellular IoT charges per byte - overhead directly impacts your bill
  2. Battery life: More data transmitted = more radio time = faster battery drain
  3. Airtime limits: LoRaWAN has strict duty cycle limits (1% airtime in EU) - overhead counts against your quota
  4. Network congestion: More overhead = more collisions in shared wireless channels

53.3.4 Practical Encapsulation Example: Wireshark View

When you capture packets with Wireshark, you can literally see the Russian doll unwrapping:

Frame 1: 158 bytes on wire
  Ethernet II, Src: 00:1a:2b:3c:4d:5e, Dst: 00:6f:7e:8d:9c:0b
    - Header: 14 bytes
    - Trailer (FCS): 4 bytes
  Internet Protocol Version 4, Src: 192.168.1.100, Dst: 10.0.0.50
    - Header: 20 bytes
  Transmission Control Protocol, Src Port: 1883, Dst Port: 52341
    - Header: 20 bytes
  MQTT Protocol
    - Fixed Header: 2 bytes
    - Payload: 100 bytes (TEMPERATURE=22.5C)

Reading this capture tells you:

  • Total overhead: 14 + 20 + 20 + 2 = 56 bytes (36% of total packet)
  • MQTT uses TCP port 1883 (standard MQTT port)
  • IP addresses show sensor (192.168.1.100) talking to broker (10.0.0.50)
  • MAC addresses identify physical network adapters
  • Payload is 100 bytes - the actual sensor data

Understanding encapsulation helps you:

  1. Debug connectivity issues - which layer is failing?
  2. Optimize bandwidth - is overhead too high?
  3. Verify security - is encryption applied at the right layer?
  4. Calculate MTU - will your packet fit or get fragmented?

TipConnect to Protocol-Specific Chapters

To understand how different IoT protocols handle encapsulation and overhead:

Optimized IoT Protocols: - CoAP Architecture - Lightweight RESTful protocol over UDP - MQTT Overview - Pub/Sub with TCP reliability - 6LoWPAN Fundamentals - IPv6 header compression for constrained networks

Low-Power Wireless: - LoRaWAN Overview - Long-range with minimal overhead - Bluetooth Architecture - BLE protocol stack - Zigbee Architecture - IEEE 802.15.4 frame structure

Network Analysis: - Network Traffic Analysis - Wireshark packet dissection techniques - Layered Models - OSI and TCP/IP encapsulation details - Transport Protocols - TCP vs UDP trade-offs


53.4 Knowledge Check: Protocol Overhead

Scenario: You’re deploying 500 soil moisture sensors across a vineyard using LoRaWAN. Each sensor needs to send a 4-byte payload (2 bytes moisture, 2 bytes battery voltage) every 30 minutes. The LoRaWAN protocol adds: - 13-byte header (MHDR, DevAddr, FCtrl, FCnt) - 4-byte trailer (MIC for authentication/integrity)

Your cellular data plan costs $0.10 per MB for the LoRaWAN gateway backhaul.

Think about: 1. What’s the total packet size for each transmission? (Header + Payload + Trailer) 2. What percentage of transmitted data is actual sensor data vs. protocol overhead? 3. How many bytes per sensor per day? How much does backhaul cost per year for 500 sensors?

Key Insights: - Total packet size: 13 + 4 + 4 = 21 bytes per transmission - Overhead ratio: Only 4 bytes out of 21 (19%) is actual data - 81% is protocol overhead! - Daily per sensor: 21 bytes x 48 transmissions/day = 1,008 bytes/day - Annual backhaul: 500 sensors x 1008 bytes x 365 days = 184 MB/year = $18.40/year

Real-world impact: Even with high protocol overhead, LoRaWAN can still be cost-effective for low-bandwidth IoT because messages are tiny. In practice, the bigger differentiator vs Wi-Fi is often power: higher duty cycle and active radio time can shorten battery life and increase maintenance cost.

Understanding packet structure helps you estimate bandwidth costs and choose appropriate protocols for your IoT deployment.


53.5 Scenario-Based Practice

Situation: You’re deploying soil moisture sensors using LoRaWAN Class A at SF12 (longest range, 51-byte max payload). Each sensor needs to send: - Moisture reading (1 byte, 0-100%) - Battery voltage (1 byte, 2.0-4.2V mapped to 0-255) - GPS coordinates (8 bytes: 4 for lat, 4 for lng)

The LoRaWAN stack adds: 13-byte header + 4-byte MIC (Message Integrity Code)

Question: Calculate the protocol efficiency. If you have a daily airtime budget of 30 seconds (EU duty cycle limit), how many messages can you send per day?

Question: What is the protocol efficiency (payload bytes / total bytes) for this 10-byte payload with 17 bytes of LoRaWAN overhead?

B. Total = 10 + 17 = 27 bytes, so efficiency = 10/27 approximately 37%.

Packet Size Calculation:

Component Size Purpose
LoRaWAN Header 13 bytes MHDR, DevAddr, FCtrl, FCnt, FPort
Payload (moisture) 1 byte Sensor data
Payload (battery) 1 byte Sensor data
Payload (GPS) 8 bytes Location
LoRaWAN MIC 4 bytes Authentication
Total 27 bytes

Protocol Efficiency: - Actual data: 10 bytes (moisture + battery + GPS) - Total packet: 27 bytes - Efficiency: 10/27 = 37% (63% overhead)

Airtime Calculation at SF12:

SF12 parameters (EU868): - Bit rate: 250 bits/second - Preamble: 8 symbols = 262.14 ms - Symbol time: 32.77 ms

Time on Air formula (simplified): - Payload symbols is approximately (8 x payload_bytes + 28) / 4 = (8 x 27 + 28) / 4 = 61 symbols - Payload time: 61 x 32.77 ms = 1,999 ms which is approximately 2.0 seconds - Preamble: 262 ms - Total per message: ~2.26 seconds

Messages per day with 30-second budget: - 30 seconds / 2.26 seconds = 13 messages/day maximum

Real-world impact: - 13 messages/day = 1 message every 1.85 hours - With 8-hour GPS sampling: 8 messages/day for GPS, 5 remaining for extra moisture readings - Optimization: Don’t send GPS every message! Send moisture hourly (24 msgs needed), GPS once/day

Optimization Strategy: 1. Message 1 (daily): GPS + moisture + battery = 27 bytes 2. Messages 2-13: Moisture + battery only = 19 bytes

With smaller payload (2 bytes instead of 10): - Total packet: 19 bytes - Time on air: ~1.6 seconds - Messages possible: 30 / 1.6 = 18 messages with GPS once

Key insight: Payload size directly impacts airtime and duty cycle compliance. Compress data aggressively for LPWAN.

Situation: You’re designing a protocol for a fleet of 500 delivery drones. Each drone needs to: 1. Stream 720p video (2 Mbps) to ground control for navigation 2. Send GPS position every 100ms for collision avoidance 3. Receive emergency “return to base” commands

All communication goes over 4G/LTE cellular with typical 50ms latency and 2% packet loss.

Question: For each data type (video, GPS, commands), would you use TCP or UDP? Consider the impact of packet loss and retransmission on each application.

Question: Which mapping best matches the recommended transport choice for this scenario?

B. Video/GPS are latency- and freshness-sensitive (UDP), while emergency commands prioritize delivery guarantees (TCP, or UDP with an explicit ACK).

Analysis by Data Type:

1. Video Stream: UDP

Factor Analysis
Latency tolerance Low - operator needs real-time view
Loss tolerance High - one dropped frame in 30 is imperceptible
TCP problem Head-of-line blocking: one lost packet stalls ALL subsequent frames
UDP solution Lost frame = minor glitch, next frame arrives on time

Real calculation: - 2% packet loss at 30 fps = 0.6 frames/second lost - With TCP retransmission (50ms RTT): each lost packet adds 50-100ms delay - 2% x 30 fps x 100ms = 600ms of stutter per second which is unwatchable - With UDP: 0.6 frames/second simply missing which is barely noticeable

Recommendation: UDP with application-level FEC (Forward Error Correction)

2. GPS Position: UDP

Factor Analysis
Latency tolerance Very low - collision avoidance is real-time
Loss tolerance Moderate - next position arrives in 100ms anyway
Data freshness Critical - old position is worse than no position

Real calculation: - Position every 100ms = 10 positions/second - 2% loss = 0.2 positions/second missing - Drone moving at 20 m/s: 100ms = 2m of travel - Missing one reading: interpolate from neighbors - TCP retransmission: 50ms delay = position is now 1m stale

Recommendation: UDP - Include sequence number to detect gaps - Include timestamp for staleness detection - Application interpolates missing positions

3. Emergency Commands: TCP (or UDP with ACK)

Factor Analysis
Latency tolerance Moderate - 100ms delay acceptable for emergency
Loss tolerance Zero - command MUST be received
Duplication Dangerous if command is “land now” and executed twice

Real calculation: - Emergency command is rare (once per flight if ever) - 2% packet loss means 2% chance command never arrives - TCP guarantees delivery with 50-100ms worst case latency - For emergency, 100ms delay is acceptable

Recommendation: TCP for simplicity, or UDP with application-level acknowledgment

Summary Table:

Data Type Protocol Reasoning
Video UDP + FEC Latency critical, loss tolerable
GPS UDP + Seq# Freshness critical, loss recoverable
Commands TCP Reliability critical, latency tolerable

Real-world note: Many drone systems use QUIC (UDP-based with selective retransmission) which provides the best of both worlds - reliable when needed, low-latency when possible.


53.6 Additional Knowledge Check

Knowledge Check: Packet Structure Quick Check

Concept: Understanding packet components, framing, and error detection.

A LoRaWAN packet has 13 bytes of header/overhead. If you send 20 bytes of sensor data, what percentage is overhead?

B is correct. Total packet = 13 + 20 = 33 bytes. Overhead percentage = 13/33 = 39.4%. For IoT, overhead is significant - doubling payload to 40 bytes drops overhead to 24.5%. This is why batching sensor readings is efficient.

An IoT device sends temperature readings over UDP. The reading is 23.5C but arrives as 73.5C. Where did the error most likely occur?

D is correct. UDP/IP checksums would detect bit flips (C). If headers were corrupted (A, B), the packet wouldn’t arrive at all. A change from 23.5 to 73.5 (exactly 50C difference) suggests an encoding/decoding mismatch - perhaps degrees Fahrenheit vs Celsius, or an offset error in the application layer.


53.8 Summary

Protocol overhead and encapsulation determine IoT system efficiency:

  • Protocol Stacking: Each layer adds headers, compounding overhead
  • Overhead Impact: Small payloads suffer most - 1 byte can become 61 bytes
  • Protocol Choice: BLE/LoRaWAN minimize overhead; TCP/IPv6 maximizes features
  • Encapsulation: Russian doll model wraps data at each layer
  • Cost Implications: Overhead directly impacts bandwidth costs and battery life

Key Takeaways: - Protocol overhead is significant for small IoT payloads - Choose protocols based on your bandwidth and power constraints - Wireshark reveals encapsulation layers for debugging - 6LoWPAN and header compression reduce IPv6 overhead for constrained networks


53.9 What’s Next

You’ve completed the packet structure series! Continue your learning with:

Continue to Data Formats for IoT ->