<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc subcompact="yes"?>
<rfc category="std" ipr="trust200902" docName="draft-ietf-6tisch-6top-protocol-11">
<front>
    <title abbrev="6tisch-6top-protocol">
        6top Protocol (6P)
    </title>
    <author initials="Q" surname="Wang" fullname="Qin Wang" role="editor">
        <organization>Univ. of Sci. and Tech. Beijing </organization>
        <address>
            <postal>
                <street>30 Xueyuan Road</street>
                <city>Beijing</city>
                <region>Hebei</region>
                <code>100083</code>
                <country>China</country>
            </postal>
            <email>wangqin@ies.ustb.edu.cn</email>
        </address>
    </author>
    <author initials="X" surname="Vilajosana" fullname="Xavier Vilajosana" >
        <organization>Universitat Oberta de Catalunya</organization>
        <address>
            <postal>
                <street>156 Rambla Poblenou</street>
                <city>Barcelona</city>
                <region>Catalonia</region>
                <code>08018</code>
                <country>Spain</country>
            </postal>
            <email>xvilajosana@uoc.edu</email>
        </address>
    </author>
    <author initials="T" surname="Watteyne" fullname="Thomas Watteyne">
        <organization>Analog Devices</organization>
        <address>
            <postal>
                <street>32990 Alvarado-Niles Road, Suite 910</street>
                <city>Union City</city>
                <region>CA</region>
                <code>94587</code>
                <country>USA</country>
            </postal>
            <email>thomas.watteyne@analog.com</email>
        </address>
    </author>
    <date/>
    <area>Internet Area</area>
    <workgroup>6TiSCH</workgroup>
    <keyword>Draft</keyword>
    <abstract>
        <t>
            This document defines the 6top Protocol (6P), which enables distributed scheduling in 6TiSCH networks.
            6P allows neighbor nodes to add/delete TSCH cells to one another.
            6P is part of the 6TiSCH Operation Sublayer (6top), the next higher layer to the IEEE Std 802.15.4 TSCH medium access control layer.
            The 6top layer terminates the 6top Protocol defined in this document, and runs one of more 6top Scheduling Function(s).
            A 6top Scheduling Function (SF) decides when to add/delete cells, and triggers 6P Transactions.
            This document lists the requirements for an SF, but leaves the definition of SFs out of scope.
        </t>
    </abstract>
    <note title="Requirements Language">
        <t>
            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 <xref target="RFC2119">RFC 2119</xref>.
        </t>
    </note>
</front>
<middle>
    <section title="Introduction">
        <t>
            All communication in a 6TiSCH network is orchestrated by a schedule <xref target="RFC7554"/>.
            The schedule is composed of cells, each identified by a [slotOffset,channelOffset].
            This specification defines the 6top Protocol (6P), terminated by the 6TiSCH Operation sublayer (6top).
            6P allows a node to communicate with a neighbor node to add/delete TSCH cells to each other.
            This results in distributed schedule management in a 6TiSCH network.
            The 6top layer terminates the 6top Protocol, and runs one or more 6top Scheduling Functions (SFs) that decide when to add/delete cells and trigger 6P Transactions.
            The SF is out of scope of this document but the requirements for an SF are defined here.
        </t>
        <figure title="A simple 6TiSCH network."                                                                  anchor="fig_network">
<artwork><![CDATA[
                                 (R)
                                 / \
                                /   \
                             (B)-----(C)
                              |       |
                              |       |
                             (A)     (D)
]]></artwork>
        </figure>
        <t>
            The example network depicted in <xref target="fig_network"/> is used to describe the interaction between nodes.
            We consider the canonical case where node "A" issues 6P requests to node "B".
            We keep this example throughout this document.
            Throughout the document, node A always represents the node that issues a 6P request; node B the node that receives this request.
        </t>
        <t>
            We consider that node A monitors the communication cells it has in its schedule to node B:
        </t>
        <t>
            <list style="symbols">
                <t>
                    If node A determines that the number of link-layer frames it is sending to node B per unit of time exceeds the capacity offered by the TSCH cells it has scheduled to node B, it triggers a 6P Transaction with node B to add one or more cells to the TSCH schedule of both nodes.
                </t>
                <t>
                    If the traffic is lower than the capacity, node A triggers a 6P Transaction with node B to delete one or more cells in the TSCH schedule of both nodes.
                </t>
                <t>
                    Node A MAY also monitor statistics to determine whether collisions are happening on a particular cell to node B.
                    If this feature is enabled, node A communicates with node B to "relocate" the cell which suffers collisions to a different [slotOffset,channelOffset] location in the TSCH schedule.
                </t>
            </list>
        </t>
        <t>
            This results in distributed schedule management in a 6TiSCH network.
        </t>
        <t>
            The 6top Scheduling Function (SF) defines when to add/delete a cell to a neighbor.
            Different applications require different SFs, so the SF is left out of scope of this document.
            Different SFs are expected to be defined in future companion specifications.
            A node MAY implement multiple SFs and run them at the same time.
            At least one SF MUST be running.
            The SFID field contained in all 6P messages allows a node to invoke the appropriate SF on a per-6P Transaction basis.
        </t>
        <t>
            <xref target="sec_6top"/> describes the 6TiSCH Operation Sublayer (6top).
            <xref target="sec_6p"/>   defines the 6top Protocol (6P).
            <xref target="sec_sf"/>   provides guidelines on how to define an SF.
        </t>
    </section>
    <section title="6TiSCH Operation Sublayer (6top)"                                                             anchor="sec_6top">
        <t>
            As depicted in <xref target="fig_stack"/>, the 6TiSCH Operation Sublayer (6top) is the next higher layer to the IEEE Std 802.15.4 TSCH medium access control (MAC) layer <xref target="IEEE802154"/>.
            We use "802.15.4" as a short version of "IEEE Std 802.15.4" in this document.
        </t>
        <figure title="The 6top sublayer in the protocol stack."                                                  anchor="fig_stack">
<artwork><![CDATA[
                                .
            |                   .                      |
            |             higher layers                |
            +------------------------------------------+
            |                 6top                     |
            +------------------------------------------+
            |          IEEE Std 802.15.4 TSCH          |
            |                   .                      |
                                .
]]></artwork>
        </figure>
        <t>
            The roles of the 6top sublayer are to:
            <list style="symbols">
                <t>Terminate the 6top Protocol (6P), which allows neighbor nodes to communicate to add/delete cells to one another.</t>
                <t>Run one or multiple 6top Scheduling Functions (SFs), which define the rules that decide when to add/delete cells.</t>
            </list>
        </t>
        <section title="Hard/Soft Cells"                                                                          anchor="sec_cells">
            <t>
                Each cell in the schedule is either "hard" or "soft":
                <list style="symbols">
                   <t>a soft cell can be read, added, deleted or updated by 6top.</t>
                   <t>a hard cell is read-only for 6top.</t>
                </list>
            </t>
            <t>
                In the context of this specification, all the cells used by 6top are soft cells.
                Hard cells can be used for example when "hard-coding" a schedule <xref target="RFC8180"/>.
            </t>
        </section>
        <section title="Using 6P with the Minimal 6TiSCH Configuration"                                           anchor="sec_6top_minimal">
            <t>
                6P MAY be used alongside the Minimal 6TiSCH Configuration <xref target="RFC8180"/>.
                In this case, it is RECOMMENDED to use 2 slotframes, as depicted in <xref target="fig_slotframes"/>:
                <list style="symbols">
                    <t>
                        Slotframe 0 is used for traffic defined in the Minimal 6TiSCH Configuration.
                        In <xref target="fig_slotframes"/>, this slotframe is 5 slots long, but the slotframe can be shorter or longer.
                    </t>
                    <t>
                        6P allocates cells from Slotframe 1.
                        In <xref target="fig_slotframes"/>, Slotframe 1 is 10 slots long, but the slotframe can be shorter or longer.
                    </t>
                </list>
            </t>
            <figure title="2-slotframe structure when using 6P alongside the Minimal 6TiSCH Configuration."       anchor="fig_slotframes">
<artwork><![CDATA[
                 | 0    1    2    3    4  | 0    1    2    3    4  |
                 +------------------------+------------------------+
     Slotframe 0 |    |    |    |    |    |    |    |    |    |    |
    5 slots long | EB |    |    |    |    | EB |    |    |    |    |
(Minimal 6TiSCH) |    |    |    |    |    |    |    |    |    |    |
                 +-------------------------------------------------+

                 | 0    1    2    3    4    5    6    7    8    9  |
                 +-------------------------------------------------+
     Slotframe 1 |    |    |    |    |    |    |    |    |    |    |
   10 slots long |    |A->B|    |    |    |    |    |    |B->A|    |
            (6P) |    |    |    |    |    |    |    |    |    |    |
                 +-------------------------------------------------+
]]></artwork>
            </figure>
            <t>
                The Minimal 6TiSCH Configuration cell SHOULD be allocated from a slotframe of higher priority than the slotframe used by 6P for dynamic cell allocation.
                This way, dynamically allocated cells cannot "mask" the cells used by the Minimal 6TiSCH Configuration.
                6top MAY support additional slotframes; how to use additional slotframes is out of scope for this document.
            </t>
        </section>
    </section>
    <section title="6top Protocol (6P)"                                                                           anchor="sec_6p">
        <t>
            The 6top Protocol (6P) enables two neighbor nodes to add/delete/relocate cells in their TSCH schedule.
            Conceptually, two neighbor nodes "negotiate" the location of the cells to add, delete, or relocate in their TSCH schedule.
        </t>
        <section title="6P Transactions"                                                                          anchor="sec_6p_transaction">
            <t>
                We call "6P Transaction" a complete negotiation between two neighbor nodes.
                A 6P Transaction starts when a node wishes to add/delete/relocate one or more cells with one of its neighbors.
                A 6P Transaction ends when the cell(s) have been added/deleted/relocated in the schedule of both nodes, or when the 6P Transaction has failed.
            </t>
            <t>
                6P messages exchanged between nodes A and B during a 6P Transaction SHOULD be exchanged on non-shared unicast cells ("dedicated" cells) between A and B.
                If no dedicated cells are scheduled between nodes A and B, shared cells MAY be used.
            </t>
            <t>
                Keeping consistency between the schedules of the two neighbor nodes is important.
                A loss of consistency can cause loss of connectivity.
                One example is when node A has a transmit cell to node B, but node B does not have the corresponding reception cell.
                To verify consistency, neighbor nodes maintain a Sequence Number (SeqNum).
                Neighbor nodes exchange the SeqNum as part of each 6P Transaction to detect possible inconsistency.
                This mechanism is explained in <xref target="sec_seqnum_inconsistency"/>.
            </t>
            <t>
                An implementation MUST include a mechanism to associate each scheduled cell with the SF that scheduled it.
                This mechanism is implementation-specific and out of scope of this document.
            </t>
            <t>
                A 6P Transaction can consist of 2 or 3 steps.
                A 2-step transaction is used when node A selects the cells to be allocated.
                A 3-step transaction is used when node B selects the cells to be allocated.
                An SF MUST specify whether to use 2-step transactions, 3-step transactions, or both.
            </t>
            <t>
                We illustrate 2-step and 3-step transactions using the topology in <xref target="fig_network"/>.
            </t>
            <section title="2-step 6P Transaction"                                                                anchor="sec_2-step">
                <t>
                    <xref target="fig_2-step"/> shows an example 2-step 6P Transaction.
                    In a 2-step transaction, node A selects the candidate cells.
                    Several elements are left out to simplify understanding.
                </t>
                <figure title="An example 2-step 6P Transaction."                                                 anchor="fig_2-step">
<artwork><![CDATA[
             +----------+                           +----------+
             |  Node A  |                           |  Node B  |
             +----+-----+                           +-----+----+
                  |                                       |
                  | 6P ADD Request                        |
                  |   Type         = REQUEST              |
                  |   Code         = ADD                  |
                  |   SeqNum       = 123                  |
   cells          |   NumCells     = 2                    |
   locked         |   CellList     = [(1,2),(2,2),(3,5)]  |
    +--           |-------------------------------------->|
    |             |                                L2 ACK |
    |  6P Timeout |<- - - - - - - - - - - - - - - - - - - |
    |        |    |                                       |
    |        |    | 6P Response                           |
    |        |    |   Type         = RESPONSE             |
    |        |    |   Code         = RC_SUCCESS           |
    |        |    |   SeqNum       = 123                  |  cells
    |        |    |   CellList     = [(2,2),(3,5)]        | locked
    +->      X    |<--------------------------------------|   --+
                  | L2 ACK                                |     |
                  | - - - - - - - - - - - - - - - - - - ->|   <-+
                  |                                       |
]]></artwork>
                </figure>
                <t>
                    In this example, the 2-step transaction occurs as follows:
                    <list style="numbers">
                        <t>
                            The SF running on node A determines that 2 extra cells need to be scheduled to node B.
                        </t>
                        <t>
                            The SF running on node A selects 3 candidate cells. 
                            Node A locks the candidate cells in it schedule until it receives a 6P response.
                        </t>
                        <t>
                            Node A sends a 6P ADD Request to node B, indicating it wishes to add 2 cells (the "NumCells" value), and specifying the list of 3 candidate cells (the "CellList" value).
                            Each cell in the CellList is a [slotOffset,channelOffset] tuple.
                            This 6P ADD Request is link-layer acknowledged by node B (labeled "L2 ACK" in <xref target="fig_2-step"/>).
                        </t>
                        <t>
                            After having successfully sent the 6P ADD Request (i.e. receiving the link-layer acknowledgment), node A starts a 6P Timeout to abort the 6P Transaction in case no response is received from node B.
                        </t>
                        <t>
                            The SF running on node B selects 2 out of the 3 cells from the CellList of the 6P ADD Request.
                            Node B locks those cells in it schedule until the transmission is successfull (i.e. node B receives a link-layer ACK from node A).
                            Node B sends back a 6P Response to node A, indicating the cells it has selected.
                            The response is link-layer acknowledged by node A.
                        </t>
                        <t>
                            Upon completion of this 6P Transaction, 2 cells from A to B have been added to the TSCH schedule of both nodes A and B.
                        </t>
                        <t>
                            An inconsistency in the schedule can happen
                                if the 6P Timeout expires when the 6P Response is in the air,
                                if the last link-layer ACK for the 6P Response is lost, or
                                if one of the nodes is power cycled.
                            6P provides an inconsistency detection mechanism described in <xref target="sec_seqnum_duplicates"/> to cope with such situations.
                        </t>
                    </list>
                </t>
            </section>
            <section title="3-step 6P Transaction"                                                                anchor="sec_3-step">
                <t>
                    <xref target="fig_3-step"/> shows an example 3-step 6P Transaction.
                    In a 3-step transaction, node B selects the candidate cells.
                    Several elements are left out to simplify understanding.
                </t>
                <figure title="An example 3-step 6P Transaction."                                                 anchor="fig_3-step">
<artwork><![CDATA[
         +----------+                           +----------+
         |  Node A  |                           |  Node B  |
         +----+-----+                           +-----+----+
              |                                       |
              | 6P ADD Request                        |
              |   Type         = REQUEST              |
              |   Code         = ADD                  |
              |   SeqNum       = 178                  |
              |   NumCells     = 2                    |
              |   CellList     = []                   |
              |-------------------------------------->|
              |                                L2 ACK |
   6P Timeout |<- - - - - - - - - - - - - - - - - - - |
         |    |                                       |
         |    | 6P Response                           |
         |    |   Type         = RESPONSE             |
         |    |   Code         = RC_SUCCESS           |
         |    |   SeqNum       = 178                  |         cells
         |    |   CellList     = [(1,2),(2,2),(3,5)]  |        locked
         X    |<--------------------------------------|          --+
              | L2 ACK                                |            |
              | - - - - - - - - - - - - - - - - - - ->| 6P Timeout |
              |                                       |    |       |
              | 6P Confirmation                       |    |       |
              |   Type         = CONFIRMATION         |    |       |
              |   Code         = RC_SUCCESS           |    |       |
 cells        |   SeqNum       = 178                  |    |       |
 locked       |   CellList     = [(2,2),(3,5)]        |    |       |
  +--         |-------------------------------------->|    X    <--+
  |           |                                L2 ACK |
  +->         |<- - - - - - - - - - - - - - - - - - - |
              |                                       |
]]></artwork>
                </figure>
                <t>
                    In this example, the 3-step transaction occurs as follows:
                    <list style="numbers">
                        <t>
                            The SF running on node A determines that 2 extra cells need to be scheduled to node B, but does not select candidate cells.
                        </t>
                        <t>
                            Node A sends a 6P ADD Request to node B, indicating it wishes to add 2 cells (the "NumCells" value), with an empty "CellList".
                            This 6P ADD Request is link-layer acknowledged by node B.
                        </t>
                        <t>
                            After having successfully sent the 6P ADD Request, node A starts a 6P Timeout to abort the transaction in case no 6P Response is received from node B.
                        </t>
                        <t>
                            The SF running on node B selects 3 candidate cells, and locks them.
                            Node B sends back a 6P Response to node A, indicating the 3 cells it has selected.
                            The response is link-layer acknowledged by node A.
                        </t>
                        <t>
                            After having successfully sent the 6P Response, node B starts a 6P Timeout to abort the transaction in case no 6P Confirmation is received from node A.
                        </t>
                        <t>
                            The SF running on node A selects 2 cells from the CellList field in the 6P Response, and locks those.
                            Node A sends back a 6P Confirmation to node B, indicating the cells it selected.
                            The confirmation is link-layer acknowledged by node B.
                        </t>
                        <t>
                            Upon completion of the 6P Transaction, 2 cells from A to B have been added to the TSCH schedule of both nodes A and B; other cells are unlocked.
                        </t>
                        <t>
                            An inconsistency in the schedule can happen
                                if the 6P Timeout expires when the 6P Confirmation is in the air,
                                if the last link-layer ACK for the 6P Confirmation is lost, or
                                if one of the nodes is power cycled.
                            6P provides an inconsistency detection mechanism described in <xref target="sec_seqnum_duplicates"/> to cope with such situations.
                        </t>
                    </list>
                </t>
            </section>
        </section>
        <section title="Message Format"                                                                           anchor="sec_message_formats">
            <section title="6top Information Element (IE)"                                                        anchor="sec_6top_ie">
                <t>
                    6P messages travel over a single hop.
                    6P messages are carried as payload of an 802.15.4 Payload Information Element (IE) <xref target="IEEE802154"/>.
                    The messages are encapsulated within the Payload IE Header.
                    The Group ID is set to the IETF IE value defined in <xref target="RFC8137"/>.
                    The content is encapsulated by a SubType ID, as defined in <xref target="RFC8137"/>.
                </t>
                <t>
                    Since 6P messages are carried in IEs, IEEE bit/byte ordering applies.
                    Bits within each field in the 6top IE are numbered from 0 (leftmost and least significant) to k-1 (rightmost and most significant), where the length of the field is k bits.
                    Fields that are longer than a single octet are copied to the packet in the order from the octet containing the lowest numbered bits to the octet containing the highest numbered bits (little endian).
                </t>
                <t>
                    This document defines the "6top IE", a SubType of the IETF IE defined in <xref target="RFC8137"/>, with subtype ID IANA_6TOP_SUBIE_ID.
                    The SubType Content of the "6top IE" is defined in  <xref target="sec_msgformat"/>.
                    The length of the "6top IE" content is variable.
                </t>
            </section>
            <section title="Generic 6P Message Format"                                                            anchor="sec_msgformat">
                <t>
                    All 6P messages follow the generic format shown in <xref target="fig_generic_format"/>.
                </t>
                <figure title="Generic 6P Message Format."                                                        anchor="fig_generic_format">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | Other Fields...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="6P Version (Version):">
                            The version of the 6P protocol.
                            Only version 0 is defined in this document.
                            Future specifications MAY define further versions of the 6P protocol.
                        </t>
                        <t hangText="Type (T):">
                            Type of message.
                            The message types are defined in <xref target="sec_iana_type"/>.
                        </t>
                        <t hangText="Reserved (R):">
                            Reserved bits.
                            These two bits SHOULD be set to zero when sending the message, and MUST be ignored upon reception.
                        </t>
                        <t hangText="Code:">
                            The Code field contains a 6P Command Identifier when the 6P message is of Type REQUEST.
                            <xref target="sec_iana_cmdid"/> lists the 6P command identifiers.
                            The Code field contains a 6P Return Code when the 6P message is of Type RESPONSE or CONFIRMATION.
                            <xref target="sec_iana_rc"/>    lists the 6P Return Codes.
                            The same return codes are used in both 6P Response and 6P Confirmation messages.
                        </t>
                        <t hangText="6top Scheduling Function Identifier (SFID):">
                            The identifier of the SF to use to handle this message.
                            The SFID is defined in <xref target="sec_sfid"/>.
                        </t>
                        <t hangText="SeqNum:">
                            Sequence number associated with the 6P Transaction, used to match the
                                6P Request,
                                6P Response and
                                6P Confirmation of the same 6P Transaction.
                            The value of SeqNum MUST be different at each new 6P Request issued to the same neighbor.
                            The SeqNum is also used to ensure consistency between the schedules of the two neighbors.
                            <xref target="sec_SeqNum_Management"/> details how the SeqNum is managed.
                        </t>
                        <t hangText="Other Fields:">
                            The list of other fields and how they are used is detailed in <xref target="sec_commands_operation"/>.
                        </t>
                   </list>
                </t>
            </section>
            <section title="6P CellOptions"                                                                       anchor="sec_6p_celloptions">
                <t>
                    An 8-bit 6P CellOptions bitmap is present in the following 6P requests: ADD, DELETE, COUNT, LIST, RELOCATE.
                    <list style="symbols">
                        <t>In the 6P ADD request,                    the 6P CellOptions bitmap is used to specify what type of cell to add.</t>
                        <t>In the 6P DELETE request,                 the 6P CellOptions bitmap is used to specify what type of cell to delete.</t>
                        <t>In the 6P COUNT and
                              the 6P LIST requests,                  the 6P CellOptions bitmap is used as a selector of a particular type of cells.</t>
                        <t>In the 6P RELOCATE request,               the 6P CellOptions bitmap is used to specify what type of cell to relocate.</t>
                    </list>
                </t>
                <t>
                    The contents of the 6P CellOptions bitmap apply to all elements in the CellList field.
                    <xref target="sec_iana_celloptions"/>           contains the RECOMMENDED format  of the 6P CellOptions bitmap.
                    <xref target="tab_celloptions_add_meaning"/>    contains the RECOMMENDED meaning of the 6P CellOptions bitmap for the 6P ADD, DELETE, RELOCATE requests.
                    <xref target="tab_celloptions_count_meaning"/>  contains the RECOMMENDED meaning of the 6P CellOptions bitmap for the 6P COUNT, LIST requests.
                </t>
                <figure title="Meaning of the 6P CellOptions bitmap for the 6P ADD, DELETE, RELOCATE requests."   anchor="tab_celloptions_add_meaning">
<artwork><![CDATA[
 Note: assuming node A issues the 6P command to node B.
+-------------+-----------------------------------------------------+
| CellOptions | the type of cells B adds/deletes/relocates to its   |
| Value       | schedule when receiving a 6P ADD/DELETE/RELOCATE    |
|             | Request from A.                                     |
+-------------+-----------------------------------------------------+
|TX=0,RX=0,S=0| Does not apply. RC_ERR is returned.                 |
+-------------+-----------------------------------------------------+
|TX=1,RX=0,S=0| add/delete/relocate RX cells at B (TX cells at A)   |
+-------------+-----------------------------------------------------+
|TX=0,RX=1,S=0| add/delete/relocate TX cells at B (RX cells at A)   |
+-------------+-----------------------------------------------------+
|TX=1,RX=1,S=0| add/delete/relocate TX|RX cells at B (and at A)     |
+-------------+-----------------------------------------------------+
|TX=0,RX=0,S=1| Does not apply. RC_ERR is returned.                 |
+-------------+-----------------------------------------------------+
|TX=1,RX=0,S=1| add/delete/relocate RX|SHARED cells at B            |
|             | (TX|SHARED cells at A)                              |
+-------------+-----------------------------------------------------+
|TX=0,RX=1,S=1| add/delete/relocate TX|SHARED cells at B            |
|             | (RX|SHARED cells at A)                              |
+-------------+-----------------------------------------------------+
|TX=1,RX=1,S=1| add/delete/relocate TX|RX|SHARED cells at B         |
|             | (and at A)                                          |
+-------------+-----------------------------------------------------+
]]></artwork>
                </figure>
                <figure title="Meaning of the 6P CellOptions bitmap for the 6P COUNT, LIST requests."             anchor="tab_celloptions_count_meaning">
<artwork><![CDATA[
 Note: assuming node A issues the 6P command to node B.
+-------------+-----------------------------------------------------+
| CellOptions | the type of cells B selects from its schedule when  |
| Value       | receiving a 6P COUNT or LIST Request from A,        |
|             | from all the cells B has scheduled with A           |
+-------------+-----------------------------------------------------+
|TX=0,RX=0,S=0| all cells                                           |
+-------------+-----------------------------------------------------+
|TX=1,RX=0,S=0| all cells marked as RX only                         |
+-------------+-----------------------------------------------------+
|TX=0,RX=1,S=0| all cells marked as TX only                         |
+-------------+-----------------------------------------------------+
|TX=1,RX=1,S=0| all cells marked as TX and RX only                  |
+-------------+-----------------------------------------------------+
|TX=0,RX=0,S=1| all cells marked as SHARED (regardless of TX, RX)   |
+-------------+-----------------------------------------------------+
|TX=1,RX=0,S=1| all cells marked as RX and SHARED only              |
+-------------+-----------------------------------------------------+
|TX=0,RX=1,S=1| all cells marked as TX and SHARED only              |
+-------------+-----------------------------------------------------+
|TX=1,RX=1,S=1| all cells marked as TX and RX and SHARED            |
+-------------+-----------------------------------------------------+
]]></artwork>
                </figure>
                <t>
                    The CellOptions is an opaque set of bits, sent unmodified to the SF.
                    The SF MAY redefine the format and meaning of the CellOptions field.
                </t>
            </section>
            <section title="6P CellList"                                                                          anchor="sec_6p_cell">
                <t>
                    A CellList field MAY be present in
                        a 6P ADD      Request,
                        a 6P DELETE   Request,
                        a 6P RELOCATE Request,
                        a 6P          Response, or
                        a 6P          Confirmation.
                    It is composed of a concatenation of zero, one or more 6P Cells as defined in <xref target="fig_6p_cell"/>.
                    The content of the CellOptions field specifies the options associated with all cells in the CellList.
                    This necessarily means that the same options are associated with all cells in the CellList.
                </t>
                <t>
                    A 6P Cell is a 4-byte field, its RECOMMENDED format is:
                </t>
                <figure title="6P Cell Format."                                                                   anchor="fig_6p_cell">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |          slotOffset           |         channelOffset         |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="slotOffset:">
                            The slot offset of the cell.
                        </t>
                        <t hangText="channelOffset:">
                            The channel offset of the cell.
                        </t>
                    </list>
                </t>
                <t>
                    The CellList is an opaque set of bytes, sent unmodified to the SF.
                    The length of the CellList field is implicit, and determined by the IE Length field, present in the Payload IE header as defined by the IEEE 802.15.4 standard <xref target="IEEE802154"/>.
                    The SF MAY redefine the format of the CellList field.
                </t>
            </section>
        </section>
        <section title="6P Commands and Operations"                                                               anchor="sec_commands_operation">
            <section title="Adding Cells"                                                                         anchor="sec_add">
                <t>
                    Cells are added by using the 6P ADD command.
                    The Type field (T) is set to REQUEST.
                    The Code field is set to ADD.
                    <xref target="fig_add_request"/> defines the format of a 6P ADD Request.
                </t>
                <figure title="6P ADD Request Format."                                                            anchor="fig_add_request">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |  CellOptions  |   NumCells    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | CellList ...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Used as extra signaling to the SF.
                            The contents of the Metadata field is an opaque set of bytes passed unmodified to the SF.
                            The meaning of this field depends on the SF, and is out of scope of this document.
                            For example, Metadata can specify in which slotframe to add the cells.
                        </t>
                        <t hangText="CellOptions:">
                            Indicates the options to associate with the cells to be added.
                            If more than one cell is added (NumCells>1), the same options are associated with each one.
                            This necessarily means that, if node A needs to add multiple cells with different options, it needs to initiate multiple 6P ADD Transactions.
                        </t>
                        <t hangText="NumCells:">
                            The number of additional cells node A wants to schedule to node B.
                        </t>
                        <t hangText="CellList:">
                            A list of 0, 1 or multiple candidate cells.
                            Its length is implicit and determined by the Length field of the Payload IE header.
                        </t>
                    </list>
                </t>
                <t>
                    <xref target="fig_add_response"/> defines the format of a 6P ADD Response and Confirmation.
                </t>
                <figure title="6P ADD Response and Confirmation Formats."                                         anchor="fig_add_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | CellList ...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="CellList:">
                            A list of 0, 1 or multiple 6P Cells.
                        </t>
                    </list>
                </t>
                <t>
                    Consider the topology in <xref target="fig_network"/> where the SF on node A decides to add NumCells cells to node B.
                </t>
                <t>
                    Node A's SF selects NumCandidate cells from its schedule.
                    These are cells that are candidates to be scheduled with node B.
                    The CellOptions field specifies the type of these cells.
                    NumCandidate MUST be larger or equal to NumCells.
                    How many cells node A selects (NumCandidate) and how that selection is done is specified in the SF and out of scope of this document.
                    Node A sends a 6P ADD Request to node B which contains
                        the CellOptions,
                        the value of NumCells, and
                        a selection of NumCandidate cells in the CellList.
                    In case the NumCandidate cells do not fit in a single packet, this operation MUST be split into multiple independent 6P ADD Requests, each for a subset of the number of cells that eventually need to be added.
                    In case of a 3-step transaction, the SF is reponsible of ensuring that the returned candidate celllist fit in the 6P Response packet.
                </t>
                <t>
                    Upon receiving the request, node B checks whether the cellOptions are set to a legal value as noted by <xref target="tab_celloptions_add_meaning"/>. 
                    If this is not the case, a Response with code RC_ERR is returned. 
                    Otherwise, node B's SF verifies which of the cells in the CellList it can install in node B's schedule, following the specified CellOptions field.
                    How that selection is done is specified in the SF and out of scope of this document.
                    The verification can
                       succeed           (NumCells cells from the CellList can be used),
                       fail              (none of the cells from the CellList can be used), or
                       partially succeed (less than NumCells cells from the CellList can be used).
                    In all cases, node B MUST send a 6P Response with return code set to RC_SUCCESS, and which specifies the list of cells that were scheduled following the CellOptions field.
                    That can contain
                        NumCells elements               (succeed),
                        0 elements                      (fail), or
                        between 0 and NumCells elements (partially succeed).
                </t>
                <t>
                    Upon receiving the response, node A adds the cells specified in the CellList according to the CellOptions field.
                </t>
            </section>
            <section title="Deleting Cells">
                <t>
                    Cells are deleted by using the 6P DELETE command.
                    The Type field (T) is set to REQUEST.
                    The Code field is set to DELETE.
                    <xref target="fig_delete_request"/> defines the format of a 6P DELETE Request.
                </t>
                <figure title="6P DELETE Request Format."                                                         anchor="fig_delete_request">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |    SeqNum     |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |  CellOptions  |   NumCells    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | CellList ...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Same usage as for the 6P ADD command, see <xref target="sec_add"/>.
                            Its format is the same as that in the 6P ADD command, but its content could be different.
                        </t>
                        <t hangText="CellOptions:">
                            Indicates the options that need to be associated to the cells to delete.
                            Only cells matching the CellOptions can are deleted.
                        </t>
                        <t hangText="NumCells:">
                            The number of cells from the specified CellList the sender wants to delete from the schedule of both sender and receiver.
                        </t>
                        <t hangText="CellList:">
                            A list of 0, 1 or multiple 6P Cells.
                            Its length is determined by the Length field of the Payload IE header.
                        </t>
                    </list>
                </t>
                <t>
                    <xref target="fig_delete_response"/> defines the format of a 6P DELETE Response and Confirmation.
                </t>
                <figure title="6P DELETE Response and Confirmation Formats."                                      anchor="fig_delete_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | CellList ...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="CellList:">
                            A list of 0, 1 or multiple 6P Cells.
                        </t>
                    </list>
                </t>
                <t>
                    The behavior for deleting cells is equivalent to that of adding cells except that:
                    <list style="symbols">
                        <t>
                            The nodes delete the cells they agree upon rather than adding them.
                        </t>
                        <t>
                            All cells in the CellList MUST already be scheduled between the two nodes and MUST match the CellOptions field.
                            If node A puts cells in its CellList that are not already scheduled between the two nodes and match the CellOptions field, node B MUST reply with a RC_ERR_CELLLIST return code.
                        </t>
                        <t>
                            If the CellList in the 6P Request is empty, the SF on the receiving node SHOULD delete any cell from the sender, as long as it matches the CellOptions field.
                        </t>
                        <t>
                            The CellList in a 6P Request (2-step transaction) or 6P Response (3-step transaction) MUST either be empty, contain exactly NumCells cells, or more than NumCells cells.
                            The case where the CellList is not empty but contains less than NumCells cells is not supported.
                        </t>
                    </list>
                </t>
            </section>
            <section title="Relocating Cells">
                <t>
                    Cell relocation consists in moving a cell to a different [slotOffset,channelOffset] location in the schedule.
                    The Type field (T) is set to REQUEST.
                    The Code is set to RELOCATE.
                    <xref target="fig_relocate_request"/> defines the format of a 6P RELOCATE Request.
                </t>
                <figure title="6P RELOCATE Request Format."                                                       anchor="fig_relocate_request">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |  CellOptions  |   NumCells    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | Relocation CellList          ...
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
  | Candidate CellList           ...
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Same usage as for the 6P ADD command, see <xref target="sec_add"/>.
                        </t>
                        <t hangText="CellOptions:">
                            Indicates the options that need to be associated with cells to be relocated.
                        </t>
                        <t hangText="NumCells:">
                            The number of cells to relocate, which MUST be equal or greater than 1.
                        </t>
                        <t hangText="Relocation CellList:">
                            The list of NumCells 6P Cells to relocate.
                         </t>
                        <t hangText="Candidate CellList:">
                            A list of NumCandidate candidate cells for node B to pick from.
                            NumCandidate MUST be 0, equal to NumCells, or greater than NumCells.
                            Its length is determined by the Length field of the Payload IE header.
                        </t>
                    </list>
                </t>
                <t>
                    In a 2-step 6P RELOCATE Transaction, node A specifies both the cells it needs to relocate, and the list of candidate cells to relocate to.
                    The Relocation CellList MUST contain exactly  NumCells entries.
                    The Candidate  CellList MUST contain at least NumCells entries (that is NumCandidate>=NumCells).
                </t>
                <t>
                    In a 3-step 6P RELOCATE Transaction,
                        node A specifies only the cells it needs to relocate,
                        but not the list of candidate cells to relocate to.
                    The Candidate CellList MUST therefore be empty.
                </t>
                <t>
                    <xref target="fig_relocate_response"/> defines the format of a 6P RELOCATE Response and Confirmation.
                </t>
                <figure title="6P RELOCATE Response and Confirmation Formats."                                    anchor="fig_relocate_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | CellList ...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="CellList:">
                            A list of 0, 1 or multiple 6P Cells.
                        </t>
                    </list>
                </t>
                <t>
                    Node A's SF wants to relocate NumCells particular cells.
                    Node A creates a 6P RELOCATE Request, and indicates the cells it wants to relocate in the Relocation CellList.
                    It also selects NumCandidate cells from its schedule as candidate cells to relocate the cells to, and puts those in the Candidate CellList.
                    The CellOptions field specifies the type of the cell(s) to relocate.
                    NumCandidate MUST be larger or equal to NumCells.
                    How many cells it selects (NumCandidate) and how that selection is done is specified in the SF and out of scope of this document.
                    Node A sends the 6P RELOCATE Request to node B.
                </t>
                <t>
                    Upon receiving the request, Node B checks if the length of the Candidate CellList is larger or equal to NumCells.
                    Node B's SF verifies that all the cells in the Relocation CellList are indeed scheduled with node A, and are associate the options specified in the CellOptions field.
                    If that check fails, node B MUST send a 6P Response to node A with return code RC_ERR_CELLLIST.
                    If that check passes, node B's SF verifies which of the cells in the Candidate CellList it can install in its schedule.
                    How that selection is done is specified in the SF and out of scope of this document.
                    That verification on Candidate CellList can
                        succeed           (NumCells cells from the Candidate CellList can be used),
                        fail              (none of the cells from the Candidate CellList can be used) or
                        partially succeed (less than NumCells cells from the Candidate CellList can be used).
                    In all cases, node B MUST send a 6P Response with return code set to RC_SUCCESS, and which specifies the list of cells that will be re-scheduled following the CellOptions field.
                    That can contain
                        NumCells elements               (succeed),
                        0 elements                      (fail),
                        between 0 and NumCells elements (partially succeed).
                    If N &lt; NumCells cells appear in the CellList, this means first N cells in the Relocation CellList have to be relocated, the remainder have not.
                </t>
                <t>
                    Upon receiving the response with Code RC_SUCCESS, node A relocates the cells specified in Relocation CellList of its RELOCATE Request to the new locations specified in the CellList of the 6P Response, in the same order.
                    In case the received Response Code is RC_ERR_CELLLIST, the transaction is aborted and no cell is relocated.
                    Upon receiving the L2 Ack of the 6P Response or 6P Confirmation in case of a 3-step transaction, Node B relocates the selected cells.
                </t>
                <t>
                    The SF SHOULD take into account situations such as the relocation of all cells at a time between two nodes. 
                    If the operation fails the schedules of both nodes may completely diverge. Is up to the SF the handling of such situation.
                </t>
                <t>
                    <xref target="fig_relocate_example_2step_success"/> shows an example of a successful 2-step 6P RELOCATION Transaction.
                    <figure title="Example of a successful 2-step 6P RELOCATION Transaction."                     anchor="fig_relocate_example_2step_success">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
             |                                       |
             | 6P RELOCATE Request                   |
             |   Type         = REQUEST              |
             |   Code         = RELOCATE             |
             |   SeqNum       = 11                   |
             |   NumCells     = 2                    |
             |   R.CellList   = [(1,2),(2,2)]        |
             |   C.CellList   = [(3,3),(4,3),(5,3)]  |
             |-------------------------------------->| B prepares
             |                                L2 ACK | to relocate
             |<- - - - - - - - - - - - - - - - - - - | (1,2)->(5,3)
             |                                       | and
             |                                       | (2,2)->(3,3)
             | 6P Response                           |
             |   Code         = RC_SUCCESS           |
             |   SeqNum       = 11                   |
             |   CellList     = [(5,3),(3,3)]        |
  A relocates|<--------------------------------------|
 (1,2)->(5,3)| L2 ACK                                |
 and         | - - - - - - - - - - - - - - - - - - ->|B relocates
 (2,2)->(3,3)|                                       |(1,2)->(5,3)
             |                                       |and
             |                                       |(2,2)->(3,3)

]]></artwork>
                    </figure>
                </t>
                <t>
                    <xref target="fig_relocate_example_2step_partial"/> shows an example of a partially successful 2-step 6P RELOCATION Transaction.
                    <figure title="Example of a partially successful 2-step 6P RELOCATION Transaction."           anchor="fig_relocate_example_2step_partial">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
             |                                       |
             | 6P RELOCATE Request                   |
             |   Type         = REQUEST              |
             |   Code         = RELOCATE             |
             |   SeqNum       = 199                  |
             |   NumCells     = 2                    |
             |   R.CellList   = [(1,2),(2,2)]        |
             |   C.CellList   = [(3,3),(4,3),(5,3)]  |B prepares
             |-------------------------------------->|to relocate
             |                                L2 ACK |(1,2)->(4,3)
             |<- - - - - - - - - - - - - - - - - - - |but cannot 
             |                                       |relocate (2,2) 
             | 6P Response                           | 
             |   Type         = RESPONSE             | 
             |   Code         = RC_SUCCESS           |
             |   SeqNum       = 199                  |
             |   CellList     = [(4,3)]              |
 A relocates |<--------------------------------------|
 (1,2)->(4,3)| L2 ACK                                |
             | - - - - - - - - - - - - - - - - - - ->|B relocates
             |                                       |(1,2)->(4,3)
             |                                       |
             |                                       |
]]></artwork>
                    </figure>
                </t>
                <t>
                    <xref target="fig_relocate_example_2step_fail"/> shows an example of a failed 2-step 6P RELOCATION Transaction.
                    <figure title="Failed 2-step 6P RELOCATION Transaction Example."                              anchor="fig_relocate_example_2step_fail">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
             |                                       |
             | 6P RELOCATE Request                   |
             |   Type         = REQUEST              |
             |   Code         = RELOCATE             |
             |   SeqNum       = 53                   |
             |   NumCells     = 2                    |
             |   R.CellList   = [(1,2),(2,2)]        |
             |   C.CellList   = [(3,3),(4,3),(5,3)]  |
             |-------------------------------------->| B cannot
             |                                L2 ACK | relocate
             |<- - - - - - - - - - - - - - - - - - - | (1,2) 
             |                                       | nor (2,2) 
             | 6P Response                           | 
             |   Type         = RESPONSE             | 
             |   Code         = RC_SUCCESS           |
             |   SeqNum       = 53                   |
             |   CellList     = []                   |
             |<--------------------------------------| B does not
             | L2 ACK                                | relocate
  A does not | - - - - - - - - - - - - - - - - - - ->|
    relocate |                                       |
             |                                       |
]]></artwork>
                    </figure>
                </t>
                <t>
                    <xref target="fig_relocate_example_3step_success"/> shows an example of a successful 3-step 6P RELOCATION Transaction.
                    <figure title="Example of a successful 3-step 6P RELOCATION Transaction."                     anchor="fig_relocate_example_3step_success">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
             |                                       |
             | 6P RELOCATE Request                   |
             |   Type         = REQUEST              |
             |   Code         = RELOCATE             |
             |   SeqNum       = 11                   |
             |   NumCells     = 2                    |
             |   R.CellList   = [(1,2),(2,2)]        |
             |   C.CellList   = []                   |
             |-------------------------------------->|
             |                                L2 ACK |
             |<- - - - - - - - - - - - - - - - - - - | B identifies
             |                                       | candidate
             |                                       | cells
             | 6P Response                           | (3,3),
             |   Code         = RC_SUCCESS           | (4,3) and
             |   SeqNum       = 11                   | (5,3)
             |   CellList     = [(3,3),(4,3),(5,3)]  |
  A prepares |<--------------------------------------|
 to relocate | L2 ACK                                |
(1,2)->(5,3) | - - - - - - - - - - - - - - - - - - ->|
         and |                                       |
(2,2)->(3,3) | 6P Confirmation                       |
             |   Code         = RC_SUCCESS           |
             |   SeqNum       = 11                   |
             |   CellList     = [(5,3),(3,3)]        |
             |-------------------------------------->| B relocates
             |                                L2 ACK | (1,2)->(5,3)
 A relocates |<- - - - - - - - - - - - - - - - - - - | and
 (1,2)->(5,3)|                                       | (2,2)->(3,3)
 and         |                                       |
 (2,2)->(3,3)|                                       |
             |                                       |
]]></artwork>
                    </figure>
                </t>
            </section>
            <section title="Counting Cells">
                <t>
                    To retrieve the number of scheduled cells a node A has with B, node A issues a 6P COUNT command.
                    The Type field (T) is set to REQUEST.
                    The Code field is set to COUNT.
                    <xref target="fig_count_request"/> defines the format of a 6P COUNT Request.
                </t>
                <figure title="6P COUNT Request Format."                                                          anchor="fig_count_request">
<artwork><![CDATA[
                     1                   2
   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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |  CellOptions  |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Same usage as for the 6P ADD command, see <xref target="sec_add"/>.
                            Its format is the same as that in the 6P ADD command, but its content could be different.
                        </t>
                        <t hangText="CellOptions:">
                            Specifies which type of cell to be counted.
                        </t>
                    </list>
                </t>
                <t>
                    <xref target="fig_count_response"/> defines the format of a 6P COUNT Response.
                </t>
                <figure title="6P COUNT Response Format."                                                         anchor="fig_count_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           NumCells            |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="NumCells:">
                            The number of cells which correspond to the fields of the request.
                        </t>
                    </list>
                </t>
                <t>
                    Node A issues a COUNT command to node B, specifying cell options.
                    Upon receiving the 6P COUNT request,
                        node B goes through its schedule and counts the number of cells scheduled with node A in its own schedule,
                        and which match the cell options in the CellOptions field of the request.
                    <xref target="sec_6p_celloptions"/> details the use of the CellOptions field.
                </t>
                <t>
                    Node B issues a 6P response to node A with return code set to RC_SUCCESS,
                        and with NumCells containing the number of cells that match the request.
                </t>
            </section>
            <section title="Listing Cells">
                <t>
                    To retrieve a list of scheduled cells node A has with node B, node A issues a 6P LIST command.
                    The Type field (T) is set to REQUEST.
                    The Code field is set to LIST.
                    <xref target="fig_list_request"/> defines the format of a 6P LIST Request.
                </t>
                <figure title="6P LIST Request Format."                                                           anchor="fig_list_request">
<artwork><![CDATA[
                     1                   2
   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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |  CellOptions  |   Reserved    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Offset              |          MaxNumCells          |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Same usage as for the 6P ADD command, see <xref target="sec_add"/>.
                            Its format is the same as that in the 6P ADD command, but its content could be different.
                        </t>
                        <t hangText="CellOptions:">
                            Specifies which type of cell to be listed.
                        </t>
                        <t hangText="Reserved:">
                            Reserved bits.
                            These bits SHOULD be set to zero when sending the message, and MUST be ignored upon reception.
                        </t>
                        <t hangText="Offset:">
                            The Offset of the first scheduled cell that is requested.
                            The mechanism assumes cells are ordered according to a rule defined in the SF.
                            The rule MUST always order the cells in the same way.
                        </t>
                        <t hangText="MaxNumCells:">
                            The maximum number of cells to be listed.
                            Node B MAY return less than MaxNumCells cells, for example if MaxNumCells cells do not fit in the frame.
                        </t>
                    </list>
                </t>
                <t>
                    <xref target="fig_list_response"/> defines the format of a 6P LIST Response.
                </t>
                <figure title="6P LIST Response Format."                                                          anchor="fig_list_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | CellList ...
  +-+-+-+-+-+-+-+-+-
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="CellList:">
                            A list of 0, 1 or multiple 6P Cells.
                        </t>
                    </list>
                </t>
                <t>
                    When receiving a LIST command, node B returns the cells scheduled with A in its schedule that match the CellOptions field as specified in <xref target="sec_6p_celloptions"/>.
                </t>
                <t>
                    When node B receives a LIST request, the returned CellList in the 6P Response contains between 1 and MaxNumCells cells, starting from the specified offset.
                    Node B SHOULD include as many cells as fit in the frame.
                    If the response contains the last cell, Node B MUST set the Code field in the response to RC_EOL ("End of List", as per <xref target="fig_iana_rc"/>), indicating to Node A that there no more cells that match the request.
                    Node B MUST return at least one cell, unless the specified Offset is beyond the end of B's cell list in its schedule.
                    If node B has less than Offset cells that match the request, node B returns an empty CellList and a Code field set to RC_EOL.
                </t>
            </section>
            <section title="Clearing the Schedule">
                <t>
                    To clear the schedule between nodes A and B (for example after a schedule inconsistency is detected), node A issues a CLEAR command.
                    The Type field (T) is set to 6P Request.
                    The Code field is set to CLEAR.
                    <xref target="fig_clear_request"/> defines the format of a 6P CLEAR Request.
                </t>
                <figure title="6P CLEAR Request Format."                                                          anchor="fig_clear_request">
<artwork><![CDATA[
                     1                   2
   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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Same usage as for the 6P ADD command, see <xref target="sec_add"/>.
                            Its format is the same as that in the 6P ADD command, but its content could be different.
                        </t>
                    </list>
                </t>
                <t>
                    <xref target="fig_clear_response"/> defines the format of a 6P CLEAR Response.
                </t>
                <figure title="6P CLEAR Response Format."                                                         anchor="fig_clear_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    When a 6P CLEAR command is issued from node A to node B, both nodes A and B MUST remove all the cells scheduled between them.
                    That is, node A MUST remove all the cells scheduled with node B, and
                             node B MUST remove all the cells scheduled with node A.
                    In a 6P CLEAR command, the SeqNum MUST NOT be checked.
                    In particular, even if the request contains a SeqNum value that would normally cause node B to detect a schedule inconsistency, the transaction MUST NOT be aborted.
                    Upon 6P CLEAR completion, the value of SeqNum MUST be reset to 0.
                </t>
                <t>
                    The Response Code to a 6P CLEAR command SHOULD be RC_SUCCESS unless the operation cannot be executed.
                    When the CLEAR operation cannot be executed, the Response Code MUST be set to RC_RESET.
                </t>
            </section>
            <section title="Generic Signaling Between SFs">
                <t>
                    The 6P SIGNAL message allows the SF implementations on two neighbor nodes to exchange generic commands.
                    The payload in a received SIGNAL message is an opaque set of bytes passed unmodified to the SF.
                    How the generic SIGNAL command is used is specified by the SF, and outside the scope of this document.
                    The Type field (T) is set to REQUEST.
                    The Code field is set to SIGNAL.
                    <xref target="fig_signal_request"/> defines the format of a 6P SIGNAL Request.
                </t>
                <figure title="6P SIGNAL Request Format."                                                         anchor="fig_signal_request">
<artwork><![CDATA[
                     1                   2
   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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Metadata            |  payload ...
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
                <t>
                    <list style="hanging" hangIndent="6">
                        <t hangText="Metadata:">
                            Same usage as for the 6P ADD command, see <xref target="sec_add"/>.
                            Its format is the same as that in the 6P ADD command, but its content could be different.
                        </t>
                    </list>
                </t>
                <t>
                    <xref target="fig_signal_response"/> defines the format of a 6P SIGNAL Response.
                </t>
                <figure title="6P SIGNAL Response Format."                                                        anchor="fig_signal_response">
<artwork><![CDATA[
                       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
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version| T | R |     Code      |     SFID      |     SeqNum    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | payload ...
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
]]></artwork>
                </figure>
            </section>
        </section>
        <section title="Protocol Functional Details">
            <section title="Version Checking">
                <t>
                    All messages contain a Version field.
                    If multiple Versions of the 6P protocol have been defined (in future specifications for Version values different from 0), a node MAY implement multiple protocol versions at the same time.
                    When a node receives a 6P message with a Version number it does not implement, the node MUST reply with a 6P Response with a Return Code field set to RC_ERR_VERSION.
                    The format of this 6P Response message MUST be compliant with Version 0 and MUST be supported by all future versions of the protocol.
                    This ensures that, when node B sends a 6P Response to node A indicating it does not implement the 6P version in the 6P Request, node A can successfully parse that response.
                </t>
                <t>
                    When a node supports a version number received in a 6P Request message,
                        the Version field in the 6P Response MUST be the same as the Version field in the corresponding 6P Request.
                    Similarly, in a 3-step transaction, the Version field in the 6P Confirmation MUST match that of the 6P Request and 6P Response of the same transaction.
                </t>
            </section>
            <section title="SFID Checking">
                <t>
                    All messages contain an SFID field.
                    A node MAY support multiple SFs at the same time.
                    When receiving a 6P message with an unsupported SFID, a node MUST reply with a 6P Response and a return code of RC_ERR_SFID.
                    The SFID field in the 6P Response MUST be the same as the SFID field in the corresponding 6P Request.
                    In a 3-step transaction, the SFID field in the 6P Confirmation MUST match that of the 6P Request and the 6P Response of the same transaction.
                </t>
            </section>
            <section title="Concurrent 6P Transactions">
                <t>
                    Only a single 6P Transaction between two neighbors, in a given direction, can take place at the same time.
                    That is, a node MUST NOT issue a new 6P Request to a given neighbor before having received the 6P Response for a previous request to that neighbor, except when the previous 6P Transaction has timed out.
                    If a node receives a 6P Request from a given neighbor before having sent the 6P Response to the previous 6P Request from that neighbor, it MUST send back a 6P Response with a return code of RC_RESET (as per <xref target="fig_iana_rc"/>) and discard this ongoing second transaction.
                    A node receiving a RC_RESET code MUST abort the second transaction and consider it never happened.
                </t>
                <t>
                    Nodes A and B MAY support having two transactions going on at the same time, one in each direction.
                    Similarly, a node MAY support concurrent 6P Transactions with different neighbors.
                    In this case, the cells involved in an ongoing 6P Transaction MUST be "locked" until the transaction finishes.
                    For example, in <xref target="fig_network"/>, node C can have a different ongoing 6P Transaction with nodes B and R.
                    In case a node does not have enough resources to handle concurrent 6P Transactions from different neighbors it MUST reply with a 6P Response with return code RC_ERR_BUSY (as per <xref target="fig_iana_rc"/>).
                    In case the requested cells are locked, it MUST reply to that request with a 6P Response with return code RC_ERR_LOCKED (as per <xref target="fig_iana_rc"/>).
                    The node receiving RC_ERR_BUSY or a RC_ERR_LOCKED MAY implement a retry mechanism, defined by the SF.
                </t>
            </section>
            <section title="6P Timeout">
                <t>
                    A timeout occurs when the node have successfully sent a 6P Request does not receive the corresponding 6P Response within an amount of time specified by the SF.
                    In a 3-step transaction, a timeout also occurs when a node sending the 6P Response does not receive a 6P Confirmation.
                    When a timeout occurs, the transaction MUST be canceled at the node where the timeout occurs.
                    The value of the 6P Timeout should be larger than the longest possible time it takes to receive the 6P Response or Confirmation.
                    The value of the 6P Timeout hence depends on
                        the number of cells scheduled between the neighbor nodes,
                        the maximum number of link-layer retransmissions, etc.
                    The SF MUST determine the value of the timeout.
                    The value of the timeout is out of scope of this document.
                </t>
            </section>
            <section title="Aborting a 6P Transaction"                                                            anchor="sec_abort">
                <t>
                    In case the receiver of a 6P Request fails during a 6P Transaction and it is unable to complete it, it SHOULD reply to that Request with a 6P Response with return code RC_RESET.
                    Upon receiving this 6P Response, the initiator of the 6P Transaction MUST consider the 6P Transaction as failed.
                </t>
                <t>
                    Similarly, in the case of 3-step transaction, when the receiver of a 6P Response fails during the 6P Transaction and is unable to complete it, it MUST reply to that 6P Response with a 6P Confirmation with return code RC_RESET.
                    Upon receiving this 6P Confirmation, the sender of the 6P Response MUST consider the 6P Transaction as failed.
                </t>
            </section>
            <section title="SeqNum Management"                                                                    anchor="sec_SeqNum_Management">
                <t>
                    The SeqNum is the field in the 6top IE header used to match Request, Response and Confirmation.
                    The SeqNum is used to detect and handle
                        duplicate commands       (<xref target="sec_seqnum_duplicates"/>) and
                        schedule inconsistencies (<xref target="sec_seqnum_inconsistency"/>).
                    Each node remembers the last used SeqNum for each neighbor.
                    That is, a node stores as many SeqNum values as it has neighbors.
                    In case of supporting multiple SFs at a time, a SeqNum value is maintained per SF and per neighbor.
                    In the remainder of this section, we describe the use of SeqNum between two neighbors;
                        the same happens for each other neighbor, independently.
                </t>
                <t>
                    When a node resets or after a CLEAR transaction, it MUST reset SeqNum to 0.
                    The 6P Response and 6P Confirmation for a transaction MUST use the same SeqNum value as that in the Request.
                    After every transaction, the SeqNum MUST be incremented by exactly 1.
                </t>
                <t>
                    Specifically, if node A receives the link-layer acknowledgment for its 6P Request, it commits to incrementing the SeqNum by exactly 1 after the 6P Transaction ends.
                    This ensure that, at the next 6P Transaction where it sends a 6P Request, that 6P Request will have a different SeqNum.
                </t>
                <t>
                    Similarly, a node B increments the SeqNum by exactly 1
                        after having received the link-layer acknowledgment for the 6P Response     (2-step 6P Transaction), or
                        after having sent     the link-layer acknowledgment for the 6P Confirmation (3-step 6P Transaction)
                    .
                </t>
                <t>
                    When a node B receives a 6P Request from node A with SeqNum equal to 0, it checks the stored SeqNum for A. If 
                    A is a new neighbor, the stored SeqNum in B will be 0. The transaction can continue.
                    If the stored SeqNum for A in B is different than 0, a potential inconsistency is detected. In this case
                    B MUST return RC_ERR_SEQNUM with SeqNum=0. The SF at A MAY decide what to do next as described in <xref target="sec_seqnum_inconsistency"/>.
                </t>
                
                <t>
                    The SeqNum MUST be implemented as a lollipop counter: it rolls over from 0xFF to 0x01 (not to 0x00).
                    This is used to detect a neighbor reset.
                    <xref target="fig_seqnum_values"/> lists the possible values of the SeqNum.
                    <figure title="Possible values of the SeqNum."                                                anchor="fig_seqnum_values">
    <artwork><![CDATA[
              +-----------+-----------------------------+
              |   Value   | Meaning                     |
              +-----------+-----------------------------+
              |      0x00 | Clear or After device Reset |
              | 0x01-0xFF | Lollipop Counter values     |
              +-----------+-----------------------------+
    ]]></artwork>
                    </figure>
                </t>
                <section title="Detecting and Handling Duplicate 6P Messages"                                     anchor="sec_seqnum_duplicates">
                    <t>
                        All 6P commands are link-layer acknowledged.
                        A duplicate message means that a node receives a second 6P Request, Response or Confirmation.
                        This happens when the link-layer acknowledgment is not received, and a link-layer retransmission happens.
                        Duplicate messages are normal and unavoidable.
                    </t>
                    <t>
                        <xref target="fig_duplicate"/> shows an example 2-step transaction in which Node A receives a duplicate 6P Response.
                        <figure title="Example duplicate 6P message."                                             anchor="fig_duplicate">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
             |                                       |
             | 6P Request (SeqNum=456)               |
             |-------------------------------------->|
             |                                L2 ACK |
             |<- - - - - - - - - - - - - - - - - - - |
             |                                       |
             | 6P Response  (SeqNum=456)             |
             |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - - - -X                | No ACK:
             |                                       | link-layer
             | 6P Response  (SeqNum=456)             | retransmit
   duplicate |<--------------------------------------|
 6P Response | L2 ACK                                |
    received | - - - - - - - - - - - - - - - - - - ->|
             |                                       |
]]></artwork>
                        </figure>
                    </t>
                    <t>
                        <xref target="fig_duplicate_ooo"/> shows example 3-step transaction in which Node A receives a out-of-order duplicate 6P Response after having sent a 6P Confirmation.
                        <figure title="Example out-of-order duplicate 6P message."                                anchor="fig_duplicate_ooo">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
             |                                       |
             | 6P Request  (SeqNum=123)              |
             |-------------------------------------->|
             |                                L2 ACK |
             |<- - - - - - - - - - - - - - - - - - - |
             |                                       |
             | 6P Response  (SeqNum=123)             |
             |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - - - -X                | No ACK:
             |                                       | link-layer
             | 6P Confirmation  (SeqNum=123)         | retransmit
             |-------------------------------------->|    |
             |                                L2 ACK |    |
             |<- - - - - - - - - - - - - - - - - - - |  frame
             |                                       |  queued
             | 6P Response  (SeqNum=123)             |    |
   duplicate |<--------------------------------------| <--+
out-of-order | L2 ACK                                |
 6P Response | - - - - - - - - - - - - - - - - - - ->|
    received |                                       |
]]></artwork>
                        </figure>
                    </t>
                    <t>
                        A node detects a duplicate 6P message when it has the same SeqNum and type as the last frame received from the same neighbor.
                        When receiving a duplicate 6P message, a node MUST send a link-layer acknowledgment, but MUST silently ignore the 6P message at the 6top sublayer.
                    </t>
                </section>
                <section title="Detecting and Handling a Schedule Inconsistency"                                  anchor="sec_seqnum_inconsistency">
                    <t>
                        A schedule inconsistency happens when the schedules of nodes A and B are inconsistent.
                        For example, when node A has a transmit cell to node B, but node B does not have the corresponding receive cell, and therefore isn't listening to node A on that cell.
                        A schedule inconsistency results in loss of connectivity.
                    </t>
                    <t>
                        The SeqNum field, which is present in each 6P message, is used to detect an inconsistency.
                        The SeqNum field increments by 1 at each message.
                        A node computes the expected SeqNum field for the next 6P Transaction.
                        If a node receives a 6P Request with a SeqNum value that is not the expected one, it has detected an inconsistency.
                    </t>
                    <t>
                        There are at least 2 cases in which a schedule inconsistency happens.
                    </t>
                    <t>
                        The first case is when a node loses state, for example when it is power cycled (turned off, then on).
                        In that case, its SeqNum value is reset to 0.
                        Since the SeqNum is a lollipop counter, its neighbor detects an inconsistency at the next 6P transaction.
                        This is illustrated in <xref target="fig_inconsistency_reset"/>.
                        <figure title="Example of inconsistency because of node reset."                           anchor="fig_inconsistency_reset">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
   SeqNum=87 |                                       | SeqNum=87
             |                                       |
             | 6P Request  (SeqNum=87)               |
             |-------------------------------------->|
             |                                L2 ACK |
             |<- - - - - - - - - - - - - - - - - - - |
             |                                       |
             | 6P Response  (SeqNum=87)              |
             |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - - - - - - - - - - - ->|
             |                                     ==== power-cycle
             |                                       |
   SeqNum=88 |                                       | SeqNum=0
             |                                       |
             | 6P Request (SeqNum=88)                |
             |-------------------------------------->| Inconsistency
             |                                L2 ACK | Detected
             |<- - - - - - - - - - - - - - - - - - - |
             |                                       |
             | 6P Response (SeqNum=0, RC_ERR_SEQNUM) |
             |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - - - - - - - - - - - ->|
]]></artwork>
                        </figure>
                    </t>
                    <t>
                        The second case is when the maximum number of link-layer retransmissions is reached on the 6P Response of a 2-step transaction (or equivalently on a 6P Confirmation of a 3-step transaction).
                        This is illustrated in <xref target="fig_inconsistency_retransmissions"/>.
                        <figure title="Example inconsistency because of maximum link-layer retransmissions (here 2)."  anchor="fig_inconsistency_retransmissions">
<artwork><![CDATA[
        +----------+                           +----------+
        |  Node A  |                           |  Node B  |
        +----+-----+                           +-----+----+
   SeqNum=87 |                                       | SeqNum=87
             |                                       |
             | 6P Request  (SeqNum=87)               |
             |-------------------------------------->|
             |                                L2 ACK |
             |<- - - - - - - - - - - - - - - - - - - |
             |                                       |
             | 6P Response  (SeqNum=87)              |
             |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - X                     |
   SeqNum=88 |                                       | no ACK:
             | 6P Response  (SeqNum=87)              | retrans. 1
 (duplicate) |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - X                     |
             |                                       | no ACK:
             | 6P Response  (SeqNum=87)              | retrans. 2
 (duplicate) |<--------------------------------------|
             | L2 ACK                                |
             | - - - - - - - - X                     |
             |                                       | max retrans.:
             |                                       | Inconsistency
             |                                       | Detected
]]></artwork>
                        </figure>
                    </t>
                    <t>
                        In both cases, node B detects the inconsistency.
                    </t>
                    <t>
                        If the inconsistency is detected during a 6P Transaction (<xref target="fig_inconsistency_reset"/>), the node that has detected it MUST send back a 6P Response or 6P Confirmation with an error code of RC_ERR_SEQNUM.
                        In this 6P Response or 6P Confirmation, the SeqNum field MUST be set to the value of the sender of the message (0 in the example in <xref target="fig_inconsistency_reset"/>).
                    </t>
                    <t>
                        The SF of the node which has detected the inconsistency MUST define how to handle the inconsistency.
                        A first  possibility is to issue a 6P CLEAR request to clear the schedule, and rebuild.
                        A second possibility is to issue a 6P LIST request to retrieve the schedule.
                        A third  possibility is to internally "roll-back" the schedule.
                        How to handle an inconsistency is out of scope of this document.
                        The SF defines how to handle an inconsistency.
                    </t>
                </section>
            </section>
            <section title="Handling Error Responses">
                <t>
                    A return code marked as Yes in the "Is Error" column in <xref target="fig_iana_rc"/> indicates an error.
                    When a node receives a 6P Response or 6P Confirmation with an error, it MUST consider the 6P Transaction as failed.
                    In particular,
                        if this was a response to a 6P ADD, DELETE or RELOCATE Request,
                        the node MUST NOT add, delete or relocate any of the cells involved in this 6P Transaction.
                    Similarly, a node sending a 6P Response or a 6P Confirmation with an error code MUST NOT add, delete, relocate any cells as part of that 6P Transaction.
                    Defining what to do after an error has occurred is out of scope of this document.
                    The SF defines what to do after an error has occurred.
                </t>
            </section>
        </section>
        <section title="Security"                                                                                 anchor="sec_6p_security">
            <t>
               6P messages are secured through link-layer security.
               When link-layer security is enabled, the 6P messages MUST be secured.
               This is possible because 6P messages are carried as Payload IEs.
            </t>
        </section>
    </section>
    <section title="Requirements for 6top Scheduling Functions (SF)"                                              anchor="sec_sf">
        <section title="SF Identifier (SFID)"                                                                     anchor="sec_sfid">
        <t>
              Each SF has a 1-byte identifier.
              <xref target="sec_iana_sfid"/> defines the rules for applying for an SFID.
        </t>
        </section>
        <section title="Requirements for an SF">
            <t>
                The specification for an SF
                <list style="symbols">
                    <t>MUST specify an identifier for that SF.</t>
                    <t>MUST specify the rule for a node to decide when to add/delete one or more cells to a neighbor.</t>
                    <t>MUST specify the rule for a Transaction source      to select cells to add to the CellList field in the 6P ADD Request.</t>
                    <t>MUST specify the rule for a Transaction destination to select cells from CellList to add to its schedule.</t>
                    <t>MUST specify a value for the 6P Timeout, or a rule/equation to calculate it.</t>
                    <t>MUST specify the rule for ordering cells.</t>
                    <t>MUST specify a meaning for the "Metadata" field in the 6P ADD Request.</t>
                    <t>MUST specify the SF behavior of a node when it boots.</t>
                    <t>MUST specify how to handle a schedule inconsistency.</t>
                    <t>MUST specify what to do after an error has occurred (either the node sent a 6P Response with an error code, or received one).</t>
                    <t>
                        MUST specify the list of statistics to gather.
                        Example statistics include the number of transmitted frames to each neighbor.
                        In case the SF requires no statistics to be gathered, the specific of the SF MUST explicitly state so.
                    </t>
                </list>
                <list style="symbols">
                    <t>SHOULD clearly state the application domain the SF is created for.</t>
                    <t>SHOULD contain examples which highlight normal and error scenarios.</t>
                    <t>SHOULD contain a list of current implementations, at least during the I-D state of the document, per <xref target="RFC6982" />.</t>
                    <t>SHOULD contain a performance evaluation of the scheme, possibly through references to external documents.</t>
                    <t>SHOULD define the format of the SIGNAL command payload and its use.</t>
                </list>
                <list style="symbols">
                    <t>MAY redefine the format  of the CellList    field.</t>
                    <t>MAY redefine the format  of the CellOptions field.</t>
                    <t>MAY redefine the meaning of the CellOptions field.</t>
                </list>
            </t>
        </section>
    </section>
    <section title="Security Considerations">
        <t>
            6P messages are carried inside 802.15.4 Payload Information Elements (IEs).
            Those Payload IEs are encrypted and authenticated at the link layer through CCM* <xref target="CCM-Star"/>.
            6P benefits from the same level of security as any other Payload IE.
            The 6P protocol does not define its own security mechanisms.
            In particular,
                although a key management solution is out of scope of this document, 
                the 6P protocol will benefit for the key management solution used in the network.
        </t>
        <t>
            The 6P protocol does not provide protection against DOS attacks.
            Example attacks include,
                not sending confirmation messages in 3-step transaction,
                sending wrongly formatted requests,
                etc.
            These cases SHOULD be handled by an appropriate policy, such as blacklisting the attacker after several attempts.
            The effect on the overall network is mostly localized to those two nodes, as communication happens in dedicated cells.
        </t>
    </section>
    <section title="IANA Considerations"                                                                          anchor="sec_iana">
        <section title="IETF IE Subtype '6P'"                                                                     anchor="sec_iana_6p_ie">
            <t>
                This document adds the following number to the "IEEE Std 802.15.4 IETF IE subtype IDs" registry defined by <xref target="RFC8137"/>:
            </t>
            <figure title="IETF IE Subtype '6P'."                                                                 anchor="fig_iana_6p_ie">
<artwork><![CDATA[
               +--------------------+------+-----------+
               | Subtype            | Name | Reference |
               +--------------------+------+-----------+
               | IANA_6TOP_SUBIE_ID | 6P   | RFCXXXX   |
               +--------------------+------+-----------+
]]></artwork>
            </figure>
        </section>
        <section title="6TiSCH parameters sub-registries">
            <t>
                This section defines sub-registries within the "IPv6 over the TSCH mode of IEEE 802.15.4e (6TiSCH) parameters" registry, hereafter referred to as the "6TiSCH parameters" registry.
                Each sub-registry is described in a subsection.
            </t>
            <section title="6P Version Numbers"                                                                   anchor="sec_iana_version">
                <t>
                    The name of the sub-registry is "6P Version Numbers".
                </t>
                <t>
                    A Note included in this registry should say:
                    "In the 6top Protocol (6P) [RFCXXXX] there is a field to identify the version of the protocol.
                    This field is 4 bits in size."
                </t>
                <t>
                    Each entry in the sub-registry must include
                        the Version in the range 0-15, and
                        a reference to the 6P version's documentation.
                </t>
                <t>
                    The initial entry in this sub-registry is as follows:
                </t>
                <figure title="6P Version Numbers."                                                               anchor="fig_iana_version">
<artwork><![CDATA[
                       +---------+-----------+
                       | Version | Reference |
                       +---------+-----------+
                       |       0 |   RFCXXXX |
                       +---------+-----------+
]]></artwork>
                </figure>
                <t>
                    All other Version Numbers are Unassigned.
                </t>
                <t>
                    The IANA policy for future additions to this sub-registry is "IETF Review or IESG Approval" as described in <xref target="RFC8126"/>.
                </t>
            </section>
            <section title="6P Message Types"                                                                     anchor="sec_iana_type">
                <t>
                    The name of the sub-registry is "6P Message Types".
                </t>
                <t>
                    A note included in this registry should say:
                        "In the 6top Protocol (6P) version 0 [RFCXXXX], there is a field to identify the type of message.
                        This field is 2 bits in size."
                </t>
                <t>
                    Each entry in the sub-registry must include
                        the Type in range b00-b11,
                        the corresponding Name, and
                        a reference to the 6P message type's documentation.
                </t>
                <t>
                    Initial entries in this sub-registry are as follows:
                </t>
                <figure title="6P Message Types."                                                                 anchor="fig_iana_type">
<artwork><![CDATA[
               +------+--------------+-----------+
               | Type | Name         | Reference |
               +------+--------------+-----------+
               | b00  | REQUEST      |   RFCXXXX |
               | b01  | RESPONSE     |   RFCXXXX |
               | b10  | CONFIRMATION |   RFCXXXX |
               +------+--------------+-----------+
]]></artwork>
                </figure>
                <t>
                    All other Message Types are Reserved.
                </t>
                <t>
                    The IANA policy for future additions to this sub-registry is "IETF Review or IESG Approval" as described in <xref target="RFC8126"/>.
                </t>
            </section>
            <section title="6P Command Identifiers"                                                               anchor="sec_iana_cmdid">
                <t>
                    The name of the sub-registry is "6P Command Identifiers".
                </t>
                <t>
                    A Note included in this registry should say:
                        "In the 6top Protocol (6P) version 0 [RFCXXXX], there is a Code field which is 8 bits in size.
                        In a 6P Request, the value of this Code field is used to identify the command."
                </t>
                <t>
                    Each entry in the sub-registry must include
                        an Identifier in the range 0-255,
                        the corresponding Name, and
                        a reference to the 6P command identifier's documentation.
                </t>
                <t>
                    Initial entries in this sub-registry are as follows:
                </t>
                <figure title="6P Command Identifiers."                                                           anchor="fig_iana_cmdid">
<artwork><![CDATA[
                +------------+------------+-----------+
                | Identifier | Name       | Reference |
                +------------+------------+-----------+
                |          0 | Reserved   |           |
                |          1 | ADD        | RFCXXXX   |
                |          2 | DELETE     | RFCXXXX   |
                |          3 | RELOCATE   | RFCXXXX   |
                |          4 | COUNT      | RFCXXXX   |
                |          5 | LIST       | RFCXXXX   |
                |          6 | SIGNAL     | RFCXXXX   |
                |          7 | CLEAR      | RFCXXXX   |
                |      8-254 | Unassigned |           |
                |        255 | Reserved   |           |
                +------------+------------+-----------+
]]></artwork>
                </figure>
                <t>
                    The IANA policy for future additions to this sub-registry is "IETF Review or IESG Approval" as described in <xref target="RFC8126"/>.
                </t>
            </section>
            <section title="6P Return Codes"                                                                      anchor="sec_iana_rc">
                <t>
                    The name of the sub-registry is "6P Return Codes".
                </t>
                <t>
                    A Note included in this registry should say:
                        "In the 6top Protocol (6P) version 0 [RFCXXXX], there is a Code field which is 8 bits in size.
                        In a 6P Response or 6P Confirmation, the value of this Code field is used to identify the return code."
                </t>
                <t>
                    Each entry in the sub-registry must include
                        a Code in the range 0-255,
                        the corresponding Name,
                        the corresponding Description, and
                        a reference to the 6P return code's documentation.
                </t>
                <t>
                    Initial entries in this sub-registry are as follows:
                </t>
                <figure title="6P Return Codes."                                                                  anchor="fig_iana_rc">
<artwork><![CDATA[
   +------+-----------------+---------------------------+-----------+
   | Code | Name            | Description               | Is Error? |
   +------+-----------------+---------------------------+-----------+
   |    0 | RC_SUCCESS      | operation succeeded       |        No |
   |    1 | RC_EOL          | end of list               |        No |
   |    2 | RC_ERR          | generic error             |       Yes |
   |    3 | RC_RESET        | critical error, reset     |       Yes |
   |    4 | RC_ERR_VERSION  | unsupported 6P version    |       Yes |
   |    5 | RC_ERR_SFID     | unsupported SFID          |       Yes |
   |    6 | RC_ERR_SEQNUM   | schedule inconsistency    |       Yes |
   |    7 | RC_ERR_CELLLIST | cellList error            |       Yes |
   |    8 | RC_ERR_BUSY     | busy                      |       Yes |
   |    9 | RC_ERR_LOCKED   | cells are locked          |       Yes |
   +------+-----------------+---------------------------+-----------+
]]></artwork>
                </figure>
                <t>
                    All other Message Types are Unassigned.
                </t>
                <t>
                    The IANA policy for future additions to this sub-registry is "IETF Review or IESG Approval" as described in <xref target="RFC8126"/>.
                </t>
            </section>
            <section title="6P Scheduling Function Identifiers"                                                   anchor="sec_iana_sfid">
                <t>
                    6P Scheduling Function Identifiers.
                </t>
                <t>
                    A Note included in this registry should say:
                        "In the 6top Protocol (6P) version 0 [RFCXXXX], there is a field to identify the scheduling function to handle the message.
                        This field is 8 bits in size."
                </t>
                <t>
                    Each entry in the sub-registry must include
                        an SFID in the range 0-255,
                        the corresponding Name, and
                        a reference to the 6P Scheduling Function's documentation.
                </t>
                <t>
                    Initial entries in this sub-registry are as follows:
                </t>
                <figure title="SF Identifiers (SFID)."                                                            anchor="sfig_iana_sfids">
<artwork><![CDATA[
+----+---------------------------------+----------------------------+
|SFID| Name                            | Reference                  |
+----+---------------------------------+----------------------------+
|  0 | Minimal Scheduling Function     | draft-chang-6tisch-msf     |
|    | (MSF)                           |                            |
+----+---------------------------------+----------------------------+
|  1 | Experimental Scheduling Function| draft-ietf-6tisch-6top-sfx |
|    | (SFX)                           |                            |
+----+---------------------------------+----------------------------+
]]></artwork>
                </figure>
                <t>
                    All other Message Types are Unassigned.
                </t>
                <t>
                    The IANA policy for future additions to this sub-registry depends on the value of the SFID, as defined in <xref target="sfig_iana_sfid_reg"/>.
                    These specifications must follow the guidelines of <xref target="sec_sf"/>.
                </t>
                <figure title="SF Identifier (SFID): Registration Procedure."                                     anchor="sfig_iana_sfid_reg">
<artwork><![CDATA[
             +-----------+------------------------------+
             |     Range | Registration Procedures      |
             +-----------+------------------------------+
             |     0-127 | IETF Review or IESG Approval |
             |   128-255 | Expert Review                |
             +-----------+------------------------------+
]]></artwork>
                </figure>
            </section>
            <section title="6P CellOptions bitmap"                                                                anchor="sec_iana_celloptions">
                <t>
                    The name of the sub-registry is "6P CellOptions bitmap".
                </t>
                <t>
                    A Note included in this registry should say:
                        "In the 6top Protocol (6P) version 0 [RFCXXXX], there is an optional CellOptions field which is 8 bits in size."
                </t>
                <t>
                    Each entry in the sub-registry must include
                        a bit position in the range 0-7,
                        the corresponding Name, and
                        a reference to the bit's documentation.
                </t>
                <t>
                    Initial entries in this sub-registry are as follows:
                </t>
                <figure title="6P CellOptions bitmap."                                                            anchor="fig_iana_celloptions">
<artwork><![CDATA[
                 +-----+---------------+-----------+
                 | bit | Name          | Reference |
                 +-----+---------------+-----------+
                 |   0 | TX (Transmit) | RFCXXXX   |
                 |   1 | RX (Receive)  | RFCXXXX   |
                 |   2 | SHARED        | RFCXXXX   |
                 | 3-7 | Reserved      |           |
                 +-----+---------------+-----------+
]]></artwork>
                </figure>
                <t>
                    All other Message Types are Reserved.
                </t>
                <t>
                    The IANA policy for future additions to this sub-registry is "IETF Review or IESG Approval" as described in <xref target="RFC8126"/>.
                </t>
            </section>
        </section>
    </section>
</middle>
<back>
    <references title="Normative References">
        <!-- RFC 6TiSCH-->
        <!-- RFC others -->
        <?rfc include='reference.RFC.2119'?>       <!-- Key words for use in RFCs to Indicate Requirement Levels -->
        <!-- I-D 6TiSCH -->
        <!-- I-D others -->
        <?rfc include='reference.RFC.8137'?>
        <!-- external -->
        <reference                                                                                                anchor="IEEE802154">
            <front>
                <title>IEEE Std 802.15.4-2015 - IEEE Standard for Low-Rate Wireless Personal Area Networks (WPANs)</title>
                <author>
                    <organization>IEEE standard for Information Technology</organization>
                </author>
                <date month="October" year="2015"/>
            </front>
        </reference>
    </references>
    <references title="Informative References">
        <!-- RFC 6TiSCH-->
        <?rfc include='reference.RFC.7554'?>       <!-- Using IEEE 802.15.4e Time-Slotted Channel Hopping (TSCH) in the Internet of Things (IoT): Problem Statement -->
        <?rfc include='reference.RFC.8180'?>       <!-- Minimal IPv6 over the TSCH Mode of IEEE 802.15.4e (6TiSCH) Configuration -->
        <!-- RFC others -->
        <?rfc include='reference.RFC.8126'?>       <!-- Guidelines for Writing an IANA Considerations Section in RFCs -->
        <?rfc include='reference.RFC.6982'?>       <!-- Improving Awareness of Running Code: The Implementation Status Section -->
        <!-- I-D 6TiSCH -->
        <!-- I-D others -->
        <!-- external -->
        <reference                                                                                                anchor="OpenWSN">
            <front>
                <title>OpenWSN: a Standards-Based Low-Power Wireless Development Environment</title>
                <author initials="T" surname="Watteyne"   fullname="Thomas Watteyne" />
                <author initials="X" surname="Vilajosana" fullname="Xavier Vilajosana" />
                <author initials="B" surname="Kerkez"     fullname="Branko Kerkez" />
                <author initials="F" surname="Chraim"     fullname="Fabien Chraim" />
                <author initials="K" surname="Weekly"     fullname="Kevin Weekly" />
                <author initials="Q" surname="Wang"       fullname="Qin Wang" />
                <author initials="S" surname="Glaser"     fullname="Steven Glaser" />
                <author initials="K" surname="Pister"     fullname="Kris Pister" />
                <date month="August" year="2012" />
            </front>
            <seriesInfo name="Transactions on Emerging Telecommunications Technologies" value="" />
        </reference>
        <reference                                                                                                anchor="CCM-Star">
            <front>
                <title>
                    Formal Specification of the CCM* Mode of Operation, IEEE P802.15 Working Group for Wireless Personal Area Networks (WPANs).
                </title>
                <author initials="R." surname="Struik" fullname="René Struik"/>
                <date month="September" year="2005"/>
            </front>
        </reference>
    </references>
    <section title="Recommended Structure of an SF Specification">
        <t>
            The following section structure for a SF document is RECOMMENDED:
            <list style="symbols">
                <t>Introduction</t>
                <t>Scheduling Function Identifier</t>
                <t>Rules for Adding/Deleting Cells</t>
                <t>Rules for CellList</t>
                <t>6P Timeout Value</t>
                <t>Rule for Ordering Cells</t>
                <t>Meaning of the Metadata Field</t>
                <t>Node Behavior at Boot</t>
                <t>Schedule Inconsistency Handling</t>
                <t>6P Error Handling</t>
                <t>Examples</t>
                <t>Implementation Status</t>
                <t>Security Considerations</t>
                <t>IANA Considerations</t>
            </list>
        </t>
    </section>
</back>
</rfc>
