The properties of the Hop-Limit option are shown in
Table 1. The formatting of this table follows the one used in Table 4 of
5.10. The C, U, N, and R columns indicate the properties Critical, Unsafe, NoCacheKey, and Repeatable defined in
Section 5.4 of
RFC 7252. None of these properties is marked for the Hop-Limit option.
Number |
C |
U |
N |
R |
Name |
Format |
Length |
Default |
16 |
|
|
|
|
Hop-Limit |
uint |
1 |
16 |
Table 1: CoAP Hop-Limit Option Properties
The Hop-Limit option (
Section 6.2) is an elective option used to detect and prevent infinite loops of CoAP requests when proxies are involved. The option is not repeatable. Therefore, any request carrying multiple Hop-Limit options
MUST be handled following the procedure specified in
Section 5.4.5 of
RFC 7252.
The value of the Hop-Limit option is encoded as an unsigned integer (see
Section 3.2 of
RFC 7252). This value
MUST be between 1 and 255 inclusive. CoAP requests received with a Hop-Limit option set to '0' or greater than '255'
MUST be rejected by a CoAP server/proxy using 4.00 (Bad Request).
The Hop-Limit option is safe to forward. That is, a CoAP proxy that does not understand the Hop-Limit option should forward it on. The option is also part of the cache key. As such, a CoAP proxy that does not understand the Hop-Limit option must follow the recommendations in
Section 5.7.1 of
RFC 7252 for caching. Note that loops that involve only such proxies will not be detected. Nevertheless, the presence of such proxies will not prevent infinite loop detection if at least one CoAP proxy that supports the Hop-Limit option is involved in the loop.
A CoAP proxy that understands the Hop-Limit option
SHOULD be instructed, using a configuration parameter, to insert a Hop-Limit option when relaying a request that does not include the Hop-Limit option.
The initial Hop-Limit value should be configurable. If no initial value is explicitly provided, the default initial Hop-Limit value of 16
MUST be used. This value is chosen so that in the majority of cases, it is sufficiently large to guarantee that a CoAP request would not be dropped in networks when there were no loops, but not so large as to consume CoAP proxy resources when a loop does occur. The value is still configurable to accommodate unusual topologies. Lower values should be used with caution and only in networks where topologies are known by the CoAP client (or proxy) inserting the Hop-Limit option.
Because forwarding errors may occur if inadequate Hop-Limit values are used, proxies at the boundaries of an administrative domain
MAY be instructed to remove or rewrite the value of Hop-Limit carried in received requests (i.e., ignore the value of Hop-Limit received in a request). This modification should be done with caution in case proxy-forwarded traffic repeatedly crosses the administrative domain boundary in a loop, rendering ineffective the efficacy of loop detection through the Hop-Limit option.
Otherwise, a CoAP proxy that understands the Hop-Limit option
MUST decrement the value of the option by 1 prior to forwarding it. A CoAP proxy that understands the Hop-Limit option
MUST NOT use a stored 5.08 (Hop Limit Reached) error response unless the value of the Hop-Limit option in the presented request is smaller than or equal to the value of the Hop-Limit option in the request used to obtain the stored response. Otherwise, the CoAP proxy follows the behavior in
Section 5.6 of
RFC 7252.
-
Note: If a request with a given value of Hop-Limit failed to reach a server because the hop limit is exhausted, then the same failure will be observed if a smaller value of the Hop-Limit option is used instead.
CoAP requests
MUST NOT be forwarded if the Hop-Limit option is set to '0' after decrement. Requests that cannot be forwarded because of exhausted Hop-Limit
SHOULD be logged with a 5.08 (Hop Limit Reached) error response sent back to the CoAP peer. It is
RECOMMENDED that CoAP implementations support means to alert administrators about loop errors so that appropriate actions are undertaken.