Constrained Application Protocol (CoAP) Hop-Limit Option
Extracted elements (22)
Each intermediate proxy prepends its identifier to the 5.08 diagnostic payload (space-separated) rather than appending, to limit message size, ease correlation with hop count, and detect proxy participation in error forwarding. Prepending is skipped if Path MTU would be exceeded.
The default Hop-Limit value of 16 was chosen to be large enough to avoid dropping legitimate requests in loop-free networks in the majority of cases, while not consuming excessive proxy resources when a loop does occur. The value remains configurable for unusual topologies.
The Hop-Limit option is made part of the cache key so that responses cached with different hop-limit values are not incorrectly served; servers with internal caching that implement this option gain improved caching efficiency.
CoAP proxies that do not understand the Hop-Limit option will forward it safely (safe-to-forward property), but loops involving only such proxies will not be detected. Loop detection remains functional if at least one Hop-Limit-aware proxy is in the loop.
For HTTP/CoAP mapping, the HTTP-to-CoAP proxy maps 5.08 (Hop Limit Reached) to HTTP 508 (Loop Detected), and the CoAP-to-HTTP proxy maps 508 (Loop Detected) back to 5.08. The CoAP-to-HTTP proxy inserts a Via header (or optionally CDN-Loop) when the CoAP request includes a Hop-Limit option.
When both HTTP-to-CoAP and CoAP-to-HTTP proxies are involved and proxy-forwarded traffic crosses both boundaries repeatedly, loop detection may break. However, if the loop is confined within the CoAP or HTTP legs alone, detection remains functional.
A CoAP proxy SHOULD be instructed via configuration to insert a Hop-Limit option when relaying a request that does not already include one.
A CoAP proxy that understands the Hop-Limit option MUST NOT use a stored 5.08 (Hop Limit Reached) error response unless the Hop-Limit value in the presented request is smaller than or equal to the value in the request used to obtain the stored response.
An intermediate proxy MUST NOT forward a 5.08 (Hop Limit Reached) error message if it detects that its own identifier is already present in the diagnostic payload; such messages SHOULD be logged and alerts sent to administrators.
Any request carrying multiple Hop-Limit options MUST be handled following the procedure in Section 5.4.5 of RFC 7252, since the option is not repeatable.
CoAP requests MUST NOT be forwarded if the Hop-Limit option is set to '0' after decrement. Such requests SHOULD be logged and a 5.08 (Hop Limit Reached) error response sent back to the CoAP peer.
If no initial Hop-Limit value is explicitly configured, the default initial value of 16 MUST be used.
New CoAP proxies MUST implement the Hop-Limit option and have it enabled by default.
The Hop-Limit option value MUST be between 1 and 255 inclusive. Requests with a Hop-Limit of 0 or greater than 255 MUST be rejected with a 4.00 (Bad Request) response.
The identifier included in the 5.08 diagnostic payload by the detecting proxy MUST NOT include any space character (ASCII value 32).
The Hop-Limit option is assigned option number 16, encoded as an unsigned integer, 1 byte in length, with a default value of 16. It is elective, safe to forward, and part of the cache key.
When a loop is detected and a 5.08 error is generated, the detecting proxy includes an identifier (e.g., proxy name, alias, or IP address) in the diagnostic payload. Each intermediate proxy relaying the error prepends its own identifier separated by a space.
IANA has registered CoAP Option Number 16 with name 'Hop-Limit' in the 'CoAP Option Numbers' subregistry of the core-parameters registry.
IANA has registered CoAP Response Code 5.08 with description 'Hop Limit Reached' in the 'CoAP Response Codes' subregistry of the core-parameters registry.
A CoAP endpoint can probe network topology by tweaking the Hop-Limit value. This probing can be mitigated by proxies at administrative domain boundaries rewriting or removing the Hop-Limit value in received requests.
The diagnostic payload of a 5.08 (Hop Limit Reached) error message may leak sensitive topology information. A boundary proxy MAY be instructed to strip part or all of the diagnostic payload before forwarding the 5.08 response.
The Hop-Limit option value is encoded as an unsigned integer (uint), 1 octet in length, carrying values between 1 and 255 inclusive. Option number is 16.