[tcpm] meaning of "idle" for TCP Keep-Alives (was: 793bis ready to go?)

Neal Cardwell <ncardwell@google.com> Sat, 13 February 2021 15:12 UTC

Return-Path: <ncardwell@google.com>
X-Original-To: tcpm@ietfa.amsl.com
Delivered-To: tcpm@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 285E43A0B44 for <tcpm@ietfa.amsl.com>; Sat, 13 Feb 2021 07:12:50 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -17.599
X-Spam-Level:
X-Spam-Status: No, score=-17.599 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=google.com
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 4TBaycBP9nOG for <tcpm@ietfa.amsl.com>; Sat, 13 Feb 2021 07:12:48 -0800 (PST)
Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 640F53A0B20 for <tcpm@ietf.org>; Sat, 13 Feb 2021 07:12:48 -0800 (PST)
Received: by mail-vs1-xe2b.google.com with SMTP id a11so1178015vsm.7 for <tcpm@ietf.org>; Sat, 13 Feb 2021 07:12:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mr/qjiYuLZLCjq/PlswHrICThn/yVf+N7kYLPca1frY=; b=vG/9s/C1XZwR0mIqbhLwUkTbb/fjq0JpA6AAAbo0Tpes74tE2Gv1Qv/f/KU+nbWkNo ov3jeS71afqaLBIk6DCe3B2wT5brvuv6ZLA8NmGjNOlqQOUnbdnjD6QQC0DSSxeEmtwu CXyYNTjPqHSCEyDMfl984i+GJvJT/lvkWlDkeH5Rp7ddelXpFh515bBYd29mk/Wjq1ba USNpnY6U6qjbD0aOV7N/UjVZ9a4EpU3DyMPVnUMkQ6SGq82hDOPVHaKBM0hG2D+LHdAm ZEAZUxr/b+QZ0AIs7C5Tq3J6N8XIYdetsbrRgRjQtKT7Qbm9gymVrYdGbYOuHnDZxWKz DAEw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mr/qjiYuLZLCjq/PlswHrICThn/yVf+N7kYLPca1frY=; b=Yl6SHS79SpRTAEarimBon9yfK+3OQdPvd1Q71whYw9mW32/gKs6ngmXEijg4Tc3O0p LdYgo1TLquoz3VhWD+VAE+91f8DyUbv4jzn+pCuyHmAAmNRLPEof5MtTz9BFPzMgHt+0 3JkGjVkfhIJFcdNONjuX0Hcqbrll47cqdv0jrRP9cx18OcDHPc25GkEBaWmf//W7Ojy4 BESuEeQT31VlPOxN7/gfnhux/3Ve5Kv8iwY5R9zlOA+ZquJwUgfS1oByPu7SyR7g/eFB X7jn1PTvpTi8APeRvycTfwePdb+hhE/7vrSD9MUMXqg0t9K00BbDxUI6ejbOIOBoM0Uo 9X0g==
X-Gm-Message-State: AOAM53156mpPb1oSmdrDz6DaJdIuWYLTvIXuxbjkwvHwPwAXVDrcaT1L hmGiR9bXCffkU7D/3+UiXBnuMoVHLLEJYqCfrnO8vw==
X-Google-Smtp-Source: ABdhPJw6Qe35HtVLokPXZMWdH2w8EtektLZ6X8McxBUeLK7p4E9k7cd5dNj1P9wTcUw4yV2lg/VlxgRbe2N0sydx3Sg=
X-Received: by 2002:a05:6102:833:: with SMTP id k19mr4734212vsb.16.1613229165403; Sat, 13 Feb 2021 07:12:45 -0800 (PST)
MIME-Version: 1.0
References: <cd600644350847ef8415d21588d1e912@hs-esslingen.de> <CAK6E8=fs_EaMpAEmpV=7_ZwmtugN=1rnuxRjfY4zPxEiyp8NgA@mail.gmail.com> <CADVnQym-W-KmR8ZN3sxSqyTBptU_tOm=u844b6-5xLRbmYtdiw@mail.gmail.com> <6D674614-847D-4600-9DE5-7FFD29043C7F@lurchi.franken.de>
In-Reply-To: <6D674614-847D-4600-9DE5-7FFD29043C7F@lurchi.franken.de>
From: Neal Cardwell <ncardwell@google.com>
Date: Sat, 13 Feb 2021 10:12:28 -0500
Message-ID: <CADVnQykUeU1oO16Qq=rVk=6SH6RZDXptmc=4x_1Y4uiPenjtGQ@mail.gmail.com>
To: Michael Tuexen <Michael.Tuexen@lurchi.franken.de>
Cc: Yuchung Cheng <ycheng@google.com>, tcpm IETF list <tcpm@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000592ba505bb392f92"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tcpm/KxcEsLtDuDNhcP8UjbyPkJqpzsE>
Subject: [tcpm] meaning of "idle" for TCP Keep-Alives (was: 793bis ready to go?)
X-BeenThere: tcpm@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: TCP Maintenance and Minor Extensions Working Group <tcpm.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tcpm>, <mailto:tcpm-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tcpm/>
List-Post: <mailto:tcpm@ietf.org>
List-Help: <mailto:tcpm-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tcpm>, <mailto:tcpm-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 13 Feb 2021 15:12:50 -0000

On Fri, Feb 12, 2021 at 10:19 AM Michael Tuexen <
Michael.Tuexen@lurchi.franken.de> wrote:

> > On 11. Feb 2021, at 06:22, Neal Cardwell <ncardwell=
> 40google.com@dmarc.ietf.org> wrote:
> >
> > The wording in the Congestion Control section looks great to me.
> >
> > > Minor:
> https://tools.ietf.org/html/draft-ietf-tcpm-rfc793bis-20#section-3.7.4
> >
> > I agree with Yuchung that it would be nice to clarify what is meant by
> "idle" connections (in the pre-existing text), with respect to keep-alives.
> It seems at least the historical behavior for two of the major
> implementations out there interpret this in different ways, and this has
> caused some confusion in the developer community about what semantics to
> expect from TCP keep-alives. I guess the rfc793bis-20 draft does have some
> nice new text (that does not seem to be in RFC793 or RFC1122) that seems to
> shed some light on this:
> >
> >    Keep-alive packets MUST only be sent when no sent data is
> >    outstanding, and no data or acknowledgement packets have been
> >    received for the connection within an interval (MUST-26).
> >
> >
> > That sentence helps quite a bit. It seems to correspond to the last 20
> years of Linux TCP keep-alive behavior, but not the BSD behavior (at least
> BSD TCP as documented in Stevens volume 2; I have not checked more recent
> BSD kernels).
> Can elaborate what Linux behaviour you are referring to an what BSD
> behaviour you are referring to?


BSD: My reading of the behavior in older BSD releases (BSD-4_2 [1983]
through BSD-4_4_Lite2 [1995], or Stevens volume 2 [1995]) is that a TCP
endpoint resets the keep-alive timer (tp->t_timer[TCPT_KEEP]) to its full
keep-alive interval upon receiving a packet, and then when the timer fires
it sends a keep-alive probe packet (case TCPT_KEEP in tcp_timers() in
tcp_timer.c). When that keep-alive timer fires it seems to send a
keep-alive packet irrespective of whether the TCP endpoint currently has
data outstanding in the network, or is sending ZWP packets.

Linux: Starting in Linux 2.3.41 in Jan 2000, and continuing through current
releases, the Linux TCP keep-alive timer code in tcp_keepalive_timer() has
two simple extra checks introduced:
  https://elixir.bootlin.com/linux/2.3.41/source/net/ipv4/tcp_timer.c#L729
The checks basically say that if the keep-alive timer goes off but the TCP
endpoint has data outstanding in the network (RTO timer is set), or
outgoing data queued and waiting for a non-zero receive window (ZWP timer
is set), then the code merely resets the keep-alive timer, and
short-circuits all the keep-alive processing that would send a keep-alive
probe packet or check to see if the connection should be torn down. This
behavior is similar to the rfc793bis-20 text,  "Keep-alive packets MUST
only be sent when no sent data is  outstanding", except that it also skips
sending a keep-alive when the sender is in the process of sending repeated
zero window probes (which would also serve to tell whether the remote
endpoint is reachable).

best,
neal