<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" docName="draft-ietf-tcpm-yang-tcp-09" number="9648" obsoletes="" updates="" ipr="trust200902" submissionType="IETF" consensus="true" xml:lang="en" tocInclude="true" symRefs="true" sortRefs="true" version="3">

  <front>
    <title abbrev="YANG Data Model for TCP">YANG Data Model for TCP
</title>    
    <seriesInfo name="RFC" value="9648"/>
    <author fullname="Michael Scharf" initials="M." surname="Scharf">
      <organization abbrev="Hochschule Esslingen">Hochschule Esslingen</organization>
      <address>
        <postal>
	  <street>University of Applied Sciences</street>	  
          <street>Kanalstr. 33</street>
          <code>73728</code>
          <city>Esslingen am Neckar</city>
          <country>Germany</country>
        </postal>
        <email>michael.scharf@hs-esslingen.de</email>
      </address>
    </author>

    <author fullname="Mahesh Jethanandani" initials="M."
            surname="Jethanandani">
      <organization>Kloud Services</organization>
      <address>
        <email>mjethanandani@gmail.com</email>
      </address>
    </author>

    <author fullname="Vishal Murgai" initials="V." surname="Murgai">
      <organization>F5, Inc.</organization>
      <address>
        <email>vmurgai@gmail.com</email>
      </address>
    </author>

    <date year="2024" month="October"/>

    <area>WIT</area>
    <workgroup>TCPM</workgroup>

    <keyword>YANG</keyword>

    <abstract>
      <t>This document specifies a minimal YANG data model for TCP on
      devices that are configured and managed by network management
      protocols. The YANG data model defines a container for all TCP
      connections and groupings of authentication
      parameters that can be imported and used in TCP implementations
      or by other models that need to configure TCP parameters. The
      model also includes basic TCP statistics. The model is compliant
      with Network Management Datastore Architecture (NMDA) (RFC
      8342).</t>
    </abstract>
  </front>

  <middle>
    <section>
      <name>Introduction</name>
      <t>The Transmission Control
      Protocol (TCP) <xref target="RFC9293"/> is used by many applications in the Internet,
      including control and management protocols. As such, TCP is
      implemented on network elements that can be configured and managed
      via network management protocols such as
      Network Configuration Protocol (NETCONF) <xref target="RFC6241"/> or
      RESTCONF <xref
      target="RFC8040"/>.</t>

      <t>This document specifies a minimal YANG
      1.1 <xref target="RFC7950"/> data model for configuring and managing TCP on network
      elements that support YANG, a TCP connection table,
      a TCP listener table containing
      information about a particular TCP listener, and an augmentation
      of the YANG data model for key
      chains <xref target="RFC8177"/> to support authentication. The YANG module specified
      in this document is compliant with
      Network Management Datastore Architecture (NMDA) <xref target="RFC8342"/>.</t>

      <t>The YANG module has a narrow scope and focuses on a subset of
      fundamental TCP functions and basic statistics. It defines a
      container for a list of TCP connections that includes definitions from
      "YANG Groupings
      for TCP Clients and TCP Servers" <xref target="RFC9643"/>. The model adheres to
      the recommendation in "BGP/MPLS IP Virtual
      Private Networks (VPNs)" <xref target="RFC4364"/>. Therefore, it allows enabling of TCP Authentication Option (TCP-AO) <xref
      target="RFC5925"/> and accommodates the installed
      base that makes use of MD5. The module can be augmented or
      updated to address more advanced or implementation-specific TCP
      features in the future.</t>
      <t>This specification does not deprecate the Management Information Base (MIB) for the Transmission
      Control Protocol (TCP) <xref
      target="RFC4022"/>. The basic statistics defined in this
      document follow the model of the TCP MIB. A TCP extended
      statistics MIB <xref target="RFC4898"/> is also available, but this document does
      not cover such extended statistics. The YANG module also omits some
      selected parameters included in TCP MIB, most notably Retransmission
      Timeout (RTO) configuration and a maximum connection limit. This is a
      conscious decision as these parameters hardly matter in a
      state-of-the-art TCP implementation. It would also be possible to
      translate a MIB into a YANG module, for instance, using "Translation of Structure of Management Information
      Version 2 (SMIv2) MIB Modules to YANG Modules" <xref
      target="RFC6643"/>. However, this
      approach is not used in this document, because a translated model would
      not be up-to-date.</t>

      <t>There are other existing TCP-related YANG data models, which are
      orthogonal to this specification. Examples are:</t>

      <ul spacing="normal">
          <li>TCP header attributes are modeled in other security-related
          models, such as those described in "YANG Data Model for Network
          Access Control Lists (ACLs)" <xref target="RFC8519"/>, "Distributed
          Denial-of-Service Open Threat Signaling (DOTS) Data Channel
          Specification" <xref target="RFC8783"/>, "I2NSF Capability
          YANG Data Model"
          <xref target="I-D.ietf-i2nsf-capability-data-model"/>, or
	  "I2NSF Network 
          Security Function-Facing Interface YANG Data Model"
          <xref target="I-D.ietf-i2nsf-nsf-facing-interface-dm"/>.</li>

          <li>TCP-related configuration of a NAT (e.g., NAT44, NAT64, or
          Destination NAT) is defined in "A YANG
          Module for Network Address Translation (NAT) and Network Prefix
          Translation (NPT)" <xref target="RFC8512"/> and "A YANG Data
          Model for Dual-Stack Lite (DS-Lite)" <xref target="RFC8513"/>.</li>

          <li>TCP-AO and TCP MD5 configuration for Layer 3 VPNs is modeled in
          "A YANG Network Data Model for Layer 3 VPNs" <xref target="RFC9182"/>.
	  This model assumes that TCP-AO-specific parameters
          are preconfigured in addition to the key chain parameters.</li>
      </ul>
      <section>
	<name>Conventions</name>
	  <t>Various examples in this document use the XML
   <xref target="W3C.REC-xml-20081126"/> encoding. Other encodings, such as JSON <xref target="RFC8259"/>,
  could alternatively be used.</t>
  <t>Various examples in this document contain long lines that may be folded,
  as described in <xref target="RFC8792"/>.</t>
      </section>
    </section>

    <section>
      <name>Requirements Language</name>
        <t>
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
    NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>
    </section>

    <section>
      <name>YANG Module Overview</name>
      <section>
	<name>Scope</name>
        <t>TCP is implemented on different system architectures. As a
        result, there are many different and often
        implementation-specific ways to configure parameters of the
        TCP engine. In addition, in many TCP/IP stacks, configuration
        exists for different scopes:</t>

        <ul spacing="normal">
            <li>System-wide configuration: Many TCP implementations have
            configuration parameters that affect all TCP
            connections from or to this TCP stack. Typical examples include
            enabling or disabling optional protocol features. For instance,
            many implementations can turn on or off use of window scaling 
            (defined in "Transmission Control Protocol (TCP)" <xref target="RFC9293"/>)
	    for all TCP connections.</li>

            <li>Interface configuration: It can be useful to use
            different TCP parameters on different interfaces, e.g.,
            different device ports or IP interfaces. In that case, TCP
            parameters can be part of the interface
            configuration. Typical examples are the Maximum Segment
            Size (MSS) or configuration related to hardware
            offloading.</li>

            <li>Connection parameters: Many implementations have means
            to influence the behavior of each TCP connection, e.g., on
            the programming interface used by applications. Typical
            examples are socket options in the socket API, such as
            disabling the Nagle algorithm (as described in "Transmission Control Protocol (TCP)" <xref
            target="RFC9293"/>)
	    by TCP_NODELAY.  If an application
            uses such an interface, it is possible that the
            configuration of the application or application protocol
            includes TCP-related parameters. An example is the BGP YANG module for service
            provider networks <xref
            target="I-D.ietf-idr-bgp-model"/>.</li>

            <li>Application preferences: Setting of TCP parameters
            can also be part of application preferences, templates,
            or profiles. An example would be the preferences defined
            in "An Abstract
            Application Layer Interface to Transport Services" <xref target="I-D.ietf-taps-interface"/>.</li>
          </ul>

        <t>As a result, there is no ground truth for setting certain TCP
        parameters, and generally different TCP implementations have used
        different modeling approaches. For instance, one implementation may
        define a given configuration parameter globally, while another one
        uses per-interface settings, and both approaches work well for the
        corresponding use cases. Also, different systems may use different
        default values. In addition, TCP can be implemented in different ways
        and design choices by the protocol engine often affect configuration
        options.</t>

        <t>Nonetheless, a number of TCP stack parameters require configuration
        by YANG data models. This document therefore defines a minimal YANG data model
        with fundamental parameters. An important use case is the TCP
        configuration on network elements, such as routers, which often use YANG
        data models. The model therefore specifies TCP parameters that are
        important on such TCP stacks.</t>

        <t>In particular, this applies to the support of the TCP Authentication Option (TCP-AO) <xref
        target="RFC5925"/> and the corresponding
        cryptographic algorithms <xref target="RFC5926"/>.
        TCP-AO is
        used on routers to secure routing protocols such as BGP. In that case,
        a YANG data model for TCP-AO configuration is required. The model defined
        in this document includes the required parameters for TCP-AO
        configuration, such as the values of SendID and RecvID. The
        key chain for TCP-AO can be modeled by the YANG
        data model for key chains <xref target="RFC8177"/>. The groupings defined in this document
        can be imported and used as part of such a preconfiguration.</t>

        <t>Given an installed base, the model also allows enabling of the
        legacy TCP MD5 <xref target="RFC2385"/> signature option.
        The TCP MD5 signature option was obsoleted by TCP-AO in 2010. If current
        implementations require TCP authentication, it is <bcp14>RECOMMENDED</bcp14> to use 
        TCP-AO <xref target="RFC5925"/>.</t>

        <t>Similar to the TCP MIB <xref target="RFC4022"/>, this document
        also specifies basic statistics, a TCP connection list, and a TCP listener
        list.</t>

        <ul spacing="normal">
            <li>Statistics: Counters for the number of active/passive opens,
            sent and received TCP segments, errors, and possibly other detailed
            debugging information.</li>
            <li>TCP connection list: Access to status information for all TCP
            connections. Note that the connection table is modeled as a list
	    that is readable and writable, even though a connection cannot be
	    created by adding entries to the table. Similarly, deletion
	    of connections from this list is implementation-specific.</li>

            <li>TCP listener list: A list containing information about
            TCP listeners, i.e., applications willing to accept connections.</li>
          </ul>

        <t>This allows implementations of TCP
        MIB <xref target="RFC4022"/> to migrate to the YANG data model defined in this memo.
        Note that the TCP MIB does not include means to reset statistics, which
        are defined in this document. This is not a major addition, as a reset
        can simply be implemented by storing offset values for the counters.</t>

        <t>This version of the module does not model details of
        Multipath TCP <xref target="RFC8684"/>. This could be addressed
        in a later version of this document.</t>
      </section>

      <section>
	<name>Model Design</name>
        <t>The YANG data model defined in this document includes definitions from
        "YANG Groupings
        for TCP Clients and TCP Servers" <xref target="RFC9643"/>. Similar to that model, this
        specification defines YANG groupings. This allows reuse of these
        groupings in different YANG data models. It is intended that these
        groupings will be used either standalone or for TCP-based protocols as
        part of a stack of protocol-specific configuration models. An example
        could be the one described in "YANG
	Model for Border Gateway Protocol (BGP-4)" <xref target="I-D.ietf-idr-bgp-model"/>.</t>
      </section>

      <section>
	<name>Tree Diagram</name>
        <t>This section provides an abridged tree diagram for the YANG
        module defined in this document. Annotations used in the
        diagram are defined in "YANG Tree
        Diagrams" <xref target="RFC8340"/>. A complete tree diagram can be found in
        <xref target="comp-tree"/>.</t>

          <sourcecode type="yangtree"><![CDATA[
module: ietf-tcp
  +--rw tcp!
     +--rw connections
     |     ...
     +--ro tcp-listeners* [type address port]
     |     ...
     +--ro statistics {statistics}?
           ...

  augment /key-chain:key-chains/key-chain:key-chain/key-chain:key:
    +--rw authentication {authentication}?
       +--rw keychain?    key-chain:key-chain-ref
       +--rw (authentication)?
             ...
]]></sourcecode>
      </section>
    </section>

    <section>
      <name>TCP YANG Data Model</name>
      <t>This YANG module references "The TCP Authentication Option" <xref target="RFC5925"/>,  "Protection of BGP Sessions via the TCP MD5 Signature Option" <xref target="RFC2385"/>, and
      "Transmission Control
      Protocol (TCP)" <xref target="RFC9293"/>
      and imports "Common YANG Data Types" <xref target="RFC6991"/>, "Network Configuration Access Control
      Model" <xref target="RFC8341"/>, and "YANG Groupings for TCP Clients
      and TCP Servers" <xref target="RFC9643"/>.</t>
          <sourcecode name="ietf-tcp@2024-10-10.yang" type="yang" markers="true"><![CDATA[
module ietf-tcp {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-tcp";
  prefix tcp;

  import ietf-yang-types {
    prefix yang;
    reference
      "RFC 6991: Common YANG Data Types.";
  }
  import ietf-tcp-common {
    prefix tcpcmn;
    reference
      "RFC 9643: YANG Groupings for TCP Clients and TCP Servers.";
  }
  import ietf-inet-types {
    prefix inet;
    reference
      "RFC 6991: Common YANG Data Types.";
  }
  import ietf-netconf-acm {
    prefix nacm;
    reference
      "RFC 8341: Network Configuration Access Control Model.";
  }
  import ietf-key-chain {
    prefix key-chain;
    reference
      "RFC 8177: YANG Data Model for Key Chains.";
  }

  organization
    "IETF TCPM Working Group";

  contact
    "WG Web:   https://datatracker.ietf.org/wg/tcpm/about
     WG List:  TCPM WG <tcpm@ietf.org>

     Authors:  Michael Scharf <michael.scharf@hs-esslingen.de>
               Mahesh Jethanandani <mjethanandani@gmail.com>
               Vishal Murgai <vmurgai@gmail.com>";

  description
    "This module focuses on fundamental TCP functions and basic
     statistics.  The model can be augmented to address more advanced
     or implementation-specific TCP features.

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
     NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
     'MAY', and 'OPTIONAL' in this document are to be interpreted as
     described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
     they appear in all capitals, as shown here.
     
     Copyright (c) 2024 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject to
     the license terms contained in, the Revised BSD License set
     forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (https://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC 9648
     (https://www.rfc-editor.org/info/rfc9648); see the RFC itself
     for full legal notices.";

  revision 2024-10-10 {
    description
      "Initial version.";
    reference
      "RFC 9648: YANG Data Model for TCP.";
  }

  // Typedefs
  typedef mss {
    type uint16;
    description
      "Type definition for the Maximum Segment Size.";
  }

  // Features
  feature statistics {
    description
      "This implementation supports statistics reporting.";
  }

  feature authentication {
    description
      "This implementation supports authentication.";
  }

  // Identities
  identity aes-128 {
    base key-chain:crypto-algorithm;
    description
      "AES128 authentication algorithm used by TCP-AO.";
    reference
      "RFC 5926: Cryptographic Algorithms for the TCP
                 Authentication Option (TCP-AO).";
  }

  // TCP-AO Groupings

  grouping ao {
    leaf send-id {
      type uint8 {
        range "0..max";
      }
      description
        "The SendID is inserted as the KeyID of the TCP-AO option
         of outgoing segments.  In a consistent configuration, the
         SendID matches the RecvID at the other endpoint.";
      reference
        "RFC 5925: The TCP Authentication Option, Section 3.1.";
    }

    leaf recv-id {
      type uint8 {
        range "0..max";
      }
      description
        "The RecvID is matched against the TCP-AO KeyID of incoming
         segments.  In a consistent configuration, the RecvID matches
         the SendID at the other endpoint.";
      reference
        "RFC 5925: The TCP Authentication Option, Section 3.1.";
    }

    leaf include-tcp-options {
      type boolean;
      default "true";
      description
        "When set to true, TCP options are included in the message
         authentication code (MAC) calculation.";
      reference
        "RFC 5925: The TCP Authentication Option, Section 3.1.";
    }

    leaf accept-key-mismatch {
      type boolean;
      description
        "Accept, when set to true, TCP segments with a Master Key
         Tuple (MKT) that is not configured.";
      reference
        "RFC 5925: The TCP Authentication Option, Section 7.3.";
    }

    leaf r-next-key-id {
      type uint8;
      config false;
      description
        "A field indicating the Master Key Tuple (MKT) that is ready
         at the sender to be used to authenticate received segments,
         i.e., the desired 'receive next' key ID.";
      reference
        "RFC 5925: The TCP Authentication Option.";
    }

    description
      "Authentication Option (AO) for TCP.";
    reference
      "RFC 5925: The TCP Authentication Option.";
  }

  // TCP configuration

  container tcp {
    presence "The container for TCP configuration.";

    description
      "TCP container.";

    container connections {
      list connection {
        key "local-address remote-address local-port remote-port";

        leaf local-address {
          type inet:ip-address;
          description
            "Identifies the address that is used by the local
             endpoint for the connection and is one of the four
             elements that form the connection identifier.";
        }

        leaf remote-address {
          type inet:ip-address;
          description
            "Identifies the address that is used by the remote
             endpoint for the connection and is one of the four
             elements that form the connection identifier.";
        }

        leaf local-port {
          type inet:port-number;
          description
            "Identifies the local TCP port used for the connection
             and is one of the four elements that form the
             connection identifier.";
        }

        leaf remote-port {
          type inet:port-number;
          description
            "Identifies the remote TCP port used for the connection
             and is one of the four elements that form the
             connection identifier.";
        }

        leaf mss {
          type mss;
          description
            "Maximum Segment Size (MSS) desired on this connection.
             Note that the 'effective send MSS' can be smaller than
             what is configured here.";
          reference
            "RFC 9293: Transmission Control Protocol (TCP).";
        }

        leaf pmtud {
          type boolean;
          default "false";
          description
            "Turns Path Maximum Transmission Unit Discovery (PMTUD)
             on (true) or off (false).";
          reference
            "RFC 9293: Transmission Control Protocol (TCP).";
        }

        uses tcpcmn:tcp-common-grouping;

        leaf state {
          type enumeration {
            enum closed {
              value 1;
              description
                "Connection is closed. Connections in this state
                 may not appear in this list.";
            }
            enum listen {
              value 2;
              description
                "Represents waiting for a connection request from any
                 remote TCP peer and port.";
            }
            enum syn-sent {
              value 3;
              description
                "Represents waiting for a matching connection request
                 after having sent a connection request.";
            }
            enum syn-received {
              value 4;
              description
                "Represents waiting for a confirming connection
                 request acknowledgment after having both received
                 and sent a connection request.";
            }
            enum established {
              value 5;
              description
                "Represents an open connection; data received can be
                 delivered to the user.  The normal state for the 
                 data transfer phase of the connection.";
            }
            enum fin-wait-1 {
              value 6;
              description
                "Represents waiting for a connection termination
                 request from the remote TCP peer or an
                 acknowledgment of the connection termination 
                 request previously sent.";
            }
            enum fin-wait-2 {
              value 7;
              description
                "Represents waiting for a connection termination
                 request from the remote TCP peer.";
            }
            enum close-wait {
              value 8;
              description
                "Represents waiting for a connection termination
                 request from the local user.";
            }
            enum last-ack {
              value 9;
              description
                "Represents waiting for an acknowledgment of the
                 connection termination request previously sent to
                 the remote TCP peer (this termination request sent
                 to the remote TCP peer already included an
                 acknowledgment of the termination request sent from
                 the remote TCP peer).";
            }
            enum closing {
              value 10;
              description
                "Represents waiting for a connection termination
                 request acknowledgment from the remote TCP peer.";
            }
            enum time-wait {
              value 11;
              description
                "Represents waiting for enough time to pass to be
                 sure the remote TCP peer received the 
                 acknowledgment of its connection termination 
                 request and to avoid new connections being impacted 
                 by delayed segments from previous connections.";
            }
          }
          config false;
          description
            "The state of this TCP connection.";
        }
        description
          "List of TCP connections with their parameters.

           The list is modeled as writable even though only some of
           the nodes are writable, e.g., keepalive.  Connections
           that are created and match this list SHOULD apply the
           writable parameters.  At the same time, implementations
           may not allow creation of new TCP connections simply by
           adding entries to the list.  Furthermore, the behavior
           upon removal is implementation-specific.  Implementations
           may not support closing or resetting a TCP connection
           upon an operation that removes the entry from the list.

           The operational state of this list SHOULD reflect
           connections that have configured but not created and
           connections that have been created.  Connections in the
           CLOSED state are not reflected on this list.";
      }
      description
        "A container of all TCP connections.";
    }

    list tcp-listeners {
      key "type address port";
      config false;

      description
        "A table containing information about a particular
         TCP listener.";

      leaf type {
        type inet:ip-version;
        description
          "The address type of address.  The value
           should be unspecified (0) if connection initiations
           to all local IP addresses are accepted.";
      }

      leaf address {
        type union {
          type inet:ip-address;
          type string {
            length "0";
          }
        }
        description
          "The local IP address for this TCP connection.

           The value of this node can be represented in three
           possible ways, depending on the characteristics of the
           listening application:

           1. For an application willing to accept both IPv4 and
              IPv6 datagrams, the value of this node must be
              ''h (a zero-length octet string), with the value
              of the corresponding 'type' object being
              unspecified (0).

           2. For an application willing to accept only IPv4 or
              IPv6 datagrams, the value of this node must be
              '0.0.0.0' or '::' respectively, with
              'type' representing the appropriate address type.

           3. For an application that is listening for data
              destined only to a specific IP address, the value
              of this node is the specific local address, with
              'type' representing the appropriate address type.";
      }

      leaf port {
        type inet:port-number;
        description
          "The local port number for this TCP connection.";
      }
    }

    container statistics {
      if-feature "statistics";
      config false;

      leaf active-opens {
        type yang:counter64;
        description
          "The number of times that TCP connections have made a
           direct transition to the SYN-SENT state from the CLOSED
           state.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf passive-opens {
        type yang:counter64;
        description
          "The number of times TCP connections have made a direct
           transition to the SYN-RCVD state from the LISTEN state.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf attempt-fails {
        type yang:counter64;
        description
          "The number of times that TCP connections have made a
           direct transition to the CLOSED state from either the
           SYN-SENT state or the SYN-RCVD state, plus the number of
           times that TCP connections have made a direct transition
           to the LISTEN state from the SYN-RCVD state.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf establish-resets {
        type yang:counter64;
        description
          "The number of times that TCP connections have made a
           direct transition to the CLOSED state from either the
           ESTABLISHED state or the CLOSE-WAIT state.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf currently-established {
        type yang:gauge32;
        description
          "The number of TCP connections for which the current state
           is either ESTABLISHED or CLOSE-WAIT.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf in-segments {
        type yang:counter64;
        description
          "The total number of TCP segments received, including those
           received in error.  This count includes TCP segments
           received on currently established connections.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf out-segments {
        type yang:counter64;
        description
          "The total number of TCP segments sent, including those on
           current connections but excluding those containing only
           retransmitted octets.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf retransmitted-segments {
        type yang:counter64;
        description
          "The total number of TCP segments retransmitted; that is,
           the number of TCP segments transmitted containing one or
           more previously transmitted octets.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf in-errors {
        type yang:counter64;
        description
          "The total number of TCP segments received in error
           (e.g., bad TCP checksums).";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf out-resets {
        type yang:counter64;
        description
          "The number of TCP segments sent containing the RST flag.";
        reference
          "RFC 9293: Transmission Control Protocol (TCP).";
      }

      leaf auth-failures {
        if-feature "authentication";
        type yang:counter64;
        description
          "The number of times that authentication has failed either
           with TCP-AO or MD5.";
      }

      action reset {
        nacm:default-deny-all;
        description
          "Reset statistics action command.";
        input {
          leaf reset-at {
            type yang:date-and-time;
            description
              "Time when the reset action needs to be
               executed.";
          }
        }
        output {
          leaf reset-finished-at {
            type yang:date-and-time;
            description
              "Time when the reset action command completed.";
          }
        }
      }
      description
        "Statistics across all connections.";
    }
  }

  augment "/key-chain:key-chains/key-chain:key-chain/key-chain:key" {
    description
      "Augmentation of the key-chain model to add TCP-AO and TCP-MD5
       authentication.";

    container authentication {
      if-feature "authentication";
      leaf keychain {
        type key-chain:key-chain-ref;
        description
          "Reference to the key chain that will be used by
           this model.  Applicable for TCP-AO and TCP-MD5
           only.";
        reference
          "RFC 8177: YANG Data Model for Key Chains.";
      }

      choice authentication {
        container ao {
          presence "Presence container for all TCP-AO related"
                 + " configuration";
          uses ao;
          description
            "Use TCP-AO to secure the connection.";
        }

        container md5 {
          presence "Presence container for all MD5 related" 
                 + " configuration";
          description
            "Use TCP-MD5 to secure the connection.  As the TCP MD5
             signature option is obsoleted by TCP-AO, it is
             RECOMMENDED to use TCP-AO instead.";
          reference
            "RFC 2385: Protection of BGP Sessions via the TCP MD5
                       Signature Option.";
        }
        description
          "Choice of TCP authentication.";
      }
      description
        "Authentication definitions for TCP configuration.
         This includes parameters such as how to secure the
         connection, which can be part of either the client
         or server.";
    }
  }
}
]]></sourcecode>
    </section>

    <section anchor="IANA">
      <name>IANA Considerations</name>
      <section>
	<name>The IETF XML Registry</name>
        <t>IANA has registered the following URI in the "ns" registry defined in the
        "IETF XML Registry" <xref target="RFC3688"/>.</t> 
<dl newline="false" spacing="compact">
  <dt>URI:</dt> <dd>urn:ietf:params:xml:ns:yang:ietf-tcp</dd>
  <dt>Registrant Contact:</dt> <dd>The IESG</dd>
  <dt>XML:</dt> <dd>N/A; the requested URI is an XML namespace.</dd>
</dl>
      </section>

      <section>
	<name>The YANG Module Names Registry</name>
        <t>IANA has registered the following in the
        "YANG Module Names" registry created by
        "YANG - A Data Modeling Language for
        the Network Configuration Protocol (NETCONF)" <xref target="RFC6020"/>.</t>
<dl newline="false" spacing="compact">
  <dt>Name:</dt>         <dd>ietf-tcp</dd>
  <dt>Namespace:</dt>    <dd>urn:ietf:params:xml:ns:yang:ietf-tcp</dd>
  <dt>Prefix:</dt>       <dd>tcp</dd>
  <dt>Reference:</dt>    <dd>RFC 9648</dd>
</dl>
        <t>This is not an IANA maintained module; however, the URI and other details of the module are maintained by IANA.</t>
      </section>
    </section>

    <section anchor="Security">
      <name>Security Considerations</name>
      <t>This section is modeled after the template defined in <xref target="RFC8407" sectionFormat="of" section="3.7.1"/>.</t>
      <t>The "ietf-tcp" YANG module defines a schema for data
      that is designed to be accessed via YANG-based management protocols, such as NETCONF <xref target="RFC6241"/> and RESTCONF <xref target="RFC8040"/>. These protocols have mandatory-to-implement secure transport layers (e.g., Secure Shell (SSH) <xref target="RFC4252"/>, TLS <xref target="RFC8446"/>, and QUIC <xref target="RFC9000"/>) and mandatory-to-implement mutual authentication.
</t>

      <t>The Network Configuration Access Control Model
      (NACM) <xref target="RFC8341"/> provides the means to restrict access for particular
      NETCONF or RESTCONF users to a preconfigured subset of all available
      NETCONF or RESTCONF protocol operations and content.</t>

      <t>There are a number of data nodes defined in this YANG module that are
      writable/creatable/deletable (i.e., "config true", which is the
      default). These data nodes may be considered sensitive or vulnerable in
      some network environments. Write operations (e.g., edit-config) to these
      data nodes without proper protection can have a negative effect on
      network operations. These are the subtrees and data nodes and their
      sensitivity/vulnerability:</t>
      <ul spacing="normal">
        <li>Common configuration included from
        NETCONF client
	and server models <xref target="RFC9643"/>. Unrestricted
        access to all the nodes, e.g., keepalive idle timer,
        can cause connections to fail or to timeout prematurely.</li>

        <li>Authentication configuration. Unrestricted access to the nodes under
        authentication configuration can prevent the use of authenticated
        communication and cause connection setups to fail. This can result
        in massive security vulnerabilities and service disruption for the
        traffic requiring authentication.</li>
      </ul>
      <t>Some of the readable data nodes in this YANG module may be considered
      sensitive or vulnerable in some network environments. It is thus
      important to control read access (e.g., via get, get-config, or
      notification) to these data nodes. These are the subtrees and data nodes
      and their sensitivity/vulnerability:</t>
      <ul spacing="normal">
          <li>Unrestricted access to connection information of the client or
          server can be used by a malicious user to launch an attack.</li>

          <li>Similarly, unrestricted access to statistics of the client or
          server can be used by a malicious user to exploit any
          vulnerabilities of the system.</li>
        </ul>
      <t>Some of the RPC operations in this YANG module may be considered
      sensitive or vulnerable in some network environments. It is thus
      important to control access to these operations. These are the
      operations and their sensitivity/vulnerability:</t>
      <ul spacing="normal">
          <li>The YANG module allows for the statistics to be cleared by
          executing the reset action. This action should be restricted to
          users with the right permission.</li>
        </ul>
      <t>The module specified in this document supports MD5 to basically
      accommodate the installed BGP base.  MD5 suffers from the security
      weaknesses discussed in <xref target="RFC6151" sectionFormat="of" section="2"/>
      or <xref target="RFC6952" sectionFormat="of" section="2.1"/>.</t>
    </section>
  </middle>

  <back>

    <displayreference target="I-D.ietf-idr-bgp-model" to="BGP-MODEL"/>
    <displayreference target="I-D.ietf-taps-interface" to="TAPS-INTERFACE"/>
    <displayreference target="I-D.ietf-i2nsf-capability-data-model" to="NSF-CAP-YANG"/>
    <displayreference target="I-D.ietf-i2nsf-nsf-facing-interface-dm" to="NSF-FACING-YANG"/>

    <references>
      <name>References</name>
      <references>
      <name>Normative References</name>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2385.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3688.xml"/> 
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4252.xml"/>     
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5925.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5926.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6020.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6241.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6991.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7950.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8040.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8177.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8340.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8341.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8342.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9000.xml"/>      
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9293.xml"/>


      <reference anchor="RFC9643" target="https://www.rfc-editor.org/info/rfc9643">
<front>
<title>YANG Groupings for TCP Clients and TCP Servers</title>
<author initials="K." surname="Watsen" fullname="Kent Watsen">
</author>
<author initials="M." surname="Scharf" fullname="Michael Scharf">
</author>
<date month="October" year="2024"/>
</front>
<seriesInfo name="RFC" value="9643"/>
<seriesInfo name="DOI" value="10.17487/RFC9643"/>
</reference>      

    </references>

    <references>
      <name>Informative References</name>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4022.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4364.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4898.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6151.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6643.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6952.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8259.xml"/>   
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8407.xml"/>      
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8512.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8513.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8519.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8684.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8783.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8792.xml"/>      
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9182.xml"/>
      <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9235.xml"/>

      <xi:include href="https://datatracker.ietf.org/doc/bibxml3/draft-ietf-idr-bgp-model.xml"/>


<reference anchor="I-D.ietf-taps-interface" target="https://datatracker.ietf.org/doc/html/draft-ietf-taps-interface-26">
<front>
<title>
An Abstract Application Layer Interface to Transport Services
</title>
<author initials="B." surname="Trammell" fullname="Brian Trammell" role="editor">
<organization>Google Switzerland GmbH</organization>
</author>
<author initials="M." surname="Welzl" fullname="Michael Welzl" role="editor">
<organization>University of Oslo</organization>
</author>
<author initials="R." surname="Enghardt" fullname="Reese Enghardt">
<organization>Netflix</organization>
</author>
<author initials="G." surname="Fairhurst" fullname="Gorry Fairhurst">
<organization>University of Aberdeen</organization>
</author>
<author initials="M." surname="Kühlewind" fullname="Mirja Kühlewind">
<organization>Ericsson</organization>
</author>
<author initials="C." surname="Perkins" fullname="Colin Perkins">
<organization>University of Glasgow</organization>
</author>
<author initials="P." surname="Tiesel" fullname="Philipp S. Tiesel">
<organization>SAP SE</organization>
</author>
<author initials="T." surname="Pauly" fullname="Tommy Pauly">
<organization>Apple Inc.</organization>
</author>
<date month="March" day="16" year="2024"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-ietf-taps-interface-26"/>
</reference>

<reference anchor="I-D.ietf-i2nsf-capability-data-model" target="https://datatracker.ietf.org/doc/html/draft-ietf-i2nsf-capability-data-model-32">
<front>
<title>I2NSF Capability YANG Data Model</title>
<author initials="S." surname="Hares" fullname="Susan Hares" role="editor">
<organization>Huawei</organization>
</author>
<author initials="J." surname="Jeong" fullname="Jaehoon Paul Jeong" role="editor">
<organization>Department of Computer Science and Engineering</organization>
</author>
<author initials="J." surname="Kim" fullname="Jinyong Tim Kim">
<organization>
Department of Electronic, Electrical and Computer Engineering
</organization>
</author>
<author initials="R." surname="Moskowitz" fullname="Robert Moskowitz">
<organization>HTT Consulting</organization>
</author>
<author initials="Q." surname="Lin" fullname="Qiushi Lin">
<organization>Huawei</organization>
</author>
<date month="May" day="23" year="2022"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-ietf-i2nsf-capability-data-model-32"/>
</reference>

<reference anchor="I-D.ietf-i2nsf-nsf-facing-interface-dm" target="https://datatracker.ietf.org/doc/html/draft-ietf-i2nsf-nsf-facing-interface-dm-29">
<front>
<title>
I2NSF Network Security Function-Facing Interface YANG Data Model
</title>
<author initials="J." surname="Kim" fullname="Jinyong Tim Kim" role="editor">
<organization>
Department of Electronic, Electrical and Computer Engineering
</organization>
</author>
<author initials="J." surname="Jeong" fullname="Jaehoon Paul Jeong" role="editor">
<organization>Department of Computer Science and Engineering</organization>
</author>
<author initials="J." surname="Park" fullname="Jung-Soo Park">
<organization>
Electronics and Telecommunications Research Institute
</organization>
</author>
<author initials="S." surname="Hares" fullname="Susan Hares">
<organization>Huawei</organization>
</author>
<author initials="Q." surname="Lin" fullname="Qiushi Lin">
<organization>Huawei</organization>
</author>
<date month="June" day="1" year="2022"/>
</front>
<seriesInfo name="Internet-Draft" value="draft-ietf-i2nsf-nsf-facing-interface-dm-29"/>
</reference>

<reference anchor="W3C.REC-xml-20081126" target="https://www.w3.org/TR/2008/REC-xml-20081126/">
  <front>
    <title>Extensible Markup Language (XML) 1.0
    (Fifth Edition)</title>
    <author initials="T." surname="Bray" fullname="Tim Bray"/>
    <author initials="J." surname="Paoli" fullname="Jean Paoli"/>
    <author initials="C.M." surname="Sperberg-McQueen" fullname="C. M. Sperberg-McQueen"/>
    <author initials="E." surname="Maler" fullname="Eve Maler"/>
    <author initials="F." surname="Yergeau" fullname="François Yergeau"/>
    <date month="November" year="2008"/>
  </front>
  <seriesInfo name="World Wide Web Consortium
         	    Recommendation" value="REC-xml-20081126"/>
</reference>

    </references>
    </references>
    <section>
      <name>Examples</name>
      <section>
	<name>Keepalive Configuration</name>
        <t>This particular example demonstrates how a particular
        connection can be configured for keepalives.</t>
<sourcecode type="xml"><![CDATA[
NOTE: '\' line wrapping per RFC 8792

<?xml version="1.0" encoding="UTF-8"?>
<!--
This example shows how TCP keepalive, MSS, and PMTU can be configure\
d for a given connection. An idle connection is dropped after
idle-time + (max-probes * probe-interval).
-->
<tcp
    xmlns="urn:ietf:params:xml:ns:yang:ietf-tcp">
  <connections>
    <connection>
      <local-address>192.0.2.1</local-address>
      <remote-address>192.0.2.2</remote-address>
      <local-port>1025</local-port>
      <remote-port>22</remote-port>
      <mss>1400</mss>
      <pmtud>true</pmtud>
      <keepalives>
        <idle-time>5</idle-time>
        <max-probes>5</max-probes>
        <probe-interval>10</probe-interval>
      </keepalives>
    </connection>
  </connections>
</tcp>
]]></sourcecode>
      </section>

      <section>
	<name>TCP-AO Configuration</name>
        <t>The following example demonstrates how to model a TCP-AO <xref
        target="RFC5925"/> configuration for the example in "TCP Authentication Option (TCP-AO) Test Vectors" <xref
        target="RFC9235"/>. The
        IP addresses and other parameters are taken from the test vectors.</t>
            <sourcecode type="xml"><![CDATA[
NOTE: '\' line wrapping per RFC 8792

<?xml version="1.0" encoding="UTF-8"?>
<!--
This example sets TCP-AO configuration parameters similarly to
the examples in RFC 9235.
-->

<key-chains
    xmlns="urn:ietf:params:xml:ns:yang:ietf-key-chain">
  <key-chain>
    <name>ao-config</name>
    <description>"An example for TCP-AO configuration."</description>
    <key>
      <key-id>55</key-id>
      <lifetime>
        <send-lifetime>
          <start-date-time>2017-01-01T00:00:00Z</start-date-time>
          <end-date-time>2017-02-01T00:00:00Z</end-date-time>
        </send-lifetime>
        <accept-lifetime>
          <start-date-time>2016-12-31T23:59:55Z</start-date-time>
          <end-date-time>2017-02-01T00:00:05Z</end-date-time>
        </accept-lifetime>
      </lifetime>
      <crypto-algorithm
          xmlns:tcp=
          "urn:ietf:params:xml:ns:yang:ietf-tcp">tcp:aes-128</crypto\
-algorithm>
      <key-string>
        <keystring>testvector</keystring>
      </key-string>
      <authentication
          xmlns="urn:ietf:params:xml:ns:yang:ietf-tcp">
        <keychain>ao-config</keychain>
        <ao>
          <send-id>61</send-id>
          <recv-id>84</recv-id>
        </ao>
      </authentication>
    </key>
  </key-chain>
</key-chains>
]]></sourcecode>
      </section>
    </section>

    <section anchor="comp-tree">
      <name>Complete Tree Diagram</name>
      <t>Here is the complete tree diagram for the TCP YANG data model.</t>

        <sourcecode type="yangtree"><![CDATA[
module: ietf-tcp
  +--rw tcp!
     +--rw connections
     |  +--rw connection*
     |          [local-address remote-address local-port remote-port]
     |     +--rw local-address     inet:ip-address
     |     +--rw remote-address    inet:ip-address
     |     +--rw local-port        inet:port-number
     |     +--rw remote-port       inet:port-number
     |     +--rw mss?              mss
     |     +--rw pmtud?            boolean
     |     +--rw keepalives! {keepalives-supported}?
     |     |  +--rw idle-time         uint16
     |     |  +--rw max-probes        uint16
     |     |  +--rw probe-interval    uint16
     |     +--ro state?            enumeration
     +--ro tcp-listeners* [type address port]
     |  +--ro type       inet:ip-version
     |  +--ro address    union
     |  +--ro port       inet:port-number
     +--ro statistics {statistics}?
        +--ro active-opens?             yang:counter64
        +--ro passive-opens?            yang:counter64
        +--ro attempt-fails?            yang:counter64
        +--ro establish-resets?         yang:counter64
        +--ro currently-established?    yang:gauge32
        +--ro in-segments?              yang:counter64
        +--ro out-segments?             yang:counter64
        +--ro retransmitted-segments?   yang:counter64
        +--ro in-errors?                yang:counter64
        +--ro out-resets?               yang:counter64
        +--ro auth-failures?            yang:counter64
        |       {authentication}?
        +---x reset
           +---w input
           |  +---w reset-at?   yang:date-and-time
           +--ro output
              +--ro reset-finished-at?   yang:date-and-time

  augment /key-chain:key-chains/key-chain:key-chain/key-chain:key:
    +--rw authentication {authentication}?
       +--rw keychain?    key-chain:key-chain-ref
       +--rw (authentication)?
          +--:(ao)
          |  +--rw ao!
          |     +--rw send-id?               uint8
          |     +--rw recv-id?               uint8
          |     +--rw include-tcp-options?   boolean
          |     +--rw accept-key-mismatch?   boolean
          |     +--ro r-next-key-id?         uint8
          +--:(md5)
             +--rw md5!
]]></sourcecode>
    </section>
    <section anchor="app_ack" numbered="false">
      <name>Acknowledgements</name>
      <t><contact fullname="Michael Scharf"/> was supported by the StandICT.eu project, which is
      funded by the European Commission under the Horizon 2020 Programme.</t>

      <t>The following persons have contributed to this document by
      reviews (in alphabetical order): <contact fullname="Mohamed Boucadair"/>, <contact fullname="Gorry Fairhurst"/>,
      <contact fullname="Jeffrey Haas"/>, and <contact fullname="Tom Petch"/>.</t>
    </section>    
  </back>
</rfc>
