← Back to the chapter · Previous detail

Technical detail · CoAP Advanced Features

TCP framing and security endpoints

CoAP can use a datagram transport, UDP, or a byte-stream transport, TCP, with different framing and protection boundaries.

16.7.4 Protocol Differences

16.7.5 Header Format Changes

CoAP over TCP changes the framing. It has no UDP message-type field or Message ID and does not use Confirmable (CON), Non-confirmable (NON) or Acknowledgment (ACK) exchanges. Length information frames messages in the stream. Choosing it therefore changes the reliability mechanism as well as the route.

16.7.6 When to Use

Use a reliable transport when the endpoints support it and the permitted path requires it. WebSockets need matching service support too; an open web port alone is insufficient. For the street sensor, compare reconnect cost and idle energy on the actual path before choosing TCP or UDP. TCP does not provide multicast, and connection setup matters when devices sleep between transfers.

Datagram Transport Layer Security (DTLS) protects traffic between its security endpoints; its setup cost depends on the cookie exchange, security configuration profile and loss. Measure full and resumed handshakes on the target link. A message flight groups messages sent before waiting for the other peer; message-flight counts are not universal round-trip counts. Session resumption, negotiating renewed use of earlier session information, may reduce repeated setup work; compare that saving with reconnect and idle energy for a sensor that sleeps between updates.

A proxy is an intermediary that handles an exchange on another peer’s behalf. If it terminates DTLS, protection ends there and a separate protection boundary begins. Name the endpoints protected on each side instead of assuming the image remains protected through every intermediary.

← Back to the chapter · Previous detail