<?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-chang-6tisch-msf-02">
<front>
    <title>
        6TiSCH Minimal Scheduling Function (MSF)
    </title>
    <author initials="T" surname="Chang" fullname="Tengfei Chang" role="editor">
        <organization>Inria</organization>
        <address>
            <postal>
                <street>2 rue Simone Iff</street>
                <city>Paris</city>
                <code>75012</code>
                <country>France</country>
            </postal>
            <email>tengfei.chang@inria.fr</email>
        </address>
    </author>
    <author initials="M." surname="Vucinic" fullname="Malisa Vucinic">
        <organization>University of Montenegro</organization>
        <address>
            <postal>
                <street>Dzordza Vasingtona bb</street>
                <city>Podgorica</city>
                <code>81000</code>
                <country>Montenegro</country>
            </postal>
            <email>malisav@ac.me</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="S" surname="Duquennoy" fullname="Simon Duquennoy">
        <organization>RISE SICS</organization>
        <address>
            <postal>
                <street>Isafjordsgatan 22</street>
                <city>164 29 Kista</city>
                <country>Sweden</country>
            </postal>
            <email>simon.duquennoy@ri.se</email>
        </address>
    </author>
    <author initials="D" surname="Dujovne" fullname="Diego Dujovne" role="editor">
        <organization>Universidad Diego Portales</organization>
        <address>
            <postal>
                <street>Escuela de Informatica y Telecomunicaciones</street>
                <street>Av. Ejercito 441</street>
                <city>Santiago</city>
                <region>Region Metropolitana</region>
                <country>Chile</country>
            </postal>
            <phone>+56 (2) 676-8121</phone>
            <email>diego.dujovne@mail.udp.cl</email>
        </address>
    </author>
    <date/>
    <area>Internet Area</area>
    <workgroup>6TiSCH</workgroup>
    <keyword>Draft</keyword>
    <abstract>
        <t>
            This specification defines the 6TiSCH Minimal Scheduling Function (MSF).
            This Scheduling Function describes both
                the behavior of a node when joining the network, and
                how the communication schedule is managed in a distributed fashion.
            MSF builds upon
                the 6TiSCH Operation Sublayer Protocol (6P) and
                the Minimal Security Framework for 6TiSCH.
        </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" />.
        </t>
    </note>
</front>
<middle>
    <section title="Introduction"                                              anchor="sec_intro">
        <t>
            The 6TiSCH Minimal Scheduling Function (MSF), defined in this specification, is a 6TiSCH Scheduling Function (SF).
            The role of an SF is entirely defined in <xref target="I-D.ietf-6tisch-6top-protocol" />: it complements <xref target="I-D.ietf-6tisch-6top-protocol" /> by providing the rules of when to add/delete cells in the communication schedule.
            The SF defined in this document follows that definition, and satisfies all the requirements for an SF listed in Section 4.2 of <xref target="I-D.ietf-6tisch-6top-protocol" />.
        </t>
        <t>
            MSF builds on top of the following specifications:
                the Minimal IPv6 over the TSCH Mode of IEEE 802.15.4e (6TiSCH) Configuration <xref target="RFC8180" />,
                the 6TiSCH Operation Sublayer Protocol (6P) <xref target="I-D.ietf-6tisch-6top-protocol" />, and
                the Minimal Security Framework for 6TiSCH <xref target="I-D.ietf-6tisch-minimal-security" />.
        </t>
        <t>
            MSF defines both
                the behavior of a node when joining the network, and
                how the communication schedule is managed in a distributed fashion.
            When a node running MSF boots up, it joins the network by following the 7 steps described in <xref target="sec_boot" />.
            The end state of the join process is that the node
                is synchronized to the network,
                has mutually authenticated to the network,
                has identified a preferred routing parent,
                has scheduled one default unicast cell to/from each of its neighbors.
            After the join process, the node can continuously add/delete/relocate cells, as described in <xref target="sec_add_delete" />.
            It does so for 3 reasons:
                to match the link-layer resources to the traffic,
                to handle changing parent,
                to handle a schedule collision.
        </t>
        <t>
            MSF is designed to operate in a wide range of application domains.
            It is optimized for applications with regular upstream traffic (from the nodes to the root).
            <xref target="sec_performance" /> contains a performance evaluation of MSF.
        </t>
        <t>
            This specification follows the recommended structure of an SF specification in Appendix A of <xref target="I-D.ietf-6tisch-6top-protocol" />, with the following adaptations:
            <list style="symbols">
                <t>
                    We have reordered part of the sections, in particular to have the section on the node behavior at boot <xref target="sec_boot" /> appear early in this specification.
                </t>
                <t>
                    We added sections on
                        the interface to the minimal 6TiSCH configuration <xref target="sec_minimal" />,
                        the use of the SIGNAL command <xref target="sec_signal" />,
                        the MSF constants <xref target="sec_constants" />,
                        the MSF statistics <xref target="sec_stats" />,
                        the performance of MSF <xref target="sec_performance" />.
                </t>
                <t>
                    This specification does not include an examples section.
                </t>
            </list>
        </t>
    </section>
    <section title="Interface to the Minimal 6TiSCH Configuration"             anchor="sec_minimal">
        <t>
            A node implementing MSF MUST implement the Minimal 6TiSCH Configuration <xref target="RFC8180" />, which defines the "minimal cell", a single shared cell providing minimal connectivity between the nodes in the network.
        </t>
        <t>
            MSF uses the minimal cell to exchange the following packets:
            <list style="numbers">
                <t>
                    Enhanced Beacons (EBs), defined by <xref target="IEEE802154-2015" />.
                    These are broadcast frames.
                </t>
                <t>
                    DODAG Information Objects (DIOs), defined by <xref target="RFC6550" />.
                    These are broadcast frames.
                </t>
            </list>
        </t>
        <t>
            Because the minimal cell is SHARED, the back-off algorithm defined in <xref target="IEEE802154-2015" /> is used to resolve collisions.
            To ensure there is enough bandwidth available on the minimal cell, a node implementing MSF SHOULD enforce the following rules for broadcast frames:
            <list style="numbers">
                <t>send EBs  on a portion of the minimal cells not exceeding 1/(3(N+1)), where N is the number of neighbors of the node.</t>
                <t>send DIOs on a portion of the minimal cells not exceeding 1/(3(N+1)), where N is the number of neighbors of the node.</t>
            </list>
            <!-- SD: do we need to restrict to EBs and DIOs? How about "any broadcast"? This is more general, and can accomodate
            any protocol e.g. 6lowpan-nd or whatever else. -->
        </t>
        <t>
            The RECOMMENDED behavior for sending EBs is to have a node send EBs with a probability of 1/(3(N+1)).
            The RECOMMENDED behavior for sending DIOs is to use a Trickle timer with rate-limiting.
        </t>
        <t>
            <xref target="sec_ebs" /> describes how to evaluate the number of neighbors during the joining process.
            After the joining process, how to evaluate the number of neighbors is implementation-specific.
        </t>
        <t>
            As detailed in Section 2.2 of <xref target="I-D.ietf-6tisch-6top-protocol" />, MSF MUST schedule cells from Slotframe 1, while Slotframe 0 is used for traffic defined in the Minimal 6TiSCH Configuration.
            The length of Slotframe 0 and Slotframe 1 SHOULD be the same value.
            <!-- SD: proposal: do not enforce that they MUST have the same value. Different values can be useful
            to provision the rendez-vous slot without affecting per-hop latency (which is determined by slotframe 1 length) -->
            The default of SLOTFRAME_LENGTH is RECOMMENDED, although any value can be advertised in the EBs.
        </t>
    </section>
    <section title="Autonomous Unicast Cells"                                  anchor="sec_autonomous_unicast_cells">
        <t>
            MSF nodes MUST initialize Slotframe 1 with a set of default cells for unicast communication with their neighbors.
            These cells are referred to as 'autonomous cells', because they are maintained autonomously by each node.
            Each node has:
            <list style="numbers">
                <t>
                    One cell to receive, at a [slotOffset,channelOffset] computed as a hash of the node's EUI64 (detailed next).
                    The cell options for this cell are RX=1.
                </t>
                <t>
                    For each neighbor in the IPv6 neighbor table, one cell to transmit, at a [slotOffset,channelOffset] computed as a hash of the neighbor's EUI64 (detailed next).
                    The cell options for this cell are TX=1, SHARED=1.
                </t>
            </list>
        </t>
        <t>
            To compute a [slotOffset,channelOffset] from an EUI64 address, nodes MUST use the hash function SAX <xref target="SAX-DASFAA"/>.
            The coordinates are computed to distribute the cells across all 16 channel offsets, and all but the first time offsets of Slotframe 1.
            The first time offset is skipped to avoid colliding with the minimal cell in Slotframe 0.
            The slot coordinates derived from a given EUI64 address are computed as follows:
            <list>
                <t>slotOffset(MAC) = 1 + hash(EUI64) % (length(Slotframe_1) - 1) </t>
                <t>channelOffset(MAC) = hash(EUI64) % 16</t>
            </list>
        </t>
        <t>
            Because of hash collisions, there are cases where one node has multiple cells scheduled at the same time offset and/or channel offset.
            Note that nodes have only one autonomous RX cell and potentially multiple TX cells.
            Hash collisions among a set of cells at a given time offset is resolved at run-time as follows:
            <list style="numbers">
                <t>The TX cell with the most packets in outgoing queue takes precedence.</t>
                <t>If all TX cells have empty outgoing queues, the RX cell takes precedence.</t>
            </list>
        </t>
        <t>
            Throughout the network lifetime, nodes MUST maintain the autonomous cells as follows:
            <list style="numbers">
                <t>The receive cell MUST always remain scheduled.</t>
                <t>Whenever a new neighbor is discovered, add a transmit cell for it.</t>
                <t>Whenever a new neighbor is removed, remove transmit cell that was assigned to it.</t>
                <t>6P CLEAR MUST NOT erase autonomous cells.</t>
            </list>
        </t>
    </section>
    <section title="Node Behavior at Boot"                                     anchor="sec_boot">
        <t>
            This section details the behavior the node SHOULD follow from the moment it is switched on, until it has successfully joined the network.
            <xref target="sec_start_state" /> details the start state;
            <xref target="sec_end_state" />   details the end   state.
            The other sections detail the 7 steps of the joining process.
            We use the term "pledge" and "joined node", as defined in <xref target="I-D.ietf-6tisch-minimal-security" />.
        </t>
        <section title="Start State"                                           anchor="sec_start_state">
            <t>
                A node implementing MSF MUST implement the Minimal Security Framework for 6TiSCH <xref target="I-D.ietf-6tisch-minimal-security" />.
                As a corollary, this means that a pledge, before being switched on, is pre-configured with the Pre-Shared Key (PSK) for joining, as well as any other configuration detailed in <xref target="I-D.ietf-6tisch-minimal-security" />.
            </t>
        </section>
        <section title="Step 1 - Choosing Frequency"                           anchor="sec_frequency">
            <t>
                When switched on, the pledge SHOULD randomly choose a frequency among the available frequencies, and start listening for EBs on that frequency.
            </t>
        </section>
        <section title="Step 2 - Receiving EBs"                                anchor="sec_ebs">
            <t>
                Upon receiving the first EB, the pledge SHOULD continue listening for additional EBs to learn:
                <list style="numbers">
                    <t>the number of neighbors N in its vicinity</t>
                    <t>which neighbor to choose as a Join Proxy (JP) for the joining process</t>
                </list>
            </t>
            <t>
                While the exact behavior is implementation-specific, the RECOMMENDED behavior is to follow <xref target="RFC8180" />, and listen until EBs sent by NUM_NEIGHBOURS_TO_WAIT nodes (defined in <xref target="RFC8180" />) have been received.
            </t>
            <t>
                During this step, the pledge MAY synchronize to any EB it receives from the network it wishes to join.
                How to decide whether an EB originates from a node from the network it wishes to join is implementation-specific, but MAY involve filtering EBs by
                    the PAN ID field it contains,
                    the presence and contents of the IE defined in <xref target="I-D.richardson-6tisch-join-enhanced-beacon" />, or
                    the key used to authenticate it.
            </t>
            <t>
                The decision of which neighbor to use as a JP is implementation-specific, and discussed in <xref target="I-D.ietf-6tisch-minimal-security" />.
            </t>
            <!-- SD: I wonder if we really need to define step 1 and step 2 above. Feels like this belongs to general 6TiSCH (and to some extent even IEEE 802.15.4-2015). Does not feel MSF-specific. -->
        </section>
        <section title="Step 3 - Setting up Autonomous Unicast Cells"          anchor="sec_auto">
            <t>
                After joining, nodes MUST set up their autonomous unicast cells, as described in <xref target="sec_autonomous_unicast_cells" />.
                This enables unicast communication in Slotframe 1, until more cells are added with 6P as defined in <xref target="sec_add_delete" />.
            </t>
        </section>
        <section title="Step 4 - Join Request/Response"                        anchor="sec_join">
            <t>
                As per <xref target="I-D.ietf-6tisch-minimal-security" />, after having selected a JP, the pledge sends a Join Request to its JP.
                Because no dedicated cells are in place at this point, this happens on the autonomous unicast cell.
                <!-- SD: do we really mean to call these cells "dedicated"? In 802.15.4-2015, this means "not shared". But our cells have the shared bit set. -->
                The JP then forwards the Join Request to the JRC, possibly over multiple hops.
                When forwarding this Join Request, a node MUST use a unicast cell (autonomous or dedicated) it has with its preferred parent.
                How dedicated cells are installed is detailed in <xref target="sec_add_delete" />.
            </t>
            <t>
                As per <xref target="I-D.ietf-6tisch-minimal-security" />, the JRC sends back a Join Response to the pledge, through the JP.
                When forwarding this Join Response, a node MUST use a unicast (autonomous or dedicated) cell it has with its child (not the minimal cell).
            </t>
            <t>
                As per <xref target="I-D.ietf-6tisch-minimal-security" />, after receiving the Join Response, the pledge learns the keying material used in the network, as well as other configurations, and becomes a "joined node".
            </t>
        </section>
        <section title="Step 5 - Acquiring a RPL rank"                         anchor="sec_rank">
            <t>
                Because it has learned the link-layer keying material used in the network, the joined node can now decrypt the DIO packets sent by its neighbors.
                Per <xref target="RFC6550" />, the joined node
                    receives DIOs,
                    computes its own rank, and
                    selects a preferred parent.
            </t>
        </section>
        <section title="Step 6 - Send EBs and DIOs"                            anchor="sec_eb_dio">
            <t>
                The node SHOULD start sending EBs and DIOs on the minimal cell, while following the transmit rules for broadcast frames from <xref target="sec_minimal" />.
            </t>
        </section>
        <section title="Step 7 - Neighbor Polling"                             anchor="sec_polling">
            <t>
                The node SHOULD send some form of keep-alive messages to all its neighbors it has unicast cells with.
                The Keep-Alive (KA) mechanism is detailed in <xref target="RFC7554" />.
                It uses the keep-alive messages to its preferred parent to stay synchronized.
                It uses the keep-alive messages to its children (with which it has a unicast cell to) to ensure the child is still reachable.
                The RECOMMENDED period for sending keep-alive messages is KA_PERIOD.
            </t>
            <t>
                If the keep-alive message to a child fails at the link layer (i.e. the maximum number of link-layer retries is reached), the node SHOULD declare the child as unreachable.
                This can happen for example when the child node is switched off.
            </t>
            <t>
                When a neighbor is declared unreachable, the node MUST remove all dedicated cells with that neighbor from its own schedule.
                In addition, it MAY issue a 6P CLEAR to that neighbor (which can fail at the link-layer).
                If the node has autonmous cells to the unreachable neighbor those cells will be removed following the procedure described in <xref target="sec_autonomous_unicast_cells" />.
            </t>
        </section>
        <section title="End State"                                             anchor="sec_end_state">
            <t>
                For a new node, the end state of the joining process is:
                <list style="symbols">
                    <t>it is synchronized to the network</t>
                    <t>it is using the link-layer keying material it learned through the secure joining process</t>
                    <t>it has identified its preferred routing parent</t>
                    <t>it has a set of autonomous unicast cells to/from its neighbors</t>
                    <t>it is periodically sending DIOs, potentially serving as a router for other nodes' traffic</t>
                    <t>it is periodically sending EBs,  potentially serving as a JP for new joining nodes</t>
                </list>
            </t>
        </section>
    </section>
    <section title="Rules for Adding/Deleting Cells"                           anchor="sec_add_delete">
        <t>
            Once a node has joined the 6TiSCH network, it adds/deletes/relocates cells with its preferred parent for three reasons:
            <list style="symbols">
                <t>to match the link-layer resources to the traffic between the node and its preferred parent (<xref target="sec_traffic" />)</t>
                <t>to handle switching preferred parent (<xref target="sec_switching_parent" />)</t>
                <t>to handle a schedule collision (<xref target="sec_collision" />)</t>
            </list>
        </t>
        <section title="Adapting to Traffic"                                   anchor="sec_traffic">
            <t>
                A node implementing MSF MUST implement the behavior described in this section.
            </t>
            <t>
                In order to handle transient traffic bursts, MSF uses the <xref target="IEEE802154-2015" /> frame pending bit (page 152, Section 7.2.1.3).
                By setting the bit, a node can transmit a series of packets to a given neighbor in consecutive time offsets.
                The next paragraphs define how to handle longer-term fluctuations in traffic, using 6P.
            </t>
            <t>
                The goal of MSF is to manage the communication schedule in the 6TiSCH schedule in a distributed manner.
                For a node, this translates into monitoring the current usage of the cells it has to its preferred parent:
                <list style="symbols">
                    <t>
                        If the node determines that the number of link-layer frames it is attempting to exchange with its preferred parent per unit of time is larger than the capacity offered by the TSCH unicast cells (dedicated and autonmous cells) it has scheduled with it, the node triggers a 6P Transaction with its preferred parent to add dedicated cells to the TSCH schedule of both nodes.
                    </t>
                    <t>
                        If the traffic is lower than the capacity, the node triggers a 6P Transaction with its preferred parent to delete dedicated cells from the TSCH schedule of both nodes.
                    </t>
                </list>
            </t>
            <t>
                From the join process, the node already has a set of autonmous unicast cells, as defined in <xref target="sec_autonomous_unicast_cells" />.
                The autonomous cells MUST NOT be removed by 6P, so that there always exists a unicast cell between a node and its preferred parent, even if no frames are being exchanged between them.
                Autonomous cells are used indistinguishably together with dedicated cells, for broadcast or unicast traffic with the target neighbor.
                The procedure to remove autonomous cells is described in <xref target="sec_autonomous_unicast_cells" />.
            </t>
            <t>
                Adding/removing/relocating cells involves exchanging frames that contain 6P commands.
                All 6P frames MUST be sent on the unicast cells (and not the minimal cell).
            </t>
            <t>
                The node MUST maintain the following counters for its preferred parent:
                <list hangIndent="4" style="hanging">
                    <t hangText="NumCellsPassed:">
                        Counts the number of unicast cells (dedicated and autonmous cells) that have passed since the counter was initialized. 
                        This counter is initialized at 0.
                        Each time the TSCH state machine indicates that the current cell is a unicast cell to the preferred parent, NumCellsPassed is incremented by exactly 1, regardless of whether the cell is used to transmit/receive a frame.
                    </t>
                    <t hangText="NumCellsUsed:">
                        Counts the number of unicast cells that have been used. 
                        This counter is initialized at 0.
                        NumCellsUsed is incremented by exactly 1 when, during a unicast cell to the preferred parent, either of the following happens:
                        <list style="symbols">
                            <t>
                                The node sends a frame to its preferred parent.
                                The counter increments regardless of whether a link-layer acknowledgment was received or not.
                            </t>
                            <t>
                                The node receives a frame from its preferred parent.
                            </t>
                        </list>
                    </t>
                </list>
            </t>
            <t>
                Implementors MAY choose to create the same counters for each neighbor, and add them as additional statistics in the neighbor table.
            </t>
            <t>
                The counters are used as follows:
                <list style="numbers">
                    <t>
                        Both NumCellsPassed and NumCellsUsed are initialized to 0 when the node boots.
                    </t>
                    <t>
                        When the value of NumCellsPassed reaches MAX_NUMCELLS:
                        <list style="symbols">
                            <t>If NumCellsUsed &gt; LIM_NUMCELLSUSED_HIGH, trigger 6P to add    a single cell to the preferred parent</t>
                            <t>If NumCellsUsed &lt; LIM_NUMCELLSUSED_LOW,  trigger 6P to remove a single cell to the preferred parent</t>
                            <t>Reset both NumCellsPassed and NumCellsUsed to 0 and go to step 2.</t>
                        </list>
                    </t>
                </list>
            </t>
        </section>
        <section title="Switching Parent"                                      anchor="sec_switching_parent">
            <t>
                A node implementing MSF MUST implement the behavior described in this section.
            </t>
            <t>
                Part of its normal operation, the RPL routing protocol can have a node switch preferred parents.
                The procedure for switching from the old preferred parent to the new preferred parent is:
                <list style="numbers">
                    <t>the node counts the number of dedicated (unicast but not autonomous) cells it has per slotframe to the old preferred parent</t>
                    <t>the node triggers one or more 6P ADD commands to schedule the same number of dedicated cells to the new preferred parent</t>
                    <t>when that successfully completes, the node issues a 6P CLEAR command to its old preferred parent</t>
                </list>
            </t>
        </section>
        <section title="Handling Schedule Collisions"                          anchor="sec_collision">
            <t>
                A node implementing MSF SHOULD implement the behavior described in this section.
                The "MUST" statements in this section hence only apply if the node implements schedule collision handling.
            </t>
            <t>
                Since scheduling is entirely distributed, there is a non-zero probability that two pairs of nearby neighbor nodes schedule a cell at the same [slotOffset,channelOffset] location in the TSCH schedule.
                In that case, data exchanged by the two pairs may collide on that cell.
                We call this case a "schedule collision".
            </t>
            <t>
                The node MUST maintain the following counters for each cell to its preferred parent:
                <list hangIndent="4" style="hanging">
                    <t hangText="NumTx:">
                        Counts the number of transmission attempts on that cell.
                        Each time the node attempts to transmit a frame on that cell, NumTx is incremented by exactly 1.
                    </t>
                    <t hangText="NumTxAck:">
                        Counts the number of successful transmission attempts on that cell.
                        Each time the node receives an acknowledgment for a transmission attempt, NumTxAck is incremented by exactly 1.
                    </t>
                </list>
            </t>
            <t>
                Implementors MAY choose to maintain the same counters for each cell in the schedule.
            </t>
            <t>
                Since both NumTx and NumTxAck are initialized to 0, we necessarily have NumTxAck &lt;= NumTx.
                We call Packet Delivery Ratio (PDR) the ratio NumTxAck/NumTx; and represent it as a percentage.
                A cell with PDR=50% means that half of the frames transmitted are not acknowledged (and need to be retransmitted).
            </t>
            <t>
                Each time the node switches preferred parent (or during the join process when the node selects a preferred parent for the first time), both NumTx and NumTxAck MUST be reset to 0.
                They increment over time, as the schedule is executed and the node sends frames to its preferred parent.
                When NumTx reaches 256, both NumTx and NumTxAck MUST be divided by 2.
                That is, for example, from NumTx=256 and NumTxAck=128, they become NumTx=128 and NumTxAck=64.
                This operation does not change the value of the PDR, but allows the counters to keep incrementing.
            </t>
            <t>
                The key for detecting a schedule collision is that, if a node has several cells to the same preferred parent, all cells should exhibit the same PDR.
                A cell which exhibits a PDR significantly lower than the others indicates than there are collisions on that cell.
            </t>
            <t>
                Every HOUSEKEEPINGCOLLISION_PERIOD, the node executes the following steps:
                <list style="numbers">
                    <t>
                        It computes, for each dedicated cell with its preferred parent (not for the autonomous cell), that cell's PDR.
                    </t>
                    <t>
                        Any cell that hasn't yet had NumTx divided by 2 since it was last reset is skipped in steps 3 and 4.
                        This avoids triggering cell relocation when the values of NumTx and NumTxAck are not statistically significant yet.
                    </t>
                    <t>
                        It identifies the cell with the highest PDR.
                    </t>
                    <t>
                        For each other cell, it compares its PDR against that of the cell with the highest PDR.
                        If it's less than RELOCATE_PDRTHRES, it triggers the relocation of that cell using a 6P RELOCATE command.
                    </t>
                </list>
            </t>
        </section>
    </section>
    <section title="6P SIGNAL command"                                         anchor="sec_signal">
        <t>
            The 6P SIGNAL command is not used by MSF.
        </t>
    </section>
    <section title="Scheduling Function Identifier"                            anchor="sec_sfid">
        <t>
            The Scheduling Function Identifier (SFID) of MSF is IANA_6TISCH_SFID_MSF.
        </t>
    </section>
    <section title="Rules for CellList"                                        anchor="sec_celllist">
        <t>
            MSF uses 2-step 6P Transactions exclusively.
            6P Transactions are only initiated by a node towards it preferred parent.
            As a result, the cells to put in the CellList of a 6P ADD command, and in the candidate CellList of a RELOCATE command, are chosen by the node initiating the 6P Transaction.
            In both cases, the same rules apply:
            <list style="symbols">
                <t>The CellList SHOULD contain 5 or more cells.</t>
                <t>Each cell in the CellList MUST have a different slotOffset value.</t>
                <t>For each cell in the CellList, the node MUST NOT have any scheduled cell on the same slotOffset.</t>
                <t>The slotOffset value of any cell in the CellList MUST NOT be the same as the slotOffset of the minimal cell (slotOffset=0).</t>
                <t>The slotOffset    of a cell in the CellList SHOULD be randomly and uniformly chosen among all the slotOffset values that satisfy the restrictions above.</t>
                <t>The channelOffset of a cell in the CellList SHOULD be randomly and uniformly chosen in [0..numFrequencies], where numFrequencies represents the number of frequencies a node can communicate on.</t>
            </list>
        </t>
    </section>
    <section title="6P Timeout Value"                                          anchor="sec_timeout">
        <t>
            The 6P Timeout is not a constant value.
            It is calculated as (1/C)*(1/PDR)*SIXP_TIMEOUT_SEC_FACTOR, where:
            <list style="symbols">
                <t>C represents the number of cells per second scheduled to that neighbor</t>
                <t>PDR represents the average PDR of those cells</t>
                <t>SIXP_TIMEOUT_SEC_FACTOR is a security factor, a constant</t>
            </list>
        </t>
    </section>
    <section title="Rule for Ordering Cells"                                   anchor="sec_ordering">
        <t>
            Cells are ordered slotOffset first, channelOffset second.
        </t>
        <t>
            The following sequence is correctly ordered (each element represents the [slottOffset,channelOffset] of a cell in the schedule):
        </t>
        <t>
            [1,3],[1,4],[2,0],[5,3],[6,0],[6,3],[7,9]
        </t>
    </section>
    <section title="Meaning of the Metadata Field"                             anchor="sec_metadata">
        <t>
            The Metadata field is not used by MSF.
        </t>
    </section>
    <section title="6P Error Handling"                                         anchor="sec_error">
        <t>
            Section 6.2.4 of <xref target="I-D.ietf-6tisch-6top-protocol" /> lists the 6P Return Codes.
            <xref target="tab_error" /> lists the same error codes, and the behavior a node implementing MSF SHOULD follow.
        </t>
        <figure title="Recommended behavior for each 6P Error Code."           anchor="tab_error">
<artwork><![CDATA[
       +-----------------+----------------------+
       | Code            | RECOMMENDED behavior |
       +-----------------+----------------------+
       | RC_SUCCESS      | nothing              |
       | RC_EOL          | nothing              |
       | RC_ERR          | quarantine           |
       | RC_RESET        | quarantine           |
       | RC_ERR_VERSION  | quarantine           |
       | RC_ERR_SFID     | quarantine           |
       | RC_ERR_SEQNUM   | clear                |
       | RC_ERR_CELLLIST | clear                |
       | RC_ERR_BUSY     | waitretry            |
       | RC_ERR_LOCKED   | waitretry            |
       +-----------------+----------------------+
]]></artwork>
        </figure>
        <t>
            The meaning of each behavior from <xref target="tab_error" /> is:
            <list hangIndent="4" style="hanging">
                <t hangText="nothing:">
                    Indicates that this Return Code is not an error.
                    No error handling behavior is triggered.
                </t>
                <t hangText="clear:">
                    Abort the 6P Transaction.
                    Issue a 6P CLEAR command to that neighbor (this command may fail at the link layer).
                    Remove all cells scheduled with that neighbor from the local schedule.
                    Keep that node in the neighbor and routing tables.
                </t>
                <t hangText="quarantine:">
                    Same behavior as for "clear".
                    In addition, remove the node from the neighbor and routing tables.
                    Place the node's identifier in a quarantine list for QUARANTINE_DURATION.
                    When in quarantine, drop all frames received from that node.
                </t>
                <t hangText="waitretry:">
                    Abort the 6P Transaction.
                    Wait for a duration randomly and uniformly chosen in [WAITDURATION_MIN,WAITDURATION_MAX].
                    Retry the same transaction.
                </t>
            </list>
        </t>
    </section>
    <section title="Schedule Inconsistency Handling"                           anchor="sec_inconsistency">
        <t>
            The behavior when schedule inconsistency is detected is explained in <xref target="tab_error" />, for 6P Return Code RC_ERR_SEQNUM.
        </t>
    </section>
    <section title="MSF Constants"                                             anchor="sec_constants">
        <t>
            <xref target="tab_constants" /> lists MSF Constants and their RECOMMENDED values.
        </t>
        <figure title="MSF Constants and their RECOMMENDED values."            anchor="tab_constants">
<artwork><![CDATA[
        +------------------------------+-------------------+
        | Name                         | RECOMMENDED value |
        +------------------------------+-------------------+
        | KA_PERIOD                    |       10 s        |
        | LIM_NUMCELLSUSED_HIGH        |       75 %        |
        | LIM_NUMCELLSUSED_LOW         |       25 %        |
        | HOUSEKEEPINGCOLLISION_PERIOD |        1 min      |
        | RELOCATE_PDRTHRES            |       50 %        |
        | SIXP_TIMEOUT_SEC_FACTOR      |        3 x        |
        | SLOTFRAME_LENGTH             |      101 slots    |
        | QUARANTINE_DURATION          |        5 min      |
        | WAITDURATION_MIN             |       30 s        |
        | WAITDURATION_MAX             |       60 s        |
        +------------------------------+-------------------+
]]></artwork>
        </figure>
    </section>
    <section title="MSF Statistics"                                            anchor="sec_stats">
        <t>
            <xref target="tab_stats" /> lists MSF Statistics and their RECOMMENDED width.
        </t>
        <figure title="MSF Statistics and their RECOMMENDED width."            anchor="tab_stats">
<artwork><![CDATA[
                +-----------------+-------------------+
                | Name            | RECOMMENDED width |
                +-----------------+-------------------+
                | NumCellsPassed  |      1 byte       |
                | NumCellsUsed    |      1 byte       |
                | NumTx           |      1 byte       |
                | NumTxAck        |      1 byte       |
                +-----------------+-------------------+
]]></artwork>
        </figure>
    </section>
    <section title="Security Considerations"                                   anchor="sec_security">
        <t>
            MSF defines a series of "rules" for the node to follow.
            It triggers several actions, that are carried out by the protocols defined in the following specifications:
                the Minimal IPv6 over the TSCH Mode of IEEE 802.15.4e (6TiSCH) Configuration <xref target="RFC8180" />,
                the 6TiSCH Operation Sublayer Protocol (6P) <xref target="I-D.ietf-6tisch-6top-protocol" />, and
                the Minimal Security Framework for 6TiSCH <xref target="I-D.ietf-6tisch-minimal-security" />.
            In particular, MSF does not define a new protocol or packet format.
        </t>
        <t>
            MSF relies entirely on the security mechanisms defined in the specifications listed above.
        </t>
    </section>
    <section title="IANA Considerations"                                       anchor="sec_iana">
        <section title="MSF Scheduling Function Identifiers"                   anchor="sec_iana_sfid">
            <t>
                This document adds the following number to the
                    "6P Scheduling Function Identifiers" sub-registry,
                    part of the "IPv6 over the TSCH mode of IEEE 802.15.4e (6TiSCH) parameters" registry,
                    as defined by <xref target="I-D.ietf-6tisch-6top-protocol" />:
            </t>
            <figure title="IETF IE Subtype '6P'."                              anchor="fig_iana_sfid">
<artwork><![CDATA[
+----------------------+-----------------------------+-------------+
|  SFID                | Name                        | Reference   |
+----------------------+-----------------------------+-------------+
| IANA_6TISCH_SFID_MSF | Minimal Scheduling Function | RFCXXXX     |
|                      | (MSF)                       | (NOTE:this) |
+----------------------+-----------------------------+-------------+
]]></artwork>
            </figure>
        </section>
    </section>
</middle>
<back>
    <references title="Normative References">
        <!-- RFC 6TiSCH-->
        <?rfc include='reference.RFC.8180'?>     <!-- Minimal IPv6 over the TSCH Mode of IEEE 802.15.4e (6TiSCH) Configuration -->
        <?rfc include='reference.RFC.7554'?>     <!-- Using IEEE 802.15.4e Time-Slotted Channel Hopping (TSCH) in the Internet of Things (IoT): Problem Statement -->
        <!-- RFC others -->
        <?rfc include='reference.RFC.6550'?>     <!-- RPL: IPv6 Routing Protocol for Low-Power and Lossy Networks -->
        <?rfc include='reference.RFC.2119'?>     <!-- Key words for use in RFCs to Indicate Requirement Levels -->
        <!-- I-D 6TiSCH -->
        <?rfc include='reference.I-D.ietf-6tisch-6top-protocol'?>
        <?rfc include='reference.I-D.ietf-6tisch-minimal-security'?>
        <?rfc include='reference.I-D.richardson-6tisch-join-enhanced-beacon'?>
        <!-- I-D others -->
        <!-- external -->
        <reference                                                             anchor="IEEE802154-2015">
            <front>
                <title>
                    IEEE Std 802.15.4-2015 Standard for Low-Rate Wireless Personal Area Networks (WPANs)
                </title>
                <author>
                    <organization>IEEE standard for Information Technology</organization>
                </author>
                <date month="December" year="2015" />
            </front>
        </reference>
    </references>
    <references title="Informative References">
        <!-- RFC 6TiSCH-->
        <!-- RFC others -->
        <?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="SAX-DASFAA">
            <front>
                <title> Performance in Practice of String Hashing Functions</title>
                <author initials="M.V" surname="Ramakrishna"/>
                <author initials="J" surname="Zobel"/>
                <date year="1997" />
            </front>
            <seriesInfo name="DASFAA" value="" />
        </reference>
    </references>
    <section title="Contributors"                                              anchor="sec_contributors">
        <t>
          Beshr Al Nahas (Chalmers University, beshr@chalmers.se) and Olaf Landsiedel (Chalmers University, olafl@chalmers.se) contributed to the design and evaluation of autonomous unicast cells.
        </t>
    </section>
    <section title="Implementation Status"                                     anchor="sec_implementation">
        <!-- START BOILERPLATE FROM RFC6982 -->
        <t>
            This section records the status of known implementations of the protocol defined by this specification at the time of posting of this Internet-Draft, and is based on a proposal described in <xref target="RFC6982" />.
            The description of implementations in this section is intended to assist the IETF in its decision processes in progressing drafts to RFCs.
            Please note that the listing of any individual implementation here does not imply endorsement by the IETF.
            Furthermore, no effort has been spent to verify the information presented here that was supplied by IETF contributors.
            This is not intended as, and must not be construed to be, a catalog of available implementations or their features.
            Readers are advised to note that other implementations may exist.
        </t>
        <t>
            According to <xref target="RFC6982" />, "this will allow reviewers and working groups to assign due consideration to documents that have the benefit of running code, which may serve as evidence of valuable experimentation and feedback that have made the implemented protocols more mature.
            It is up to the individual working groups to use this information as they see fit".
        </t>
        <!-- STOP BOILERPLATE FROM RFC6982 -->
        <t>
            <list style="hanging">
                <t hangText="OpenWSN:">
                    MSF is being implemented in the OpenWSN project <xref target="OpenWSN"/> under a BSD open-source license.
                    The authors of this document are collaborating with the OpenWSN community to gather feedback about the status and performance of the protocols described in this document.
                    Results from that discussion will appear in this section in future revision of this specification.
                    More information about this implementation at http://www.openwsn.org/.
                </t>
                <t hangText="6TiSCH simulator">
                    The 6TiSCH simulator is a Python-based high-level simulator on which MSF is being implemented.
                    More information at https://bitbucket.org/6tisch/simulator/.
                </t>
            </list>
        </t>
    </section>
    <section title="Performance Evaluation"                                    anchor="sec_performance">
        <t>
            The performance of MSF may be published as companion documents to this specification, possibly under the form a applicability statements.
        </t>
    </section>
    <section title="[TEMPORARY] Changelog">
        <t>
            <list style="symbols">
                <t>draft-chang-6tisch-msf-02
                    <list style="symbols">
                        <t>Added autonomous cell.</t>
                    </list>
                </t>
                <t>draft-chang-6tisch-msf-01
                    <list style="symbols">
                        <t>When neighbor is unreachable, sending a CLEAR command was a MUST, now a MAY.</t>
                        <t>Fixing 6P Timeout calculation.</t>
                        <t>Clearer text for "Handling Schedule Collisions" section.</t>
                        <t>Typos.</t>
                        <t>Input from Yasuyuki Tanaka's review (https://www.ietf.org/mail-archive/web/6tisch/current/msg05723.html).</t>
                    </list>
                </t>
                <t>draft-chang-6tisch-msf-00
                    <list style="symbols">
                        <t>Initial submission.</t>
                    </list>
                </t>
            </list>
        </t>
    </section>
</back>
</rfc>
