Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

IoT ecosystem, communication models and APIs

Overview of the IoT ecosystem components, common communication models (D2D, D2C, publish–subscribe, request–response) and APIs used to connect devices, gateways and cloud services.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

IoT systems combine many small devices, networks and cloud services; an engineer must choose the right communication model and API to meet latency, power, reliability and scale requirements. Correct choices here determine whether an IoT solution is efficient, secure and maintainable.

Key ideas

Start from first principles: an IoT system moves sensor data and control commands between physical things and software services. Build definitions and models from that.

  • IoT ecosystem: the set of interacting components that deliver an IoT solution. Typical components: devices, gateways, connectivity, cloud/backend, applications, data storage and analytics, and management & security services. Describe each:

    • Device — a hardware node that senses or actuates (examples: temperature sensor, smart bulb). It usually has limited CPU, memory, power and a network interface. When used in an exam diagram, draw a small box labelled Device with arrows for Sensor and Actuator.
    • Gateway — a local node that aggregates devices, performs protocol translation, local processing and security. Gateways often connect constrained devices (e.g., Zigbee) to IP networks (Wi-Fi, Ethernet). Draw between Devices and Network/cloud.
    • Connectivity — the physical and link-layer technologies (Wi-Fi, LoRaWAN, cellular) that carry packets. Label with bandwidth, range and energy trade-offs.
    • Cloud / Backend — servers that store data, run analytics, and host applications. Expose APIs for applications and devices. Draw as a large server symbol.
    • Applications — user-facing apps (mobile/web) or automated control that consume processed data.
    • Management & Security — identity, authentication, firmware updates, and monitoring services.
  • Communication models — how messages move between components. Define each and give assumptions.

    • Device-to-Device (D2D) — direct communication between devices, used when low latency or local coordination is required. Assumes devices share a local network or radio and a trust relationship (e.g., via secure pairing).
    • Device-to-Gateway (D2G) — device talks to a local gateway which forwards to cloud. Useful when devices are constrained or use non-IP protocols. Assumes gateway can translate protocols and provide buffering.
    • Device-to-Cloud (D2C) — device connects directly to cloud (e.g., over Wi‑Fi or cellular). Assumes device has enough networking stack and security keys.
    • Device-to-Backend-as-a-Service (D2BaaS) — device uses a third-party managed service API (e.g., AWS IoT Core) for telemetry and control. Assumes dependency on third-party SLA and APIs.
    • Publish–Subscribe (pub/sub) — decouples producers and consumers using topics; usually brokered (e.g., MQTT). Producers publish to topics; consumers subscribe. Assumes existence of a broker and topic namespace. Good for many-to-many, intermittent connections, and low-power devices.
    • Request–Response — client sends a request and receives a corresponding response (e.g., HTTP REST). Typically synchronous at the application level (one response per request), but can be implemented asynchronously; often higher overhead due to headers and connection setup unless using keep-alive/HTTP/2.
  • APIs used in IoT — the concrete protocols and styles engineers use.

    • REST API: Representational State Transfer over HTTP. Use for resource-oriented access (e.g., get device config); stateless, uses verbs GET/POST/PUT/DELETE and commonly JSON payloads (content negotiated via media types like application/json).
    • MQTT: a lightweight pub/sub protocol with small headers, three QoS levels (0,1,2: at most once, at least once, exactly once), and a broker. Use for low-bandwidth, high-latency-tolerant telemetry.
    • CoAP: Constrained Application Protocol for constrained devices; UDP-based, supports observe (pub/sub-like) and request/response, low overhead, maps to REST semantics.
    • WebSocket: Full-duplex over a single TCP connection; use for real-time bidirectional channels from web clients to servers.
    • gRPC / RPC: Binary, efficient remote procedure call; good for high-performance service-to-service communication but heavy for constrained devices.
    • Device SDKs and Device Shadow APIs: higher-level abstractions provided by cloud vendors to store device state and manage connectivity.
  • Security and management basics: always assume authentication (keys, certificates), authorization (ACLs), confidentiality (TLS/DTLS) and integrity; prefer mutual authentication and secure provisioning. Devices need secure boot or measured boot in higher-assurance systems.

  • Diagrams to draw in an exam: draw a layered architecture from bottom to top: Sensors/Actuators -> Edge devices/Gateways -> Network connectivity -> Cloud Backend (ingest, storage, analytics) -> Applications. Label arrows with typical protocols (Zigbee/BLE at device layer, MQTT/CoAP between edge and cloud, REST for apps).

Formulas

T_total = T_prop + T_trans + T_proc + T_queue

  • T_total: total one-way message delay (s). T_prop: propagation delay (s). T_trans: transmission time = message_size(bits)/link_bandwidth(bits/s) (s). T_proc: processing delay (s). T_queue: queueing delay (s). Applies to estimating latency.

T_trans = S / B

  • S: message size in bits. B: bandwidth in bits per second. SI units: bits, bits/s, seconds. Use when message fits into one link and no fragmentation.

Throughput_eff = (payload_size) / (payload_size + protocol_overhead)

  • Ratio (unitless) shows efficiency of payload vs protocol overhead.

Syntax to remember (short examples, one per line): GET /devices/{id}/telemetry HTTP/1.1 — REST request line. client.publish("sensors/temp", payload, qos=1) — MQTT publish (pseudo-code). coap://[::1]/sensors/temp — CoAP URI format. ws://host:port/path — WebSocket URL for handshake; use wss:// for TLS.

Worked examples

  1. Latency estimation (numerical) Given: device sends 200-byte telemetry to broker over a 250 kbps uplink. Propagation delay 10 ms, processing delay 5 ms, queueing 2 ms. Step 1: message size S = 200 bytes = 200 × 8 = 1600 bits. Step 2: bandwidth B = 250 kbps = 250000 bits/s. Step 3: T_trans = S / B = 1600 / 250000 = 0.0064 s = 6.4 ms. Step 4: T_total = T_prop + T_trans + T_proc + T_queue = 10 ms + 6.4 ms + 5 ms + 2 ms = 23.4 ms. Answer: 23.4 ms one-way.

  2. Protocol overhead comparison (numerical, approximate) Compare REST over HTTP vs MQTT for a 50-byte sensor payload. Assume HTTP request total size 800 bytes (headers + TCP) and MQTT packet total size 10 bytes overhead. Step 1: REST efficient payload fraction = 50 / (50+800) = 50/850 = 0.0588 -> 5.9%. Step 2: MQTT efficient payload fraction = 50 / (50+10) = 50/60 = 0.833 -> 83.3%. Conclusion: MQTT is much more bandwidth-efficient for small frequent telemetry. Mark this as approximate — actual HTTP header size depends on headers and keep-alive.

  3. Model-answer exam question (short essay): "Choose a communication model for a home security camera that streams video and must accept remote pan/tilt commands." Answer model: For video streaming, use Device-to-Cloud (D2C) with a high-bandwidth link (Wi‑Fi). For the media protocol, use RTSP/RTP or WebRTC; secure the stream with SRTP (with DTLS for keying) or TLS for TCP-based streaming as appropriate. For control commands, low-latency and reliability are needed — use a persistent channel (WebSocket or MQTT with QoS 1 or 2) for Device-to-Cloud and Cloud-to-Device commands. A Gateway could be optional. Include authentication (TLS), and use token-based authorization. Explain trade-offs: streaming to cloud eases remote access but increases bandwidth and latency; local processing at gateway can reduce cloud bandwidth for motion detection.

Common mistakes

  • Ignoring headers and transport overhead in bandwidth calculations (using payload size only).
  • Using MQTT QoS semantics incorrectly (treating QoS 0 as reliable).
  • Saying "HTTP is always unsuitable for IoT" — HTTP can be fine for occasional large messages or devices with enough resources.
  • Missing security: forgetting to state TLS/DTLS or authentication when describing models.

For your exam

Possible question types: definitions, short notes, compare-and-contrast, derivations (latency/throughput), design choices (justify a communication model), and API examples (show HTTP request, MQTT publish). What full-marks answers include:

  • Clear definitions of terms (ecosystem components, pub/sub, request/response).
  • A labeled diagram for architecture questions showing devices, gateway, network and cloud and indicating protocols on arrows.
  • For numerical questions: state formulas, list data with units, show stepwise substitution and final unit.
  • For design questions: state requirements (latency, energy, reliability), list options, explain trade-offs and conclude with justified choice and security measures.

Quick check

  1. What is the main difference between pub/sub and request/response models?
  2. Name two protocols designed for constrained IoT devices.
  3. Write the simple formula for transmission time for a message of S bits on a link of bandwidth B. Answers: 1) Pub/sub decouples producers and consumers in time and space via a broker and topics; request/response is a direct client-server interaction with one response per request. 2) MQTT and CoAP. 3) T_trans = S / B.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?