Re: [tcpm] RFC 5925 SNE algorithm concern

Joseph Touch <touch@strayalpha.com> Wed, 06 May 2020 19:36 UTC

Return-Path: <touch@strayalpha.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 DAD363A0AC1 for <tcpm@ietfa.amsl.com>; Wed, 6 May 2020 12:36:29 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.318
X-Spam-Level:
X-Spam-Status: No, score=-1.318 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=strayalpha.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 3OhR0l5JjMnL for <tcpm@ietfa.amsl.com>; Wed, 6 May 2020 12:36:27 -0700 (PDT)
Received: from server217-3.web-hosting.com (server217-3.web-hosting.com [198.54.115.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id CFFF03A0ABC for <tcpm@ietf.org>; Wed, 6 May 2020 12:36:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=strayalpha.com; s=default; h=References:To:In-Reply-To:Subject:Date: Mime-Version:Content-Type:Message-Id:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7tfhCUBXB+Tc4CDLWMIUIIH/J0BOd1HSVPnYwB4Kvw4=; b=nRTGK4tIgjnNZIuu1zoLTY3Vk BSxApLNZ0wisMjk0LSKSsBImaWJRPVkWNmUqo8iSJdOgs6CrzHBQ7Yt2N2aIF2DtQT+/15gRUtURk b6eGxxfNkX5zcq366KFD4nKSjX42MrLCsNZl2f+n9dnE5QYyAFHcpdpEYOxSRF4k+mgAgKcnK4Geu 6hittpYNlpMuo3E9rJt9h7XBMj3HdMgVfKmEFrPVoz4XG+HOX3CIK1dGJaqcd58u0Z90aVfS7Fq6y svCwOvW8VxRBjC7f9zPYsFDGqvKrE+8cLJCqv+njJAbVot2MFZ7o8omtXdp1AI7ZQx+c2J3KgNWSg uiqSK6iQQ==;
Received: from cpe-172-250-225-198.socal.res.rr.com ([172.250.225.198]:61343 helo=[192.168.1.14]) by server217.web-hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from <touch@strayalpha.com>) id 1jWPqB-001XhO-0F; Wed, 06 May 2020 15:36:27 -0400
From: Joseph Touch <touch@strayalpha.com>
Message-Id: <4E2DD376-438F-416E-9D1C-0934F517E2C2@strayalpha.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_A7C2B710-EF89-40DF-9510-AD09176A1501"
Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\))
Date: Wed, 06 May 2020 12:36:22 -0700
In-Reply-To: <85AAF68F-DB45-475C-996C-8F99EF66D198@strayalpha.com>
To: tcpm IETF list <tcpm@ietf.org>
References: <CACS3ZpBLAO2=O6Vf2Vx766qAGqmY2yD_yiLag-K7C3sYFjH9hw@mail.gmail.com> <EAE578C4-4C60-429A-9826-821B3075DA08@strayalpha.com> <CACS3ZpCjWb2+-v8MCjRJvMCARZ1YDLAr5HyRUTSTteMefu76qQ@mail.gmail.com> <CACS3ZpC3z-D8C=g90vuz-1n-w4oX8y2vOzJWrhouNqnKeuZ42w@mail.gmail.com> <26C2355F-AAF8-405B-BA38-8E7F50013D27@strayalpha.com> <85AAF68F-DB45-475C-996C-8F99EF66D198@strayalpha.com>
X-Mailer: Apple Mail (2.3608.60.0.2.5)
X-OutGoing-Spam-Status: No, score=-1.0
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - server217.web-hosting.com
X-AntiAbuse: Original Domain - ietf.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - strayalpha.com
X-Get-Message-Sender-Via: server217.web-hosting.com: authenticated_id: touch@strayalpha.com
X-Authenticated-Sender: server217.web-hosting.com: touch@strayalpha.com
X-Source:
X-Source-Args:
X-Source-Dir:
X-From-Rewrite: unmodified, already matched
Archived-At: <https://mailarchive.ietf.org/arch/msg/tcpm/7yf2nmcbGTmKVbfWzKQvB6YMHwA>
Subject: Re: [tcpm] RFC 5925 SNE algorithm concern
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: Wed, 06 May 2020 19:36:31 -0000

Here’s a full version, with everything including initialization and definitions. 

// compute the distance from x to y assuming they are in the same SNE
#define DIST(x,y) (((x)<(y))?((y)-(x)):((x)-(y)))
#define HALF      (0x80000000)              // shorthand used in the code below

// variables, with inits where required
unsigned long RCV_SNE = 0;                  // high-watermark SNE, init per RFC5925
int           RCV_SNE_FLAG = 1;             // set during first half of rollover
unsigned long RCV_PREV_SEQ;                 // high-watermark SEQ, init by ISN
unsigned long SEG_SEQ;                      // input - received SEQ
unsigned long SNE;                          // output - SNE corresponding to received SEQ

if (SYN == 1) {                             // SYN or SYN-ACK initialization
  RCV_PREV_SEQ = RECV_ISN;
}                                           // after SYN or SYN-ACK
SNE = RCV_SNE;                              // use current SNE (as default)
if (DIST(SEG_SEQ,RCV_PREV_SEQ) < HALF) {    // both in same SNE range?
  if ((SEG_SEQ >= HALF) 
      && (RCV_PREV_SEQ < HALF)) {           // jumps fwd over N/2?
    RCV_SNE_FLAG = 0;                       // reset wrap increment flag
  }
  RCV_PREV_SEQ = MAX(SEG_SEQ,RCV_PREV_SEQ); // move prev forward if needed
} else {                                    // both in diff SNE ranges
  if (SEG_SEQ < HALF) {                     // jumps forward over zero?
    RCV_PREV_SEQ = SEG_SEQ;                 // update prev
    if (RCV_SNE_FLAG == 0) {.               // first jump over zero? (wrap)
      RCV_SNE_FLAG = 1;                     // set flag so we increment once
      RCV_SNE = RCV_SNE + 1;                // increment window
      SNE = RCV_SNE;                        // use updated SNE value
    }
  } else {                                  // jump backward over zero
    SNE = RCV_SNE - 1;                      // use pre-rollover SNE value
  }
}