The Four Pillars of IoT Web Connectivity Design
The Four Pillars of IoT Web Connectivity Design
1. Minimal Packet Overhead
Headers must be short binary numbers (2 to 4 bytes) instead of long text lines.
2. Asynchronous Communication
Devices should send data and immediately continue their work without waiting synchronously for replies.
3. Deep Sleep Support
Sensors must be able to sleep for hours, wake up for 10 milliseconds to transmit, and return to sleep.
4. Tolerance to Lossy Networks
Must handle dropped packets smoothly without slow, energy-draining TCP connection handshakes.
Explanation
- Identify the resource, message format and way a device will reach the service.
- Security and reliable handling of interruptions matter alongside connectivity.
Classes of IoT Web Connectivity Protocols
Classes of IoT Web Connectivity Protocols
1. Standard Web Protocols (HTTP / REST)
Used for powered devices (Smart TVs, gateways, Raspberry Pi) that have continuous wall power and fast Wi-Fi.
2. Constrained Protocols (CoAP)
A binary web protocol designed for tiny battery microcontrollers; uses REST commands (GET/POST) over lightweight UDP.
Explanation
- Web connectivity can support direct requests, ongoing streams or brokered messages.
- Choose the exchange pattern that suits the device's power and timing limits.
MQTT Publish-Subscribe Architecture
MQTT Publish-Subscribe Architecture
Publisher (ESP32 Sensor)
Publishes to:
Publishes to:
room/temp = 28°C➔ MQTT Broker (Mosquitto / EMQX)
Routes message ➔
Routes message ➔
Subscribers
Mobile App & AC Controller
Mobile App & AC Controller
Explanation
- The sensor publishes a message to a topic managed by a broker.
- The broker delivers it to clients subscribed to that topic.
SOAP vs. REST Architectural Styles
SOAP vs. REST Architectural Styles
SOAP (Simple Object Access Protocol)
Strict, heavy XML envelopes, high RAM & CPU usage. Very poor fit for small microcontrollers.
REST (Representational State Transfer)
Flexible, lightweight JSON messages, uses standard HTTP verbs. Ideal for IoT devices and mobile apps.
Explanation
- SOAP defines a message envelope for exchanging structured data.
- REST organises interactions around resources and their representations.
WebSocket Handshake and Data Flow
WebSocket Handshake and Data Flow
1. Client sends HTTP Request with
Upgrade: websocket➔ 2. Server accepts with
101 Switching Protocols ➔3. Persistent Open Socket!
Both sides talk freely with tiny 2-byte headers!
Both sides talk freely with tiny 2-byte headers!
Explanation
- A client first requests an upgrade to a WebSocket connection.
- After setup either side can send a message without a new HTTP request.
The Three Stages of IoT Internet Connectivity
The Three Stages of IoT Internet Connectivity
1. Local Sensor Network
Wi-Fi, Zigbee, BLE, LoRaWAN
Wi-Fi, Zigbee, BLE, LoRaWAN
➔ 2. IoT Border Gateway
Translates local packets to IP & routes ➔
Translates local packets to IP & routes ➔
3. Global Internet
Public IPv4 / IPv6 Routers & Cloud
Public IPv4 / IPv6 Routers & Cloud
Explanation
- A device first joins its local link and obtains usable network settings.
- Routing then connects it to the service it needs outside that link.
Address Space Comparison: IPv4 vs. IPv6
Address Space Comparison: IPv4 vs. IPv6
IPv4 (32-Bit Address Space)
Total addresses: 2³² ≈ 4.3 Billion.
Already completely run out because of smartphones, laptops, and servers!
Already completely run out because of smartphones, laptops, and servers!
IPv6 (128-Bit Address Space)
Total addresses: 2¹²⁸ ≈ 3.4 × 10³⁸.
Practically infinite; enough to give a unique IP address to every grain of sand on Earth!
Practically infinite; enough to give a unique IP address to every grain of sand on Earth!
Explanation
- An IPv4 address has 32 bits and an IPv6 address has 128.
- The larger address space gives far more possible addresses to connected devices.
The 6LoWPAN Adaptation Layer Position
The 6LoWPAN Adaptation Layer Position
Network Layer
Standard IPv6 (1280-byte MTU)
Standard IPv6 (1280-byte MTU)
➔ 6LoWPAN Adaptation Layer
Compression, Fragmentation & Routing ➔
Compression, Fragmentation & Routing ➔
Data Link Layer
IEEE 802.15.4 MAC (127-byte Frame)
IEEE 802.15.4 MAC (127-byte Frame)
Explanation
- The adaptation layer sits between IPv6 and the low-power link.
- It helps a normal IPv6 packet fit the constraints of a small radio frame.
The Three Core Mechanisms of 6LoWPAN
The Three Core Mechanisms of 6LoWPAN
1. Header Compression
Compresses 40-byte IPv6 + 8-byte UDP headers down to just 2 to 4 bytes!
2. Fragmentation & Reassembly
Splits 1,280-byte IPv6 packets across multiple 127-byte frames and reassembles them at the receiver.
3. Mesh Routing (Layer 2.5)
Passes packets hop-by-hop between battery-operated sensor nodes to reach the gateway.
Explanation
- Header compression saves bytes and fragmentation divides packets that will not fit.
- Mesh addressing can support forwarding across low-power links.
The Two MAC Channel Access Paradigms
The Two MAC Channel Access Paradigms
1. Contention-Based (Random Access)
Devices compete for the channel using CSMA/CA (Listen before talk).
Simple and flexible, but packet collisions can happen during heavy traffic.
Simple and flexible, but packet collisions can happen during heavy traffic.
2. Scheduled-Based (Time-Slotted)
Uses TDMA (Time Division Multiple Access).
Each device gets its own fixed time slot.
Zero collisions, but devices must keep their internal clocks perfectly synced.
Each device gets its own fixed time slot.
Zero collisions, but devices must keep their internal clocks perfectly synced.
Explanation
- Scheduled access reserves transmission turns and can make sleep times predictable.
- Contention-based access lets devices compete as new readings arrive.