CoAP - Constrained Application Protocol

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.

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.

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.

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.

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.

What are the key features?

  • Lightweight and low overhead.

  • Built-in retransmission and timeout handling.

  • Supports Confirmable (CON) and Non-confirmable (NON) messages.

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.

What kind of devices typically use CoAP?

  • Smart thermostats

  • Light bulbs

  • Environmental sensors

  • Low-power embedded systems

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.

What are some applications that use CoAP?

  • Smart Home Automation

  • Environmental Monitoring

  • Industrial IoT (IIoT)

  • Smart Cities

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

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.

  • In this section, you are going to learn

  • Terminology

  • Version Info

CoAP Version

RFC

Year

Core Ideas/Contribution

CoAP Core Protocol

RFC 7252

2014

Introduced CoAP as a lightweight, RESTful protocol for constrained devices and networks. Supports request/response

model, URIs, content negotiation, and easy HTTP integration.

CoAP Link Format

RFC 6690

2012

Defined a simple link format for resource discovery in CoAP,

self-description of resources.

Observe for CoAP

RFC 7641

2015

Added the observe extension for CoAP, allowing clients to

observe changes in resource state (pub/sub model).

Block-wise Transfers

RFC 7959

2016

Enabled block-wise transfer of large payloads in CoAP, improving

reliability over constrained networks.

CoAP over TCP, TLS, WebSockets

RFC 8323

2018

Extended CoAP to support reliable transports like TCP, TLS,

and WebSockets.

Group Communication

RFC 7390

2014

Defined how CoAP can be used for group communication using

IP multicast.

OSCORE (Object Security)

RFC 8613

2019

Introduced end-to-end security for CoAP messages using

CBOR Object Signing and Encryption (COSE).

Echo, Request-Tag Options

RFC 9175

2022

Added options to improve message integrity and replay protection.

CoAP Congestion Control

RFC 8974

2021

Provided guidelines for congestion control in CoAP implementations.

  • setup

  • setup

CoAP CONFIRMABLE(CON) Packet

S.No

Protocol Packets

Description

Size(bytes)

1

Confirmable (CON)

Requires acknowledgment. Used for reliable message delivery.

20100

Version

Indicates CoAP version (currently 1)

2 bits

Type

Message type: Confirmable (0)

2 bits

Token Length

Length of the token (08 bytes)

4 bits

Code

Request method or response code (e.g., GET = 0.01)

1 byte

Message ID

Unique ID for message deduplication

2 bytes

Token

Used to match requests and responses

08 bytes

Options

URI path, content format, etc.

Variable

Payload Marker

Indicates start of payload (0xFF)

1 byte

Payload

Actual application data

Variable.

CoAP NON-CONFIRMABLE(NON) Packet

2

Non-confirmable (NON)

No acknowledgment needed. Used for non-critical messages.

20100

Version

CoAP version (currently 1)

2 bits

Type

Type = 1 for Non-confirmable

2 bits

Token Length

Length of the token (08 bytes)

4 bits

Code

Request method or response code

1 byte

Message ID

Unique ID for message deduplication

2 bytes

Token

Used to match requests and responses

08 bytes

Options

URI path, content format, etc.

Variable

Payload Marker

Indicates start of payload (if present)

1 byte (0xFF)

Payload

Actual application data

Variable

CoAP ACKNOWLEDGMENT(ACK) Packet

3

Acknowledgement (ACK)

Sent in response to CON messages. May carry a piggybacked

20100 bytes

response.

Version

CoAP version (currently 1)

2 bits

Type

Type = 2 for Acknowledgement

2 bits

Token Length

Length of the token (08 bytes)

4 bits

Code

Response code (e.g., 2.05 Content)

1 byte

Message ID

Echoes the Message ID of the CON message

2 bytes

Token

Echoes the token of the request

08 bytes

Options

Response metadata (e.g., Content-Format)

Variable

Payload Marker

Indicates start of payload (if present)

1 byte (0xFF)

Payload

Response data

Variable

CoAP RESET(RST) Packet

4

Reset (RST)

Indicates a message was received but not understood or

420

processed.

Version

CoAP version (currently 1)

2 bits

Type

Type = 3 for Reset

2 bits

Token Length

Usually 0 (no token)

4 bits

Code

Always 0.00 (Empty message)

1 byte

Message ID

Echoes the Message ID of the message being reset

2 bytes

Token

Not used

0 bytes

Options

Not used

0 bytes

Payload Marker

Not used

0 bytes

Payload

Not used

0 bytes

S.No

Use Case

Descrption

1

Smart Home Automation

Used for controlling lights, thermostats, and appliances in constrained networks.

2

Industrial IoT (IIoT)

Enables communication between sensors, actuators, and controllers in factories.

3

Smart Agriculture

Facilitates monitoring of soil moisture, temperature, and irrigation systems.

4

Smart Cities

Supports applications like smart street lighting, waste management, and parking.

5

Environmental Monitoring

Used in remote sensors for air quality, water levels, and weather conditions.

6

Healthcare and Wearables

Enables low-power communication in medical devices and fitness trackers.

7

Asset Tracking and Logistics

Helps track goods and vehicles using constrained GPS and sensor devices.

8

Building Automation

Manages HVAC, lighting, and security systems in commercial buildings.

9

Energy Management (Smart Grid)

Used in smart meters and grid monitoring for efficient energy distribution.

10

Vehicle-to-Infrastructure (V2I)

Supports communication between vehicles and roadside units in intelligent transport systems.

S.No

Feature

Descrption

1

Lightweight Protocol

Designed for constrained devices and networks with low overhead.

2

RESTful Architecture

Supports REST methods like GET, POST, PUT, DELETE similar to HTTP.

3

UDP-Based Communication

Operates over UDP for low-latency, low-power communication.

4

Asynchronous Messaging

Supports non-blocking communication using Confirmable and Non-confirmable messages.

5

Built-in Reliability

Provides message reliability using retransmissions and acknowledgments.

6

Low Header Overhead

Uses a compact 4-byte base header to reduce bandwidth usage.

7

Resource Discovery

Supports discovery of resources using CoRE Link Format (RFC 6690).

8

Multicast Support

Allows group communication using IP multicast.

9

Observe Option

Enables clients to observe resource changes (publish/subscribe model).

10

Security Support

Supports DTLS for transport-layer security and OSCORE for end-to-end security.

Lightweight Protocol - Testcases

S.No

Test Case

Description

Expected Result

1

CoAP GET Request

Send a GET request to a resource

Resource is retrieved successfully

2

CoAP POST Request

Send a POST request with payload

Resource is created or updated

3

CoAP PUT Request

Send a PUT request to update resource

Resource is updated

4

CoAP DELETE Request

Send a DELETE request

Resource is deleted

5

Resource Discovery

Discover available resources

Resource list is returned

6

Observe Feature

Subscribe to resource changes

Notifications are received

7

Cancel Observation

Unsubscribe from resource

Notifications stop

8

Confirmable Message

Send confirmable message

ACK is received

9

Non-confirmable Message

Send non-confirmable message

No ACK expected

10

Message Retransmission

Simulate lost message

Message is retransmitted

11

Duplicate Detection

Send duplicate message

Duplicate is ignored

12

Token Matching

Match response with token

Correct response is matched

13

URI Parsing

Parse complex URI

URI is parsed correctly

14

Payload Encoding

Encode payload in CBOR

Payload is encoded properly

15

Payload Decoding

Decode CBOR payload

Payload is decoded correctly

16

Content Format Negotiation

Request specific format

Correct format is returned

17

Block-wise Transfer

Transfer large payload in blocks

Payload is reassembled correctly

18

Timeout Handling

Simulate timeout

Timeout error is handled

19

Resource Not Found

Request non-existent resource

4.04 Not Found is returned

20

Unauthorized Access

Access protected resource

4.01 Unauthorized is returned

21

Forbidden Access

Access forbidden resource

4.03 Forbidden is returned

22

Internal Server Error

Simulate server error

5.00 Internal Error is returned

23

Method Not Allowed

Use unsupported method

4.05 Method Not Allowed

24

URI Too Long

Send request with long URI

4.14 URI Too Long

25

Payload Too Large

Send large payload

4.13 Payload Too Large

26

Empty Message Handling

Send empty message

Message is processed correctly

27

Multicast Request

Send multicast GET

Multiple responses received

28

DTLS Handshake

Establish secure session

DTLS handshake succeeds

29

DTLS Encryption

Encrypt CoAP messages

Messages are encrypted

30

DTLS Replay Protection

Replay old message

Replay is detected and blocked

31

DTLS Session Timeout

Simulate session timeout

Session is terminated

32

DTLS Reconnection

Reconnect after timeout

Session is re-established

33

CoAP over TCP

Send CoAP message via TCP

Message is delivered correctly

34

CoAP over UDP

Send CoAP message via UDP

Message is delivered correctly

35

CoAP over SMS

Send CoAP message via SMS

Message is delivered correctly

36

CoAP over WebSockets

Send CoAP message via WebSocket

Message is delivered correctly

37

Resource Caching

Cache resource response

Cached response is used

38

ETag Support

Use ETag for caching

ETag is validated

39

Max-Age Header

Use Max-Age for freshness

Resource expires correctly

40

Proxy Forwarding

Forward request via proxy

Request is forwarded correctly

41

Proxy Response

Receive response via proxy

Response is received correctly

42

URI Path Matching

Match URI path segments

Correct resource is accessed

43

URI Query Matching

Match query parameters

Correct resource is accessed

44

Server Load Test

Simulate high traffic

Server handles load gracefully

45

Client Load Test

Simulate multiple clients

Clients operate correctly

46

Resource Update Notification

Notify clients on update

Clients receive update

47

Resource Expiry

Expire resource after time

Resource becomes unavailable

48

CoAP Logging

Log CoAP transactions

Logs are accurate

49

CoAP Debugging

Enable debug mode

Debug info is displayed

50

CoAP Compliance Test

Run protocol compliance test

All tests pass successfully

RESTful Architecture - Testcases

S.No

Test Case

Description

Expected Result

1

Resource GET

Retrieve resource using GET

Resource data is returned

2

Resource POST

Create resource using POST

Resource is created

3

Resource PUT

Update resource using PUT

Resource is updated

4

Resource DELETE

Delete resource using DELETE

Resource is deleted

5

Stateless Interaction

Send independent requests

Server does not retain state

6

Resource URI Structure

Access resource via URI

Correct resource is accessed

7

Resource Representation

Request JSON format

JSON response is returned

8

Content Negotiation

Request CBOR format

CBOR response is returned

9

Resource Discovery

Discover available endpoints

List of resources is returned

10

Resource Filtering

Use query parameters

Filtered data is returned

11

Resource Sorting

Sort data via query

Sorted data is returned

12

Resource Pagination

Request paginated data

Page-wise data is returned

13

Resource Caching

Use ETag and Max-Age

Cached response is used

14

Resource Versioning

Access versioned resource

Correct version is returned

15

URI Path Parameters

Use path variables

Resource is accessed correctly

16

URI Query Parameters

Use query strings

Resource is filtered correctly

17

Error 404

Access non-existent resource

4.04 Not Found is returned

18

Error 400

Send malformed request

4.00 Bad Request is returned

19

Error 405

Use unsupported method

4.05 Method Not Allowed

20

Error 403

Access forbidden resource

4.03 Forbidden is returned

21

Error 401

Access without auth

4.01 Unauthorized is returned

22

Error 500

Simulate server error

5.00 Internal Server Error

23

Resource Update Conflict

Simulate concurrent update

Conflict is detected

24

Resource Creation Conflict

Duplicate POST request

Conflict response is returned

25

Resource Deletion Validation

Delete and re-access

Resource is unavailable

26

Resource Modification Validation

Modify and re-access

Updated resource is returned

27

Statelessness Validation

Send repeated requests

Server treats each independently

28

URI Encoding

Encode special characters

URI is parsed correctly

29

URI Decoding

Decode encoded URI

Correct resource is accessed

30

Method Idempotency

Repeat PUT request

Same result each time

31

Method Safety

GET does not modify data

Data remains unchanged

32

Observe Resource

Subscribe to changes

Notifications are received

33

Cancel Observation

Unsubscribe from resource

Notifications stop

34

Block-wise Transfer

Transfer large resource

Resource is reassembled correctly

35

Proxy Forwarding

Access via CoAP proxy

Request is forwarded correctly

36

Proxy Response

Receive response via proxy

Response is received correctly

37

DTLS Security

Secure RESTful interaction

Data is encrypted

38

DTLS Authentication

Authenticate client

Authenticated session is established

39

DTLS Session Timeout

Simulate timeout

Session is terminated

40

DTLS Reconnection

Reconnect after timeout

Session resumes

41

Resource Logging

Log resource access

Logs are accurate

42

Resource Monitoring

Monitor resource usage

Usage data is collected

43

Resource Metrics

Collect performance metrics

Metrics are available

44

Resource Load Test

Simulate high traffic

Server handles load

45

Resource Stress Test

Simulate overload

Server responds gracefully

46

Resource Backup

Backup resource data

Backup is created

47

Resource Restore

Restore from backup

Data is restored

48

Resource Sync

Sync across devices

Data is consistent

49

Resource Audit

Audit resource changes

Audit log is complete

50

RESTful Compliance

Validate REST principles

All principles are followed

UDP Based Communication - Testcases

S.No

Test Case

Description

Expected Result

1

Version Check

Validate CoAP version in header

Response with correct version or reset

2

Message Type Confirmable

Send confirmable message

ACK received

3

Message Type Non-confirmable

Send non-confirmable message

No ACK expected

4

Message Type Acknowledgement

Send ACK to confirmable message

Message acknowledged

5

Message Type Reset

Send reset message

Communication reset

6

Token Length Validity

Send message with valid token length

Message processed

7

Token Length Invalid

Send message with invalid token length

Error or ignore

8

Empty Message

Send empty message

Reset or ignore

9

GET Method

Request resource using GET

Resource returned

10

POST Method

Create resource using POST

Resource created

11

PUT Method

Update resource using PUT

Resource updated

12

DELETE Method

Delete resource using DELETE

Resource deleted

13

URI Path Parsing

Send request with URI path

Correct resource accessed

14

URI Query Parsing

Send request with URI query

Query processed

15

Payload Format Valid

Send valid payload

Payload accepted

16

Payload Format Invalid

Send invalid payload

Error response

17

Observe Option

Register for resource observation

Notifications received

18

Cancel Observation

Cancel observation

Notifications stopped

19

Block1 Transfer

Send large payload using Block1

Payload received in blocks

20

Block2 Transfer

Receive large response using Block2

Response received in blocks

21

Content-Format Option

Specify content format

Format respected

22

Accept Option

Specify accepted response format

Response in accepted format

23

Max-Age Option

Set max-age for response

Response cached accordingly

24

ETag Option

Send ETag for resource

ETag validated

25

If-Match Option

Conditional request with If-Match

Request processed if match

26

If-None-Match Option

Conditional request with If-None-Match

Request processed if no match

27

Message ID Uniqueness

Send message with unique ID

Message processed

28

Duplicate Message ID

Send duplicate message ID

Duplicate detected

29

Timeout Handling

Simulate timeout

Retry or error

30

Retransmission

Trigger retransmission

Message resent

31

Congestion Control

Simulate congestion

Messages throttled

32

URI Length Limit

Send long URI

URI truncated or error

33

Option Order

Send options in different order

Options parsed correctly

34

Option Repeat

Repeat options

Options handled correctly

35

Proxy Support

Send request via proxy

Request forwarded

36

Multicast Request

Send multicast GET

Multiple responses

37

DTLS Security

Send secured message

Message decrypted

38

DTLS Handshake

Perform DTLS handshake

Secure session established

39

Invalid Header

Send malformed header

Error response

40

Unsupported Method

Send unsupported method

4.05 Method Not Allowed

41

Resource Discovery

Use /.well-known/core

Resource list returned

42

Server Availability

Ping server

Server responds

43

Client Availability

Ping client

Client responds

44

URI Wildcard

Use wildcard in URI

Matching resources accessed

45

Option Length Validity

Send options with valid length

Options parsed

46

Option Length Invalid

Send options with invalid length

Error response

47

Message Size Limit

Send oversized message

Message rejected

48

Message Fragmentation

Fragment message

Message reassembled

49

Server Restart

Restart server during session

Session recovery

50

Client Restart

Restart client during session

Session recovery

Asynchronous Messaging - Testcases

S.No

Test Case

Description

Expected Result

1

Async Message Delivery

Send message without waiting for response

Message delivered independently

2

Async Notification

Server sends notification to client

Client receives notification

3

Message Queueing

Queue messages when recipient is offline

Messages delivered when online

4

Retry on Failure

Retry sending message after failure

Message eventually delivered

5

Message Ordering

Send multiple async messages

Messages received in correct order

6

Duplicate Detection

Detect duplicate async messages

Duplicates ignored

7

Timeout Handling

Async message times out

Retry or error logged

8

Message Acknowledgement

Acknowledge async message receipt

ACK received asynchronously

9

Async Error Handling

Send malformed async message

Error response or discard

10

Async Broadcast

Send async message to multiple clients

All clients receive message

11

Async Multicast

Send async message to group

Group members receive message

12

Async Subscription

Subscribe to async updates

Updates received periodically

13

Async Unsubscription

Unsubscribe from updates

Updates stop

14

Async Payload Validation

Send payload in async message

Payload validated

15

Async Message Size Limit

Send large async message

Message accepted or rejected

16

Async Message Fragmentation

Fragment large async message

Message reassembled correctly

17

Async Security Check

Send async message with security token

Token validated

18

Async Encryption

Send encrypted async message

Message decrypted successfully

19

Async Authentication

Authenticate sender of async message

Sender verified

20

Async Session Persistence

Maintain session across async messages

Session state preserved

21

Async Resource Update

Notify client of resource change

Client receives update

22

Async Event Trigger

Trigger event via async message

Event executed

23

Async Message Filtering

Filter messages based on criteria

Only relevant messages received

24

Async Priority Handling

Send messages with priority levels

High-priority messages processed first

25

Async Load Handling

Send messages under high load

System handles load gracefully

26

Async Logging

Log all async messages

Logs created

27

Async Message Compression

Compress async message

Message decompressed correctly

28

Async Message Format

Validate format of async message

Format accepted

29

Async Message Routing

Route message to correct recipient

Message delivered correctly

30

Async Message Scheduling

Schedule message for future delivery

Message sent at scheduled time

31

Async Message Cancellation

Cancel scheduled message

Message not sent

32

Async Message Expiry

Set expiry for message

Expired message discarded

33

Async Message Replay

Replay previously sent message

Message reprocessed

34

Async Message Throttling

Limit message rate

Excess messages dropped or delayed

35

Async Message Duplication

Send same message to multiple endpoints

All endpoints receive message

36

Async Message Delay Simulation

Simulate network delay

Message received after delay

37

Async Message Loss Simulation

Simulate message loss

Message not received

38

Async Message Recovery

Recover lost message

Message resent or logged

39

Async Message Corruption

Send corrupted message

Error detected

40

Async Message Audit

Audit trail of async messages

Audit log available

41

Async Message Retry Policy

Define retry policy

Policy enforced

42

Async Message Backoff

Implement exponential backoff

Retry intervals increase

43

Async Message Rate Limit

Enforce rate limit

Excess messages rejected

44

Async Message Queue Overflow

Overflow message queue

Messages dropped or delayed

45

Async Message Queue Drain

Drain queued messages

Messages delivered

46

Async Message Queue Persistence

Persist queued messages

Messages survive restart

47

Async Message Queue Monitoring

Monitor queue status

Status visible

48

Async Message Queue Cleanup

Cleanup old messages

Messages deleted

49

Async Message Queue Prioritization

Prioritize messages in queue

High-priority messages sent first

50

Async Message Queue Isolation

Isolate queues per client

No cross-client interference

Bulit In Reliability - Testcases

S.No

Test Case

Description

Expected Result

1

Message Retransmission

Send confirmable message without ACK

Message retransmitted

2

ACK Reception

Send confirmable message

ACK received within timeout

3

Duplicate Message Detection

Send same message twice

Duplicate ignored

4

Message ID Uniqueness

Send messages with unique IDs

All messages processed

5

Timeout Handling

Simulate delayed ACK

Retransmission triggered

6

Exponential Backoff

Retry with increasing delay

Retries spaced out

7

Max Retries Reached

Fail to receive ACK

Message dropped after max retries

8

Message Ordering

Send multiple messages

Messages received in correct order

9

Session Persistence

Restart client/server

Session state preserved

10

Message Integrity Check

Send message with checksum

Checksum validated

11

Corrupted Message Detection

Send corrupted message

Message rejected

12

Message Acknowledgement Loss

Drop ACK intentionally

Retransmission triggered

13

Message Queueing

Queue messages during downtime

Messages sent when connection resumes

14

Message Replay Protection

Replay old message

Message rejected

15

Message Expiry

Send expired message

Message discarded

16

Congestion Control

Simulate network congestion

Messages throttled

17

Flow Control

Send messages rapidly

Flow regulated

18

Resource Availability Check

Request unavailable resource

Error response

19

Server Overload Simulation

Overload server

Server handles gracefully

20

Client Overload Simulation

Overload client

Client handles gracefully

21

Network Partition Recovery

Simulate network split

Messages delivered after recovery

22

Message Fragmentation

Fragment large message

Message reassembled correctly

23

Fragment Loss Recovery

Drop fragment

Retransmission triggered

24

Fragment Reordering

Send fragments out of order

Correct reassembly

25

Message Prioritization

Send high and low priority messages

High priority processed first

26

Retry Policy Enforcement

Define retry rules

Rules followed

27

Message Logging

Log all messages

Logs available for audit

28

Message Audit Trail

Track message flow

Complete trace available

29

Message Delivery Confirmation

Confirm delivery to application layer

Confirmation received

30

Message Buffer Overflow

Overflow buffer

Messages dropped or queued

31

Message Buffer Drain

Drain buffer

Messages delivered

32

Message Buffer Monitoring

Monitor buffer usage

Usage stats available

33

Message Buffer Cleanup

Cleanup old messages

Messages deleted

34

Message Queue Isolation

Isolate queues per session

No cross-session interference

35

Message Queue Persistence

Persist messages across restarts

Messages retained

36

Message Queue Recovery

Recover messages after crash

Messages restored

37

Message Queue Throttling

Limit queue rate

Excess messages dropped

38

Message Queue Prioritization

Prioritize messages in queue

Priority respected

39

Message Queue Overflow Handling

Handle overflow gracefully

System stable

40

Message Queue Expiry

Expire old messages

Messages discarded

41

Message Queue Replay

Replay queued messages

Messages reprocessed

42

Message Queue Scheduling

Schedule message delivery

Delivered on time

43

Message Queue Cancellation

Cancel queued message

Message not sent

44

Message Queue Delay Simulation

Simulate delay

Message received after delay

45

Message Queue Loss Simulation

Simulate loss

Message not received

46

Message Queue Recovery Simulation

Recover lost messages

Messages resent

47

Message Queue Corruption Simulation

Corrupt message

Error detected

48

Message Queue Audit

Audit queued messages

Audit log available

49

Message Queue Security

Secure queued messages

Messages protected

50

Message Queue Authentication

Authenticate message source

Source verified

Low Header Overhead - Testcases

S.No

Test Case

Description

Expected Result

1

Minimal Header Size

Send basic CoAP message

Header size 4 bytes

2

Header Compression

Apply header compression

Reduced header size

3

No Redundant Fields

Check for unnecessary header fields

Only essential fields present

4

Token Length Optimization

Use minimal token length

Token 8 bytes

5

Option Encoding Efficiency

Encode options compactly

Minimal overhead

6

Message Type Encoding

Use 2-bit message type field

Correct type decoded

7

Code Field Efficiency

Use 8-bit code field

Correct method decoded

8

Message ID Size

Validate 16-bit message ID

Proper ID handling

9

Header Parsing Speed

Measure parsing time

Fast parsing (< threshold)

10

Header Validation

Validate header structure

Header accepted

11

Header Corruption Detection

Send corrupted header

Error or discard

12

Header Field Reuse

Reuse fields across messages

No duplication

13

Header Field Omission

Omit optional fields

Message still valid

14

Header Field Ordering

Change field order

Message still parsed correctly

15

Header Field Encoding

Use binary encoding

Correct decoding

16

Header Size Limit

Send message with max header size

Message accepted

17

Header Size Overflow

Send message exceeding header size

Message rejected

18

Header Size Comparison

Compare CoAP vs HTTP header

CoAP significantly smaller

19

Header Size in Fragmented Message

Fragment message

Header size remains minimal

20

Header Size in Multicast

Send multicast message

Minimal header overhead

21

Header Size in Confirmable Message

Send confirmable message

Header size within limits

22

Header Size in Non-confirmable Message

Send non-confirmable message

Header size within limits

23

Header Size in ACK

Send ACK message

Minimal header size

24

Header Size in Reset

Send reset message

Minimal header size

25

Header Size with Options

Add multiple options

Header size remains efficient

26

Header Size with Payload

Add payload

Header size unaffected

27

Header Size with Observe Option

Add observe option

Efficient encoding

28

Header Size with Block Option

Add block-wise transfer option

Efficient encoding

29

Header Size with URI Path

Add URI path

Compact encoding

30

Header Size with URI Query

Add URI query

Compact encoding

31

Header Size with Content-Format

Specify content format

Efficient encoding

32

Header Size with Accept Option

Specify accept format

Efficient encoding

33

Header Size with Max-Age

Add max-age option

Efficient encoding

34

Header Size with ETag

Add ETag option

Efficient encoding

35

Header Size with If-Match

Add If-Match option

Efficient encoding

36

Header Size with If-None-Match

Add If-None-Match option

Efficient encoding

37

Header Size with Proxy-Uri

Add proxy URI

Efficient encoding

38

Header Size with Proxy-Scheme

Add proxy scheme

Efficient encoding

39

Header Size with Location-Path

Add location path

Efficient encoding

40

Header Size with Location-Query

Add location query

Efficient encoding

41

Header Size with Size1 Option

Add Size1 option

Efficient encoding

42

Header Size with Size2 Option

Add Size2 option

Efficient encoding

43

Header Size with No Options

Send message with no options

Minimal header size

44

Header Size with Max Options

Send message with many options

Header size within limits

45

Header Size in Secure Message

Send DTLS-secured message

CoAP header remains minimal

46

Header Size in Encrypted Message

Encrypt message

Header size unaffected

47

Header Size in Compressed Message

Compress message

Header size reduced

48

Header Size in Retry Message

Retry message

Header size consistent

49

Header Size in Cached Message

Send cached message

Header size minimal

50

Header Size in Observed Message

Send observed update

Header size minimal

Resource Discovery - Testcases

S.No

Test Case

Description

Expected Result

1

Basic Discovery Request

Send GET to /.well-known/core

List of available resources returned

2

Discovery with URI Filtering

Send GET with URI filter

Only matching resources listed

3

Discovery with Query Parameters

Use query like ?rt=temperature

Only temperature resources listed

4

Discovery with Content-Format

Request specific format (e.g., JSON)

Response in requested format

5

Discovery with Accept Option

Use Accept option in request

Server respects format preference

6

Discovery with Empty Response

Server has no resources

Empty list or appropriate response

7

Discovery with Large Resource List

Server has many resources

Full list returned in blocks

8

Discovery with Block2 Option

Use block-wise transfer

Paginated resource list received

9

Discovery with Observe Option

Observe /.well-known/core

Updates received on resource changes

10

Discovery with Proxy

Send discovery via proxy

Proxy forwards and returns result

11

Discovery with Invalid URI

Use incorrect URI

4.04 Not Found response

12

Discovery with Unauthorized Access

Access restricted resource list

4.01 Unauthorized response

13

Discovery with Malformed Query

Send invalid query string

4.00 Bad Request response

14

Discovery with DTLS

Perform discovery over secure channel

Encrypted response received

15

Discovery with Multicast

Send multicast discovery request

Multiple servers respond

16

Discovery with Timeout

Simulate delayed response

Timeout or retry triggered

17

Discovery with Retry

Retry after failed attempt

Successful response on retry

18

Discovery with Caching

Cache discovery response

Cached result used

19

Discovery with ETag

Use ETag for caching validation

Conditional response returned

20

Discovery with If-None-Match

Conditional GET request

2.03 Valid or 4.12 Precondition Failed

21

Discovery with Resource Attributes

Check for rt, if, ct attributes

Attributes correctly listed

22

Discovery with Wildcard

Use wildcard in query

Matching resources returned

23

Discovery with URI Path Traversal

Traverse nested paths

Sub-resources discovered

24

Discovery with URI Length Limit

Send long URI

Response handled correctly or error

25

Discovery with Server Restart

Restart server and retry discovery

Resources rediscovered

26

Discovery with Client Restart

Restart client and retry

Discovery works post-restart

27

Discovery with Resource Update

Update server resources

Discovery reflects changes

28

Discovery with Resource Removal

Remove resource from server

Resource no longer listed

29

Discovery with Resource Addition

Add new resource

Resource appears in discovery

30

Discovery with Custom Resource Types

Use custom rt values

Custom types listed correctly

31

Discovery with Interface Description

Use if attribute

Interface details returned

32

Discovery with Content-Type Filtering

Filter by ct attribute

Matching content types listed

33

Discovery with Multiple Filters

Use combined filters

Filtered result returned

34

Discovery with Invalid Accept Option

Use unsupported format

4.06 Not Acceptable response

35

Discovery with URI Encoding

Use encoded URI characters

Correct decoding and response

36

Discovery with URI Case Sensitivity

Use different cases in URI

Case handled correctly

37

Discovery with Resource Aliases

Use alias in URI

Correct resource resolved

38

Discovery with Resource Redirection

Redirect discovery request

Resource list from new location

39

Discovery with Resource Metadata

Include metadata in response

Metadata correctly formatted

40

Discovery with Resource Grouping

Group resources logically

Grouped listing returned

41

Discovery with Resource Hierarchy

Hierarchical resource structure

Nested resources listed

42

Discovery with Resource Tags

Use tags in query

Tagged resources listed

43

Discovery with Resource Priority

Prioritize certain resources

Priority reflected in listing

44

Discovery with Resource Localization

Localized resource names

Correct language returned

45

Discovery with Resource Access Control

Access control on resources

Unauthorized resources hidden

46

Discovery with Resource Expiry

Expired resources removed

Not listed in discovery

47

Discovery with Resource Versioning

Include version info

Versioned resources listed

48

Discovery with Resource Capabilities

List capabilities of resources

Capabilities described

49

Discovery with Resource Dependencies

Show dependent resources

Dependencies listed

50

Discovery with Resource Health Status

Include health/status info

Status shown in listing

MultiCast Support - Testcases

S.No

Test Case

Description

Expected Result

1

Basic Multicast Request

Send multicast GET to group

Multiple servers respond

2

Multicast Address Validation

Use valid multicast IP

Request accepted

3

Invalid Multicast Address

Use invalid IP

Request rejected

4

Multicast Group Join

Client joins multicast group

Group membership confirmed

5

Multicast Group Leave

Client leaves multicast group

No longer receives messages

6

Multicast Message Delivery

Send message to group

All members receive message

7

Multicast Message Filtering

Filter messages by URI or query

Only relevant responses received

8

Multicast Response Aggregation

Collect responses from multiple servers

Responses aggregated

9

Multicast Response Timeout

Set timeout for responses

Responses collected within time

10

Multicast Response Deduplication

Handle duplicate responses

Duplicates ignored

11

Multicast with Confirmable Message

Send confirmable multicast message

No ACK expected (per CoAP spec)

12

Multicast with Non-confirmable Message

Send non-confirmable message

Responses received

13

Multicast with Observe Option

Observe resource via multicast

Notifications from multiple sources

14

Multicast with Block2 Option

Receive large responses in blocks

Block-wise responses handled

15

Multicast with URI Filtering

Use URI filter in multicast

Filtered responses received

16

Multicast with Query Parameters

Use query in multicast request

Relevant responses returned

17

Multicast with Accept Option

Specify response format

Responses in requested format

18

Multicast with Content-Format

Servers respond with correct format

Format respected

19

Multicast with DTLS

Attempt multicast over DTLS

Not supported or error

20

Multicast with Proxy

Send multicast via proxy

Proxy forwards correctly

21

Multicast with Resource Discovery

Discover resources via multicast

Multiple resource lists received

22

Multicast with Server Restart

Restart server during multicast

Server rejoins group

23

Multicast with Client Restart

Restart client during multicast

Client rejoins group

24

Multicast with Network Partition

Simulate network split

Partial responses received

25

Multicast with Message Loss

Simulate packet loss

Some responses missing

26

Multicast with Message Delay

Simulate delay

Responses received after delay

27

Multicast with Message Corruption

Corrupt multicast message

Error or discard

28

Multicast with Message Retry

Retry multicast request

New set of responses received

29

Multicast with Message Logging

Log all multicast messages

Logs available

30

Multicast with Message Audit

Audit multicast communication

Complete trace available

31

Multicast with Resource Update

Update resource on server

Updated responses received

32

Multicast with Resource Removal

Remove resource from server

Resource no longer listed

33

Multicast with Resource Addition

Add new resource

Resource appears in responses

34

Multicast with Resource Filtering

Filter by resource type

Only matching resources listed

35

Multicast with Resource Attributes

Include attributes in response

Attributes correctly listed

36

Multicast with Large Payload

Send large multicast message

Message fragmented or rejected

37

Multicast with Invalid Payload

Send malformed payload

Error response or discard

38

Multicast with Security Token

Include token in request

Token validated

39

Multicast with Authentication

Authenticate sender

Sender verified

40

Multicast with Encryption

Encrypt multicast message

Message decrypted

41

Multicast with Message Prioritization

Prioritize multicast messages

High-priority messages processed first

42

Multicast with Rate Limiting

Limit multicast message rate

Excess messages dropped

43

Multicast with Congestion Control

Simulate congestion

Messages throttled

44

Multicast with Flow Control

Regulate message flow

Controlled delivery

45

Multicast with Message Scheduling

Schedule multicast message

Sent at scheduled time

46

Multicast with Message Expiry

Set expiry for message

Expired messages discarded

47

Multicast with Message Replay

Replay multicast message

Message reprocessed

48

Multicast with Message Queueing

Queue multicast messages

Delivered when ready

49

Multicast with Message Buffering

Buffer multicast messages

Messages stored temporarily

50

Multicast with Message Monitoring

Monitor multicast traffic

Traffic stats available

Observe Option - Testcases

S.No

Test Case

Description

Expected Result

1

Basic Observe Registration

Client sends GET with Observe option

Server registers client for updates

2

Observe Notification Delivery

Server changes resource state

Client receives notification

3

Observe Cancellation

Client sends GET without Observe option

Observation cancelled

4

Observe with Confirmable Messages

Server sends confirmable notifications

Client acknowledges each message

5

Observe with Non-confirmable Messages

Server sends non-confirmable notifications

No ACK expected

6

Observe with Multiple Clients

Multiple clients observe same resource

All clients receive updates

7

Observe with Token Matching

Server uses correct token in notifications

Client matches response to request

8

Observe with ETag

Server includes ETag in notifications

Client validates resource version

9

Observe with Max-Age

Server sets Max-Age in response

Client knows when to expect next update

10

Observe with Timeout

Server stops sending updates

Client times out and retries

11

Observe with Resource Deletion

Observed resource is deleted

Client receives 4.04 Not Found

12

Observe with Resource Update

Resource value changes

Client receives updated value

13

Observe with No Change

Resource remains unchanged

No notification sent

14

Observe with Block2 Option

Large notification sent in blocks

Client reassembles full message

15

Observe with DTLS

Observe over secure channel

Notifications encrypted and received

16

Observe with Proxy

Observe via proxy

Proxy forwards notifications correctly

17

Observe with Invalid Token

Server sends wrong token

Client discards notification

18

Observe with Invalid Sequence

Server sends out-of-order notifications

Client handles gracefully

19

Observe with Sequence Wraparound

Sequence number wraps around

Client maintains correct order

20

Observe with Server Restart

Server restarts during observation

Observation re-established or cancelled

21

Observe with Client Restart

Client restarts during observation

Observation re-initiated

22

Observe with Network Loss

Simulate packet loss

Client retries or times out

23

Observe with Message Delay

Simulate delayed notifications

Client receives updates late

24

Observe with Message Corruption

Corrupt notification message

Client discards message

25

Observe with Unauthorized Access

Unauthorized client tries to observe

Server responds with 4.01 Unauthorized

26

Observe with Malformed Request

Send invalid Observe request

Server responds with 4.00 Bad Request

27

Observe with URI Filtering

Observe specific URI path

Only relevant updates received

28

Observe with Query Parameters

Observe with query like ?rt=temperature

Only matching updates received

29

Observe with Content-Format

Server sends notifications in specified format

Client parses correctly

30

Observe with Accept Option

Client specifies acceptable format

Server respects format preference

31

Observe with Resource Attributes

Server includes attributes in notifications

Attributes correctly parsed

32

Observe with Resource Expiry

Resource expires during observation

Client receives expiry notification

33

Observe with Resource Addition

New resource added

Client receives update if observing parent

34

Observe with Resource Removal

Resource removed

Client receives 4.04 Not Found

35

Observe with Resource Metadata

Metadata included in notifications

Client parses metadata

36

Observe with Resource Hierarchy

Observe parent resource

Updates received for child changes

37

Observe with Multicast

Send multicast Observe request

Multiple servers respond

38

Observe with Rate Limiting

Server limits notification rate

Notifications throttled

39

Observe with Priority Updates

Server prioritizes updates

High-priority updates sent first

40

Observe with Caching

Client caches observed values

Cache updated on notification

41

Observe with Logging

Log all notifications

Logs available for audit

42

Observe with Audit Trail

Track observation lifecycle

Complete trace available

43

Observe with Retry Mechanism

Retry failed Observe registration

Observation re-established

44

Observe with Message Replay

Replay old notification

Client detects and ignores

45

Observe with Message Expiry

Notification expires before delivery

Client discards expired message

46

Observe with Message Queueing

Queue notifications during downtime

Delivered when client reconnects

47

Observe with Message Buffering

Buffer notifications temporarily

Delivered in order

48

Observe with Message Monitoring

Monitor notification traffic

Stats available

49

Observe with Message Compression

Compress notification payload

Client decompresses correctly

50

Observe with Message Authentication

Authenticate notification source

Verified before processing

Security Support - Testcases

S.No

Test Case

Description

Expected Result

1

DTLS Handshake

Initiate DTLS handshake between client and server

Secure session established

2

DTLS Session Resumption

Resume previous DTLS session

Session resumed successfully

3

DTLS Encryption

Send encrypted CoAP message

Message decrypted correctly

4

DTLS Authentication

Authenticate client during handshake

Client identity verified

5

DTLS Rejection of Invalid Certificate

Use invalid certificate

Handshake fails

6

DTLS Rejection of Expired Certificate

Use expired certificate

Handshake fails

7

DTLS Mutual Authentication

Both client and server authenticate

Mutual trust established

8

DTLS Cipher Suite Negotiation

Negotiate cipher suite

Supported cipher selected

9

DTLS Replay Protection

Replay old message

Message rejected

10

DTLS Message Integrity

Modify message in transit

Integrity check fails

11

DTLS Session Timeout

Let session expire

Session terminated

12

DTLS Session Renegotiation

Renegotiate session parameters

New session established

13

DTLS Alert Handling

Trigger alert (e.g., bad record)

Alert processed correctly

14

Secure Resource Access

Access protected resource

Access granted with valid credentials

15

Unauthorized Access Attempt

Access resource without credentials

4.01 Unauthorized response

16

Token-Based Authentication

Use token in request

Token validated

17

Invalid Token Handling

Use expired or invalid token

Request rejected

18

Secure Observe Registration

Register for Observe over DTLS

Notifications received securely

19

Secure Block-Wise Transfer

Transfer large payload securely

Blocks encrypted and reassembled

20

Secure Multicast Handling

Attempt multicast over DTLS

Not supported or error

21

Secure Proxy Communication

Communicate via secure proxy

Message forwarded securely

22

Secure URI Access

Access URI with sensitive data

Data encrypted

23

Secure Option Encoding

Encode options securely

Options parsed correctly

24

Secure Message Logging

Log secure messages

Logs encrypted or access-controlled

25

Secure Message Replay Detection

Replay secure message

Replay detected and rejected

26

Secure Message Expiry

Expire secure message

Message discarded

27

Secure Message Queueing

Queue secure messages

Delivered securely

28

Secure Message Buffering

Buffer secure messages

Integrity maintained

29

Secure Message Monitoring

Monitor secure traffic

Stats available without exposing data

30

Secure Message Compression

Compress secure message

Decompressed securely

31

Secure Message Fragmentation

Fragment secure message

Reassembled securely

32

Secure Message Prioritization

Prioritize secure messages

High-priority messages processed first

33

Secure Message Rate Limiting

Limit secure message rate

Excess messages dropped

34

Secure Message Congestion Control

Simulate congestion

Secure messages throttled

35

Secure Message Flow Control

Regulate secure message flow

Controlled delivery

36

Secure Message Scheduling

Schedule secure message

Sent at scheduled time

37

Secure Message Cancellation

Cancel scheduled secure message

Message not sent

38

Secure Message Expiry Handling

Handle expired secure message

Message discarded

39

Secure Message Replay Logging

Log replay attempts

Logged for audit

40

Secure Message Audit Trail

Track secure message flow

Complete trace available

41

Secure Resource Discovery

Discover resources over DTLS

Resource list received securely

42

Secure Content-Format Negotiation

Negotiate content format securely

Format respected

43

Secure Accept Option Handling

Use Accept option securely

Server respects format

44

Secure Max-Age Option

Set Max-Age securely

Response cached securely

45

Secure ETag Validation

Validate ETag securely

ETag matched

46

Secure If-Match Option

Use If-Match securely

Conditional request processed

47

Secure If-None-Match Option

Use If-None-Match securely

Conditional request processed

48

Secure Location-Path Handling

Handle location path securely

Path parsed correctly

49

Secure Location-Query Handling

Handle location query securely

Query parsed correctly

50

Secure Size Option Handling

Handle Size1/Size2 securely

Size validated

  • Reference links