<?xml version='1.0' encoding='US-ASCII'?>
<rfc version='3' ipr='trust200902' submissionType='IETF' docName='draft-mcquistin-augmented-tcp-example-02' category='exp'>
 <front>
     <title abbrev='TCP APHD Example'>
         Describing TCP with Augmented Packet Header Diagrams
     </title>
     <seriesInfo name='Internet-Draft' value='drdraft-mcquistin-augmented-tcp-example-02' status="experimental" />

     <author fullname='Stephen McQuistin' initials='S.' surname='McQuistin'>
         <organization>University of Glasgow</organization>
         <address>
             <postal>
                 <street>School of Computing Science</street>
                 <city>Glasgow</city>
                 <code>G12 8QQ</code>
                 <country>UK</country>
             </postal>
             <email>sm@smcquistin.uk</email>
         </address>
     </author>

     <author fullname='Vivian Band' initials='V.' surname='Band'>
         <organization>University of Glasgow</organization>
         <address>
             <postal>
                 <street>School of Computing Science</street>
                 <city>Glasgow</city>
                 <code>G12 8QQ</code>
                 <country>UK</country>
             </postal>
             <email>vivianband0@gmail.com</email>
         </address>
     </author>

     <author fullname='Dejice Jacob' initials='D.' surname='Jacob'>
         <organization>University of Glasgow</organization>
         <address>
             <postal>
                 <street>School of Computing Science</street>
                 <city>Glasgow</city>
                 <code>G12 8QQ</code>
                 <country>UK</country>
             </postal>
             <email>d.jacob.1@research.gla.ac.uk</email>
         </address>
     </author>

     <author fullname='Colin Perkins' initials='C. S.' surname='Perkins'>
         <organization>University of Glasgow</organization>
         <address>
             <postal>
                 <street>School of Computing Science</street>
                 <city>Glasgow</city>
                 <code>G12 8QQ</code>
                 <country>UK</country>
             </postal>
             <email>csp@csperkins.org</email>
         </address>
     </author>

     <?date year='2021' month='May' day='5'/?>

     <abstract>
         <t>
           This document describes TCP, and a number of its extensions, using
           Augmented Packet Header Diagrams. This document is an example of
           the Augmented Packet Header Diagram language: it is not intended as
           a contribution to any ongoing or future work on maintaining or
           extending TCP.
         </t>
     </abstract>
 </front>

 <middle>
     <section>
         <name>
             Introduction
         </name>
         <t>
             This document uses Augmented Packet Header Diagrams <xref target="AUGMENTED-DIAGRAMS" /> to describe TCP <xref target="RFC793" />, and is intended to further discussion about the design and implementation of the Augmented Packet Header Diagram language and tooling. Given this purpose, this document is not intended as a contribution to any ongoing or future work on maintaining or extending TCP. Further, this document does not necessarily reflect TCP, and its extensions, as presently standardised.
         </t>
     </section>
         <section anchor="tcpheader">
             <name>TCP Header</name>
             <t>
               This document describes the TCP protocol. The TCP protocol uses TCP Headers.
             </t>
                 <t>
                  A TCP Header is formatted as follows:
                 </t>
                 <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |       |C|E|U|A|P|R|S|F|                               |
| Offset| Rsrvd |W|C|R|C|S|S|Y|I|         Window Size           |
|       |       |R|E|G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          [Options]                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               :
:                            Payload                            :
:                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 </artwork>
                 <t>
                     where:
                 </t>
                 <dl>
                     <dt>
                         Source Port: 16 bits.
                     </dt>
                     <dd>
                         <t>
                             The source port number.
                         </t>
                     </dd>
                     <dt>
                         Destination Port: 16 bits.
                     </dt>
                     <dd>
                         <t>
                             The destination port number.
                         </t>
                     </dd>
                     <dt>
                         Sequence Number: 32 bits.
                     </dt>
                     <dd>
                         <t>
                           The sequence number of the first data octet
                           in this segment (except when the SYN flag is
                           set). If SYN is set the sequence number is
                           the initial sequence number (ISN) and the
                           first data octet is ISN+1.
                         </t>
                     </dd>
                     <dt>
                         Acknowledgment Number: 32 bits.
                     </dt>
                     <dd>
                         <t>
                           If the ACK control bit is set, this field
                           contains the value of the next sequence
                           number the sender of the segment is expecting
                           to receive. Once a connection is established,
                           this is always sent.
                         </t>
                     </dd>
                     <dt>
                         Data Offset (DOffset): 4 bits; DOffset >= 5.
                     </dt>
                     <dd>
                         <t>
                           The number of 32 bit words in the TCP Header.
                           This indicates where the data begins. The TCP
                           header (even one including options) is an
                           integral number of 32 bits long.
                         </t>
                     </dd>
                     <dt>
                         Reserved (Rsrvd): 4 bits; Rsrvd == 0.
                     </dt>
                     <dd>
                         <t>
                           A set of control bits reserved for future
                           use. Must be zero in generated segments and
                           must be ignored in received segments, if
                           corresponding future features are unimplemented
                           by the sending or receiving host.
                         </t>
                     </dd>
                     <dt>
                         CWR: 1 bit.
                     </dt>
                     <dd>
                         <t>
                             Congestion Window Reduced
                         </t>
                     </dd>
                     <dt>
                         ECE: 1 bit.
                     </dt>
                     <dd>
                         <t>
                             ECN-Echo
                         </t>
                     </dd>
                     <dt>
                         URG: 1 bit.
                     </dt>
                     <dd>
                         <t>
                             Urgent Pointer field significant
                         </t>
                     </dd>
                     <dt>
                         ACK: 1 bit.
                     </dt>
                     <dd>
                         <t>
                              Acknowledgment field significant.
                         </t>
                     </dd>
                     <dt>
                         PSH: 1 bit.
                     </dt>
                     <dd>
                         <t>
                              Push Function (see the Send Call description)
                         </t>
                     </dd>
                     <dt>
                         RST: 1 bit.
                     </dt>
                     <dd>
                         <t>
                             Reset the connection
                         </t>
                     </dd>
                     <dt>
                         SYN: 1 bit.
                     </dt>
                     <dd>
                         <t>
                             Synchronize sequence numbers
                         </t>
                     </dd>
                     <dt>
                         FIN: 1 bit; (FIN == 0) || (SYN == 0).
                     </dt>
                     <dd>
                         <t>
                             No more data from sender.
                         </t>
                     </dd>
                     <dt>
                         Window Size: 16 bits.
                     </dt>
                     <dd>
                         <t>
                           The number of data octets beginning with the
                           one indicated in the acknowledgment field that
                           the sender of this segment is willing to accept.
                         </t>
                         <t>
                            The window size MUST be treated as an unsigned number, or else
                            large window sizes will appear like negative windows and TCP will
                            not work (MUST-1).  It is RECOMMENDED that implementations will
                            reserve 32-bit fields for the send and receive window sizes in the
                            connection record and do all window computations with 32 bits (REC-
                            1).
                         </t>
                     </dd>
                     <dt>
                         Checksum: 16 bits.
                     </dt>
                     <dd>
                         <t>
                           The checksum field is the 16 bit one's complement of the one's
                           complement sum of all 16 bit words in the header and text.  The
                           checksum computation needs to ensure the 16-bit alignment of the
                           data being summed.  If a segment contains an odd number of header
                           and text octets, alignment can be achieved by padding the last
                           octet with zeros on its right to form a 16 bit word for checksum
                           purposes.  The pad is not transmitted as part of the segment.
                           While computing the checksum, the checksum field itself is replaced
                           with zeros.
                         </t>
                     </dd>
                     <dt>
                         Urgent Pointer: 16 bits.
                     </dt>
                     <dd>
                         <t>
                            This field communicates the current value of the urgent pointer as
                            a positive offset from the sequence number in this segment.  The
                            urgent pointer points to the sequence number of the octet following
                            the urgent data.  This field is only be interpreted in segments
                            with the URG control bit set.
                         </t>
                     </dd>
                     <dt>
                         Options: [TCP Option]; size(Options) == (DOffset-5)*32; present only when DOffset > 5.
                     </dt>
                     <dd>
                         <t>
                           Options may occupy space at the end of the TCP header and are a
                           multiple of 8 bits in length.  All options are included in the
                           checksum.
                         </t>
                     </dd>
                     <dt>
                         Payload.
                     </dt>
                     <dd>
                         Payload.
                     </dd>
                 </dl>
             </section>

             <section anchor="tcpoptions">
                 <name>TCP Options</name>
                     <t>
                         A TCP Option is one of: a EOL Option, a NOOP Option, a Maximum Segment Size Option, a Window Scale Factor Option, a Timestamp Option, a SACK Permitted Option, or a SACK Range Option.
                     </t>
                     <t>
                      An EOL Option is formatted as follows:
                     </t>
                     <artwork>
 0
 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|       0       |
+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 0.
                         </dt>
                         <dd>
                             <t>
                                This option code indicates the end of the option list.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A NOOP Option is formatted as follows:
                     </t>
                     <artwork>
 0
 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|       1       |
+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 1.
                         </dt>
                         <dd>
                             <t>
                                This option code can be used between options, for example, to
                                align the beginning of a subsequent option on a word boundary.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A Maximum Segment Size Option is formatted as follows:
                     </t>
                     <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       2       |     Length    |   Maximum Segment Size (MSS)  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 2.
                         </dt>
                         <dd>
                             <t>
                                If this option is present, then it communicates the maximum
                                receive segment size at the TCP endpoint that sends this segment.
                             </t>
                         </dd>
                         <dt>
                             Option Length (Length): 1 byte; Length == 4.
                         </dt>
                         <dd>
                             <t>
                                 Option length.
                             </t>
                         </dd>
                         <dt>
                             Maximum Segment Size (MSS): 2 bytes.
                         </dt>
                         <dd>
                             <t>
                                The maximum segment size allowed.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A Window Scale Factor Option is formatted as follows:
                     </t>
                     <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       3       |     Length    | Window Scale  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 3.
                         </dt>
                         <dd>
                             <t>
                                If present, this option carries the window scale factor.
                             </t>
                         </dd>
                         <dt>
                             Option Length (Length): 1 byte; Length == 3.
                         </dt>
                         <dd>
                             <t>
                                 Option length.
                             </t>
                         </dd>
                         <dt>
                             Window Scale: 1 byte.
                         </dt>
                         <dd>
                             <t>
                                 Window scale factor.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A Timestamp Option is formatted as follows:
                     </t>
                     <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       8       |     Length    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Timestamp value (TSval)                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                  Timestamp echo reply (TSecr)                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 8.
                         </dt>
                         <dd>
                             <t>
                                If present, this option carries a timestamp and an echoed timestamp.
                             </t>
                         </dd>
                         <dt>
                             Option Length (Length): 1 byte; Length == 10.
                         </dt>
                         <dd>
                             <t>
                                 Option length.
                             </t>
                         </dd>
                         <dt>
                             Timestamp value (TSval): 4 bytes.
                         </dt>
                         <dd>
                             <t>
                                 TSval.
                             </t>
                         </dd>
                         <dt>
                             Timestamp echo reply (TSecr): 4 bytes.
                         </dt>
                         <dd>
                             <t>
                                 TSecr.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A SACK Permitted Option is formatted as follows:
                     </t>
                     <artwork>
 0                   1
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       4       |     Length    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 4.
                         </dt>
                         <dd>
                             <t>
                                If present, this option indicates that SACK is permitted.
                             </t>
                         </dd>
                         <dt>
                             Option Length (Length): 1 byte; Length == 2.
                         </dt>
                         <dd>
                             <t>
                                 Option length.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A SACK Range Option is formatted as follows:
                     </t>
                     <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       5       |     Length    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            [Blocks]                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Option Kind (Kind): 1 byte; Kind == 5.
                         </dt>
                         <dd>
                             <t>
                                If present, this option contains one or more SACK blocks.
                             </t>
                         </dd>
                         <dt>
                             Option Length (Length): 1 byte.
                         </dt>
                         <dd>
                             <t>
                                 Option length.
                             </t>
                         </dd>
                         <dt>
                            Blocks: (Length-2)/8 SACK Blocks.
                         </dt>
                         <dd>
                             <t>
                                 SACK blocks.
                             </t>
                         </dd>
                     </dl>
                     <t>
                      A SACK Block is formatted as follows:
                     </t>
                     <artwork>
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Left Edge                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          Right Edge                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                     </artwork>
                     <t>
                         where:
                     </t>
                     <dl>
                         <dt>
                             Left Edge: 4 bytes.
                         </dt>
                         <dd>
                             <t>
                                This is the first sequence number of this block.
                             </t>
                         </dd>
                         <dt>
                             Right Edge: 4 bytes.
                         </dt>
                         <dd>
                             <t>
                               This is the sequence number immediately following the last
      sequence number of this block.
                             </t>
                         </dd>
                     </dl>
                 </section>

     <section anchor='aphd-comparison'>
         <name>Comparison with draft-ietf-tcpm-rfc793bis</name>
             <t>
                  The Augmented Packet Header Diagram format used in this example has also
                  been adopted within <xref target="draft-ietf-tcpm-rfc793bis" />. This
                  example goes beyond <xref target="draft-ietf-tcpm-rfc793bis" />, and
                  includes a number of TCP options that are not defined as part of that
                  document, including the Window Scale Factor, Timestamp, SACK permitted,
                  and SACK block options. In addition, the definition of the TCP header
                  (<xref target="tcpheader" />) in this document includes a number of
                  field constraints that are not specified in <xref target="draft-ietf-tcpm-rfc793bis" />.
             </t>
             <t>
                  The purpose of this document is to give an example use of the Augmented
                  Packet Header Diagrams, and not to contribute to ongoing or future TCP 
                  standardisation efforts. We include additional constraints and TCP options
                  to demonstrate the ease with which these can be expressed in our format, and
                  that these are then supported by the generated parser code.
             </t>
     </section>

     <section anchor='IANA'>
         <name>IANA Considerations</name>
         <t>
             This document contains no actions for IANA.
         </t>
     </section>

     <section anchor='security'>
         <name>Security Considerations</name>
         <t>
             The security implications of the Augmented Packet Header Diagrams format are
             considered in <xref target="AUGMENTED-DIAGRAMS" />.
         </t>
     </section>

     <section anchor='Acknowledgements'>
         <name>Acknowledgements</name>
         <t>
             This work has received funding from the UK Engineering and Physical
             Sciences Research Council under grant EP/R04144X/1.
         </t>
     </section>
 </middle>

 <back>
     <references>
         <name>Informative References</name>
         <reference anchor="AUGMENTED-DIAGRAMS" target="http://www.ietf.org/internet-drafts/draft-mcquistin-augmented-ascii-diagrams-09.txt">
             <front>
                 <title>Describing Protocol Data Units with Augmented Packet Header Diagrams</title>

                 <author initials='S' surname='McQuistin' fullname='Stephen McQuistin'><organization /></author>
                 <author initials='V' surname='Band' fullname='Vivian Band'><organization /></author>
                 <author initials='D' surname='Jacob' fullname='Dejice Jacob'><organization /></author>
                 <author initials='C. S.' surname='Perkins' fullname='Colin Perkins'><organization /></author>

                 <date month='October' day='25' year='2021' />
             </front>

             <seriesInfo name='Internet-Draft' value='draft-mcquistin-augmented-ascii-diagrams-09' />
         </reference>
         <reference anchor="RFC793" target="https://www.rfc-editor.org/info/rfc793">
             <front>
                 <title>Transmission Control Protocol</title>

                 <author initials='J' surname='Postel' fullname='Jon Postel'><organization /></author>

                 <date month='September' year='1981' />
             </front>
             <seriesInfo name='RFC' value='793'/>
         </reference>
         <reference anchor="draft-ietf-tcpm-rfc793bis" target="http://www.ietf.org/internet-drafts/draft-ietf-tcpm-rfc793bis-25.txt">
             <front>
                 <title>Transmission Control Protocol (TCP) Specification</title>

                 <author initials='W' surname='Eddy' fullname='Wesley Eddy'><organization /></author>

                 <date month='September' day='7' year='2021' />
             </front>

             <seriesInfo name='Internet-Draft' value='draft-ietf-tcpm-rfc793bis-25' />
         </reference>
     </references>

     <section anchor='source'>
         <name>Source code repository</name>
         <t>
             The source code for tooling that can be used to parse this document, and generate
             parser code for the protocol it describes, is available from <eref target="https://github.com/glasgow-ipl/ips-protodesc-code" />.
         </t>
     </section>
 </back>
</rfc>
