CoAP - Constrained Application Protocol =========================================== .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is CoAP?** CoAP stands for Constrained Application Protocol. It is a lightweight protocol designed for resource-constrained devices and low-power networks, typically used in IoT (Internet of Things) environments. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is CoAP useful?** * Lightweight – Minimal overhead, ideal for devices with limited CPU, memory, and power. * Low Bandwidth Friendly – Works well over lossy networks like 6LoWPAN or UDP. * Supports Security – Can use DTLS (Datagram Transport Layer Security) for secure communication. * Asynchronous Communication – Supports both request/response and publish/subscribe models. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** * **Client Sends Request** – A CoAP client sends a request (e.g., GET) to a server. * **Server Processes Request** – The server processes the request and prepares a response. * **Server Sends Response** – The response is sent back to the client (e.g., sensor data). * **Optional Acknowledgment** – If using confirmable messages, the client sends an ACK. * **Observe Option (Optional)** – Clients can "observe" resources and get updates when they change. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is CoAP used?** * Smart Homes – Thermostats, lights, door locks, and sensors. * Industrial IoT – Monitoring machinery, temperature, and pressure sensors. * Smart Cities – Street lighting, traffic monitoring, waste management. * Agriculture – Soil moisture sensors, irrigation systems. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI Layer does this protocol belong to?** * **Application Layer (Layer 7)** * CoAP operates at the Application Layer because it defines how applications on devices communicate. * It handles methods like `GET`, `POST`, `PUT`, `DELETE`, resource URIs, content types, and negotiation. * Although it uses UDP for transport (Layer 4), the protocol logic and semantics are defined at Layer 7. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the key features?** * Lightweight and low overhead. * Built-in retransmission and timeout handling. * Supports Confirmable (CON) and Non-confirmable (NON) messages. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What transport protocol does CoAP use?** CoAP uses **UDP (User Datagram Protocol)** by default, which makes it fast and suitable for low-power and lossy networks. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What kind of devices typically use CoAP?** * Smart thermostats * Light bulbs * Environmental sensors * Low-power embedded systems .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is CoAP suitable for real-time systems?** Yes, CoAP is designed for timely, low-latency communication in constrained networks, though it is not strictly real-time guaranteed. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are some applications that use CoAP?** * Smart Home Automation * Environmental Monitoring * Industrial IoT (IIoT) * Smart Cities .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the working flow of CoAP?** * **Device Sends a CoAP Request** - A client (e.g., smart sensor or app) accesses a resource using one of the following methods: - `GET` – Retrieve data - `POST` – Send data - `PUT` – Update a resource - `DELETE` – Remove a resource * **Message Type is Chosen** – Confirmable or Non-confirmable * **Message is Sent via UDP** – Lightweight, fast communication * **Server Receives and Processes the Request** – Responds appropriately * **Server Sends Back a Response** – Includes ACK if necessary * **Client Processes the Response** – Reads the response; ACK confirms delivery .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Can CoAP work over IPv6?** Yes, CoAP is designed to work efficiently over **IPv6** and **6LoWPAN**, making it ideal for low-power wireless mesh networks. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`CoAP Version&RFC Details ` * :ref:`CoAP Basic Setup on Ubuntu using IPv4 ` * :ref:`CoAP Basic Setup on Ubuntu using IPv6 ` * :ref:`CoAP Protocol Packet Details ` * :ref:`CoAP Usecases ` * :ref:`CoAP Basic Features ` * :ref:`CoAP Feature : Lightweight Protocol ` * :ref:`CoAP Feature : RESTful Architecture ` * :ref:`CoAP Feature : UDP Based Communication ` * :ref:`CoAP Feature : Asynchronous Messaging ` * :ref:`CoAP Feature : Bulit In Reliability ` * :ref:`CoAP Feature : Low Header Overhead ` * :ref:`CoAP Feature : Resource Discovery ` * :ref:`CoAP Feature : Multicast Support ` * :ref:`CoAP Feature : Observe Option ` * :ref:`CoAP Feature : Security Support ` * :ref:`Reference links ` .. _CoAP_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _CoAP_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _CoAP_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _CoAP_step5: .. tab-set:: .. tab-item:: CoAP Version&RFC Details .. csv-table:: :file: ./CoAP/CoAP_RFC.csv :widths: 10,10,10,30 :header-rows: 1 .. _CoAP_step20: .. tab-set:: .. tab-item:: CoAP Basic Setup on Ubuntu using IPv4 * setup .. _CoAP_step21: .. tab-set:: .. tab-item:: CoAP Basic Setup on Ubuntu using IPv6 * setup .. _CoAP_step6: .. tab-set:: .. tab-item:: CoAP Protocol Packet Details **CoAP CONFIRMABLE(CON) Packet** .. csv-table:: :file: ./CoAP/CoAP_Confirmable_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **CoAP NON-CONFIRMABLE(NON) Packet** .. csv-table:: :file: ./CoAP/CoAP_Non_Confirmable_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **CoAP ACKNOWLEDGMENT(ACK) Packet** .. csv-table:: :file: ./CoAP/CoAP_ACK_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **CoAP RESET(RST) Packet** .. csv-table:: :file: ./CoAP/CoAP_Reset_Packet.csv :widths: 10,20,30,10 :header-rows: 1 .. _CoAP_step7: .. tab-set:: .. tab-item:: CoAP Usecases .. csv-table:: :file: ./CoAP/CoAP_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _CoAP_step8: .. tab-set:: .. tab-item:: CoAP Basic Features .. csv-table:: :file: ./CoAP/CoAP_Features.csv :widths: 10,10,30 :header-rows: 1 .. _CoAP_step9: .. tab-set:: .. tab-item:: CoAP Feature : Lightweight Protocol **Lightweight Protocol - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature1_Lightweight_Protocol_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step10: .. tab-set:: .. tab-item:: CoAP Feature : RESTful Architecture **RESTful Architecture - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature2_RESTful_Architecture_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step11: .. tab-set:: .. tab-item:: CoAP Feature : UDP Based Communication **UDP Based Communication - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature3_UDP_Based_Communication_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step12: .. tab-set:: .. tab-item:: CoAP Feature : Asynchronous Messaging **Asynchronous Messaging - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature4_Asynchronous_Messaging_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step13: .. tab-set:: .. tab-item:: CoAP Feature : Bulit In Reliability **Bulit In Reliability - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature5_Built_in_Reliability_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step14: .. tab-set:: .. tab-item:: CoAP Feature : Low Header Overhead **Low Header Overhead - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature6_Low_Header_Overhead_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step15: .. tab-set:: .. tab-item:: CoAP Feature : Resource Discovery **Resource Discovery - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature7_Resource_discovery_test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step16: .. tab-set:: .. tab-item:: CoAP Feature : Multicast Support **MultiCast Support - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature8_Multicast_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step17: .. tab-set:: .. tab-item:: CoAP Feature : Observe Option **Observe Option - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature9_Observe_Option_Test_cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step18: .. tab-set:: .. tab-item:: CoAP Feature : Security Support **Security Support - Testcases** .. csv-table:: :file: ./CoAP/CoAP_Feature10_Security_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _CoAP_step19: .. tab-set:: .. tab-item:: Reference links * Reference links