%%{init: {'theme': 'base', 'themeVariables': {'primaryColor':'#2C3E50','primaryTextColor':'#fff','primaryBorderColor':'#16A085','lineColor':'#16A085','secondaryColor':'#E67E22','tertiaryColor':'#ecf0f1','background':'#ffffff','mainBkg':'#2C3E50','secondBkg':'#16A085','tertiaryBorderColor':'#95a5a6','clusterBkg':'#ecf0f1','clusterBorder':'#95a5a6','titleColor':'#2C3E50','edgeLabelBackground':'#ffffff','nodeTextColor':'#2C3E50'}}}%%
graph TD
Start{IoT Application} --> Q1{Reliability<br/>Critical?}
Q1 -->|Yes| Q2{Real-time<br/>Required?}
Q1 -->|No| Q3{Security<br/>Needed?}
Q2 -->|Yes| SCTP[Consider SCTP<br/>or UDP+App-layer]
Q2 -->|No| Q4{Security<br/>Needed?}
Q4 -->|Yes| TLS[TCP + TLS<br/>Firmware Updates]
Q4 -->|No| TCP[Plain TCP<br/>Configuration]
Q3 -->|Yes| DTLS[UDP + DTLS<br/>CoAPS]
Q3 -->|No| UDP[Plain UDP<br/>CoAP/Telemetry]
SCTP -->|Example| E1[VoIP, Streaming]
TLS -->|Example| E2[OTA Updates]
TCP -->|Example| E3[MQTT]
DTLS -->|Example| E4[Secure Sensors]
UDP -->|Example| E5[Temp Readings]
style Q1 fill:#E67E22,stroke:#16A085,color:#fff
style Q2 fill:#E67E22,stroke:#16A085,color:#fff
style Q3 fill:#E67E22,stroke:#16A085,color:#fff
style Q4 fill:#E67E22,stroke:#16A085,color:#fff
style SCTP fill:#9b59b6,stroke:#8e44ad,color:#fff
style TLS fill:#2C3E50,stroke:#16A085,color:#fff
style TCP fill:#2C3E50,stroke:#16A085,color:#fff
style DTLS fill:#16A085,stroke:#2C3E50,color:#fff
style UDP fill:#16A085,stroke:#2C3E50,color:#fff
style E1 fill:#95a5a6,stroke:#7f8c8d,color:#fff
style E2 fill:#95a5a6,stroke:#7f8c8d,color:#fff
style E3 fill:#95a5a6,stroke:#7f8c8d,color:#fff
style E4 fill:#95a5a6,stroke:#7f8c8d,color:#fff
style E5 fill:#95a5a6,stroke:#7f8c8d,color:#fff
737 Transport Protocol Selection for IoT Scenarios
By the end of this section, you will be able to:
- Select appropriate transport protocols for different IoT scenarios
- Apply decision criteria based on reliability, latency, power, and security needs
- Analyze real-world IoT scenarios and justify protocol choices
- Calculate overhead and power consumption for protocol comparison
737.1 Prerequisites
Before diving into this chapter, you should be familiar with:
- Transport Protocol Fundamentals: Understanding TCP vs UDP characteristics and trade-offs
- DTLS Security: Understanding when security is needed and DTLS overhead
In one sentence: Protocol selection depends on your specific requirements - thereโs no universal โbestโ protocol.
Remember this: Ask three questions: (1) Can I tolerate loss? (2) Am I battery-powered? (3) Do I transmit frequently? The answers guide your choice.
Prerequisites: - Transport Protocol Fundamentals - TCP/UDP basics - DTLS Security - Securing UDP
Deep Dives: - Transport Protocols Overview - Index page - TCP Optimizations - Making TCP efficient - Decision Framework - Detailed decision matrices
737.2 Protocol Selection Decision Tree
This variant presents the transport protocol selection through a decision-tree lens - useful for engineers choosing between TCP and UDP based on specific IoT application requirements.
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#E67E22', 'secondaryColor': '#16A085', 'tertiaryColor': '#7F8C8D', 'fontSize': '11px'}}}%%
flowchart TD
START["IoT Transport<br/>Protocol Selection"]
Q1{"Data loss<br/>acceptable?"}
Q2{"Latency<br/>critical?<br/>(<50ms)"}
Q3{"Transmission<br/>frequency?"}
Q4{"Need multicast/<br/>broadcast?"}
Q5{"Reliable<br/>delivery<br/>required?"}
UDP["Use UDP<br/>--------<br/>8-byte header<br/>No connection state<br/>Best for: CoAP,<br/>real-time sensors,<br/>video streaming"]
TCP["Use TCP<br/>--------<br/>20-byte header<br/>Connection state<br/>Best for: MQTT,<br/>firmware updates,<br/>critical commands"]
COAP["Use CoAP + UDP<br/>--------<br/>Application-level<br/>reliability with<br/>CON messages"]
START --> Q1
Q1 -->|"Yes<br/>(sensors, telemetry)"| Q2
Q1 -->|"No<br/>(commands, files)"| Q5
Q2 -->|"Yes"| UDP
Q2 -->|"No"| Q3
Q3 -->|"High<br/>(>1/10s)"| UDP
Q3 -->|"Low<br/>(<1/min)"| Q4
Q4 -->|"Yes"| UDP
Q4 -->|"No"| COAP
Q5 -->|"Yes"| TCP
Q5 -->|"No"| COAP
style START fill:#2C3E50,stroke:#16A085,color:#fff
style Q1 fill:#16A085,stroke:#2C3E50,color:#fff
style Q2 fill:#16A085,stroke:#2C3E50,color:#fff
style Q3 fill:#16A085,stroke:#2C3E50,color:#fff
style Q4 fill:#16A085,stroke:#2C3E50,color:#fff
style Q5 fill:#16A085,stroke:#2C3E50,color:#fff
style UDP fill:#E67E22,stroke:#2C3E50,color:#fff
style TCP fill:#E67E22,stroke:#2C3E50,color:#fff
style COAP fill:#7F8C8D,stroke:#2C3E50,color:#fff
737.3 Selection Criteria
Use TCP when: - Reliability is critical: Firmware updates, configuration - Data must be ordered: Sequential commands, file transfers - Data loss unacceptable: Financial transactions, critical commands - Network is reliable: Wired connections, stable Wi-Fi - Power not a constraint: Mains-powered devices
Use UDP when: - Low latency required: Real-time monitoring, video streaming - Periodic data: Sensor readings every N seconds - Data loss tolerable: Occasional reading loss OK - Broadcast/multicast needed: One-to-many communication - Power constrained: Battery-powered sensors - Overhead matters: 6LoWPAN, constrained networks
Consider hybrid approach: - UDP for telemetry (sensor data) - TCP for critical ops (firmware, config) - Application-level reliability on UDP (CoAP confirmable messages)
737.4 Example Scenarios
737.4.1 Scenario 1: Temperature Sensor (Battery-Powered)
737.4.2 Scenario 2: Firmware Update (Battery or Mains)
737.4.3 Scenario 3: Video Surveillance (Mains-Powered)
737.4.4 Scenario 4: Smart Lock (Battery-Powered, Critical)
737.5 Overhead Calculation Lab
737.6 Protocol Selection Quiz
737.7 Summary
Selection Criteria: 1. Reliability: TCP if critical, UDP if tolerable loss 2. Latency: UDP for real-time, TCP if not time-sensitive 3. Power: UDP more efficient (no connection state, ACKs) 4. Security: DTLS for UDP, TLS for TCP 5. Overhead: UDP 8 bytes, TCP 20-60 bytes 6. Application: CoAP (UDP), MQTT (TCP)
The 3-Question Framework: 1. Can I tolerate loss? YES = UDP, NO = TCP or UDP+App-Layer ACK 2. Am I battery-powered? YES = prefer UDP, NO = either works 3. Do I transmit frequently? YES = UDP critical, NO = TCP acceptable
Common Patterns: - Telemetry: UDP + CoAP NON (non-confirmable) - Commands: UDP + CoAP CON or TCP - Firmware: TCP + TLS - Video: UDP + RTP
737.8 Whatโs Next?
Continue to TCP Optimizations and Implementation to learn techniques for making TCP more efficient in constrained IoT environments.