[TLS] DTLS 1.3 ACK sorting, and when to clear the ACK buffer
David Benjamin <davidben@chromium.org> Sun, 03 November 2024 12:50 UTC
Return-Path: <davidben@google.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id AF603C16942A for <tls@ietfa.amsl.com>; Sun, 3 Nov 2024 04:50:22 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.402
X-Spam-Level:
X-Spam-Status: No, score=-9.402 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001, USER_IN_DEF_SPF_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XhkrvN4sNuJV for <tls@ietfa.amsl.com>; Sun, 3 Nov 2024 04:50:18 -0800 (PST)
Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 7251BC15108D for <tls@ietf.org>; Sun, 3 Nov 2024 04:50:18 -0800 (PST)
Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a99ebb390a5so804237866b.1 for <tls@ietf.org>; Sun, 03 Nov 2024 04:50:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730638216; x=1731243016; darn=ietf.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=oaHWttdVuY+hVxZNH389lkkYw0gNW5eKagwisOsXJdU=; b=gnTOeJhwTtOZB8U8pVb9I1q18vPIXWDMpHv+m+A9paaUQ/OUiQCCU/Aw8CGTIfwUyO MhCM6ve1dYuaEnM+d/ZbHhYD+Hq4dFWz2wNVDUvDtrEjum4InxGm62kxG73kkE4BeafU RkUlAcEPurnS7/ulB6cF+zOh6YZwb0aad010U=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730638216; x=1731243016; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=oaHWttdVuY+hVxZNH389lkkYw0gNW5eKagwisOsXJdU=; b=LbISvmWN0QIGS+fABSAKbRGsILc0Uwt1ofCCltvpGCnUdImAC8bFN+Hc77yMOG5+Ys efgCFSOHZbiBzai2RE7+4OYvmuS3HoNnG0C00RYflfkZL0qi8AC1fV8QbsWQBZYlKKhC i/fmXdp5wAuZzeDpkoatkfosC6nIca/m8Hivv4RlpHXF6Zns5bCTf1WNgIa9n9Cj28SK vi1r/A0LEDHVOMgq+3W1hqQXyKMd5E31DihsYV6mUAGUci1mwPT6KpduFaQwcL4hQ9f6 ocC3O1C1IXawXqlCGXXACs5s3N45uLSMMNhHkvePHm04Bi3jD9ORkbJ1mH1dkNi7DJeb Ckng==
X-Gm-Message-State: AOJu0YwzhaxMM649CXrZqsZOu9sMHlmmz2xib6348myYlQLI1ets7Wok VCQ2HV2Sb5nbyBlX7utftilOs5e40S5aXWidGtTdH5YyIDZCpDXLLrDy8oWZjrviPu8E/RUJSwM THozNtp9kR8Ful3ASKMNrgQMOv6nrVhQENgj2T5GynfZJFA7drw3Kuw==
X-Google-Smtp-Source: AGHT+IGGwrKaNZoCwQ3y1Ps+8nmWL4AkS9GpaGeRdorjeSpEzLTjjTq3kiIXNBv+feEoQz4Z6NBMjcWq23tpkIKBzGY=
X-Received: by 2002:a17:907:2d93:b0:a99:eef5:d360 with SMTP id a640c23a62f3a-a9e6538f74bmr853050766b.19.1730638215694; Sun, 03 Nov 2024 04:50:15 -0800 (PST)
MIME-Version: 1.0
From: David Benjamin <davidben@chromium.org>
Date: Sun, 03 Nov 2024 12:49:59 +0000
Message-ID: <CAF8qwaCKtjis=h6npApRAtT=AbHtDHO333zAXKPMowH_V5K8NQ@mail.gmail.com>
To: "<tls@ietf.org>" <tls@ietf.org>
Content-Type: multipart/alternative; boundary="0000000000001585490626019c30"
Message-ID-Hash: TK7GEMRHZPE5FNHLZGT3VFKE6MJWX7VF
X-Message-ID-Hash: TK7GEMRHZPE5FNHLZGT3VFKE6MJWX7VF
X-MailFrom: davidben@google.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-tls.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [TLS] DTLS 1.3 ACK sorting, and when to clear the ACK buffer
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/kjJnquJOVaWxu5hUCmNzB35eqY0>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tls>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Owner: <mailto:tls-owner@ietf.org>
List-Post: <mailto:tls@ietf.org>
List-Subscribe: <mailto:tls-join@ietf.org>
List-Unsubscribe: <mailto:tls-leave@ietf.org>
Hi all, In another thread, I was asked whether I thought I had gotten a complete list of issues, and I said it is hard to know when one is done realizing all the things one hasn't realized yet. Particularly in the process of implementing things. That seems to have been correct. Here's another topic for the list. :-) So, Section 7 says the ACK contains: > A list of the records containing handshake messages in the current flight which the endpoint has received and either processed or buffered, in numerically increasing order. https://www.rfc-editor.org/rfc/rfc9147.html#name-ack-message First, it is ambiguous what "numerically increasing order" means when there are two integers in a packet number, not one. But, more importantly, I'm not sure this matches what implementations do. I haven't tested carefully, so I may be wrong about this, but at a glance, I don't think either NSS or wolfSSL's DTLS 1.3 implementations (are there any other DTLS 1.3 implementations yet) do this? Keep in mind that appending records to the list as you receive them will *not* result in numerical order because packets may be reordered. If no one is following this rule anyway, perhaps we should just remove it? In particular, it seems a natural implementation will result in receive order, not numerical order. Implementations should bound their ACK buffers to avoid DoS, and are expected to preferentially ACK more recent records: > Implementations MAY acknowledge the records corresponding to each transmission of each flight or simply acknowledge the most recent one. In general, implementations SHOULD ACK as many received packets as can fit into the ACK record, as this provides the most complete information and thus reduces the chance of spurious retransmission; if space is limited, implementations SHOULD favor including records which have not yet been acknowledged. Given that, the natural implementation is some kind of bounded MRU queue of records, where old ones fall off the end. (I'm planning to use a ring buffer for our implementation.) To get numerical order, you'd need to re-sort when sending an ACK. That is not hard, but it's unclear to me what's the point. Next, the spec's guidance on when to clear the ACK buffer seems odd to me. Section 7 also says: > During the handshake, ACKs only cover the current outstanding flight (this is possible because DTLS is generally a lock-step protocol). In particular, receiving a message from a handshake flight implicitly acknowledges all messages from the previous flight(s). Accordingly, an ACK from the server would not cover both the ClientHello and the client's Certificate message, because the ClientHello and client Certificate are in different flights. Implementations can accomplish this by clearing their ACK list upon receiving the start of the next flight. The claim that clearing this ACK list accomplishes this is not true, for several reasons: First, there's nothing stopping you from receiving a (redundant) portion of the previous flight while you're receiving the new one. You'll notice all the sequence numbers are old and ignore them when processing, but that still keeps the record eligible for an ACK. Moreover, it's still important ACK to old fragments. When the old fragment is in the *current* flight, the peer may have lost an earlier ACK and not realize they can stop retransmitting. It's only old fragments in *previous* flights that are unnecessary to ACK, but the specification does not suggest to distinguish them. (Distinguishing them would require extra state in the record layer to store a low watermark for the flight, and that seems a waste. There's no real harm in adding that record to the ACK buffer.) Next, packets can be reordered. You might receive not the start of the next flight, but the middle of the next flight. In general, any DTLS record layer rule keyed on the start of a flight is suspect because of packet reordering. But actually I'm not sure if the spirit of this rule is correct at all. If the peer sent flight N-1, you sent N, and now you're in the middle of receiving flight N+1, you can stop ACKing flight N-1 as soon as you start *sending* N. You don't need to wait to receive N+1. *Every* fragment of N implicitly ACKs all of N-1, so as soon as you're ready to send any part of N, you may as well send that instead of ACKing individual records because then you also make progress in the connection. The spec instead says to wait until receiving part of N+1, which seems later than needed and may not even exist. (Neither version achieves the stated goal in the spec. The stated goal seems to require tracking extra state.) With all that said, it seems odd to be clearing the ACK buffer at all. I've gathered the reason to ACK by record number instead of message ranges (and thus require the implementation keep around some state) was so that RTT measurements could work despite retransmits. Is that right? But if the happy path doesn't ACK most records in the first place, you won't actually get an estimate out of it. David
- [TLS] DTLS 1.3 ACK sorting, and when to clear the… David Benjamin
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… Ilari Liusvaara
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… David Benjamin
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… Ilari Liusvaara
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… David Benjamin
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… Ilari Liusvaara
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… David Benjamin
- [TLS] Re: DTLS 1.3 ACK sorting, and when to clear… Ilari Liusvaara