Re: [core] [Technical Errata Reported] RFC7252 (5429)

Marian Buschsieweke <marian.buschsieweke@ovgu.de> Thu, 19 July 2018 20:02 UTC

Return-Path: <marian.buschsieweke@ovgu.de>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 947F2130DC6 for <core@ietfa.amsl.com>; Thu, 19 Jul 2018 13:02:01 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.201
X-Spam-Level:
X-Spam-Status: No, score=-4.201 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6zMayK-kiawr for <core@ietfa.amsl.com>; Thu, 19 Jul 2018 13:01:56 -0700 (PDT)
Received: from mail.ovgu.de (mail.ovgu.de [141.44.1.66]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 32C27130DC9 for <core@ietf.org>; Thu, 19 Jul 2018 13:01:54 -0700 (PDT)
Received: from mail.ovgu.de (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id A67FE40065; Thu, 19 Jul 2018 22:01:52 +0200 (CEST)
Received: from faultier2go (x4db3412b.dyn.telefonica.de [77.179.65.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.ovgu.de (Postfix) with ESMTPSA id 663924005F; Thu, 19 Jul 2018 22:01:51 +0200 (CEST)
Date: Thu, 19 Jul 2018 22:01:47 +0200
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
To: Christian Amsüss <christian@amsuess.com>
Cc: RFC Errata System <rfc-editor@rfc-editor.org>, ben@nostrum.com, aamelnikov@fastmail.fm, adam@nostrum.com, jaime.jimenez@ericsson.com, core@ietf.org, "Prof. Dr. Mesut Güneş" <mesut.guenes@ovgu.de>
Message-ID: <20180719220147.305db3cd@faultier2go>
In-Reply-To: <20180719160221.GB22079@hephaistos.amsuess.com>
References: <20180718144754.8CFA2B810BB@rfc-editor.org> <20180719160221.GB22079@hephaistos.amsuess.com>
Organization: Otto-von-Guericke-Universität Magdeburg
X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-alpine-linux-musl)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg="pgp-sha256"; boundary="Sig_/rgipNpyKMBS=uEQ69+rV9/C"; protocol="application/pgp-signature"
X-PMX-Version: 6.4.4.2767743, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2018.7.19.195717, AntiVirus-Engine: 5.50.0, AntiVirus-Data: 2018.7.19.5500001
X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, INVALID_MSGID_NO_FQDN 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, URI_WITH_PATH_ONLY 0, __ANY_URI 0, __ATTACHMENT_SIZE_0_10K 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __DQ_NEG_HEUR 0, __DQ_NEG_IP 0, __FORWARDED_MSG 0, __FROM_DOMAIN_IN_ANY_CC1 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_ATTACHMENT 0, __HAS_ATTACHMENT2 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __IN_REP_TO 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_TEXT_P2 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_NEGATE 0, __SUBJ_REPLY 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_IN_BODY 0, __URI_NOT_IMG 0, __URI_NS , __URI_WITH_PATH 0'
X-PMX-consideredAsSpam: no
Archived-At: <https://mailarchive.ietf.org/arch/msg/core/pMOWf8ocMTpa7Sc3NxJ6HgYM3uk>
Subject: Re: [core] [Technical Errata Reported] RFC7252 (5429)
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.27
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 19 Jul 2018 20:05:07 -0000

Dear Christian,

thanks for the fast reply.

> The memory requirements may have their point, but I think that this
> change would be far too severe for an erratum. If servers started
> relying on this change, that would easily invalidate duplicate message
> detection with existing implementations that use a single increasing
> message ID counter for all their peers.

The suggested change does not make it mandatory to have more than one counter.
The only mandatory change would be to actually use counters (one or more)
at all and to increment them for generating a new Message ID. It is
suggested to use more than one counter if a node is communicating with many
nodes at the same time, as it SHOULD keep jumps in Message IDs less than or
equal to 16. With messages coming in out of order or being lost a server still
expects jumps to be potentially bigger. But it is extremely likely that
Message IDs will remain in a range of lets say 64 consecutively numbers
(wrapping around at 65535). As a result, only the number of the lowest
expected Message ID needs to be stored and a 64 bit bitmask can be used to
store which Messages IDs have so far been used. This "window" can be moved
upwards as needed and any Message ID below that "window" is almost certainly a
duplicate. (I can provide more details how an efficient implementation could
look like and how also the time can be tracked efficiently regarding memory and
computational requirements - but I believe that might not be relevant for the
discussion.)

As far as I know, no CoAP implementation that is actively used employs a
different strategy than using counter(s) and increments it/them. If that is
true, it wouldn't hurt to make that behavior mandatory.

> That aside, I'm not sure the overhead estimations work that way.
> Duplicate message detection not only means that the message ID and the
> timestamp must be stored (your 4 bytes), but also the often much larger
> response message.

This is only partly true. With NSTART = 1 at most one request is outstanding. As
a result, at most one response needs to be cached per client - a client would
not send a new request without having the last response received or no longer
expecting to receive the response. The required memory for a single response is
usually much less than the 1 KiB for duplicate detection.

> Only non-idempotent (POST; which most applications will try to avoid)
> requests actually need the duplicate detection

In a scenario with many simultaneous clients this might not be true. E.g. if
Client A turns smart light on and Client B turns it off (e.g. "PUT /light on"
and "PUT /light off"), both requests would be idempotent. The expected result
would be that on requests comes in first - let's say the one of client A. So
the light turns first on and than off. But with many duplicates and no
duplicate detection, the light would be constantly switching on and off.

Kind regards,
Marian

-------------------------------------------------------------
M.Sc. Marian Buschsieweke
Dept. Communication and Networked Systems (ComSys)
Institute for Intelligent Cooperating Systems (IKS)
Otto-von-Guericke-University of Magdeburg
Universitätsplatz 2, Building 29, Room 314
39106 Magdeburg
Germany

http://www.comsys.ovgu.de/Team/Marian+Buschsieweke.html
Tel.: +49 - 391 - 67 - 52673
Fax:  +49 - 391 - 67 - 41161

-------------------------------------------------------------

On Thu, 19 Jul 2018 18:02:22 +0200
Christian Amsüss <christian@amsuess.com> wrote:

> Hello Marian, hello CoRE WG,
> 
> (CC list stripped expecting that the authors are subscribed to CoRE)
> 
> On Wed, Jul 18, 2018 at 07:47:54AM -0700, RFC Errata System wrote:
> > [...] Message IDs of subsequence messages send to the
> > same endpoint within EXCHANGE_LIFETIME MUST be strictly ascending
> > (wrapping around at a value of 65535).  Additionally, two
> > subsequently send Message IDs to the same endpoint SHOULD have a
> > difference of at most 16.
> > [...]
> > 
> > Notes
> > -----
> > Without any restrictions on how Message IDs are generated, an
> > implementation of CoAP duplication detection must be prepared to
> > receive a random sequence of Message IDs.
> >
> > One simple implementation strategy would be to store the received
> > Message IDs along with a timestamp when they were received.
> >
> > If a 16 bit time stamp would be used, 4 Bytes per tracked Message ID
> > would be required.
> >
> > If additionaly a CoAP server expects requests to be received at a rate
> > of 1 message per second, at least 247 * 4 Byte or approximately 1 KiB
> > have to be allocated per client.
> >
> > A class 1 (see RFC 7228 Section 3) server could handle at most 10
> > clients in parallel, if anything apart duplicate detection could be
> > implemented without using any memory at all.
> > 
> > If instead Message IDs have to be generated by incrementing a (global
> > or per endpoint/network prefix/...) counter variable, duplicate
> > detection can be implemented in a time and memory efficient way
> > without limiting the rate of the message exchange between to nodes.
> 
> The memory requirements may have their point, but I think that this
> change would be far too severe for an erratum. If servers started
> relying on this change, that would easily invalidate duplicate message
> detection with existing implementations that use a single increasing
> message ID counter for all their peers.
> 
> That aside, I'm not sure the overhead estimations work that way.
> Duplicate message detection not only means that the message ID and the
> timestamp must be stored (your 4 bytes), but also the often much larger
> response message. As that is costly and should be avoided, constrained
> implementations will look into whether they need to deduplicate at all:
> 
> * For safe or idempotent request messages, message deduplication can be
>   skipped. (You'd build the response to a GET once again when a
>   duplicate hits you rather than storing the old response. For PUT,
>   you'll set the resource's state anew, and if that's part of a race
>   condition, so would a delayed package have been).
> 
>   Even some cases of POST can be treated like that (the application
>   would need to let the library know that).
> 
> * For observe notifications, the recipient would silently disregard the
>   apparently out-of-order package.
> 
> * For non-observe non-piggy-backed responses, the client would RST the
>   duplicate response rather than ACK it, which is just as good. (There
>   are no "The client received the response" semantics to the ACK).
> 
> Constrained implementations should avoid keeping MIDs and timestamps
> around for any of those.
> 
> Only non-idempotent (POST; which most applications will try to avoid)
> requests actually need the duplicate detection -- and then, there is
> also a response message to store, and then the overhead of actually
> storing the MID becomes far less significant.
> 
> 
> I'd be happy to be shown wrong, so please let's have the discussion if I
> am, but this is not something that should easily go into the errata.
> 
> Best regards
> Christian
>