<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc ipr="trust200902" 
category="std" 
docName="draft-ietf-manet-rfc5444-usage-00"
updates="5444">

<front>
<title abbrev="RFC5444-Usage">Rules For Designing Protocols Using the RFC5444 Generalized Packet/Message Format</title>


<author fullname="Thomas Clausen" initials="T" surname="Clausen">
<organization>LIX, Ecole Polytechnique</organization>
<address>
<postal>
<street></street>
<city>91128 Palaiseau Cedex</city>
<region></region>
<country>France</country>
</postal>
<phone>+33-6-6058-9349</phone>
<email>T.Clausen@computer.org</email>
<uri>http://www.thomasclausen.org</uri>
</address>
</author>

<author initials="C.M." surname="Dearlove" fullname="Christopher Dearlove">
<organization abbrev="BAE Systems AI Labs">BAE Systems Applied Intelligence Laboratories</organization>
<address>
<postal>
<street>
West Hanningfield Road
</street>
<city>
Great Baddow, Chelmsford
</city>
<country>
United Kingdom
</country>
</postal>
<phone>+44 1245 242194</phone>
<email>chris.dearlove@baesystems.com</email>
<uri>http://www.baesystems.com/</uri>
</address>
</author>

<author fullname="Ulrich Herberg" initials="U" surname="Herberg">
<address>
<email>ulrich@herberg.name</email>
<uri>http://www.herberg.name</uri>
</address>
</author>

<author fullname="Henning Rogge" initials="H" surname="Rogge">
<address>
<email>henning.rogge@fkie.fraunhofer.de</email>
</address>
</author>

<date/>

<workgroup>Network Working Group</workgroup>
<keyword>MANET</keyword>

<abstract>
<t>
This document updates the generalized MANET packet/message format, specified in RFC5444, by providing prescriptive guidelines for how protocols can use that packet/message format. In particular, these mandatory guidelines prohibit a number of uses of RFC5444 that have been suggested in various proposals, and which would have lead to interoperability problems, to impediment of protocol extension development, and to inability to use generic RFC5444 parsers.
</t>
</abstract>

</front>

<middle>

<section title="Introduction" anchor="introduction">

  <t>
   <xref target="RFC5444"/> specifies a generalized packet/message format, designed for use by MANET routing protocols. <xref target="RFC5498"/> mandates the use of this format by protocols operating over the manet IP protocol and port numbers whose allocation it requested.
  </t>

  <t>
    Following experiences with <xref target="RFC3626"/> which attempted - but did not quite succeed in - providing a packet/message format accommodating for diverse protocol extensions, <xref target="RFC5444"/> was designed by the MANET working group as a common building block for use by both proactive and reactive MANET routing protocols.
  </t>

  <section title="History and Purpose">

    <t>
    	 Since the publication of <xref target="RFC5444"/> in 2009, several RFCs have been published, including <xref target="RFC5497"/>, <xref target="RFC6130"/>, <xref target="RFC6621"/>, <xref target="RFC7181"/>, <xref target="RFC7182"/>, <xref target="RFC7183"/>, and <xref target="RFC7188"/>, which use the format of <xref target="RFC5444"/>. The ITU-T recommendation <xref target="G9903"/> also uses the format of <xref target="RFC5444"/> for encoding some of its control signals.  In developing these specifications, experience with the use of <xref target="RFC5444"/> has been acquired, specifically with respect to how to write specifications using <xref target="RFC5444"/> so as to (i) enable the use of an efficient and generic parser for all protocols using <xref target="RFC5444"/>, (ii) ensure "forward compatibility" of a protocol with future extensions, and (iii) enable the creation of efficient messages.
    </t>

    <t>
	 During the same time period, other suggestions have been made to use <xref target="RFC5444"/> in a manner that would lead to incompatibilities with generic RFC 5444 parsers, would inhibit the development of interoperable protocol extensions, or would potentially lead to inefficiencies. While these uses were not all explicitly prohibited by <xref target="RFC5444"/>, they should be strongly discouraged. This document is intended to prohibit such uses, to present experiences from designing protocols using <xref target="RFC5444"/> and to provide these as guidelines (with their rationale) for future protocol designs using <xref target="RFC5444"/>.
    </t>
	      
  </section>

  <section title="RFC 5444 Features">

    <t>
      Among the characteristics, and design criteria, of the packet/message format of <xref target="RFC5444"/> are:

	 <list style="symbols">

    	   <t>
     		It is designed for carrying MANET routing protocol control signals.
	   </t>

    	   <t>	
          It defines a packet as a packet header with a set of packet TLVs, followed by a set of messages. Each message has a well-defined structure consisting of a message header (designed for making processing and forwarding decisions) followed by set of message TLVs (Type-Length-Value structures), and a set of (address, type, value) associations using address blocks and their address block TLVs. The <xref target="RFC5444"/> packet/message format then enables the use of simple and generic parsing logic for packets, message headers, and message content.

          <vspace blankLines="1"/>

          A packet may include messages from different protocols, such as <xref target="RFC6130"/> and <xref target="RFC7181"/>, in a single transmission. This was observed in <xref target="RFC3626"/> to be beneficial, especially in wireless networks where media contention may be significant. <xref target="RFC5444"/> defines a multiplexing process to achieve this that is mandated by <xref target="RFC5498"/> for use on the manet IP port and UDP port. This makes the contents of the packet header, which may also contain packet TLVs, and the transmission of packet over UDP or directly over IP, the responsibility of this multiplexing process.
	   </t>

        <t>
          A packet is designed to travel between two neighboring interfaces, which will result in a single decrement/increment of the IPv4 TTL or IPv6 hop limit. The packet header and any packet TLVs should convey information relevant to that link (for example, the packet sequence number can be used to count transmission successes across that link). Packets are not retransmitted, a packet transmission following a successful packet reception may include all, some, or none of the received messages, plus possibly additional messages received in separate  packets or generated at that router. Messages may thus travel more than one hop, and are designed to carry end-to-end protocol signals.
        </t>
		
        <t>
         It supports "internal extensibility" using TLVs; an extension can add information to an existing message type without that information rendering the message un-parseable by a router that does not support the extension. An extension is typically of the protocol that created the message to be extended, for example <xref target="RFC7181"/> adds information to the HELLO messages created by <xref target="RFC6130"/>. However an extension may also be independent of the protocol, for example <xref target="RFC7182"/> can add ICV (Integrity Check Value) and timestamp information to any message (or to a packet, thus extending the <xref target="RFC5444"/> multiplexing process).

          <vspace blankLines="1"/>

          Information can be added to the message as a whole, such as the <xref target="RFC7182"/> integrity information, or may be associated with specific addresses in the message, such as the MPR selection and link metric information added to HELLO messages by <xref target="RFC7181"/>. An extension may also add addresses to a message.
		</t>

		<t>
         It uses address aggregation into compact address blocks by exploiting commonalities between addresses. In many deployments, addresses (IPv4 and IPv6) used on interfaces share a common prefix that need not be repeated. Using IPv6, several addresses (of the same interface) may have a common interface Identifiers, also, that need not be repeated.
	  </t>

    	  <t>
     	    It sets up common namespaces, formats, and data structures for use by different protocols, where common parsing logic can be used. For example, <xref target="RFC5497"/> defines a generic TLV type for representing time information (such as interval time or validity time).
	  </t>

    	  <t>
         It contains a minimal message header (a maximum of five elements: type, originator, sequence number, hop count and limit) that permit decisions whether to locally process a message, or forward a message (thus enabling MANET-wide flooding of a message) without processing the body of the message. 
	  </t>

      </list>

    </t>

  </section>

  <section title="Status of This Document">

    <t>
    	This document updates <xref target="RFC5444"/>, and is intended for publication as a Proposed Standard (rather than as Informational) because it specifies and mandates constraints on the use of <xref target="RFC5444"/> which, if not followed, make desirable forms of generic parsers impossible, or make forms of extensions of those protocols impossible, or impedes on the ability to generate efficient messages.
    </t>

  </section>
	      
</section>
<section title="Terminology" anchor="terminology">

  <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>

  <t>
    This document uses the terminology and notation defined in <xref target="RFC5444"/>, specifically the terms "Packet", "Packet Header", "Message", "Message Header", "Address", "Address Block", "TLV" and "TLV Block" are to be interpreted as described therein.
      </t>

</section>
<section title="Applicability Statement" anchor="applicability statement">

  <t>
    This document does not specify a protocol, but documents constraints on how to design protocols which are using the generic packet/message format defined in <xref target="RFC5444"/> which, if not followed, make desirable forms of generic parsers impossible, or make forms of extensions of those protocols impossible, or impedes on the ability to generate efficient (small) messages. The use of this format is mandated by <xref target="RFC5498"/> for all protocols running over the MANET protocol and port number, defined therein. Thus, the constraints in this document apply to all protocols running over the MANET protocol and port number.
  </t>
		
</section>
<section title="Information Transmission">

  <t>
    Protocols need to transmit information from one instance implementing the protocol to another.
  </t>

  <section title="Where to Record Information">

    <t>
      A protocol has the following choices as to where to put information for transmission:
      <list style="symbols">
        <t>
          In a TLV to be added to the packet header.
        </t>
        <t>
          In a message of a type owned by another protocol.
        </t>
        <t>
          In a message of a type owned by the protocol.
        </t>
      </list>
    </t>

    <t>
      The first case (a Packet TLV) can only be used when the information is to be carried one hop. It SHOULD only be used either where the information relates to the packet as a whole (for example packet integrity check values and timestamps, as specified in <xref target="RFC7182"/>) or if the information is of expected wider application than the single protocol. A protocol can also request that the packet header include packet sequence numbers, but does not control those numbers.
    </t>

    <t>
      The second case (in a message of a type owned by another protocol) is only possible if the adding protocol is an extension to the owning protocol, for example OLSRv2 <xref target="RFC7181"/> is an extension of NHDP <xref target="RFC6130"/>. #### SEE COMMENTS IN SVN COMMIT MESSAGE AND ON LIST #### While this is not the most common case, protocols SHOULD be designed to enable this to be possible, and most rules in this document are to help facilitate that. An extension to <xref target="RFC5444"/>, such as <xref target="RFC7182"/> is considered to be an extension to all protocols in this regard.
    </t>

    <t>
      The third case is the normal case for a new protocol. Protocols MUST be conservative in the number of new message types that they require, as the total available number of allocatable message types is only 224. Protocol design SHOULD consider whether different functions can be implemented by differences in TLVs carried in the same message type, rather than using multiple message types. If a protocol's needs can be covered by use of the second case, then this SHOULD be considered.
    </t>

    <t>
      TLV space, although greater than message space, SHOULD also be used efficiently. The full type of TLV occupies two octets, thus there are many more available TLVs. However, in some cases (currently LINK_METRIC from <xref target="RFC7181"/> and ICV and TIMESTAMP from <xref target="RFC7182"/> in the global TLV space) a full set of 256 TLVs is defined (but not necessarily allocated). Each message has a block of message specific TLV types (128 to 233, each with 256 type extensions), these SHOULD be used in preference to the common TLV types (0 to 127, each with 256 type extensions) when a TLV is message-specific.
    </t>

    <t>
      A message contains a message header and a message body; note that the Message TLV block is considered as part of the latter. The message header contains information whose primary purpose is to decide whether to process the message, and whether to forward the message. <xref target="RFC7181"/> contains a general purpose process for doing that, albeit one presented as for use with MPR flooding. (Blind flooding can be handled similarly by assuming that all other routers are MPR selectors; it is not necessary in this case to differentiate between interfaces on which a message is received.)
    </t>

    <t>
      Most protocol information is thus contained in the message body. A model of how such information may be viewed is described in the following section. To use that model, addresses (for example of neighboring or otherwise known routers) SHOULD be recorded in address blocks, not as data in TLVs. Recording addresses in TLV value fields both breaks the model of addresses as identities and associated information (attributes) and also inhibits address compression. However in some cases alternative addresses (e.g., HW addresses when the address block is recording IP addresses) MAY be carried as TLV values. Note that a message contains a Message Address Length (MAL) field that can be used to allow carrying alternative message sizes, but only one length of addresses in all address blocks can be used in a single message.
    </t>

  </section>

  <section title="Packets and Messages">

    <t>
      The <xref target="RFC5444"/> multiplexing process has to handle packet reception and message demultiplexing, and message transmission and packet multiplexing.
    </t>

    <t>
      When a packet arrives, the following steps are required:

      <list style="symbols">

        <t>
          The packet and/or the messages it contains MAY be verified by an extension to the demultiplexer, such as <xref target="RFC7182"/>.
        </t>

        <t>
          Each message MUST be sent to its owning protocol, which MAY also view the packet header.
        </t>

        <t>
          The owning protocol SHOULD verify each message, it SHOULD allow any extending protocol(s) to also contribute to this.
        </t>

        <t>
          The owning protocol MUST process each message, or make an informed decision not to do so. In the former case an owning protocol that permits this MUST allow any extending protocols to process or ignore the message.
        </t>

      </list>
    </t>
       
    <t>
      Packets are formed for transmission by:

      <list style="symbols">
 
        <t>
          Outgoing messages MAY be created by the owning protocol, and MAY be modified by any extending protocols if the owning protocol permits this. Messages MAY also be forwarded by their owning protocol. It is RECOMMENDED that messages are not modified in the latter case.
        </t>

        <t>
          Outgoing messages are then sent to the <xref target="RFC5444"/> multiplexing process. The owning protocol MAY request that messages are kept together in a packet, the multiplexing process SHOULD respect this request if possible. A protocol MAY also request that a packet sequence number and/or specified packet TLVs are included, such requests SHOULD also be respected if possible.
        </t>

        <t>
          The multiplexing process MAY combine messages from multiple protocols in a packet.
        </t>

        <t>
          An extension to the multiplexing process MAY add TLVs to the packet and/or the messages (for example as by <xref target="RFC7182"/>).
        </t>

      </list>

    </t>

  </section>

  <section title="Messages, Addresses and Attributes">

    <t>
      The information in a message body, including Message TLVs and Address Block TLVs, can be considered to consist of:
      <list style="symbols">
        <t>
          Attributes of the message, each attribute consisting of an extended type, a length, and a value (of that length).
        </t>
        <t>
          A set of addresses, carried in one or more Address Blocks.
        </t>
        <t>
         Attributes of each address, each attribute consisting of an extended type, a length, and a value (of that length). 
        </t>
      </list>
    </t>

    <t>
      Attributes are carried in TLVs. For Message TLVs the mapping from TLV to attribute is one to one. For Address Block TLVs the mapping from TLV to attribute is one to many, one TLV can carry attributes for multiple addresses, but only one attribute per address. Attributes for different addresses may be the same or different.
    </t>

    <t>
      A TLV extended type may be (and this is RECOMMENDED whenever possible) defined so that there may only be one TLV of that extended type associated with the message (Message TLV) or any value of any address (Address TLV). Note that an address may appear more than once in a message, but the restriction on associating TLVs with addresses covers all copies of that address. It is RECOMMENDED that addresses are not repeated in a message.
    </t>

  </section>

  <section title="Addresses Require Attributes">

    <t>
	 It is not mandatory in <xref target="RFC5444"/> to associate an address with attributes using Address Block TLVs, information about an address could thus, in principle be carried using:
      <list style="symbols">
        <t>
          The simple presence of an address.
        </t>
        <t>
          The ordering of addresses in an address block.
        </t>
        <t>
          The use of different meanings for different address blocks.
        </t>
      </list>
    </t>
	
    <t>
      This specification, however, requires that those methods of carrying information MUST NOT be used for any protocol using <xref target="RFC5444"/>. Information about the meaning of an address MUST only be carried using Address Block TLVs.
    </t>

    <t>
      In addition, rules for the extensibility of OLSRv2 and NHDP are described in <xref target="RFC7188"/>. This specification extends their applicability to other uses of <xref target="RFC5444"/>.
    </t>

    <t>
      The following points indicate the reasons for these rules, based on considerations of extensibility and efficiency.
    </t>

    <t>
      A protocol MUST NOT assign any meaning to the presence, or absence, of an address, as this would prevent the addition of addresses with other meanings. For example consider NHDP's HELLO messages <xref target="RFC6130"/>. The basic function of a HELLO message is to indicate that an address is of a neighbor, using the LINK_STATUS and OTHER_NEIGHB TLVs. An extension to NHDP might decide to use the HELLO message to report that, for example, an address is one that could be used for a specialized purpose, but not for normal NHDP-based purposes. Such an example already exists (but within the basic specification, rather than as an extension) in the use of LOST values in the LINK_STATUS and OTHER_NEIGHB TLVs to report that an address is of a router known not to be a neighbor. A future example might be to list an address to be added to a "blacklist" of addresses not to be used. This would be indicated by a new TLV (or a new value of an existing TLV, see below). An unmodified extension to NHDP would ignore such addresses, as required, as it does not support that specialized purpose. If NHDP had been designed so that just the presence of an address indicated a neighbor, that extension would not have been possible.
    </t>

    <t>
      This example can be taken further. NHDP must also not reject a HELLO message because it contains an unrecognized TLV. This also applies to unrecognized TLV values, where a TLV supports only a limited set of values. For example, the blacklisting described in the previous paragraph could be signaled not with a new TLV, but with a new value of a LINK_STATUS or OTHER_NEIGHB TLV (requiring an IANA allocation as described in <xref target="RFC7188"/>), as is already done in the LOST case.
    </t>

    <t>
      Information may also be added to addresses recognized by the base protocol. For example OLSRv2 <xref target="RFC7181"/> is, among other things, an extension to NHDP. It adds information to addresses in an NHDP HELLO message using a LINK_METRIC TLV. A non-OLSRv2 implementation of NHDP (for example, to support SMF <xref target="RFC6621"/>) must still process the HELLO message, ignoring the LINK_METRIC TLVs.
    </t>

    <t>
      This does not, however, mean that added information is completely ignored for purposes of the base protocol. Suppose that a faulty implementation of OLSRv2 (including NHDP) creates a HELLO message that assigns two different values of the same link metric to an address, something which is not permitted by <xref target="RFC7181"/>. A receiving OLSRv2-aware implementation of NHDP should reject such a message, even though a receiving OLSRv2-unaware implementation of NHDP will process it. This is because the OLSRv2-aware implementation has access to additional information, that the HELLO message is definitely invalid, and the message is best ignored, as it is unknown what other errors it may contain.
    </t>

    <t>
      The restrictions on the use of address ordering and an address presence or absence in given address blocks for carrying information are for two reasons. First use of those prevents the approach to information representation described in <xref target="representation"/>. Second, it reduces the options available for message optimization described in <xref target="efficiency"/>.
    </t>

  </section>

  <section title="Information Representation" anchor="representation">

    <t>
      A message (excluding the message header) can thus be represented by two, possibly multivalued, maps:
      <list style="symbols">
        <t>
          Message: (extended type) -> (length, value)
        </t>
        <t>
          Address: (address, extended type) -> (length, value)
        </t>
      </list>
    </t>

    <t>
      These maps (plus a representation of the message header) can be the basis for a generic representation of information in a message. Such maps can be created by parsing the message, or can be constructed using the protocol rules for creating a message, and later converted into the octet form of the message specified in <xref target="RFC5444"/>.
    </t>

    <t>
      While of course any implementation of software that represents software in the above form can specify an application programming interface (API) for that software, such an interface is not proposed here. First, a full API would be programming language specific. Second, even within the above framework, there are alternative approaches to such an interface. For example, and for illustrative purposes only, for the address mapping:
      <list style="symbols">
       <t>
         Input: address and extended type. Output: list of (length, value) pairs. Note that for most extended types it will be known in advance that this list will have length zero or one. The list of addresses that can be used as inputs with non-empty output would need to be provided as a separate output.
       </t>
       <t>
         Input: extended type. Output: list of (address, length, value) triples. As this list length may be significant, the likely output will be of one or two iterators that will allow iterating through that list. (One iterator that can detect the end of list, or a pair of iterators specifying a range.)
       </t>
      </list>
    </t>

    <t>
      Additional differences in the interface may relate to, for example, the ordering of output lists.
    </t>

  </section>

  <section title="Message Integrity">

    <t>
      In addition to not rejecting a message due to unknown TLVs or TLV values, a protocol MUST NOT fail to forward a message (by whatever means of message forwarding are appropriate to that protocol) due to the presence of such TLVs or TLV values, and MUST NOT remove such TLVs or values. Such behavior would have the consequences that:

      <list style="symbols">

        <t>
          It might disrupt the operation of an extension of which it is unaware. Note that it is the responsibility of a protocol extension to handle interoperation with unextended instances of the protocol. For example OLSRv2 <xref target="RFC7181"/> adds an MPR_WILLNG TLV to HELLO messages (created by NHDP, <xref target="RFC6130"/>, of which it is in part an extension) to recognize this case (and for other reasons). If an incompatible protocol extension were defined, it would be the responsibility of network management to ensure that incompatible routers were not both present in the MANET, this case is NOT RECOMMENDED.
        </t>

        <t>
          It would prevent the operation of end to end message authentication using <xref target="RFC7182"/>, or any similar mechanism. The use of immutable (apart from hop count and/or limit) messages by a protocol is strongly RECOMMENDED for that reason.
        </t>

      </list>

    </t>

  </section>

</section>
<section title="Structure">

  <t>
    The elements defined in <xref target="RFC5444"/> have structures that are managed by a number of flags fields:
    <list style="symbols">
      <t>
        Packet flags (4 bits, 2 used) that manages the contents of the packet header.
      </t>
      <t>
        Message flags (4 bits, 4 used) that manages the contents of the message header.
      </t>
      <t>
        Address Block flags (8 bits, 4 used) that manages the contents of an Address Block.
      </t>
      <t>
        TLV flags (8 bits, 5 used) that manages the contents of a TLV.
      </t>
    </list>
  </t>

  <t>
    Note that all of these flags are structural, they specify which elements are present or absent, or field lengths, or whether a field has one or multiple values in it.
  </t>
    
    <t>	
    	In the current version of <xref target="RFC5444"/>, indicated by version number 0 in the &lt;version&gt; field of the packet header, unused bits in these flags fields "are RESERVED and SHOULD each be cleared ('0') on transmission and SHOULD be ignored on reception.". 
    </t>
    	
    <t>
    	If a specification introduces new flags in one of the flags fields of a packet, message or Address Block, the following rules MUST be followed:
    	
    <list style="symbols">
      <t>
        The version number contained in the &lt;version&gt; field of the packet header MUST NOT be 0.
      </t>
    		
    	 <t>
        The new flag(s) MUST indicate the structure of the corresponding packet, message, Address Block or TLV, and MUST NOT be used to indicate any other semantics, such as message forwarding behavior.
      </t>
   </list>

  </t>

  <t>
    During the development of <xref target="RFC5444"/>, and since publication hereof, some proposals have been made to use these RESERVED flags to specify behavior rather than structure, in particular message forwarding. These were, after due consideration, not accepted, for a number of reasons. These include that message forwarding, in particular, is protocol-specific. For example <xref target="RFC7181"/> forwards messages using its MPR (Multi-Point Relay) mechanism, rather than a "blind" flooding mechanism. The later addition of a 4 bit Message Address Length field later left no spare flags bits at the message level for such use.
  </t>

</section><section title="Message Efficiency" anchor="efficiency">

	<t>
	  The ability to organize addresses into different, or the same, address blocks, as well as to change the order of addresses within an address block, enables avoiding unnecessary repetition of information - and, consequently, generation of smaller messages.
	</t>
  <section title="Addressesblock compression">

    <t>
        Addresses in an address block can be compressed, and SHOULD be. While no algorithm for compression is given in <xref target="RFC5444"/>, an efficient compression algorithm given a set of addresses, has to obey certain contraints.
    </t>
    
    <t>
        The protocol using RFC5444 sets the constraints by defining the list of addresses and a list of addressblock TLV types and values for each of the addresses.
        A compression strategy has to decide two additional things which will have a major influence on the compression efficiency.
        
        <list style="symbols">
            <t>
                the split of the addresses into address blocks
            </t>
            <t>
                the order of the addresses within the address blocks.
            </t>
        </list>
        
        The order of addresses can be as simple as sorting the addresses, but if a lot of addresses have the same TLV types attached, it might be more useful to group the messages by sections with same or similar TLV types (e.g. RFC6130 HELLO messages with local interface addresses first and neighbor addresses later).
    </t>

    <t>
        Compression of address blocks is obtained by considering addresses to consist of a Head, a Mid, and a Tail, where all addresses in an address block have the same Head and Tail, but different Mids.
        An additional compression is possible when the Tail consists of all zero-valued octets. 
        Expected use cases are IPv4 and IPv6 addresses from within the same prefix and which therefore have a common Head, IPv4 subnets with a common zero-valued Tail, and IPv6 addresses with a common Tail representing an interface identifier as well as a possible common Head.
        Note that when, for example, IPv4 addresses have a common Head, their Tail will be empty.
        For example 192.0.2.1 and 192.0.2.2 would have a 3 octet Head, a 1 octet Mid, and a 0 octet Tail.
    </t>

    <t>
        Address blocks with few similar addresses will save more bytes by using longer Head and Tails in the address block header.
        Address blocks with a lot of addresses will reduce the overhead created by the address block header and TLV headers for multivalue TLVs.
        The compression strategy will have to select the tradeof between these two optimizations that will lead to a minimal number of bytes.
    </t>
  </section>

  <section title="TLVs">

    <t>
      The main opportunities for efficient messages when considering TLVs are Address Block TLVs, rather than Message TLVs.
    </t>

    <t>
      An Address Block TLV provides attributes for one address or a contiguous (as stored in the address block) set of addresses (with a special case for when this is all addresses in an address block). When associated with more than one address, a TLV may be single-valued (associating the same attribute with each address) or multi-valued (associating a separate attribute with each address).
    </t>

    <t>
      The simplest to implement approach is to use multi-valued TLVs that cover all affected addresses. However unless care is taken to order addresses appropriately, these affected addresses may not all be contiguous. Approaches to this are to:
      <list style="symbols">
        <t>
          Reorder the addresses. It is, for example, possible (though not straightforward) to order all addresses in HELLO message as specified in <xref target="RFC6130"/> so that all TLVs used only cover contiguous addresses. This is even possible if the MPR TLV specified in OLSRv2 <xref target="RFC7181"/> is added; but it is not possible, in general, if the LINK_METRIC TLV is also added.
        </t>
        <t>
          Allow the TLV to span over addresses that do not need the corresponding attribute, using a value that indicates no information, see <xref target="tlvvalues"/>.
        </t>
        <t>
          Use more than one TLV. Note that this can be efficient when the TLVs thus become single-valued. In a typical case where a LINK_STATUS TLV uses only the values HEARD and SYMMETRIC, with enough addresses, sorted appropriately, two single-valued TLVs can be more efficient than one multi-valued TLV. (When only one value is involved, such as NHDP in a steady state with LINK_STATUS equal to SYMMETRIC in all cases, a single single-valued TLV should always be used.)
        </t>
      </list>
    </t>

  </section>

  <section title="TLV Values" anchor="tlvvalues">

    <t>
      If, for example, an address block contains five addresses, the first two and the last two requiring values assigned using a LINK_STATUS TLV, but the third does not, then this can be indicated using two TLVs. It is however more efficient to do this with a single multivalue LINK_STATUS TLV, assigning the third address the value UNSPECIFIED. This approach was specified in <xref target="RFC7188"/>, and required for protocols that extend <xref target="RFC6130"/> and <xref target="RFC7181"/>. It is here RECOMMNDED that this approach is followed when defining any Address Block TLV that may be used by a protocol using <xref target="RFC5444"/>.
    </t>

    <t>
      It might be argued that this is not necessary in the example above, because the addresses can be reordered. However ordering addresses in such a way for all possible TLVs is not, in general, possible.
    </t>

    <t>
      As indicated, the LINK_STATUS TLV, and some other TLVs that take single octet values (per address) has a value UNSPECIFIED defined, as the value 255, in <xref target="RFC7188"/>. A similar approach (and a similar value) is RECOMMENDED in any similar cases. Some other TLVs may need a different approach, as noted in <xref target="RFC7188"/>, but implicitly permissible before then, the LINK_METRIC TLV has two octet values whose first four bits are flags indicating whether the metric value applies in four cases; if these are all zero then the metric value does not apply in this case, which is thus the equivalent of an UNSPECIFIED value.
    </t>

  </section>

  <section title="Automation">

    <t>
      There is scope for creating a protocol-independent optimizer for <xref target="RFC5444"/> messages that performs appropriate address re-organization (ordering and block separation) and TLV changes (of number, single- or multi- valuedness and use of unspecified values) to create more compact messages. The possible gain depends on the efficiency of the original message creation, and the specific details of the message. Note that while protocol-independent, this cannot be entirely TLV-independent, for example a LINK_METRIC TLV has a more complicated value structure than a LINK_STATUS TLV does if using unspecified values.
   </t>

  </section>

</section>
<section anchor="Security" title="Security Considerations">

  <t>
    This document does not specify a protocol, but provides rules and recommendations for how to design protocols using <xref target="RFC5444"/>. This document does not introduce any new security considerations; protocols designed according to these guidelines and recommendations are subject to the security considerations detailed in <xref target="RFC5444"/>. In particular the applicability of the security framework for <xref target="RFC5444"/> specified in <xref target="RFC7182"/> is unchanged.
  </t>

</section>

    <section anchor="IANA" title="IANA Considerations">
		<t>
			This document has no actions for IANA.
		</t>
	</section>
<section anchor="acknowledgments" title="Acknowledgments">
	<t>
     TBD
	<!--	The authors would like to gratefully acknowledge the following people for intense technical discussions, early reviews, and comments on the documents (listed alphabetically): Christopher Dearlove (BAE Systems) and Henning Rogge (FKIE). -->
	</t>
</section>

</middle>

<back>
    <references title="Normative References">
    

    
  <reference anchor="RFC2119">
    <front>
      <title abbrev="RFC2119">Key words for use in RFCs to Indicate Requirement Levels</title>
      <author initials="S." surname="Bradner" fullname="Scott Bradner">
        <organization abbrev="HU">Harvard University</organization>
      </author>
      <date month="March" year="1997" />
    </front>
    <seriesInfo name="RFC" value="2119" />
    <seriesInfo name="BCP" value="14" />
  </reference>
  
  <reference anchor="RFC5444">
    <front>
      <title abbrev="RFC5444">Generalized MANET Packet/Message Format</title>
        <author initials="T.H." surname="Clausen" fullname="Thomas Heide Clausen">
          <organization abbrev="X">Ecole Polytechnique, France</organization>
        </author>
        <author initials="C.M." surname="Dearlove" fullname="Christopher Dearlove">
          <organization abbrev="BAE">BAE Systems Advanced Technology Centre, UK</organization>
        </author>
        <author initials="J.W." surname="Dean" fullname="Justin W. Dean">
          <organization abbrev="NRL">Naval Research Laboratory, USA</organization>
        </author>
        <author initials="C." surname="Adjih" fullname="Cedric Adjih">
          <organization>INRIA Rocquencourt</organization>
        </author>
        <date month="February" year="2009" />
      </front>
      <seriesInfo name="RFC" value="5444"/>
    </reference>
 
    
    </references>

    <references title="Informative References">
  
   <reference anchor="RFC3626">
    <front>
      <title>The Optimized Link State Routing Protocol</title>
      <author initials="T.H." surname="Clausen" fullname="Thomas Heide Clausen (ed.)">
        <organization abbrev="PCRI">Ecole Polytechnique, France</organization>
      </author>
      <author initials="P." surname="Jacquet" fullname="Philippe Jacquet (ed.)">
        <organization abbrev="INRIA">Project Hipercom, INRIA Rocquencourt, France</organization>
      </author>
      <date month="October" year="2003"/>
    </front>
    <seriesInfo name="RFC" value="3626"/>
  </reference>
     
   <reference anchor="RFC5497">
    <front>
      <title abbrev="RFC5497">Representing Multi-Value Time in Mobile Ad Hoc Networks (MANETs)</title>
        <author initials="T.H." surname="Clausen" fullname="Thomas Heide Clausen">
          <organization abbrev="X">Ecole Polytechnique, France</organization>
        </author>
        <author initials="C.M." surname="Dearlove" fullname="Christopher Dearlove">
          <organization abbrev="BAE">BAE Systems Advanced Technology Centre, UK</organization>
        </author>
        <date month="March" year="2009"/>
      </front>
      <seriesInfo name="RFC" value="5497"/>
    </reference>

  <reference anchor="RFC5498">
    <front>
      <title abbrev="RFC5498">IANA Allocations for Mobile Ad Hoc Network (MANET) Protocols</title>
        <author initials="I." surname="Chakeres" fullname="Ian Chakeres">
          <organization abbrev="CenGen">CenGen</organization>
        </author>
        <date month="March" year="2009" />
      </front>
      <seriesInfo name="RFC" value="5498"/>
    </reference>
    
    <reference anchor="RFC6130">
    <front>
      <title abbrev="NHDP">Mobile Ad Hoc Network (MANET) Neighborhood Discovery Protocol (NHDP)</title>
      <author initials="T.H." surname="Clausen" fullname="Thomas Heide Clausen">
        <organization abbrev="X">Ecole Polytechnique, France</organization>
      </author>
      <author initials="J.W." surname="Dean" fullname="Justin W. Dean">
        <organization abbrev="NRL">Naval Research Laboratory, USA</organization>
      </author>
      <author initials="C.M." surname="Dearlove" fullname="Christopher Dearlove">
        <organization>BAE Systems Advanced Technology Centre, UK</organization>
      </author>
      <date month="April" year="2011"/>
    </front>
    <seriesInfo name="RFC" value="6130" />
  </reference>

  <reference anchor='RFC6621'>
	<front>
		<title abbrev="SMF">Simplified Multicast Forwarding</title>
		<author initials='J.' surname='Macker' fullname='Joe Macker'/>
		<date year='2012' month='May' />
	</front>
	<seriesInfo name='RFC' value='6621' />
  </reference>


	<reference anchor="RFC7181">
		<front>
			<title>The Optimized Link State Routing Protocol version 2</title>
			<author initials="T." surname="Clausen">
			</author>
			<author initials="C." surname="Dearlove">
			</author>
			<author initials="P." surname="Jacquet">
			</author>
			<author initials="U." surname="Herberg">
			</author>
			<date month="April" year="2014" />
		</front>
		<seriesInfo name="RFC" value="7181" />
	</reference>

	<reference anchor="RFC7182">
		<front>
			<title>Integrity Check Value and Timestamp TLV Definitions for Mobile Ad Hoc Networks (MANETs)</title>
			<author fullname="Ulrich Herberg" initials="U" surname="Herberg">
				<organization>Fujitsu Laboratories of America</organization>
			</author>
			<author fullname="Thomas Heide Clausen" initials="T" surname="Clausen">
				<organization>LIX, Ecole Polytechnique</organization>
			</author>
			<author initials="C." surname="Dearlove">
			</author>
			<date year="2014" month="April"/>
		</front>
		<seriesInfo name="RFC" value="7182"/>
	</reference>

	<reference anchor="RFC7183">
  		<front>
  			<title abbrev="Integrity Protection for NHDP and OLSRv2">
			    Integrity Protection for the Neighborhood Discovery Protocol (NHDP) and
                    Optimized Link State Routing Protocol Version 2 (OLSRv2)
			</title>
			<author fullname="Ulrich Herberg" initials="U" surname="Herberg">
			</author>
			<author initials="C.M." surname="Dearlove" fullname="Christopher Dearlove">
				<organization>BAE Systems ATC</organization>
			</author>
			<author fullname="Thomas Heide Clausen" initials="T" surname="Clausen">
				<organization>LIX, Ecole Polytechnique</organization>
			</author>
			<date month="April" year="2014" />
		</front>
		<seriesInfo name="RFC" value="7183" />
     </reference>

	<reference anchor="RFC7188">
  		<front>
  			<title abbrev="NHDP and OLSRv2 Extension TLVs">
                    Optimized Link State Routing Protocol version 2 (OLSRv2)
                    and MANET Neighborhood Discovery Protocol (NHDP) Extension TLVs
			</title>
			<author initials="C.M." surname="Dearlove" fullname="Christopher Dearlove">
				<organization>BAE Systems ATC</organization>
			</author>
			<author fullname="Thomas Heide Clausen" initials="T" surname="Clausen">
				<organization>LIX, Ecole Polytechnique</organization>
			</author>
			<date month="April" year="2014" />
		</front>
		<seriesInfo name="RFC" value="7188" />
  </reference>
  
	<reference anchor="G9903">
  		<front>
  			<title abbrev="G3-PLC">
                    ITU-T G.9903: Narrow-band orthogonal frequency division multiplexing power line communication transceivers for G3-PLC networks
			</title>
                <author/>
			<date month="May" year="2013" />
		</front>
  </reference>
    
</references>

</back>
</rfc>
