<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
    which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
        <!-- One method to get references from the online citation libraries.
            There has to be one entity for each item to be referenced.
            An alternate method (rfc include) is described in the references. -->

        <!ENTITY RFC6330 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6330.xml">
        <!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
        <!ENTITY RFC5226 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5226.xml">
        ]>

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
    please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
    (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
    (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="info" docName="draft-yang-nwcrg-bats-code-00" ipr="trust200902">
    <!-- category values: std, bcp, info, exp, and historic
       ipr values: trust200902, noModificationTrust200902, noDerivativesTrust200902,
          or pre5378Trust200902
       you can add the attributes updates="NNNN" and obsoletes="NNNN"
       they will automatically be output with "(if approved)" -->

    <!-- ***** FRONT MATTER ***** -->

    <front>
        <!-- The abbreviated title is used in the page header - it is only necessary if the
             full title is longer than 39 characters -->

        <title abbrev="BATS Code">BATS Code Scheme for Multi-hop File Delivery</title>

        <!-- add 'role="editor"' below for the editors if appropriate -->
        <!-- Another author who claims to be an editor -->

        <author fullname="Shenghao Yang" initials="S" surname="Yang">
            <organization>CUHK(SZ)</organization>
            <address>
                <postal>
                    <street></street>
                    <!-- Reorder these if your country does things differently -->
                    <city>Shenzhen</city>
                    <region>Guangdong</region>
                    <code></code>
                    <country>China</country>
                </postal>
                <phone>+86 755 8427 3827</phone>
                <email>shyang@cuhk.edu.cn</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>

        <author fullname="Xuan Huang" initials="X" surname="Huang">
            <organization>CUHK(SZ)</organization>
            <address>
                <postal>
                    <street></street>
                    <!-- Reorder these if your country does things differently -->
                    <city>Shenzhen</city>
                    <region>Guangdong</region>
                    <code></code>
                    <country>China</country>
                </postal>
                <phone>+86 755 8427 3814</phone>
                <email>115010159@link.cuhk.edu.cn</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>

        <author surname="R.W. Yeung" fullname="Raymond W. Yeung">
            <organization>CUHK</organization>
            <address>
                <postal>
                    <street></street>
                    <!-- Reorder these if your country does things differently -->
                    <city>Hong Kong</city>
                    <region>Hong Kong SAR</region>
                    <code></code>
                    <country>China</country>
                </postal>
                <phone>+852 3943 8375</phone>
                <email>whyeung@ie.cuhk.edu.hk</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>

        <author fullname="John Zao" initials="J" surname="Zao">
            <!--organization>National Chiao Tung University</organization-->
            <organization>NCTU</organization>
            <address>
                <postal>
                    <street></street>
                    <!-- Reorder these if your country does things differently -->
                    <city>Hsinchu</city>
                    <region>Taiwan</region>
                    <code></code>
                    <country>China</country>
                </postal>
                <phone></phone>
                <email>jkzao@ieee.org</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>

        <date year="2018" month="October" day="20" />

        <!-- If the month and year are both specified and are the current ones, xml2rfc will fill
             in the current day for you. If only the current year is specified, xml2rfc will fill
          in the current day and month for you. If the year is not the current one, it is
          necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the
          purpose of calculating the expiry date).  With drafts it is normally sufficient to
          specify just the year. -->

        <!-- Meta-data Declarations -->

        <area>General</area>
        <workgroup>Internet Engineering Task Force</workgroup>

        <!-- WG name at the upperleft corner of the doc,
             IETF is fine for individual submissions.
          If this element is not present, the default is "Network Working Group",
             which is used by the RFC Editor as a nod to the history of the IETF. -->

        <keyword>BATS code</keyword>
        <keyword>multi-hop</keyword>

        <!-- Keywords will be incorporated into HTML output
             files in a meta tag but they have no effect on text or nroff
             output. If you submit your draft to the RFC Editor, the
             keywords will be used for the search engine. -->

        <abstract>
            <t>This document describe a BATS code scheme for communication through a multi-hop network. BATS code is a class of efficient linear network coding scheme with a matrix generalization of fountain codes as the outer code, and batch-based linear network coding as the inner code. </t>
        </abstract>
    </front>

    <middle>
        <section title="Introduction">
            <t>This document specifies a <xref target="BATS">BATS code</xref> scheme for file delivery applications in multi-hop networks. The BATS code described here includes an outer code and an inner code. The outer code is a matrix generalization of the fountain codes (see also the RapterQ code described in <xref target="RFC6330">RFC&nbsp;6330</xref>), which inherits the advantages of reliability and efficiency and possesses the extra desirable property of being network coding compatible. The inner code is formed by linear network coding for combating packet loss, improving the multicast efficiency, etc. A detailed design and analysis of BATS codes are provided in <xref target="BATSMonograph">BATSMonograph</xref>.</t>
            <section title="Requirements Language">
                <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
                    "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
                    document are to be interpreted as described in <xref
                            target="RFC2119">RFC 2119</xref>.</t>
            </section>
        </section>


        <section anchor="procedures" title="Procedures">
            <section title="Introduction">
                <t>
                    A BATS code scheme includes an outer code encoder (also called encoder), an inner code encoder (also called recoder) and a decoder. The BATS code scheme described in this document can be used by a File Delivery Protocol (FDP) with the following procedures.
                    <list>
                        <t>Encoding at a source node which has the file for transmission:
                            <list style="symbols">
                                <t>The FDP provides the file to be delivered and the related information to the BATS encoder.</t>
                                <t>The BATS encoder generates a sequence of batches, each consisting of a set of coded packets and the
                                    information pertaining to the batch.</t>
                                <t>The FDP forms and transmits the FDP packets using the batches and the corresponding batch information.</t>
                            </list>
                        </t>
                        <t>Recoding at an intermediate node that does not need the file:
                            <list style="symbols">
                                <t>The FDP extracts the batches and the corresponding batch information from its received FDP packets.</t>
                                <t>A BAST recoder generates recoded packets of a batch.</t>
                                <t>The FDP forms and transmits FDP packets using the recoded packets and the corresponding batch information.</t>
                            </list>
                        </t>

                        <t>Decoding at a destination node that needs the file:
                            <list style="symbols">
                                <t>The FDP extracts the batches and the corresponding batch information from its received FDP packets.</t>
                                <t>A BATS  decoder tries to recover the transmitted file using the received batches.</t>
                                <t>The FDP sends the decoded file to the application that needs the file.</t>
                            </list>
                        </t>
                    </list>
                </t>
            </section>

            <section title="File Partitioning and Padding">
                <t>
                    Suppose that the FDP has a file of F octets for transmission.
                    The construction of source packets from the file depends on two parameters K and T:
                    <list style="symbols">
                        <t>K: the number of source packets.</t>
                        <t>T: the size of a source packet, in octets.</t>
                    </list>
                </t>

                <t>If F is smaller than T*K, the file needs to be padded to have T*K octets, so that file can be partitioned into K source packets, each of which has T octets.
                </t>
            </section>

            <section title="File Delivery Procedures">
                <section title="Source Node Procedures">
                    <t>
                        A source node has the file for transmission. The FDP will first pad and partition the file into K source packets, each containing T octets.
                        The FDP provides the BATS encoder with the following information:
                        <list style="symbols">
                            <t>Batch size (M): the number of coded packets in a batch.</t>
                            <t>Recoding field size (q): the number of elements in the finite field for recoding.</t>
                            <t>The degree distribution (DD), optional.</t>
                            <t>A sequence of batch IDs (ID[i],i=0,1,...).</t>
                            <t>Number of source packets (K).</t>
                            <t>Packet size (T): the number of octets in a source packet.</t>
                            <t>The source packets (b[i],i=0,1,...,K-1).</t>
                        </list>
                        Using this information, the (outer code) encoder generates a batch for each batch ID. For each batch ID, the encoder returns the FDP
                        <list style="symbols">
                            <t>a sparse degree (d), and</t>
                            <t>M coded packets (X'[i],i=0,1,...,M-1), each containing T' octets.</t>
                        </list>
			            Here T' = T + M*ceil(log2(q))/8.
                    </t>
                    <t>
                        The FDP will use the batches to form FDP packets to be transmitted to other network nodes towards the destination nodes. The FDP MUST deliver with each coded packet its
                        <list style="symbols">
                            <t>sparse degree,</t>
                            <t>batch ID and certain extra information so that any receiver of the coded packets of the batch can know whether the coded packets are in the same batch or not, and whether two different batches are generated from the same file or not.</t>
                        </list>
                        The FDP MUST deliver the following information to each recoder:
                        <list style="symbols">
                            <t>batch size M, and</t>
                            <t>recoding field size q.</t>
                        </list>
                        The FDP MUST deliver the following information to each decoder:
                        <list style="symbols">
                            <t>batch size M,</t>
                            <t>recoding field size q,</t>
                            <t>the file size F, and</t>
                            <t>the number of source packet K.</t>
                        </list>
                        The packet length information is assumed to be known by all the nodes.
                    </t>
                </section>

                <section title="Intermediate Node Procedures">
                    <t>
                        An intermediate node does not need the file, but only helps to deliver the file to the destination nodes.
                        At an intermediate node, the FDP only receives the FDP packets from the other network nodes, and should be able to extract coded packets and the corresponding batch information from these packets.
                    </t>
                    <t>
                        The FDP provides the recoder with the following information:
                        <list style="symbols">
                            <t>the batch size M,</t>
                            <t>the recoding field size q,</t>
                            <t>a number of received coded packets of the same batch, each containing T' octets, and</t>
                            <t>a number M' of recoded packets to be generated.</t>
                        </list>
                    </t>
                    <t>
                        The recoder uses the information provided by the FDP to generate M' recoded packets, each containing T' octets. The FDP uses the M' recoded packets to form the FDP packets for transmitting.
                    </t>
                </section>

                <section title="Destination Node Procedures">
                    <t>
                        A destination node needs the file transmitted by the source node. At the destination node, the FDP receives FDP packets from the other network nodes, and should be able to extract coded packets and the corresponding batch information from these packets.
                    </t>

                    <t>
                        The FDP provides the decoder with the following information:
                        <list style="symbols">
                            <t>F: number of octets in the file,</t>
                            <t>M: batch size,</t>
                            <t>q: recoding field size,</t>
                            <t>K: number of source packets</t>
                            <t>A sequence of batches with their corresponding batch IDs and degrees.</t>
                        </list>
                        The decoder uses this information to decode the K source packets. If successful, the decoder returns the recovered K source packets to the FDP, which will use the source packets to form the source file.
                    </t>
                </section>
            </section>
            <section title="Recommandation for the Parameters">
                <t>
                    The recommendation for the parameters M, K, T, and T' is shown as follows:
                    <list style="symbols">
                        <t>M is 8, 16 or 32.</t>
                        <t>q is 2, 4, 8, 16, 32, 64, 128 or 256.</t>
                        <t>T' is not larger than the maximum coded packet payload size.</t>
                        <t>T = T' - M*ceil(log2(q))/8.</t>
                        <t>K = ceil(F/T).</t>
                    </list>
                    It is RECOMMENDED that K is at least 128. However, the encoder/decoder SHALL support an arbitrary positive integer value of K.
                </t>
            </section>
            <section title="Example FDP Packets">
                <t>A FDP can form a FDP packet by appending a header and a footer to each coded packets.</t>
		<t>The header should include F, M, K, q, batch ID, and degree.</t>
            </section>
        </section>

        <?rfc needLines="8" ?>

        <section anchor="specification" title="BATS Code Specification">
            <section anchor="background" title="Background">
                <t>
                     The T octets of a source packets are treated as a column vector of T elements in GF[256]. Linear algebra and matrix operations over finite fields are assumed in this section.
                </t>

                <t> Assume that a pseudo-random number generator Rand() is given.</t>
            </section>

            <section title="Outer Code Encoder">
                <t>
                    Let b[0], b[1], ...,b[K-1] be the K source packets. A batch with batch ID bID is generated in the following steps.
                </t>
                <t>
                    First, a degree DEG=DEG(bID) is sampled using the give degree distribution and Rand() with the default seed. After that, initialize Rand() with bID as the seed.
                </t>
                <t>
                    Second, using Rand() sample DEG packets among all the source packets. Suppose the indices of the packets sampled are i_1, i_2, ..., i_DEG.
                </t>
                <t>
                    Third, sample a DEGxM generator matrix G.
                </t>
                <t>
                    Fourth, form the batch X = (b[i_1], b[i_2], ..., b[i_DEG])*G, where each column is a coded packet of the batch.
                </t>
                <t>
                    Last, append coefficient vectors to the packets of the batches. Let X[i], i=0,1,...,M-1, be the (i+1)th column of X. The coefficient vector of X[i] is the (i+1)th column of the MxM identity matrix with entries in GF(q), which can be represented by M*log2(q)/8 octets. The coded packet X'[i] is formed by appending the coefficient vector before X[i].
                </t>
            </section>
            <section title="Inner Code Encoder (Recoder) Recommandations">
                <t>
                    The inner code comprises (random) linear network coding applied on the coded packets belonging to the same batch. At a particular network node, recoded packets are generated by (random) linear combinations of the received coded packets of a batch. The recoded packets have the same batch ID, sparse degree and coded packet length.
                </t>
            </section>
            <section title="Decoder Recommandations">
                <t>
                    The belief propagation decoding algorithm suggested in <xref target="BATS">the BATS code paper</xref> is recommanded.
                </t>
                <!--t>
                    Let Y' be the coded packets of a batch X received by the destination node. Let H be the first M*log2(q)/8 octets of all the coded packets of Y', and let Y be the remaining T octets of all the coded packets of Y'. We have that Y=X*H.
                </t-->
            </section>
        </section>

        <!-- This PI places the pagebreak correctly (before the section title) in the text output. -->

        <?rfc needLines="8" ?>


        <!--section anchor="Acknowledgements" title="Acknowledgements">
            <t></t>
        </section-->

        <!-- Possibly a 'Contributors' section ... -->

        <section anchor="IANA" title="IANA Considerations">
            <t>This memo includes no request to IANA.</t>
        </section>

        <section anchor="Security" title="Security Considerations">
            <t>
                Subsuming both Random Linear Network Codes (RLNC) and fountain codes, BATS codes naturally inherit both their desirable capability of offering confidentiality protection as well as their vulnerability towards pollution attacks.
            </t>
            <section title="Provision of Confidentiality Protection">
                <t>
                    Since the transported messages are linearly combined with random coefficients at each recoding node, it is statistically impossible to recover individual messages by capturing the coded messages at any one or small number of nodes. As long as the coding matrices of the transported messages cannot be fully recovered, any attempt of decoding is equivalent to randomly guessing the transported messages. Thus, with the use of BATS codes, information confidentiality throughout the data transport process is assured.
                </t>
                <t>
                    The only thread towards confidentiality exists in the form of eavesdropping onto the initial encoding process, which takes place at the encoding nodes. In these nodes, the transported files are presented in plain text and can be read along their transfer paths. Hence, information isolation between the encoding process and all other user processes running on the node must be assured.
                </t>
                <t>
                    In addition, the authenticity and trustworthiness of the encoding, recoding and decoding program running on all the nodes must be attested by a trusted authority. Such a measure is also necessary in countering the pollution attacks.
                </t>
            </section>
            <section title="Countermeasures against Pollution Attacks">
                <t>Like all network codes, BATS codes are vulnerable under pollution attacks. In these attacks, one or more compromised coding node(s) can pollute the coded messages or inject forged messages into the coding network. These attacks can prevent the receivers from recovering the transported files correctly. Although error detection mechanisms can be put in place to prevent the receivers from getting the wrong messages, detection and discard of the polluted messages still constitute a form of denial-of-service (DoS) attack. </t>
                <t>The research community has long been investigating the use of various signature schemes (including homomorphic signatures) to identify the forged messages and stall the attacks (see <xref target="Zhao07">Zhao07</xref>, <xref target="Yu08">Yu08</xref>, <xref target="Agrawal09">Agrawal09</xref>). Nevertheless, these counter measures are regarded as being computationally to expensive to be employed in broadband communications. A practical approach to protect against pollution attacks consists of the following system-level countermeasures:
                    <list style="numbers">
                        <t>  Attestation and Validation of all encoding, recoding and decoding nodes in the  network. Remote attestation and repetitive validation of a node based on valid public key certificates with proper authorization MUST be a pre-requisite of admitting that node into a network and permitting it to remain in that network.</t>
                        <t> Attestation of all encoding, recoding and decoding programs used in the coding nodes. All programs used to perform the BATS encoding, recoding and decoding processes MUST be remotely attested before they are permitted to run on any of the coding nodes. Reloading or alteration of programs MUST NOT be permitted during an encoding session. Programs MUST be attested or validated again when they are executed in new execution environments instantiated even in the same nodes.</t>
                        <t> Original Authentication of all coded messages using network or transport level secure protocols such as IP-sec or TLS/DTLS MUST be used to provide Peer or Message Origin Authentication to every coded message sent through the coding network.</t>
                    </list>
                </t>
            </section>
        </section>
    </middle>

    <!--  *****BACK MATTER ***** -->

    <back>
        <!-- References split into informative and normative -->

        <!-- There are 2 ways to insert reference entries from the citation libraries:
         1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
         2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
            (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

         Both are cited textually in the same manner: by using xref elements.
         If you use the PI option, xml2rfc will, by default, try to find included files in the same
         directory as the including file. You can also define the XML_LIBRARY environment variable
         with a value containing a set of directories to search.  These can be either in the local
         filing system or remote ones accessed by http (http://domain/dir/... ).-->

        <references title="Normative References">
            <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->
            &RFC2119;

        </references>

        <references title="Informative References">
            <!-- Here we use entities that we defined at the beginning. -->
            &RFC6330;

            <!-- A reference written by by an organization not a person. -->
            <reference anchor="BATS">
                <front>
                    <title>Batched Sparse Codes</title>
                    <author surname="S. Yang">
                    </author>
                    <author surname="R.W. Yeung">
                    </author>
                    <date year="2014" />
                </front>
                <seriesInfo name="IEEE Transactions on Information Theory" value="60(9), 5322-5346" />
            </reference>

            <reference anchor="BATSMonograph">
                <front>
                    <title>BATS Codes: Theory and Practice</title>
                    <author surname="S. Yang" fullname="Shenghao Yang">
                    </author>
                    <author surname="R.W. Yeung">
                    </author>
                    <date year="2017"/>
                </front>
                <seriesInfo name="Morgan &#38; Claypool Publishers" value=""/>
            </reference>

            <reference anchor="Zhao07">
                <front>
                    <title>Signatures for content distribution with network coding</title>
                    <author surname="F. Zhao" fullname="Fang Zhao"></author>
                    <author surname="T. Kalker"></author>
                    <author surname="M. Medard"></author>
                    <author surname="K.J. Han"></author>
                    <date year="2007" />
                </front>
                <seriesInfo name="ISIT" value=""/>
            </reference>

            <reference anchor="Yu08">
                <front>
                    <title>An Efficient Signature-Based Scheme for Securing Network Coding Against Pollution Attacks</title>
                    <author surname="Z. Yu"></author>
                    <author surname="Y. Wei"></author>
                    <author surname="B. Ramkumar"></author>
                    <author surname="Y. Guan"></author>
                    <date year="2008" />
                </front>
                <seriesInfo name="NFOCOM" value=""/>
            </reference>

            <reference anchor="Agrawal09">
                <front>
                    <title>Homomorphic MACs: MAC-based integrity for network coding</title>
                    <author surname="S. Agrawal"></author>
                    <author surname="D. Boneh"></author>
                    <date year="2009" />
                </front>
                <seriesInfo name="International Conference on Applied Cryptography and Network Security" value="" />
            </reference>

        </references>

        <section anchor="app-additional" title="Additional Stuff">
            <t>This becomes an Appendix.</t>
        </section>

        <!-- Change Log

     v00 2006-03-15  EBD   Initial version

     v01 2006-04-03  EBD   Moved PI location back to position 1 -
                          v3.1 of XMLmind is better with them at this location.
     v02 2007-03-07  AH    removed extraneous nested_list attribute,
                          other minor corrections
     v03 2007-03-09  EBD   Added comments on null IANA sections and fixed heading capitalization.
                          Modified comments around figure to reflect non-implementation of
                          figure indent control.  Put in reference using anchor="DOMINATION".
                          Fixed up the date specification comments to reflect current truth.
     v04 2007-03-09 AH     Major changes: shortened discussion of PIs,
                          added discussion of rfc include.
     v05 2007-03-10 EBD    Added preamble to C program example to tell about ABNF and alternative
                          images. Removed meta-characters from comments (causes problems).

     v06 2010-04-01 TT     Changed ipr attribute values to latest ones. Changed date to
                          year only, to be consistent with the comments. Updated the
                          IANA guidelines reference from the I-D to the finished RFC.  -->
    </back>
</rfc>
