Robust Header Compression                                   G. Pelletier
Internet-Draft                                               K. Sandlund
Intended status: Standards Track                                Ericsson
Expires: March 10, November 26, 2007                                      Ericsson
                                                            May 25, 2007                                September 6, 2006

RObust Header Compression Version 2 (RoHCv2): Profiles for RTP, UDP, IP,
                            ESP and UDP Lite
           draft-ietf-rohc-rfc3095bis-rohcv2-profiles-00.txt
             draft-ietf-rohc-rfc3095bis-rohcv2-profiles-01

Status of this Memo

   By submitting this Internet-Draft, each author represents that any
   applicable patent or other IPR claims of which he or she is aware
   have been or will be disclosed, and any of which he or she becomes
   aware will be disclosed, in accordance with Section 6 of BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF), its areas, and its working groups.  Note that
   other groups may also distribute working documents as Internet-
   Drafts.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   The list of current Internet-Drafts can be accessed at
   http://www.ietf.org/ietf/1id-abstracts.txt.

   The list of Internet-Draft Shadow Directories can be accessed at
   http://www.ietf.org/shadow.html.

   This Internet-Draft will expire on March 10, November 26, 2007.

Copyright Notice

   Copyright (C) The Internet Society (2006). IETF Trust (2007).

Abstract

   This document specifies ROHC (Robust Header Compression) profiles
   that efficiently compress RTP/UDP/IP (Real-Time Transport Protocol,
   User Datagram Protocol, Internet Protocol), RTP/UDP-Lite/IP (User
   Datagram Protocol Lite), UDP/IP, UDP-Lite/IP, IP and ESP/IP
   (Encapsulating Security Payload) headers.

   This specification update defines a second version of the profiles defined found in
   RFC 3095, RFC 3843 and RFC 4019 to their second version (RoHCv2 profiles).  The profiles
   herein thus supersede 4019; it supersedes their earlier definition, but they do
   does not obsolete them.

   The RoHCv2 specification profiles introduce a number of simplifications to the
   rules and algorithms that govern the behavior of the compression
   endpoints.  It also defines robustness mechanisms that may be used by
   a compressor implementation to increase the probability of
   decompression success when packets can be lost and/or reordered on
   the ROHC channel.  Finally, the RoHCv2 profiles define its own
   specific set of packet formats, using the ROHC formal notation.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   5
   2.  Terminology . . . . . . . . . . . . . . . . . . . . . . . . .   5
   3.  Acronyms  . . . . . . . . . . . . . . . . . . . . . . . . . .   7
   4.  Background  . . . . . . . (Informative)  . . . . . . . . . . . . . . . . . .   7
     4.1.  Classification of header fields . . . . . . . . . . . . .   8   7
     4.2.  Operational Characteristics of RoHCv2 Profiles  . . . . .   9   8
   5.  Overview of the RoHCv2 Profiles . . . . . . . (Informative) . . . . . . . .   9
     5.1.  General Concepts  . . . . . . . . . . . . . . . . . . . .  10   9
       5.1.1.  Control Fields and Context Updates  . . . . . . . . .  10   9
     5.2.  Compressor Concepts . . . . . . . . . . . . . . . . . . .  10
       5.2.1.  Optimistic Approach . . . . . . . . . . . . . . . . .  10
       5.2.2.  Tradeoff between robustness to losses and to
               reordering  . . . . . . . . . . . . . . . . . . . . .  11  10
       5.2.3.  Interactions with the Decompressor Context  . . . . .  12
     5.3.  Decompressor Concepts . . . . . . . . . . . . . . . . . .  13
       5.3.1.  Decompressor State Machine  . . . . . . . . . . . . .  14  13
       5.3.2.  Decompressor Context Management . . . . . . . . . . .  16
       5.3.3.  Feedback logic  . . . . . . . . . . . . . . . . . . .  17
   6.  RoHCv2 Profiles (Normative) . . . . . . . . . . . . . . . . .  18
     6.1.  Profile Operation, per-context  . . . . . . . . . . . . .  18
     6.2.  Control Fields  . . . . . . . . . . . . . . . . . . . . .  19
       6.2.1.  Master Sequence Number (MSN)  . . . . . . . . . . . .  19
       6.2.2.  IP-ID behavior  . . . . . . . . . . . . . . . . . . .  20
     6.3.  Reconstruction and Verification . . . . . . . . . . . . .  20
     6.4.  Reordering and Segmentation . . . . . . . . . . . . . . .  20
       6.4.1.  Optimistic Approach . . . . . . . . . . . . . . . . .  21
     6.5.  Compressed Header Chains  . . . . . . . . . . . . . . . .  21
     6.5.
     6.6.  Packet Formats and Encoding Methods . . . . . . . . . . .  22
       6.5.1.
       6.6.1.  baseheader_extension_headers  . . . . . . . . . . . .  22
       6.5.2.
       6.6.2.  baseheader_outer_headers  . . . . . . . . . . . . . .  22
       6.5.3.  23
       6.6.3.  inferred_udp_length . . . . . . . . . . . . . . . . .  23
       6.5.4.
       6.6.4.  inferred_ip_v4_header_checksum  . . . . . . . . . . .  23
       6.5.5.
       6.6.5.  inferred_mine_header_checksum . . . . . . . . . . . .  23
       6.5.6.  24
       6.6.6.  inferred_ip_v4_length . . . . . . . . . . . . . . . .  24
       6.5.7.
       6.6.7.  inferred_ip_v6_length . . . . . . . . . . . . . . . .  24
       6.5.8.  25
       6.6.8.  Scaled RTP Timestamp Encoding . . . . . . . . . . . .  25
       6.5.9.  inferred_scaled_field
       6.6.9.  Timer-Based RTP Timestamp Encoding  . . . . . . . . .  26
       6.6.10. inferred_scaled_field . . . . . . . .  26
       6.5.10. control_crc3 . . . . . . . .  26
       6.6.11. control_crc3_encoding . . . . . . . . . . . .  26
       6.5.11. . . . .  27
       6.6.12. inferred_sequential_ip_id . . . . . . . . . . . . . .  27
       6.5.12.  28
       6.6.13. list_csrc(cc_value) . . . . . . . . . . . . . . . . .  27
     6.6.  28
     6.7.  Encoding Methods With External Parameters . . . . . . . .  32
     6.8.  Packet Formats  . . . . . . . . . . . . . . . . . . . . .  31
       6.6.1.  36
       6.8.1.  Initialization and Refresh Packet (IR)  . . . . . . .  31
       6.6.2.  36
       6.8.2.  IR  Packet Payload Discard (IR-PD)  . . . . . . . . .  32
       6.6.3.  IR Dynamic Packet (IR-DYN)  . . . . . . . . . . . . .  33
       6.6.4.  37
       6.8.3.  Compressed Packet Formats (CO)  . . . . . . . . . . .  34
     6.7.  38
     6.9.  Feedback Formats and Options  . . . . . . . . . . . . . .  85
       6.7.1. 100
       6.9.1.  Feedback Formats  . . . . . . . . . . . . . . . . . .  85
       6.7.2. 100
       6.9.2.  Feedback Options  . . . . . . . . . . . . . . . . . .  87 101
   7.  Security Considerations . . . . . . . . . . . . . . . . . . .  89 104
   8.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  89 104
   9.  Acknowledgements  . . . . . . . . . . . . . . . . . . . . . .  90 106
   10. References  . . . . . . . . . . . . . . . . . . . . . . . . .  90 106
     10.1. Normative References  . . . . . . . . . . . . . . . . . .  90 106
     10.2. Informative References  . . . . . . . . . . . . . . . . .  92 107
   Appendix A.      Detailed classification of header fields . . . .  92 107
   Appendix A.1.    General classification . . . . . . . . . . . . .  93 108
   Appendix A.1.1.  IPv4 header fields . . . . . . . . . . . . . . .  93 108
   Appendix A.1.2.  IPv6 header fields . . . . . . . . . . . . . . .  95 110
   Appendix A.1.3.  UDP header fields  . . . . . . . . . . . . . . .  96 111
   Appendix A.1.4.  UDP-Lite header fields . . . . . . . . . . . . .  96 111
   Appendix A.1.5.  RTP header fields  . . . . . . . . . . . . . . .  97 112
   Appendix A.1.6.  ESP header fields  . . . . . . . . . . . . . . . 113
   Appendix A.2.    Analysis of change patterns of header fields . .  98 113
   Appendix A.2.1.  IPv4 Identification  . . . . . . . . . . . . . . 100 116
   Appendix A.2.2.  IP Traffic Class / Type-Of-Service . . . . . . . 101 117
   Appendix A.2.3.  IP Hop-limit / Time-To-Live  . . . . . . . . . . 101 117
   Appendix A.2.4.  IPv4 Don't Fragment  . . . . . . . . . . . . . . 102 117
   Appendix A.2.5.  UDP Checksum . . . . . . . . . . . . . . . . . . 102 117
   Appendix A.2.6.  UDP-Lite Checksum Coverage . . . . . . . . . . . 102 117
   Appendix A.2.7.  UDP-Lite Checksum  . . . . . . . . . . . . . . . 102 117
   Appendix A.2.8.  RTP CSRC Counter . . . . . . . . . . . . . . . . 102 117
   Appendix A.2.9.  RTP Marker . . . . . . . . . . . . . . . . . . . 102 118
   Appendix A.2.10. RTP Padding  . . . . . . . . . . . . . . . . . . 103 118
   Appendix A.2.11. RTP Extension  . . . . . . . . . . . . . . . . . 103 118
   Appendix A.2.12. RTP Payload Type . . . . . . . . . . . . . . . . 103 118
   Appendix A.2.13. RTP Sequence Number  . . . . . . . . . . . . . . 103 118
   Appendix A.2.14. RTP Timestamp  . . . . . . . . . . . . . . . . . 103 118
   Appendix A.2.15. RTP Contributing Sources (CSRC)  . . . . . . . . 104 119
   Appendix A.3.    Header compression strategies  . . . . . . . A.2.16. ESP Sequence Number  . . 104
   Appendix A.3.1.  Do not send at all . . . . . . . . . . . . 119
   Appendix B.      Differences between RoHCv2 and RFC3095
                    profiles . . . 104
   Appendix A.3.2.  Transmit only initially . . . . . . . . . . . . 104
   Appendix A.3.3.  Transmit initially, be prepared to update . . . 105
   Appendix A.3.4.  Be prepared to update, or send as-is
                    frequently . . 119
   Authors' Addresses  . . . . . . . . . . . . . . . . . 105
   Appendix A.3.5.  Guarantee continuous robustness . . . . . . 120
   Intellectual Property and Copyright Statements  . . 105
   Appendix A.3.6.  Transmit as-is in all packets . . . . . . . . . 105
   Appendix A.3.7.  Establish and be prepared to update delta  . . . 106
   Appendix B.      Differences between RoHCv2 and RFC3095
                    profiles . . . . . . . . . . . . . . . . . . . . 106
   Appendix C.      Sample CRC algorithm . . . . . . . . . . . . . . 106
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . . 108
   Intellectual Property and Copyright Statements  . . . . . . . . . 110 121

1.  Introduction

   The ROHC WG has developed a header compression framework on top of
   which various profiles can be defined for different protocol sets or
   compression requirements.  The ROHC framework was first documented in
   [RFC3095], together with profiles for compression of RTP/UDP/IP
   (Real-Time Transport Protocol, User Datagram Protocol, Internet
   Protocol), UDP/IP, IP and ESP/IP (Encapsulating Security Payload)
   headers.  Additional profiles for compression of IP headers [RFC3843]
   and UDP-Lite (User Datagram Protocol Lite) headers [RFC4019] were
   later specified to complete the initial set of ROHC profiles.

   This document defines an updated version for each of the above
   mentionned
   mentioned profiles, and its definition is based on the specification
   of the RoHC framework as found in
   [I-D.ietf-rohc-rfc3095bis-framework].

   Specifically, this document defines header compression schemes for:

   o RTP/UDP/IP      : profile 0x0101 (updates profile 0x0001 [RFC3095])
   o UDP/IP          : profile 0x0102 (updates profile 0x0002 [RFC3095])
   o ESP/IP          : profile 0x0103 (updates profile 0x0003 [RFC3095])
   o IP              : profile 0x0104 (updates profile 0x0004 [RFC3843])
   o RTP/UDP-Lite/IP : profile 0x0107 (updates profile 0x0007 [RFC4019])
   o UDP-Lite/IP     : profile 0x0108 (updates profile 0x0008 [RFC4019])

   ROHCv2 compresses the following type of extension headers:

   o  AH [RFC4302]
   o  GRE [RFC2784][RFC2890]
   o  MINE [RFC2004]
   o  NULL-encrupted ESP [RFC4303]
   o  IPv6 Destination Options header[RFC2460]
   o  IPv6 Hop-by-hop Options header[RFC2460]
   o  IPv6 Routing header [RFC2460].

2.  Terminology

   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 RFC 2119 [RFC2119].

   This document is consistent with the terminology found in the ROHC
   framework [I-D.ietf-rohc-rfc3095bis-framework] and in the formal
   notation for ROHC [I-D.ietf-rohc-formal-notation].  In addition, this
   document uses or defines the following terms:

   Chaining of Items

      A chain groups fields based on similar characteristics.  ROHCv2
      defines chain items for static, dynamic and irregular fields.
      Chaining is done by appending an item for e.g. each header to the
      chain in their order of appearance in the uncompressed packet.
      Chaining is useful to construct compressed headers from an
      arbitrary number of any of the protocol headers for which a ROHCv2
      profile defines a compressed format.

   CRC-8 validation

      The CRC-8 validation refers to the validation of the integrity
      against bit error(s) of the received IR and in the IR-DYN header,
      using the 8-bit CRC that is included in the header.

   CRC verification

      The CRC verification refers to the verification of the result of a
      decompression attempt, using the 3-bit CRC or 7-bit CRC included
      in the header of a compressed packet format (CO).

   Delta

      The delta refers to the difference in terms of the absolute value
      of a field between two consecutive packets and processed by the
      same compression endpoint.

   Reordering Depth

      The number of packets by which a packet made late in its sequence.
      See definition of sequentially late packet below.

   ROHCv2 packet types

      ROHCv2 profiles use two different packet types: the Initialization
      and Refresh (IR) packet type, and the Compressed packet type (CO).

   Sequentially early packet

      A packet that reaches the decompressor before one or several
      packets that were delayed over the channel, whereas all of the
      said packets belong to the same header-compressed flow and are
      associated to the same compression context (CID).  At the time of
      the arrival of a sequentially early packet, the packet(s) delayed
      on the link cannot be differentiated from lost packet(s).

   Sequentially late packet

      A packet is late within its sequence if it reaches the
      decompressor after one or several other packets belonging to the
      same CID have been received, although the sequentially late packet
      was sent from the compressor before the other packet(s).

   Timestamp stride (ts_stride)
      The timestamp stride (TS_STRIDE) is the expected increase in the
      timestamp value between two RTP packets with consecutive sequence
      numbers.

3.  Acronyms

   This section lists most acronyms used for reference, in addition to
   those defined in [I-D.ietf-rohc-rfc3095bis-framework].

   AH       Authentication Header.
   ESP      Encapsulating Security Payload.
   GRE      Generic Routing Encapsulation. RFC 2784, RFC 2890.
   IC       Initial Context state (decompressor)
   FC       Full Context state (decompressor)
   IP       Internet Protocol.
   LSB      Least Significant Bits.
   MINE     Minimal Encapsulation in IP
   MSB      Most Significant Bits.
   MSN      Master Sequence Number.
   NC       No Context state (decompressor).
   OA       Optimistic Approach.
   ROHCv2   Set of header compression profiles defined in this document
   RTP      Real-time Transport Protocol.
   SSRC     Synchronization source. Field in RTP header.
   CSRC     Contributing source. Optional list of CSRCs in RTP header.
   TC       Traffic Class. Octet in IPv6 header. See also TOS.
   TOS      Type Of Service. Octet in IPv4 header. See also TC.
   TS       RTP Timestamp.
   UDP      User Datagram Protocol.
   UDP-Lite User Datagram Protocol Lite.

4.  Background (Informative)

   This section provides background information on the compression
   profiles defined in this document.  The fundamentals of general
   header compression and of the ROHC framework may be found in section
   3 and 4 of [I-D.ietf-rohc-rfc3095bis-framework], respectively.  The
   fundamentals of the formal notation for ROHC are defined in
   [I-D.ietf-rohc-formal-notation].  [RFC4224] describes the impacts of
   out-of-order delivery on profiles based on [RFC3095].

4.1.  Classification of header fields

   Section 3.1 of [I-D.ietf-rohc-rfc3095bis-framework] explains that
   header compression is possible due to the fact that there is much
   redundancy between field values within the headers of a packet, but
   especially between the headers of consecutive packets.

   Appendix A lists and classifies in detail all the header fields
   relevant to this document.  The appendix concludes with
   recommendations on how the various fields should be handled by header
   compression algorithms.

   The main conclusion is that most of the header fields can easily be
   compressed away since they never or seldom change.  A small number of
   fields however need more sophisticated mechanisms.

   These fields are:

   - IPv4 Identification        (16 bits) - IP-ID
   - ESP Sequence Number        (32 bits) - ESP SN
   - UDP Checksum               (16 bits) - Checksum
   - UDP-Lite Checksum          (16 bits) - Checksum
   - UDP-Lite Checksum Coverage (16 bits) - CC CCov
   - RTP Marker                 ( 1 bit ) - M-bit
   - RTP Sequence Number        (16 bits) - RTP SN
   - RTP Timestamp              (32 bits) - TS

   In particular, for RTP, the analysis in Appendix A reveals that the
   values of the RTP Timestamp (TS) field usually have a strong
   correlation to the RTP Sequence Number (SN), which increments by one
   for each packet emitted by an RTP source.  The RTP M-bit is expected
   to have the same value most of the time, but it needs to be
   communicated explicitly on occasion.

   For UDP, the Checksum field cannot be inferred or recalculated at the
   receiving end without violating its end-to-end properties, and is
   thus sent as-is when enabled (mandatory with IPv6).  The same applies
   to the UDP-Lite Checksum (mandatory with both IPv4 and IPv6), while
   the UDP-Lite Checksum Coverage may in some cases be compressible.

   For IPv4, a similar correlation as the one of the RTP TS to the RTP
   SN is often observed between the Identifier field (IP-ID) and the
   master sequence number used for compression (e.g. the RTP SN when
   compressing RTP headers).

4.2.  Operational Characteristics of RoHCv2 Profiles

   Robust header compression can be used over many type of link
   technologies.  Section 4.4 of [I-D.ietf-rohc-rfc3095bis-framework]
   lists the operational characteristics of the ROHC channel.  The
   RoHCv2 profiles address a wide range of applications, and this
   section summarizes some of the operational characteristics that are
   specific to these profiles.

   Packet length

      ROHCv2 profiles assume that the lower layer indicates the length
      of a compressed packet.  ROHCv2 compressed headers do not contain
      length information for the payload.

   Out-of-order delivery between compression endpoints

      The definition of the RoHCv2 profiles places no strict requirement
      on the delivery sequence between the compression endpoints, i.e.
      packets may be received in a different order than the compressor
      sent them with and still have a fair chance of successfully probability to be successfully
      decompressed.

      However, frequent out-of-order delivery and/or significant
      reordering depth will negatively impact the compression
      efficiency.  More specifically, if the channel state includes
      parameters that provide compressor can operate
      using a proper estimate of such significant out-
      of-order delivery, the reordering characteristics of the
      path between the compression endpoints, larger headers can be sent
      more often to increase the robustness against decompression
      failures due to
      reordering.  Otherwise if the compressor cannot operate with
      sufficient knowledge for such reordering, out-of-order delivery.  Otherwise, the compression
      efficiency will be impaired from an increase in the frequency of
      decompression failures and recovery attempts.

5.  Overview of the RoHCv2 Profiles (Informative)

   This section provides an overview of important and useful concepts of
   ROHCv2 profiles.  These concepts may be used as guidelines for
   implementations but they are not part of the normative definition of
   the profiles, as these concepts relates to the compression efficiency
   of the protocol without impacting the interoperability
   characteristics of an implementation.

5.1.  General Concepts

5.1.1.  Control Fields and Context Updates

   Control fields have the same attributes and properties as
   uncompressed fields [I-D.ietf-rohc-formal-notation].  These fields
   are used for compression and decompression of some of the
   uncompressed header fields.  Updating the value of one or more
   control field(s) is thus no less important than updating context
   values for header fields.  Control fields are defined in
   [I-D.ietf-rohc-formal-notation].

   Packet types that initialize or update the value of one or more
   control field(s) thus include an additional 3-bit CRC, as defined by
   the packet formats in Section 6.6. 6.8.  The CRC is calculated using the
   UVALUE of the control field(s) that it covers.

   This CRC validates all the control fields that are updated.  Failure
   to verify this CRC should be interpreted by the decompressor as a
   decompression failure, in the algorithm it implements to assess the
   validity of its context.

5.2.  Compressor Concepts

   Header compression can be conceptually characterized as the
   interaction of a compressor with a decompressor state machine, one
   per context.  The responsability of the compressor is to minimally
   send convey the
   information needed to successfully decompress a packet, based on a
   certain confidence regarding the state of the decompressor context.

   This confidence is obtained from the frequency and the type of
   information the compressor sends when updating the decompressor
   context, from the optimistic approach (Section 5.2.1) and optionally
   from feedback messages received from the decompressor.

5.2.1.  Optimistic Approach

   A compressor always uses the optimistic approach when it performs
   context updates.  The compressor normally repeats the same type of
   update until it is fairly confident that the decompressor has
   successfully received the information.  If the decompressor
   successfully receives any of the headers containing this update,
   state will be available for the decompressor to process smaller
   compressed headers.

   If field X in the uncompressed header changes value, the compressor
   uses a packet type that contains an encoding of field X until it has
   gained confidence that the decompressor has received at least one
   packet containing the new value for X. The compressor normally
   selects a compressed format with the smallest header that can convey
   the changes needed to achieve confidence.

   The number N of repetitions for the optimistic approach that is
   needed to obtain this confidence is normally related to the packet
   loss and to the out-of-order delivery characteristics of the link where
   header compression is used; it is thus not defined in this document
   and is left open to implementations.

5.2.2.  Tradeoff between robustness to losses and to reordering

   The ability of a header compression algorithm to handle sequentially
   late packets is mainly limited by two factors: the interpretation
   interval offset of the sliding window used for LSB encoded fields
   [I-D.ietf-rohc-formal-notation], and the optimistic approach
   Section 5.2.1 for seldom changing fields.

   The interpretation interval offset specifies an upper limit for the
   maximum reordering depth, by which is it possible for decompressor to
   recover the original value of a dynamically changing field that is
   encoded using W-LSB.  Its value is bound to the number of LSB
   compressed bits in the compressed header format, and grows with the
   number of bits transmitted.  However, the offset and the LSB encoding
   only provide robustness for the field that it compresses, and
   (implicitly) for other sequentially changing fields that are derived
   from that field.

   This is shown in the figure below:

      <--- interpretation interval (size is 2^k) ---->
      |------------------+---------------------------|
   v_ref-p             v_ref              v_ref + (2^k-1) - p
    Lower                                          Upper
    Bound                                          Bound
      <--- reordering --> <--------- losses --------->

      where delta(SN) = p is the maximum negative delta, corresponding
      to the maximum reordering depth for which the lsb encoding can
      recover the original value of the field;
      where delta(SN) = (2^k-1) - p is the maximum positive delta,
      corresponding to the maximum number of consecutive losses for
      which the lsb encoding can recover the original value of the
      field;
      where v_ref is the reference value, as defined in the lsb encoding
      method in [I-D.ietf-rohc-formal-notation].

   The optimistic approach Section 5.2.1 (Section 5.2.1) provides the upper limit for
   the maximum reordering depth for seldom changing fields.

   There is thus a tradeoff between the robustness against reordering
   and the robustness against packet losses, with respect to the number
   of MSN bits needed and the distribution of the interpretation
   interval between negative and positive deltas in the MSN.

   There is also a tradeoff between compression efficiency and
   robustness.  When only information on the MSN needs to be conveyed to
   the decompressor, the tradeoff relates to the number of compressed
   MSN bits in the compressed header format.  Otherwise, the tradeoff
   relates to the implementation of the optimistic approach.

5.2.3.  Interactions with the Decompressor Context

   The compressor normally starts compression with the initial
   assumption that the decompressor has no useful information to process
   the new flow, and sends Initialization and Refresh (IR) packets.

   The compressor can then adjust the compression level based on its
   confidence that

   Initially, when sending the decompressor has first IR packet for a compressed flow,
   the compressor does not expect to receive feedback for that flow,
   until such feedback is first received.  At this point, the compressor
   may then assume that the decompressor will continue to send feedback
   in order to repair its context when necessary.  The former is
   referred to as unidirectional operation, while the latter is called
   bidirectional operation.

   The compressor can then adjust the compression level based on its
   confidence that the decompressor has the necessary information to
   successfully process the compressed headers that it selects.  In
   other words, the responsability responsibility of the compressor is to ensure that
   the decompressor operates with state information that is sufficient
   to allow decompression of the most efficient compressed header(s),
   and to allow the decompressor to successfully recover that state
   information as soon as possible otherwise.

   The compressor thus has the entire responsability to ensure that the
   decompressor has the proper information to decompress the type of
   compressed header that it sends.  In other words, the choice of
   compressed header depends on the following factors:

   o  the outcome of the encoding method applied to each field;
   o  the optimistic approach, with respect to the characteristics of
      the channel;
   o  the presence or not type of an established feedback channel, operation (unidirectional or bidirectional), and if
      present, in
      birectional operation, feedback received from the decompressor
      (ACKs, NACKs,
      Static-NACK Static-NACK, and options).

   Encoding methods normally use previous value(s) from a history of
   packets whose headers it has previously compressed.  The optimistic
   approach is meant to ensure that at least one compressed header
   containing the information to update the state for a field is
   received.  Finally, feedback indicates what actions the decompressor
   has taken with respect its assumptions regarding the validity of its
   context Section 5.3.2; (Section 5.3.2); it indicates what type of compressed header
   the decompressor can or cannot decompress.

   The decompressor has the means to detect decompression failures for
   any type of compressed (CO) header, using the CRC verification.
   Depending on the frequency and/or on the type of the failure, it
   might send a negative acknowledgement (NACK) or an explicit request
   for a complete context update (Static-NACK).  However, the
   decompressor does not have the means to identify the cause of the
   failure, and in particular decompression of what field(s) is
   responsible for the failure.  The compressor is thus always
   reponsible to figure out what is the most suitable response to a
   negative acknowledgement, using the confidence it has in the state of
   the decompressor context, when selecting the type of compressed
   header it will use when compressing a header.

5.3.  Decompressor Concepts

   Initially, when sending the first IR packet for a compressed flow,
   the compressor does not expect to receive feedback for that flow,
   until such feedback is first received.  At this point, the compressor
   may then assume that the decompressor will continue to send feedback
   in order to repair its context when necessary.  The former is
   referred to as unidirectional operation, while the latter is called
   bidirectional operation.

   The decompressor normally always uses the last received and
   successfully validated (IR or IR-DYN packets) or verified (CO packets) header
   as the reference for future decompression.  If the received packet is
   older than the current reference packet based on the MSN in the
   compressed header, the decompressor may refrain from using this
   packet as the new reference packet, even if the correctness of its
   header was successfully verified.

   The decompressor's responsability responsibility is thus to minimally and
   consistently verify the outcome of the decompression attempt, update
   its context when successful and finally to request context repairs by
   making coherent usage of feedback, once it starts using it.

   Specifically, the outcome of every decompression attempt is verified
   using the CRC present in the compressed header; the decompressor
   updates the context information when this outcome is successfully
   verified; finally if the decompressor uses feedback once for a
   compressed flow then it will continue to do so for as long as the
   corresponding context is associated with the same profile.

5.3.1.  Decompressor State Machine

   The decompressor operation may be represented as a state machine
   defining three states: No Context (NC), Initial Context (IC) and Full
   Context (FC).

   The decompressor starts with no valid context, the NC state.
   Successful CRC-8 validation of an IR packet moves the decompressor to
   the IC state, where it stays until it successfully verifies a
   decompression attempt for a compressed header with a 7-bit CRC.  The
   decompressor state machine normally does not leave the FC state once
   it has entered this state; only repeated decompression failures will
   force the decompressor to transit downwards to a lower state.

   Below is the state machine for the decompressor.  Details of the
   transitions between states and decompression logic are given in the
   sub-sections following the figure.

                                                          CRC-8(IR) or
                                                          CRC-8(IR-DYN)
                                                          Validation
                                                          CRC-8(IR) or
                                                          Validation
                                                          CRC-7(CO) or
    CRC-8(IR)  CRC-8(IR)     CRC-8(IR-DYN)     CRC-8(IR)      CRC-7(CO)     CRC-3(CO)
    Failure    Validation    Validation     Verification  Verification
    +--->---+  +-->---->--+  +-->----->--+  +-->---->--+  +-->---->--+
    |       |  |          |  |           |  |          |  |          |
    |       v  |          v  |           v  |          v  |          v
   +-----------------+  +----------------------+  +-------------------+
   | No Context (NC) |  | Initial Context (IC) |  | Full Context (FC) |
   +-----------------+  +----------------------+  +-------------------+
       ^                 | ^ CRC-7(CO)      | ^                 |
       | Static Context  | | Failure or     | | Context Damage  |
       | Damage Detected | | PT not allowed | | Detected        |
       +--<-----<-----<--+ +----<------<----+ +--<-----<-----<--+
   where:
      CRC-8(IR) and/or CRC-8(IR-DYN) validation: successful CRC-8 validation for the IR header and the IR-DYN header, respectively.
      header.
      CRC-7(CO) and/or CRC-3(CO) verification: successful CRC
      verification for the CO header, based on the number of CRC bits
      carried in the CO header.
      CRC-7(CO) failure: failure to CRC verify the decompression of a CO
      header carrying a 7-bit CRC.
      PT not allowed: the decompressor has received a packet type (PT)
      for which the decopressor's current context does not provide
      enough valid state information for that packet to be decompressed.
      Static Context Damaged Detected: see definition in Section 5.3.2.
      Context Damage Detected: see definition in Section 5.3.2.

5.3.1.1.  No Context (NC) State

   Initially, while working in the No Context (NC) state, the
   decompressor has not yet successfully validated an IR packet.

   Attempting decompression:

      In the NC state, only packets carrying sufficient information on
      the static fields (i.e.  IR packets) can be decompressed.

   Upward transition:

      Upon receiving an IR packet, the decompressor validates the
      integrity of its header using the CRC-8 validation.  If the IR
      packet is successfully validated, the decompressor updates the
      context and use this packet as the reference packet.  Once an IR
      packet has initialized the context, the decompressor can transit
      to the IC state.

   Feedback logic:

      In the No Context state, the decompressor should send a STATIC-
      NACK if a packet of a type other than IR is received, or if an IR
      packet has failed the CRC-8 validation, subject to the feedback
      rate limitation as described in Section 5.3.3.

5.3.1.2.  Initial Context (IC) State

   In the IC state, the decompressor has successfully validated a an IR
   packet.

   Attempting decompression:

      In the Initial Context state, only packets carrying sufficient
      information on the dynamic fields covered by an 8-bit CRC (e.g.
      IR and IR-DYN) (i.e.
      IR) or CO packets carrying a 7-bit CRC can be decompressed.

   Upward transition:

      The decompressor can move to the Full Context (FC) state when the
      CRC verification succeeds for a CO header carrying a 7-bit CRC.

   Downward transition:

      The decompressor moves back to the NC state if it assumes static
      context damage.

   Feedback logic:

      In the IC state, the decompressor should send a STATIC-NACK when
      CRC-8 validation of an IR/IR-DYN IR fails, or when a CO header carrying a
      7-bit CRC fails and if static context damage is assumed, subject
      to the feedback rate limitation as described in Section 5.3.3.  If
      any other packet type is received, the decompressor should treat
      it as a CRC verification failure when deciding if a NACK is to be
      sent.

5.3.1.3.  Full Context (FC) State

   In the FC state, the decompressor has successfully verified a CO
   header with a 7-bit CRC.

   Attempting decompression:

      In the Full Context state, decompression can be attempted
      regardless of the type of packet received.

   Downward transition:

      I.

      The decompressor moves back to the IC state if it assumes context
      damage, and back to the NC state if it assumes static context
      damage.

   Feedback logic:

      In the Full Context state, the decompressor should send a NACK
      when CRC-8 validation or CRC verification of any packet type fails
      and if context damage is assumed, subject to the feedback rate
      limitation as described in Section 5.3.3.

5.3.2.  Decompressor Context Management

   All header formats carry a CRC and are context updating.  A packet
   for which the CRC succeeds updates the reference values of all header
   fields, either explicitly (from the information about a field carried
   within the compressed header) or implicitly (fields that are inferred
   from other fields).

   The decompressor may assume that some or the entire context is
   invalid, following one or more failures to validate or verify a
   header using the CRC.  Because the decompressor cannot know the exact
   reason(s) of for a CRC failure or what field caused it, the validity of
   the context hence does not refer to what exact context entry is
   deemed valid or not.

   Validity of the context rather relates to the detection of a problem
   with the context.  The decompressor first assume that the type of
   information that most likely caused the failure(s) is the state that
   normally changes for each packet, i.e. context damage of the dynamic
   part of the context.  Upon repeated failures and unsuccessful
   repairs, the decompressor then assume that the entire context,
   including the static part, needs to be repaired, i.e. static context
   damage.

   Context Damage Detection

      The assumption of context damage means that the decompressor will
      not attemp decompression of a CO headers that carries a 3-bit CRC,
      and only attempt decompression of IR or IR-DYN headers, or CO headers
      protected by a CRC-7.

   Static Context Damage Detection
      The assumption of static context damage means that the
      decompressor refrains from attempting decompression of any type of
      header other than the IR header, as it cannot know what part of
      its context can be relied upon after first assuming context damage
      and failed to repair its context, and as a result of too many
      failures.

   How these assumptions are made, i.e. how context damage is detected,
   is open to implementations.  It can be based on the residual error
   rate, where a low error rate makes the decompressor assume damage
   more often than on a high rate link.

   The decompressor implements these assumptions by selecting the type
   of compressed header for it may attempt decompression.  In other
   words, validity of the context refers to the ability of a
   decompressor to attempt or not decompression of specific packet
   types.

5.3.3.  Feedback logic

   When RoHCv2 profiles may be are used in environments with or without feedback
   capabilities from decompressor to compressor.  RoHCv2 however assumes
   that if over a ROHC feedback channel is available and if this channel is
   used at least once by that cannot guarantee
   in-order delivery, the decompressor for a specific context, this
   channel will be used during may refrain to update its context
   with the entire compression operation for content of a sequentially late packet that is successfully
   decompressed.  This is to avoid updating the context with information
   that is older than what the decompressor already has in its context.  If
   How the connection decompressor detects a sequentially late packet is broken and outside
   the scope of this specification, but it can for example use the MSN
   to this purpose.

5.3.3.  Feedback logic

   RoHCv2 profiles may be used in environments with or without feedback
   capabilities from decompressor to compressor.  RoHCv2 however assumes
   that if a ROHC feedback channel
   disappears, compression should is available and if this channel is
   used at least once by the decompressor for a specific context, this
   channel will be restarted. used during the entire compression operation for that
   context (i.e. bidirectional operation).

   The RoHC framework defines 3 types of feedback messages: ACKs, NACKs
   and STATIC-NACKs.  The semantics of each message if defined insection in
   section 5.2.3.1. of [I-D.ietf-rohc-rfc3095bis-framework] What
   feedback to send is coupled to the context management of the
   decompressor, i.e. to the implementation of the context damage
   detection algorithms as described in Section 5.3.2.

   The decompressor should send a NACK when it assumes context damage,
   and it should send a STATIC-NACK when it assumes static context
   damage.  The decompressor is not strictly expected to send ACK
   feedback upon successful decompression, other than for the purpose of
   improving compression efficiency.

   When RoHCv2 profiles are used over a channel that cannot guarantee
   in-order delivery, the decompressor may refrain to send ACK feedback
   for a sequentially late packet that is successfully decompressed.
   How the decompressor detects a sequentially late packet is outside
   the scope of this specification, but it can for example use the MSN
   to this purpose.

   The decompressor should limit the rate at which it sends feedback , feedback,
   for both ACKs and STATIC-NACK/NACKs, and should avoid sending
   unnecessary duplicates of the same type of feedback message that may
   be associated to the same event.

6.  RoHCv2 Profiles (Normative)

6.1.  Profile Operation, per-context

   RoHCv2 profiles operates differently, per context, depending on how
   the decompressor uses makes use of a the feedback channel. channel, if any.  Once the
   decompressor uses the feedback channel for a context, it establishes
   the feedback channel for that CID.

   The compressor always start assuming that the decompressor will not
   send feedback when it initializes a new context (see also , section
   5.1.1.)  [I-D.ietf-rohc-rfc3095bis-framework],
   5.1.1. of [I-D.ietf-rohc-rfc3095bis-framework]), i.e. there is no
   established feedback channel for the new context.  There will always
   be a possibility of decompression failure with the optimistic
   approach, because the decompressor may not have received sufficient
   information for correct decompression.  Therefore, until the
   decompressor has established a feedback channel, the compressor
   SHOULD periodically send IR packets.  The periodicity can be based on
   timeouts, on the number of compressed packets sent for the flow, or
   any other strategy the implementer chooses.

   The reception of either positive feedback (ACKs) or negative feedback
   (NACKs) establishes the feedback channel from the decompressor for
   the context (CID) for which the feedback was received.  Once there is
   an established feedback channel for a specific context, the
   compressor can make use of this feedback to estimate the current
   state of the decompressor.  This helps increasing the compression
   efficiency by providing the information needed for the compressor to
   achieve the necessary confidence level.  When the feedback channel is
   established, it becomes superfluous for the compressor to send
   periodic refreshes, and instead it can rely entirely on the
   optimistic approach and feedback from the decompressor.

   The decompressor MAY send positive feedback (ACKs) to initially
   establish the feedback channel for a particular flow.  Either
   positive feedback (ACKs) or negative feedback (NACKs) establishes
   this channel.  The decompressor is REQUIRED to continue sending
   feedback once it has established a feedback channel for a CID, for
   the lifetime of the context, i.e. until the CID is associated with a
   different profile from the reception of an IR packet, to send error
   recovery requests and (optionally) acknowledgments of significant
   context updates.

   Due to the periodic refreshes and the lack of feedback for initiation
   of error recovery, compression without an established feedback
   channel will be less efficient and have a slightly higher probability
   of loss propagation compared to the decompressor making use of
   feedback.

6.2.  Control Fields

   RoHCv2 defines a number of control fields that are used by the
   decompressor in its interpretation of the packet formats received
   from the compressor.

   A control field is a field that is transmitted from the compressor to
   the decompressor, but is not part of the uncompressed header.  Values
   for control fields can be set up in the context of both the
   compressor and the decompressor.  Once established at the
   decompressor, the values of these fields MUST be kept until updated
   by another packet.

6.2.1.  Master Sequence Number (MSN)

   The Master Sequence Number (MSN) field is either taken from a field
   that already exists in each of the headers of the protocol that the
   profile compresses (e.g.  RTP SN), or alternatively it is created at
   the compressor.

   The MSN field has the following two functions:

   o  Differentiating between packets when sending feedback data.
   o  Inferring the value of incrementing fields (e.g.  IPv4
      Identifier).

   The MSN field is present in every packet sent by the compressor.  The
   MSN is sent in full in IR and IR-DYN packets, while it is sent LSB encoded
   within CO header formats.  The decompressor always sends the MSN as
   part of the feedback information.  The compressor can later use the
   MSN to infer which packet the decompressor is acknowledging.

   When

   For profiles for which the MSN is initialized, it is initialized to a random value. created by the compressor, the
   following rules applies:

   o  The compressor should only initialize a new MSN for the initial IR
   packet
      sent for a new context, i.e. for a CID that corresponds to a context that is not already
      associated with the profile used in the
   IR header.  In other words, if the compressor reuses the same CID
   with the same profile to compress many flows one after the other, the
   MSN is not reinitialized but rather continues to increment
   monotonically.

   For profiles for which the MSN is created by the compressor, the
   following rules applies:

   o  The compressor should only initialize a new MSN for the initial IR
      sent for a CID that corresponds to a context that is not already
      associated with this profile;
   o  When this profile;
   o  When the MSN is initialized, it is initialized to a random value;
   o  The value of the MSN is incremented by one for each packet that
      the compressor sends.

6.2.2.  IP-ID behavior

   The IP-ID field of the IPv4 header can have different change
   patterns: sequential in network byte order, sequential byte-swapped,
   random and or constant (a constant value of zero, although not conformant
   with [RFC0791], as been observed in practice).The practice).  The control field for
   the IP-ID behavior determines which set of packet formats will be
   used.  Note that these control fields are also used to determine the
   contents of the irregular chain item for each IP header.

   If more than one level of IP headers is present, RoHCv2 profiles can
   assign a sequential behavior (network byte order or byte-swapped)
   only to the IP-ID of innermost IP header.  This is because only this
   IP-ID can possibly have a sufficiently close correlation with the MSN
   to compress it as a sequentially changing field.  Therefore, a
   compressor MUST assign either the constant zero IP-ID or the random
   IP-ID behavior to tunneling headers.

6.3.  Reconstruction and Verification

   The CRC carried within compressed headers MUST be used to verify
   decompression.  When the decompression is verified and successful,
   the decompressor updates the context with the information received in
   the current header; otherwise if the reconstructed header fails the
   CRC verification, these updates MUST NOT be performed.

   A packet for which the decompression attempt cannot be verified using
   the CRC MUST NOT be delivered to upper layers.

   Note: Decompressor implementations may attempt corrective or repair
   measures prior to performing the above actions, and the result of any
   decompression attempt MUST be verified using the CRC.

6.4.  Reordering and Segmentation

   When ROHCv2 profiles are used on a channel that may reorder packets,
   the compressor should take into account some extra considerations
   compared to when used on a channel that guarantees in-order
   delivery.ROHC Segmentation (see [I-D.ietf-rohc-rfc3095bis-framework]
   section 5.2.5) must not be used, i.e.  MRRU MUST be set to 0).

6.4.1.  Optimistic Approach

   The optimistic approach is affected by the reordering characteristics
   of the channel when operating over a reordering channel.  Compressor
   implementations should therefore adjust their optimistic approach
   strategy to match both packet loss and reordering characteristics.

   For example, the number of repetitions for each update of a non-LSB
   encoded field can be increased.  The compressor should ensure that
   each such update is repeated until it is reasonably confident that at
   least one packet containing this change has reached the decompressor
   before the first packet sent after this sequence.

6.5.  Compressed Header Chains

   Some packet types use one or more chains containing sub-header
   information.  The function of a chain is to group fields based on
   similar characteristics, such as static, dynamic or irregular fields.

   Chaining is done by appending an item for each header to the chain in
   their order of appearance in the uncompressed packet, starting from
   the fields in the outermost header.

   Static chain:

      The static chain consists of one item for each header of the chain
      of protocol headers to be compressed, starting from the outermost
      IP header.  In the formal description of the packet formats, this
      static chain item for each header type is labelled
      <protocol_name>_static.  The static chain is only used in IR
      packets.

   Dynamic chain:

      The dynamic chain consists of one item for each header of the
      chain of protocol headers to be compressed, starting from the
      outermost IP header.  In the formal description of the packet
      formats, the dynamic chain item for each header type is labelled
      <protocol_name>_dynamic.  The dynamic chain is used both in IR and
      IR-DYN packet
      format

   Irregular chain:

      The structure of the irregular chain is analogous to the structure
      of the static chain.  For each compressed packet, the irregular
      chain is appended at the specified location in the general format
      of the compressed packets as defined in Section 6.6. 6.8.  The
      irregular chain is used for all CO packets.
      The format of the irregular chain for the innermost IP header
      differs from the format of the one for the outer IP headers, since
      this header is part of the compressed base header.  What irregular
      chain items to use is determined by the argument "is_innermost",
      which is passed as an argument to the corresponding encoding
      method (ipv4 or ipv6).  The format of the irregular chain item for
      the outer IP headers is also determined using one flag for TTL/Hop
      Limit and one for TOS/TC.  These flags are defined in the format
      of some of the compressed base headers.
   RoHCv2 profiles compresses extension headers as other headers, and
   thus extension headers have a static chain, a dynamic chain and an
   irregular chain.

   Chains are defined for all headers compressed by RoHCv2 profiles,
   i.e.  RTP [RFC3550], UDP [RFC0768], UDP Lite [RFC3828], IPv4
   [RFC0791], IPv6 [RFC2460], AH [RFC4302], GRE [RFC2784][RFC2890], MINE
   [RFC2004], NULL-encrupted ESP [RFC4303], IPv6 Destination Options
   header[RFC2460], IPv6 Hop-by-hop Options header[RFC2460] and IPv6
   Routing header [RFC2460].

6.5.

6.6.  Packet Formats and Encoding Methods

   The packet formats used for are defined using the ROHC formal
   notation.  Some of the encoding methods used in the packet formats
   are defined in [I-D.ietf-rohc-formal-notation], while other methods
   are defined in this section.

6.5.1.

6.6.1.  baseheader_extension_headers

   In CO packets (see Section 6.6.4), 6.8.3), the innermost IP header can be
   combined with other header(s) (i.e.  UDP, UDP Lite, RTP) to create
   the compressed base header.  In such case, the IP header may have a
   number of extension headers between itself and the other headers.

   The base header defines some representation of these extension
   headers, to comply with the syntax of the formal notation; this
   encoding method provides this representation.  The
   baseheader_extension_headers encoding method skips over all fields of
   the extension headers of the innermost IP header, without encoding
   any of the them.  Fields in these extension headers are instead
   encoded in the irregular chain.

6.5.2.

6.6.2.  baseheader_outer_headers

   This encoding method, similarly to the baseheader_extension_headers
   encoding method above, is needed to keep the definition of the packet
   formats syntactically correct.  It describe tunneling IP headers and
   their respective extension headers (i.e. all headers located before
   the innermost IP header) for CO headers (see Section 6.6.4). 6.8.3).  The
   baseheader_outer_headers encoding method skips over all the fields of
   the extension header(s) that do not belong to the innermost IP
   header, without encoding any of them.  Changed fields in outer
   headers are instead handled by the irregular chain.

6.5.3.

6.6.3.  inferred_udp_length

   The UDP length field is inferred by the decompressor to be the size
   of the UDP payload.  This also means that the compressor MUST make
   sure that the UDP length field is consistent with the length field(s)
   of preceeding subheaders, i.e., there must not be any padding after
   the UDP payload that is covered by the IP Length.

6.5.4.

6.6.4.  inferred_ip_v4_header_checksum

   This encoding method compresses the header checksum field of the IPv4
   header.  This checksum is defined in RFC 791 [RFC0791] as follows:

      Header Checksum: 16 bits

         A checksum on the header only.  Since some header fields change
         (e.g., time to live), this is recomputed and verified at each
         point that the internet header is processed.

      The checksum algorithm is:

         The checksum field is the 16 bit one's complement of the one's
         complement sum of all 16 bit words in the header.  For purposes
         of computing the checksum, the value of the checksum field is
         zero.

   As described above, the header checksum protects individual hops from
   processing a corrupted header.  When almost all IP header information
   is compressed away, and when decompression is verified by a CRC
   computed over the original header for every compressed packet, there
   is no point in having this additional checksum; instead it can be
   recomputed at the decompressor side.

   The "inferred_ip_v4_header_checksum" encoding method thus compresses
   the IPv4 header checksum down to a size of zero bit, i.e. no bits are
   transmitted in compressed headers for this field.  Using this
   encoding method, the decompressor infers the value of this field
   using the computation above.

   The compressor MAY use the header checksum to validate the
   correctness of the header before compressing it, to avoid compressing
   a corrupted header.

6.5.5.

6.6.5.  inferred_mine_header_checksum

   This encoding method compresses the minimal encapsulation header
   checksum.  This checksum is defined in RFC 2004 [RFC2004] as follows:

      Header Checksum

         The 16-bit one's complement of the one's complement sum of all
         16-bit words in the minimal forwarding header.  For purposes of
         computing the checksum, the value of the checksum field is 0.
         The IP header and IP payload (after the minimal forwarding
         header) are not included in this checksum computation.

   The "inferred_mine_header_checksum" encoding method compresses the
   minimal encapsulation header checksum down to a size of zero bit,
   i.e. no bits are transmitted in compressed headers for this field.
   Using this encoding method, the decompressor infers the value of this
   field using the above computation.

   The motivations for inferring this checksum are similar to the ones
   explained above in Section 6.5.4. 6.6.4.

   The compressor MAY use the minimal encapsulation header checksum to
   validate the correctness of the header before compressing it, to
   avoid compressing a corrupted header.

6.5.6.

6.6.6.  inferred_ip_v4_length

   This encoding method compresses the total length field of the IPv4
   header.  The total length field of the IPv4 header is defined in RFC
   791 [RFC0791] as follows:

      Total Length: 16 bits

         Total Length is the length of the datagram, measured in octets,
         including internet header and data.  This field allows the
         length of a datagram to be up to 65,535 octets.

   The "inferred_ip_v4_length" encoding method compresses the IPv4
   header checksum down to a size of zero bit, i.e. no bits are
   transmitted in compressed headers for this field.  Using this
   encoding method, the decompressor infers the value of this field by
   counting in octets the length of the entire packet after
   decompression.

6.5.7.

6.6.7.  inferred_ip_v6_length

   This encoding method compresses the payload length field in the IPv6
   header.  This length field is defined in RFC 2460 [RFC2460] as
   follows:

      Payload Length: 16-bit unsigned integer

         Length of the IPv6 payload, i.e., the rest of the packet
         following this IPv6 header, in octets.  (Note that any
         extension headers present are considered part of the payload,
         i.e., included in the length count.)

   The "inferred_ip_v6_length" encoding method compresses the payload
   length field of the IPv6 header down to a size of zero bit, i.e. no
   bits are transmitted in compressed headers for this field.  Using
   this encoding method, the decompressor infers the value of this field
   by counting in octets the length of the entire packet after
   decompression.

6.5.8.

6.6.8.  Scaled RTP Timestamp Encoding

   The RTP timestamp (TS) usually increases by a multiple of the RTP
   Sequence Number's (SN) increase and is therefore a suitable candidate
   for scaled encoding.  The scaling factor is decided by the compressor by
   observing the increase in Timestamp compared to the RTP Sequence
   Number.  This scaling factor is labeled ts_stride in the
   definition of the profile in ROHC-FNSection 6.6.

   For the ROHC-FN Section 6.8.  The compressor
   sets the scaling factor based on the change in TS with respect to use the scaled timestamps, it MUST first
   explicitly transmit
   change in the RTP SN.

   The initial value of the scaling factor ts_stride is always set to the decompressor, using
   one of the packet types 1
   [NOTE: define what is initial?  New context with this profile?].
   When ts_stride is set to 1, scaling is not applied on the field for
   any format.

   Initially, the scaling factor is set to 1, meaning that no actual
   scaling is performed even in the scaled packet formats.  For the
   compressor to use a different scaling value, it must first explicitly
   transmit the new value of ts_stride to the decompressor, using one of
   the packet types that can carry this information.  Once the new value
   of the scaling factor is established, before using this scaled
   encoding the new scaling
   factor, the compressor must have enough confidence that the
   decompressor has successfully calculated the residue (ts_offset) of
   the scaling function for the timestamp.  This is done by sending
   unscaled timestamp values to allow the compressor decompressor to establish the
   residue based on the current ts_stride.  The compressor MAY send the
   unscaled timestamp in the same packets as the ones establishing the
   new ts_stride established. value.

   Once the compressor has gained enough confidence that both the value
   of the scaling factor and the value of the residue have been
   established in the decompressor, the compressor can start compressing
   packets using the scaled representation of the timestamp.  The
   compressor MUST NOT use the scaled timestamp encoding with the value
   of the ts_stride is set to zero. new scaling factor.

   If the compressor notices that the residue (ts_offset) value changes,
   the compressor cannot use scaled timestamp packet formats until it
   has re-established the residue as described above.

   If the decompressor receives a packet containing scaled timestamp
   bits while the ts_stride equals zero, it MUST NOT deliver the packet
   to upper layers.

   When the value of the timestamp field wraps around, the value of the
   residue of the scaling function is likely to change.  When this
   occurs, the compressor re-establishes the new residue value, e.g.
   using the unscaled representation of the field value as
   described above.

   The compressor MAY use the scaled timestamp encoding; what value it
   will use as the scaling factor is up to the compressor
   implementation, but to achive any gains from the scaling, the
   ts_stride should be set to the value of the expected incease in
   timestamp between consecutive sequence numbers.

   When scaled timestamp encoding is used for packet formats that do not
   transmit any LSB-encoded timestamp bits at all, the Section 6.5.9 6.6.10 is
   used for encoding the timestamp.

6.5.9.

6.6.9.  Timer-Based RTP Timestamp Encoding

   Text to be added.  Same encoding method as in RFC 3095, section
   4.5.4.

6.6.10.  inferred_scaled_field

   The "inferred_scaled_field" encoding method is used to encode a field
   that is defined as changing in relation to the MSN but for each
   increase is scaled by an established scaling factor.  This encoding
   method is to be used in the case when a packet format contains MSN
   bits, but does not contain any bits for the scaled field.  In this
   case, the new value for the field being scaled is calculated
   according to the following formula:

      unscaled_value = delta_msn * stride + previous_unscaled_value
   Where "delta_msn" is the difference is MSN between the previous value
   of MSN in the context and the value of the MSN decompressed from this
   packet, "previous_unscaled_value" is the value of the field being
   scaled in the context, and "stride" is the scaling value for this
   field.

   For example, when this encoding method is applied to the RTP
   timestamp in the RTP profile, the calculation above becomes:
      timestamp = delta_msn * ts_stride + previous_timestamp

6.5.10.  control_crc3

   Some

6.6.11.  control_crc3_encoding

   The "control_crc3_encoding" method provides a CRC calculated over a
   number of control fields that can be transmit by the co_common packet type fields.  The definition of each profile might not be used when decompressing this packet, and
   therefore will not be encoding method is
   the same as for the "crc" encoding method specified in section 4.11.6
   of [I-D.ietf-rohc-formal-notation], with the difference that the data
   that is covered by the included 7-bit CRC.  If such CRC is given by a concatenated list of control field has been corrupted on
   fields.

   In other words, the link between compressor and
   decompressor, the decompressor might send an ACK for this packet
   which would be interpreted by the compressor as if definition of the control fields
   included in this packet were successfully decompressed.  To avoid
   such a situation, an additional 3-bit CRC control_crc3_encoding method is included in the
   co_common packets.

   This 3-bit CRC uses
   equivalent to the same polynomial as following definition:

     control_crc_encoding(data_value, data_length)
     {
       UNCOMPRESSED {
       }

       COMPRESSED {
         control_crc3 =:=
           crc(3, 0x06, 0x07, ctrl_data_value, ctrl_data_length) [ 3 ];
       }
     }

   where the crc3 encoding method
   defined in parameter "ctrl_data_value" binds to the formal notation, but has a different coverage.  This
   CRC should be calculated over concatenated
   values of the following field, control fields, in the order that
   they are listed below:
   o  reorder_ratio, 2 bits padded by 6 MSB of zeroes
   o  ts_stride, 16 bits (if (applicable only for profiles 0x0101 and
      0x0107)
   o  msn,16 bits (not applicable for profiles 0x0101 and 0x0107)
   The "ctrl_data_length" binds to the sum of the length of the control
   field(s) that are applicable.

   A 3-bit CRC is used to validate the control fields that are updated
   by the co_common and co_repair packet types; it cannot verify the
   outcome of a decompression attempt.  The definition of this profile)

6.5.11. CRC comes
   from the fact that the decompression of a header that carries and
   updates control fields does not necessarily make use of these control
   fields, and the update to the control fields is thus not protected by
   the CRC-7 validation.

   For example, without a verification of the updates to the control
   fields, there would be a possibility that a decompression attempt
   succeeds for a co_common or for a co_repair packet for which the
   decompressor would send a positive feedback, even in the case where
   one of the control fields had been corrupted on the link between the
   compression endpoints.

6.6.12.  inferred_sequential_ip_id

   This encoding method is used when a sequential IP-ID behavior is used
   (sequential or sequential byte-swapped) and no coded IP-ID bits are
   present in the compressed header.  When these packet types are used,
   the IP-ID offset from the MSN will be constant, and therefore, the
   IP-ID will increase by the same amount as the MSN increases by
   (similar to the inferred_scaled_field encoding method).

   Therefore, the new value for the IP-ID is calculated according to the
   following formula:
      IP-ID = delta_msn + previous_IP_ID_value
   Where "delta_msn" is the difference is MSN between the previous value
   of MSN in the context and the value of the MSN decompressed from this
   packet, "previous_IP_ID_value" is the value of the IP-ID in the
   context.

   If the IP-ID behavior is random or zero, this encoding method does
   not update any fields.

6.5.12.

6.6.13.  list_csrc(cc_value)

   This encoding method describes how the list of CSRC identifiers can
   be compressed using list compression.  This list compression operates
   by establishing content for the different CSRC identifiers (items)
   and list describing the order that they appear.

   The argument to this encoding method (cc_value) is the CC field from
   the RTP header which the compressor passes to this encoding method.
   The decompressor is reuired required to bind the value of this argument to
   the number of items in the list, which will allow the decompressor to
   corectly reconstruct the CC field.

6.5.12.1.

6.6.13.1.  List Compression

   The CSRC identifiers in the uncompressed packet can be represented as
   an ordered list, whose order and presence are usually constant
   between packets.  The generic structure of such a list is as follows:

            +--------+--------+--...--+--------+
      list: | item 1 | item 2 |       | item n |
            +--------+--------+--...--+--------+

   When performing list compression on a CSRC list, each item is the
   uncompressed value of one CSRC identifier.

   The basic principles of list-based compression are the following:

      1) When a context is being initialized, a complete representation
      of the compressed list of options is transmitted.  All items that
      have any content are present in the compressed list of items sent
      by the compressor.

   Then, once the context has been initialized:

      2) When the structure of the list is unchanged no information
      about the list is sent in compressed headers.
      3) When the structure of the list changes, a compressed list is
      sent in the compressed header, including a representation of its
      structure and order.  Previously unknown items are sent
      uncompressed in the list, while previously known items are only
      represented by an index pointing to the context.

6.5.12.2.

6.6.13.2.  Table-based Item Compression

   The Table-based item compression compresses individual items sent in
   compressed lists.  The compressor assigns a unique identifier,
   "Index", to each item "Item" of a list.

   Compressor Logic

      The compressor conceptually maintains an Item Table containing all
      items, indexed using "Index".  The (Index, Item) pair is sent
      together in compressed lists until the compressor gains enough
      confidence that the decompressor has observed the mapping between
      items and their respective index.  Confidence is obtained from the
      reception of an acknowledgment from the decompressor, or by
      sending (Index, Item) pairs using the optimistic approach.  Once
      confidence is obtained, the index alone is sent in compressed
      lists to indicate the presence of the item corresponding to this
      index.

      The compressor may reassign an existing index to a new item, by
      re-establishing the mapping using the procedure described above.

   Decompressor Logic

      The decompressor conceptually maintains an Item Table that
      contains all (Index, Item) pairs received.  The Item Table is
      updated whenever an (Index, Item) pair is received and
      decompression is successfully verified using the CRC.  The
      decompressor retrieves the item from the table whenever an Index
      without an accompanying Item is received.

      If an index without an accompanying item is received and the
      decompressor does not have any context for this index, the packet
      MUST NOT be delivered to upper layers.

6.5.12.3.

6.6.13.3.  Encoding of Compressed Lists

   Each item present in a compressed list is represented by:

   o  an index into the table of items, and
   o  a presence bit indicating if a compressed representation of the
      item is present in the list.
   o  an item (if the presence bit is set)

   If the presence bit is not set, the item must already be known by the
   decompressor.

   A compressed list of items uses the following encoding:

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | Reserved  |PS |       m       |
      +---+---+---+---+---+---+---+---+
      |        XI_1, ..., XI_m        | m octets, or m * 4 bits
      /                --- --- --- ---/
      |               :    Padding    : if PS = 0 and m is odd
      +---+---+---+---+---+---+---+---+
      |                               |
      /      item_1, ..., item_n      / variable
      |                               |
      +---+---+---+---+---+---+---+---+

      Reserved: Must be set to zero.

      PS: Indicates size of XI fields:
         PS = 0 indicates 4-bit XI fields;
         PS = 1 indicates 8-bit XI fields.

      m: Number of XI item(s) in the compressed list.  Also the value of
      the cc_value argument.

      XI_1, ..., XI_m: m XI items.  Each XI represents one item in the
      list of item of the uncompressed header, in the same order as they
      appear in the uncompressed header.

         The format of an XI item is as follows:

                 +---+---+---+---+
         PS = 0: | X |   Index   |
                 +---+---+---+---+

                   0   1   2   3   4   5   6   7
                 +---+---+---+---+---+---+---+---+
         PS = 1: | X | Reserved  |     Index     |
                 +---+---+---+---+---+---+---+---+

         X: Indicates whether the item present in the list:

            X = 1 indicates that the item corresponding to the Index is
            sent in the item_1, ..., item_n list;
            X = 0 indicates that the item corresponding to the Index is
            not sent.

         Reserved: Set to zero when sending, ignored when received.

         Index: An index into the item table.  See Section 6.5.12.4 6.6.13.4

         When 4-bit XI items are used and, the XI items are placed in
         octets in the following manner:

           0   1   2   3   4   5   6   7
         +---+---+---+---+---+---+---+---+
         |     XI_k      |    XI_k + 1   |
         +---+---+---+---+---+---+---+---+
      Padding: A 4-bit padding field is present when PS = 0 and the
      number of XIs is odd.  The Padding field is set to zero when
      sending and ignored when receiving.

      Item 1, ..., item n: Each item corresponds to an XI with X = 1 in
      XI 1, ..., XI m.  Each entry in the item list is the uncompressed
      representation of one CSRC identifier.

6.5.12.4.

6.6.13.4.  Item Table Mappings

   The item table for list compression is limited to 16 different items,
   since the RTP header can only carry at most 15 simultaneous CSRC
   identifiers.  The effect of having more than 16 items will only cause
   a slight overhead to the compressor when items are swappen in/out of
   the item table.

6.5.12.5.

6.6.13.5.  Compressed Lists in Dynamic Chain

   A compressed list that is part of the dynamic chain (e.g. in IR or
   IR-DYN
   packets) must have all its list items present, i.e. all X-bits in the
   XI list MUST be set.

6.6.  Packet Formats

   ROHCv2 profiles use two different packet types:  All items previously established in the Initialization
   and Refresh (IR) packet type, and item
   table that are not present in the Compressed packet type (CO).

   Each list decompressed from this packet type defines a
   MUST also be retained in the decompressor context.

6.7.  Encoding Methods With External Parameters

   A number of packet formats: two packet
   formats are defined encoding methods in Section 6.8.3.2 have one or more
   arguments for which the IR type, and two sets base header formats
   are defined for derivation of the CO type with one additional format that parameter's value is common
   to both sets.

   When
   outside the number scope of bits available in compressed header fields exceeds the number ROHC-FN specification of bits in the value, header formats.
   This section lists the most significant field is padded encoding methods together with zeroes in its most significant bits.

   Updating Properties: all packet types carry a CRC and are context
   updating.  Packets update the entire context besides definition of
   each of their parameters.

   o  ip_dest_opt(repair_flag):

         repair_flag: This parameter must be set to the fields value that was
         used for
   which they explicitly convey information for, since the context can
   be expressed as corresponding "repair_flag" parameter of the collection
         "[profilename]_baseheader" encoding method when extracting the
         irregular chain for a compressed header; otherwise it is set to
         zero and ignored for other types of chains.

   o  ip_hop_opt(repair_flag):

         See definition of arguments for "ip_dest_opt" above.

   o  gre(repair_flag):

         See definition of arguments for "ip_dest_opt" above.

   o  ah(repair_flag):

         See definition of arguments for "ip_dest_opt" above.

   o  esp_null(next_header_value, repair_flag):

         next_header_value: Set to the reference value of each field
   together with the function established with respect to Next Header field
         located in the MSN.

6.6.1.  Initialization and Refresh Packet (IR)

   The IR packet format uses ESP trailer, usually 12 octets from the structure end of
         the ROHC IR packet as
   defined in [I-D.ietf-rohc-rfc3095bis-framework], section 5.2.2.1.

   Packet type: IR packet.  Compression of null-encrypted ESP headers should
         only be performed when the compressor has prior knowledge of
         the exact location of the next header field.

         repair_flag: This packet type communicates parameter must be set to the static part and value that was
         used for the dynamic part corresponding "repair_flag" parameter of the context.

   The ROHCv2 IR packet has
         "[profilename]_baseheader" encoding method when extracting the following format:

        0   1   2   3   4   5   6   7
       --- --- --- --- --- --- --- ---
      :        Add-CID octet          : if
         irregular chain for small CIDs a compressed header; otherwise it is set to
         zero and (CID != 0)
      +---+---+---+---+---+---+---+---+
      | 1   1   1   1   1   1   0   1 | IR type octet
      +---+---+---+---+---+---+---+---+
      :                               :
      /       0-2 octets of CID       / 1-2 octets if ignored for large CIDs
      :                               :
      +---+---+---+---+---+---+---+---+
      |            Profile            | 1 octet
      +---+---+---+---+---+---+---+---+
      |              CRC              | 1 octet
      +---+---+---+---+---+---+---+---+
      |                               |
      /         Static chain          / variable length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /         Dynamic chain         / variable length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /            Payload            / variable length
      |                               |
       - - - - - - - - - - - - - - - -

      Static chain: See Section 6.4.

      Dynamic chain: See Section 6.4.

      Payload: The payload other types of chains.

   o  ipv6(profile, is_innermost, ip_outer_flag, repair_flag)):

         profile: Set to the corresponding original packet, if any.
      The presence profile number of a payload is inferred from the packet length.

6.6.2.  IR  Packet Payload Discard (IR-PD)

   The IR-PD packet format uses profile used to
         compress this packet.

         is_innermost: This boolean flag is set to 1 when processing the structure
         innermost IP header; otherwise it is set to 0.

         repair_flag: This parameter must be set to the value that was
         used for the corresponding "repair_flag" parameter of the ROHC IR packet as
   defined in [I-D.ietf-rohc-rfc3095bis-framework], section 5.2.2.1.

   Packet type: IR-PD
      This packet type communicates
         "[profilename]_baseheader" encoding method when extracting the static part
         irregular chain for a compressed header; otherwise it is set to
         zero and ignored for other types of chains.

   o  ipv4(profile, is_innermost, ip_outer_flag, repair_flag)

         See definition of arguments for "ipv6" above.

   o  udp(profile)

         profile: Set to the dynamic part profile number of the context, but without profile used to
         compress this packet.

   o  rtp(profile, ts_stride_value, time_stride_value)
         profile: Set to the payload profile number of the original packet for
      which it carries profile used to
         compress this packet.

         ts_stride_value: This parameter is set to a user-selected value
         that is the header information.

   The ROHCv2 IR packet has expected increase in the following format:

        0   1   2   3   4   5   6   7
       --- --- --- --- --- --- --- ---
      :        Add-CID octet          : if RTP Timestamp between
         consecutive sequence numbers.  See also Section 6.6.8.

         time_stride_value: This parameter is set to a user-selected
         value that is the expected inter-arrival time between
         consecutive packets for small CIDs and (CID != 0)
      +---+---+---+---+---+---+---+---+
      | 1   1   1   1   1   1   0   0 | IR type octet
      +---+---+---+---+---+---+---+---+
      :                               :
      /       0-2 octets this flow.  See also Section 6.6.9.

   o  esp(profile)

         profile: Set to the profile number of CID       / 1-2 octets if for large CIDs
      :                               :
      +---+---+---+---+---+---+---+---+
      |            Profile            | 1 octet
      +---+---+---+---+---+---+---+---+
      |              CRC              | 1 octet
      +---+---+---+---+---+---+---+---+
      |                               |
      /         Static chain          / variable length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /         Dynamic chain         / variable length
      |                               |
       - - - - - - - - - - - - - - - -

      Static chain: the profile used to
         compress this packet.

   o  udp_lite(profile)

         profile: Set to the profile number of the profile used to
         compress this packet.

   o  rtp_baseheader(profile, ts_stride_value, time_stride_value,
      outer_ip_flag, repair_flag):

         profile: Set to the profile number of the profile used to
         compress this packet.

         ts_stride_value: This parameter is set to a user-selected value
         that is the expected increase in the RTP Timestamp between
         consecutive sequence numbers.  See also Section 6.4.

      Dynamic chain: 6.6.8.

         time_stride_value: This parameter is set to a user-selected
         value that is the expected inter-arrival time between
         consecutive packets for this flow.  See also Section 6.4.

6.6.3.  IR Dynamic Packet (IR-DYN) 6.6.9.

         outer_ip_flag: This parameter is set to 1 of one or more of a a
         number of semi-static fields in outer IP headers have changed
         compared to their reference values in the context, otherwise it
         is set to 0.  The IR-DYN packet format uses value used for this parameter is also used
         for the structure "outer_ip_flag" argument for a number of the ROHC IR-DYN packet
   as encoding
         methods defined in [I-D.ietf-rohc-rfc3095bis-framework], section 5.2.2.2.

   Packet type: IR-DYN above, when these are processing the irregular
         chain.  This packet type communicates flag may only be set to 1 either for the dynamic chains of
         "co_common" or the header(s)
      that it compresses.

   The RoHCv2 IR-DYN "co_repair" packet has formats in the following format:

        0 different
         profiles.

         repair_flag: This parameter is set to 1   2   3   4   5   6   7
       --- --- --- --- --- --- --- ---
      :         Add-CID octet         : if for small CIDs and (CID != 0)
      +---+---+---+---+---+---+---+---+
      | 1   1   1   1   1   0   0   0 | IR-DYN type octet
      +---+---+---+---+---+---+---+---+
      :                               :
      /       0-2 octets of CID       / 1-2 octets if for large CIDs
      :                               :
      +---+---+---+---+---+---+---+---+
      |            Profile            | 1 octet
      +---+---+---+---+---+---+---+---+
      |              CRC              | 1 octet
      +---+---+---+---+---+---+---+---+
      |                               |
      /         Dynamic chain         / variable length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /            Payload            / variable length
      |                               |
       - - - - - - - - - - - - - - - -

      Dynamic chain: See Section 6.4.

      Payload: The payload of the corresponding original packet, if any.
      The presence of a payload is inferred from the packet length.

6.6.4.  Compressed Packet Formats (CO)

6.6.4.1.  Design rationale for compressed base certain fields
         in extension headers or outer IP headers have changed compared
         to their reference values in the context, otherwise it is set
         to 0.  The compressed packet formats are defined as two separate sets value used for
   each profile: one set this parameter is also used for the packets where the innermost IP header
   contains
         "repair_flag" argument for a sequential IP-ID (either network byte order or byte
   swapped), and one number of encoding methods defined
         above, when these are processing the irregular chain.  This may
         only be set to 1 for the packets without sequential IP-ID
   (either random, zero, or no IP-ID).

   The design of the "co_repair" packet formats is derived from in the field behavior
   analysis found in Appendix A.

   All
         different profiles.
   o  udp_baseheader(profile, outer_ip_flag, repair_flag):

         profile: Set to the profile number of the compressed base headers transmit LSB-encoded MSN bits and profile used to
         compress this packet.

         outer_ip_flag: This parameter is set to 1 of one or more of a CRC.  In addition, each base header a
         number of semi-static fields in the sequential packet format
   set contains LSB encoded IP-ID bits.

   The following packet formats exist outer IP headers have changed
         compared to their reference values in both the sequential and random
   packet format sets:

   o  Format 1: This packet format transmits changes [Author's note:
      TBW]

   o  Format 2: This packet format transmits changes [Author's note:
      TBW]

   o  Common packet format: context, otherwise it
         is set to 0.  The common packet format can be value used
      indenpendently of for this parameter is also used
         for the type "outer_ip_flag" argument for a number of IP-ID behavior.  It should also be
      useful encoding
         methods defined above, when some of these are processing the more rarely changing fields in irregular
         chain.  This flag may only be set to 1 either for the IP
      header changes.  Since this
         "co_common" or the "co_repair" packet format modify formats in the value of different
         profiles.

         repair_flag: This parameter is set to 1 if the
      control certain fields that determine how
         in extension headers or outer IP headers have changed compared
         to their reference values in the decompressor interprets
      different compressed header format, context, otherwise it carries a 7-bit CRC is set
         to
      reduce 0.  The value used for this parameter is also used for the probability
         "repair_flag" argument for a number of context corruption. encoding methods defined
         above, when these are processing the irregular chain.  This packet can
      change most of may
         only be set to 1 for the dynamic fields "co_repair" packet formats in the IP header,
         different profiles.

   o  esp_baseheader(profile, outer_ip_flag, repair_flag):

         See definition of arguments for "udp_baseheader" above.

   o  iponly_baseheader(profile, outer_ip_flag, repair_flag):

         See definition of arguments for "udp_baseheader" above.

   o  udplite_rtp_baseheader(profile, ts_stride_value,
      time_stride_value, outer_ip_flag, repair_flag):

         See definition of arguments for "rtp_baseheader" above.

   o  udplite_baseheader(profile, outer_ip_flag, repair_flag):

         See definition of arguments for "udp_baseheader" above.

6.8.  Packet Formats

   ROHCv2 profiles use two different packet types: the Initialization
   and it uses Refresh (IR) packet type, and the Compressed packet type (CO).

   Each packet type defines a
      large set number of flags to provide information about which fields packet formats: two packet
   formats are
      present in defined for the IR type, and two sets base header formats
   are defined for the packet format.

6.6.4.2.  General CO Header Format

   The CO packets communicate irregularities type with one additional format that is common
   to both sets.

   When the number of bits available in compressed header fields exceeds
   the number of bits in the value, the most significant field is padded
   with zeroes in its most significant bits.

   Updating Properties: all packet header.  All
   CO packets types carry a CRC and can are context
   updating.  Packets update the context. entire context besides the fields for
   which they explicitly convey information for, since the context can
   be expressed as the collection of the reference value of each field
   together with the function established with respect to the MSN.

6.8.1.  Initialization and Refresh Packet (IR)

   The general IR packet format for a compressed header is uses the structure of the ROHC IR packet as follows:
   defined in [I-D.ietf-rohc-rfc3095bis-framework], section 5.2.2.1.

   Packet type: IR

      This packet type communicates the static part and the dynamic part
      of the context.

   The ROHCv2 IR packet has the following format:

        0   1   2   3   4   5   6   7
       --- --- --- --- --- --- --- ---
      :        Add-CID octet          : if for small CIDs and CID 1-15 (CID != 0)
      +---+---+---+---+---+---+---+---+
      |  first octet of base header 1   1   1   1   1   1   0   1 | (with IR type indication) octet
      +---+---+---+---+---+---+---+---+
      :                               :
      /   0, 1, or 2       0-2 octets of CID       / 1-2 octets if for large CIDs
      :                               :
      +---+---+---+---+---+---+---+---+
      |            Profile            | 1 octet
      +---+---+---+---+---+---+---+---+
      |              CRC              | 1 octet
      +---+---+---+---+---+---+---+---+
      |                               |
      /   remainder of base header         Static chain          / variable number of octets
   +---+---+---+---+---+---+---+---+
   :                               : length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /        Irregular Chain         Dynamic chain         / variable
   :                               :
    --- --- --- --- --- --- --- --- length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /            Payload            / variable length
      |                               |
       - - - - - - - - - - - - - - - -

      Static chain: See Section 6.5.

      Dynamic chain: See Section 6.5.

      Payload: The base header in the figure above is the compressed representation payload of the innermost IP header and other header(s), corresponding original packet, if any, in the
   uncompressed packet.

   Upon receiving other types any.
      The presence of packet, a payload is inferred from the decompressor will
   decompress it. packet length.

6.8.2.  IR  Packet Payload Discard (IR-PD)

   The decompressor MUST verify IR-PD packet format uses the correctness structure of the
   decompressed ROHC IR packet by CRC check.  If this verification succeeds, as
   defined in [I-D.ietf-rohc-rfc3095bis-framework], section 5.2.2.1.

   Packet type: IR-PD
      This packet type communicates the
   decompressor passes static part and the decompressed dynamic part
      of the context, but without the payload of the original packet to for
      which it carries the system's network
   layer. header information.

   The decompressor will then use this ROHCv2 IR packet as has the reference
   packet.

   The entire set following format:

        0   1   2   3   4   5   6   7
       --- --- --- --- --- --- --- ---
      :        Add-CID octet          : if for small CIDs and (CID != 0)
      +---+---+---+---+---+---+---+---+
      | 1   1   1   1   1   1   0   0 | IR type octet
      +---+---+---+---+---+---+---+---+
      :                               :
      /       0-2 octets of CID       / 1-2 octets if for large CIDs
      :                               :
      +---+---+---+---+---+---+---+---+
      |            Profile            | 1 octet
      +---+---+---+---+---+---+---+---+
      |              CRC              | 1 octet
      +---+---+---+---+---+---+---+---+
      |                               |
      /         Static chain          / variable length
      |                               |
       - - - - - - - - - - - - - - - -
      |                               |
      /         Dynamic chain         / variable length
      |                               |
       - - - - - - - - - - - - - - - -

      Static chain: See Section 6.5.

      Dynamic chain: See Section 6.5.

6.8.3.  Compressed Packet Formats (CO)

6.8.3.1.  Design rationale for compressed base headers

   The compressed packet formats are described in defined as two separate sets for
   each profile: one set for the remainder of this
   section.

   ////////////////////////////////////////////
   // Constants
   ////////////////////////////////////////////

   // packets where the innermost IP header
   contains a sequential IP-ID behavior constants
   IP_ID_BEHAVIOR_SEQUENTIAL         = 0;
   IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED = 1;
   IP_ID_BEHAVIOR_RANDOM             = 2;
   IP_ID_BEHAVIOR_ZERO               = 3;

   // UDP-lite checksum coverage behavior constants
   UDP_LITE_COVERAGE_INFERRED  = 0;
   UDP_LITE_COVERAGE_STATIC    = 1;
   UDP_LITE_COVERAGE_IRREGULAR = 2;
   UDP_LITE_COVERAGE_RESERVED  = 3;

   // Variable reordering offset
   REORDERING_NONE          = 0;
   REORDERING_QUARTER       = 1;
   REORDERING_HALF          = 2;
   REORDERING_THREEQUARTERS = 3;

   // Profile names (either network byte order or byte
   swapped), and versions
   PROFILE_RTP_0101     = 1;
   PROFILE_UDP_0102     = 2;
   PROFILE_ESP_0103     = 3;
   PROFILE_IP_0104      = 4;
   PROFILE_RTP_0107     = 7; // With UDP-LITE
   PROFILE_UDPLITE_0108 = 8; // Without RTP

   ////////////////////////////////////////////
   // Global control fields
   ////////////////////////////////////////////

   CONTROL {
     msn                 [ 16 ];
     reorder_ratio       [  2 ];
   }

   ///////////////////////////////////////////////
   // Encoding methods not specified in FN syntax:
   ///////////////////////////////////////////////

   baseheader_extension_headers   "defined in Section X.Y.Z";
   baseheader_outer_headers       "defined in Section X.Y.Z";
   inferred_udp_length            "defined in Section X.Y.Z";
   inferred_ip_v4_header_checksum "defined in Section X.Y.Z";
   inferred_mine_header_checksum  "defined in Section X.Y.Z";
   inferred_ip_v4_length          "defined in Section X.Y.Z";
   inferred_ip_v6_length          "defined one set for the packets without sequential IP-ID
   (either random, zero, or no IP-ID).

   The design of the packet formats is derived from the field behavior
   analysis found in Section X.Y.Z";
   list_csrc(cc_value)            "defined Appendix A.

   All of the compressed base headers transmit LSB-encoded MSN bits and
   a CRC.

   The following packet formats exist for all profiles defined in Section X.Y.Z";
   inferred_scaled_field          "defined this
   document, both for the sequential and random packet format sets:

   o  co_common: The common packet format is designed so that it can be
      used for chagnes to all the dynamic fields in Section X.Y.Z";
   inferred_sequential_ip_id      "defined the context, but can
      not always transmit all these fields uncompressed can be used.  It
      is therefore useful for when some of the more rarely changing
      fields in Section X.Y.Z";
   control_crc3                   "defined the headers change.  Since this packet format may modify
      the value of the control fields that determine how the
      decompressor interprets different compressed header format, it
      carries a 7-bit CRC to reduce the probability of context
      corruption.  This packet format uses a large set of flags to
      provide information about which fields are present in Section X.Y.Z";

   ////////////////////////////////////////////
   // General encoding methods
   ////////////////////////////////////////////

   reorder_ratio_choice
   {
     UNCOMPRESSED {
       ratio [ 2 ];
     }

     DEFAULT {
       ratio =:= irregular(2);
     }

     COMPRESSED none {
       ratio [ 2 ];
       ENFORCE(ratio.UVALUE == REORDERING_NONE);
     }

     COMPRESSED quarter {
       ratio [ 2 ];
       ENFORCE(ratio.UVALUE == REORDERING_QUARTER);
     }

     COMPRESSED half {
       ratio [ 2 ];
       ENFORCE(ratio.UVALUE == REORDERING_HALF);
     }

     COMPRESSED three_quarters {
       ratio [ 2 ];
       ENFORCE(ratio.UVALUE == REORDERING_THREEQUARTERS);
     }
   }

   static_or_irreg(flag, width)
   {
     UNCOMPRESSED {
       field [ width ];
     }

     COMPRESSED irreg_enc {
       field =:= irregular(width) [ width ];
       ENFORCE(flag == 1);
     }

     COMPRESSED static_enc {
       field =:= static [ 0 ];
       ENFORCE(flag == 0);
     }
   }

   optional32(flag)
   {
     UNCOMPRESSED {
       item [ 0, 32 ];
     }

     COMPRESSED the packet
      format and can therefore be of very varied size.

   o  co_repair: This format is very similar to the co_common format
      described above.  The difference is that this packet is intended
      to be used when context damage has been assumed, and therefore
      changing fields are transmit uncompressed when present {
       item =:= irregular(32) [ 32 ];
       ENFORCE(flag == 1);
     }

     COMPRESSED not_present {
       item =:= compressed_value(0, 0) [ 0 ];
       ENFORCE(flag == 0);
     }
   }

   // Self-describing variable length encoding
   sdvl(field_width)
   {
     UNCOMPRESSED {
       field [ field_width ];
     }

     COMPRESSED lsb7 {
       discriminator =:= '0' [ 1 ];
       field =:= lsb(7, 63)  [ 7 ];
     }
     COMPRESSED lsb14 {
       discriminator =:= '10'   [ 2 ];
       field =:= lsb(14, 16383) [ 14 ];
     }

     COMPRESSED lsb21 {
       discriminator =:= '110'  [ 3 ];
       field =:= lsb(21, 65535) [ 21 ];
     }

     COMPRESSED lsb29 {
       discriminator =:= '110'  [ 3 ];
       field =:= lsb(29, 65535) [ 29 ];
     }
   }

   optional_stride(flag, value)
   {
     UNCOMPRESSED {
       field [ 32 ];
     }

     COMPRESSED present {
       field =:= sdvl(32);
       ENFORCE(flag == 1);
     }

     COMPRESSED not_present {
       field =:= static;
       ENFORCE(flag == 0);
     }
   }

   optional_scaled_timestamp(tss_flag, tsc_flag)
   {
     UNCOMPRESSED { in this
      format.  This format also contains some options to transmit semi-
      static fields from extension headers which cannot be transmit with
      the co_common format.  This packet format should be considered a
      replacement for the IR-DYN packet format which is not defined for
      the profiles defined in this document.

   o  pt_0_crc3: This packet format only transmit the MSN, and can
      therefore only be used to update the MSN and fields that are
      derived from the MSN, such as IP-ID and the RTP Timestamp (where
      applicable).  This packet format is equivalent to the UO-0 packet
      format in [RFC3095]

   o  pt_0_crc7: This packet has the same properties as pt_0_crc3, but
      is instead protected by a 7-bit CRC and contains a larger amount
      of LSB-encoded MSN bits.  This format is intended to be used for
      the compressor to transmit from IC state to FC state (see
      Section 5.3.1 or it can be used on ROHC channels that expect a
      high amount of reordering.

   The following packet formats exist exclusively for profiles 0x101 and
   0x107.

   o  pt_1_rnd: This format is a replacement for the UO-1 packet format
      in [RFC3095] and can be used to transmit changes in the MSN, RTP
      Marker bit and it can update the RTP timestamp [ 32 ];
     }

     COMPRESSED present { using scaled
      timestamp =:= sdvl(32);
       ENFORCE((tss_flag == 0) && (tsc_flag == 1));
     }

     COMPRESSED not_present {
       ENFORCE(((tss_flag == 1) && (tsc_flag == 0)) ||
               ((tss_flag == 0) && (tsc_flag == 0)));
     }
   }

   optional_unscaled_timestamp(tss_flag, tsc_flag)
   {
     UNCOMPRESSED { encoding.

   o  pt_1_seq_id: This format is a replacement for the UO-1-ID packet
      format in [RFC3095] and can be used to transmit changes in the MSN
      and IP-ID.

   o  pt_1_seq_ts: This format is a replacement for the UO-1-TS packet
      format in [RFC3095] and can be used to transmit changes in the
      MSN, RTP Marker bit and can update the RTP Timestamp using scaled
      timestamp [ 32 ];
     }

     COMPRESSED present { encoding.

   o  pt_2_rnd: This format is a replacement for the UOR-2 packet format
      in [RFC3095] and can be used to transmit changes in the MSN, RTP
      Marker bit and the RTP Timestamp, and is protected by a 7-bit CRC.

   o  pt_2_seq_id: This format is a replacement for the UO-2-ID packet
      format in [RFC3095] and can be used to transmit changes in the MSN
      and IP-ID.  This format is also protected by a 7-bit CRC.

   o  pt_2_seq_ts: This format is a replacement for the UO-2-TS packet
      format in [RFC3095] and can be used to transmit changes in the
      MSN, RTP Marker bit and can update the RTP Timestamp using scaled
      timestamp =:= sdvl(32);
       ENFORCE(((tss_flag == 1) && (tsc_flag == 0)) ||
               ((tss_flag == 0) && (tsc_flag == 0)));
     }

     COMPRESSED not_present {
       ENFORCE((tss_flag == 0) && (tsc_flag == 1));
     }
   }

   lsb_7_or_31
   {
     UNCOMPRESSED {
       item [ 32 ];
     }

     COMPRESSED lsb_7 {
       discriminator =:= '0'       [ 1 ];
       item          =:= lsb(7, 8) [ 7 ];
     }

     COMPRESSED lsb_31 {
       discriminator =:= '1'          [ encoding.  This format is also protected by a 7-bit CRC.

   o  pt_2_seq_both: This format is replaces the UOR-2-ID extension 1 ];
       item          =:= lsb(31, 256) [ 31 ];
     }
   }

   opt_lsb_7_or_31(flag)
   {
     UNCOMPRESSED {
       item [ 0, 32 ];
     }

     COMPRESSED present {
       item =:= lsb_7_or_31 [ 8, 32 ];
       ENFORCE(flag == 1);
     }

     COMPRESSED not_present {
       item =:= compressed_value(0, 0) [ 0 ];
       ENFORCE(flag == 0);
     }
   }

   crc3(data_value, data_length)
   {
     UNCOMPRESSED {
     }

     COMPRESSED {
       crc_value =:=
         crc(3, 0x06, 0x07, data_value, data_length) [ 3 ];
     }
   }

   crc7(data_value, data_length)
   {
     UNCOMPRESSED {
     }

     COMPRESSED {
       crc_value =:=
         crc(7, 0x79, 0x7f, data_value, data_length) [ 7 ];
     }
   }

   optional_pt(flag)
   {
     UNCOMPRESSED {
       payload_type [ 7 ];
     }

     COMPRESSED not_present {
       payload_type =:= static [ 0 ];
       ENFORCE(flag == 0);
     }

     COMPRESSED present {
       reserved     =:= compressed_value(1, 0) [ 1 ];
       payload_type =:= irregular(7)           [ 7 ];
       ENFORCE(flag == 1);
     }
   }

   csrc_list_presence(presence, cc_value)
   {
     UNCOMPRESSED {
       csrc_list;
     }

     COMPRESSED no_list {
       csrc_list =:= static [ 0 ];
       ENFORCE(presence == 0);
     }

     COMPRESSED list_present {
       csrc_list =:= list_csrc(cc_value) [ VARIABLE ];
       ENFORCE(presence == 1);
     }
   }

   // Variable reordering offset used for MSN
   msn_lsb(k)
   {
     UNCOMPRESSED {
       master [ 16 ];
     }

     COMPRESSED none {
       master =:= lsb(k, -1);
       ENFORCE(reorder_ratio.UVALUE == REORDERING_NONE);
     }

     COMPRESSED quarter {
       master =:= lsb(k, ((2^k) / 4) - 1);
       ENFORCE(reorder_ratio.UVALUE == REORDERING_QUARTER);
     }

     COMPRESSED half {
       master =:= lsb(k, ((2^k) / 2) - 1);
       ENFORCE(reorder_ratio.UVALUE == REORDERING_HALF);
     }

     COMPRESSED threequarters {
       master =:= lsb(k, (((2^k) * 3) / 4) - 1);
       ENFORCE(reorder_ratio.UVALUE == REORDERING_THREEQUARTERS);
     }
   }

   // Encoding method for updating a scaled field
      format in [RFC3095] and its associated
   // control fields. Should be used can carry changes in both when the value RTP
      Timestamp and IP-ID in addition to the MSN and Marker bit.

   The following packet formats exist exclusively for profiles 0x102,
   0x103, 0x104 and 0x108.

   o  pt_1_seq_id: This format is scaled
   // or unscaled a replacement for the UO-1-ID packet
      format in [RFC3095] and can be used to transmit changes in the MSN
      and IP-ID.

   o  pt_2_rnd: This format is a replacement for the UOR-2 packet format
      in [RFC3095] and can be used to transmit changes in the MSN and is
      protected by a 7-bit CRC.

   o  pt_2_seq_id: This format is a replacement for the UO-2-ID packet
      format in [RFC3095] and can be used to transmit changes in the MSN
      and IP-ID.  This format is also protected by a 7-bit CRC.

6.8.3.2.  General CO Header Format

   The CO packets communicate irregularities in the packet header.  All
   CO packets carry a CRC and can update the context.

   The general format for a compressed format.
   field_scaling(stride_value, scaled_value, unscaled_value)
   {
     UNCOMPRESSED {
       residue_field [ 32 ];
     }

     COMPRESSED no_scaling {
       ENFORCE(stride_value == 0);
       ENFORCE(residue_field.UVALUE == unscaled_value);
       ENFORCE(scaled_value == 0);
     }

     COMPRESSED scaling_used {
       ENFORCE(stride_value != 0);
       ENFORCE(residue_field.UVALUE == (unscaled_value % stride_value));
       ENFORCE(unscaled_value ==
               scaled_value * stride_value + residue_field.UVALUE);
     }
   }

   ////////////////////////////////////////////
   // IPv6 Destination options header
   ////////////////////////////////////////////

   ip_dest_opt
   {
     UNCOMPRESSED {
       next_header [ 8 ];
       length      [ 8 ];
       value       [ VARIABLE ];
     }

     DEFAULT {
       length      =:= static;
       next_header =:= static;
       value       =:= static;
     }

     COMPRESSED dest_opt_static {
       next_header =:= irregular(8) [ 8 ];
       length      =:= irregular(8) [ 8 ];
     }

     COMPRESSED dest_opt_dynamic {
       value =:= irregular(length.UVALUE * 64 + 48) [ VARIABLE ];
     }
   }

   ////////////////////////////////////////////
   // IPv6 Hop-by-Hop options header
   ////////////////////////////////////////////
   ip_hop_opt
   {
     UNCOMPRESSED {
       next_header [ 8 ];
       length      [ 8 ];
       value       [ VARIABLE ];
     }

     DEFAULT {
       length      =:= static;
       next_header =:= static;
       value       =:= static;
     }

     COMPRESSED hop_opt_static {
       next_header =:= irregular(8) [ 8 ];
       length      =:= irregular(8) [ 8 ];
     }

     COMPRESSED hop_opt_dynamic {
       value =:= irregular(length.UVALUE*64+48) [ VARIABLE ];
     }
   }

   ////////////////////////////////////////////
   // IPv6 Routing header
   ////////////////////////////////////////////

   ip_rout_opt
   {
     UNCOMPRESSED {
       next_header [ 8 ];
       length      [ 8 ];
       value       [ VARIABLE ];
     }

     DEFAULT {
       length      =:= static;
       next_header =:= static;
       value       =:= static;
     }

     COMPRESSED rout_opt_static {
       next_header =:= irregular(8)                   [ 8 ];
       length      =:= irregular(8)                   [ 8 ];
       value       =:= irregular(length.UVALUE*64+48) [ VARIABLE ];
     }
     COMPRESSED rout_opt_dynamic {
     }
   }

   ////////////////////////////////////////////
   // GRE Header
   ////////////////////////////////////////////

   optional_checksum(flag_value)
   {
     UNCOMPRESSED {
       value     [ 0, 16 ];
       reserved1 [ 0, 16 ];
     }

     COMPRESSED cs_present {
       value     =:= irregular(16)             [ 16 ];
       reserved1 =:= uncompressed_value(16, 0) [ 0 ];
       ENFORCE(flag_value == 1);
     }

     COMPRESSED not_present {
       value     =:= compressed_value(0, 0) [ 0 ];
       reserved1 =:= compressed_value(0, 0) [ is as follows:
     0 ];
       ENFORCE(flag_value == 0);
     }
   }

   gre_proto
   {
     UNCOMPRESSED {
       protocol [ 16 ];
     }

     COMPRESSED ether_v4 {
       discriminator =:= compressed_value(1, 0) [ 1 ];
       protocol      =:= uncompressed_value(16, 0x0800);
     }

     COMPRESSED ether_v6 {
       discriminator =:= compressed_value(1, 1) [ 1 ];
       protocol      =:= uncompressed_value(16, 0x86DD);
     }
   }

   gre
   {
     UNCOMPRESSED {
       c_flag                                 [ 1 ];
       r_flag    =:= uncompressed_value(1, 0) [ 1 ];
       k_flag                                 [ 1 ];
       s_flag                                 [   1 ];
       reserved0 =:= uncompressed_value(9, 0) [ 9 ];
       version   =:= uncompressed_value(3, 0) [   2   3 ];
       protocol                               [ 16 ];
       checksum_and_res                       [ 0, 32 ];
       key                                    [ 0, 32 ];
       sequence_number                        [ 0, 32 ];
     }

     DEFAULT {
       c_flag           =:= static;
       k_flag           =:= static;
       s_flag           =:= static;
       protocol         =:= static;
       key              =:= static;
       sequence_number  =:= static;
     }

     COMPRESSED gre_static {
       protocol =:= gre_proto                 [ 1 ];
       c_flag   =:= irregular(1)              [ 1 ];
       k_flag   =:= irregular(1)              [ 1 ];
       s_flag   =:= irregular(1)              [ 1 ];
       padding  =:= compressed_value(4, 0)    [   4 ];
       key      =:= optional32(k_flag.UVALUE) [ 0, 32 ];
     }

     COMPRESSED gre_dynamic {
       checksum_and_res =:=
         optional_checksum(c_flag.UVALUE)             [ 0, 16 ];
       sequence_number  =:= optional32(s_flag.UVALUE) [ 0, 32 ];
     }

     COMPRESSED gre_irregular {
       checksum_and_res =:=
         optional_checksum(c_flag.UVALUE) [ 0, 16 ];
       sequence_number  =:=
         opt_lsb_7_or_31(s_flag.UVALUE)   [ 0, 8, 32 ];
     }
   }

   /////////////////////////////////////////////
   // MINE header
   /////////////////////////////////////////////
   mine
   {
     UNCOMPRESSED {
       next_header [ 8 ];
       s_bit       [ 1 ];
       res_bits    [ 7 ];
       checksum    [ 16 ];
       orig_dest   [ 32 ];
       orig_src    [ 0, 32 ];
     }

     DEFAULT {
       next_header =:= static;
       s_bit       =:= static;
       res_bits    =:= static;
       checksum    =:= inferred_mine_header_checksum;
       orig_dest   =:= static;
       orig_src    =:= static;
     }

     COMPRESSED mine_static {
       next_header =:= irregular(8)             [ 8 ];
       s_bit       =:= irregular(1)             [ 1 ];
       // Reserved are included - no benefit in removing them
       res_bits    =:= irregular(7)             [   5   6   7 ];
       orig_dest   =:= irregular(32)            [ 32 ];
       orig_src    =:= optional32(s_bit.UVALUE) [
    --- --- --- --- --- --- --- ---
   :         Add-CID octet         : if for small CIDs and CID 1-15
   +---+---+---+---+---+---+---+---+
   |  first octet of base header   | (with type indication)
   +---+---+---+---+---+---+---+---+
   :                               :
   /   0, 32 ];
     }

     COMPRESSED mine_dynamic {
     }
   }

   /////////////////////////////////////////////
   // Authentication Header (AH)
   /////////////////////////////////////////////

   ah
   {
     UNCOMPRESSED {
       next_header     [ 8 ];
       length          [ 8 ];
       res_bits        [ 16 ];
       spi             [ 32 ];
       sequence_number [ 32 ];
       auth_data       [ VARIABLE ];
     }
     DEFAULT {
       next_header     =:= static;
       length          =:= static;
       res_bits        =:= static;
       spi             =:= static;
       sequence_number =:= static;
     }

     COMPRESSED ah_static {
       next_header =:= irregular(8)  [ 8 ];
       length      =:= irregular(8)  [ 8 ];
       spi         =:= irregular(32) [ 32 ];
     }

     COMPRESSED ah_dynamic {
       res_bits        =:= irregular(16) [ 16 ];
       sequence_number =:= irregular(32) [ 32 ];
       auth_data       =:=
         irregular(length.UVALUE*32-32)  [ VARIABLE ];
     }

     COMPRESSED ah_irregular {
       sequence_number =:= lsb_7_or_31  [ 8, 32 ];
       auth_data       =:=
         irregular(length.UVALUE*32-32) [ VARIABLE ];
     }
   }

   /////////////////////////////////////////////
   // ESP 1, or 2 octets of CID    / 1-2 octets if large CIDs
   :                               :
   +---+---+---+---+---+---+---+---+
   /   remainder of base header    / variable number of octets
   +---+---+---+---+---+---+---+---+
   :                               :
   /        Irregular Chain        / variable
   :                               :
    --- --- --- --- --- --- --- ---

   The base header (NULL encrypted)
   /////////////////////////////////////////////

   // Since the "next header" field is located in the packet trailer
   // and ROHC-FN requires all UNCOMPRESSED fields to be contiguous,
   // figure above is the values compressed representation
   of the next innermost IP header field is passed as a parameter.
   // To avoid forcing and other header(s), if any, in the decompression to access
   uncompressed packet.

   Upon receiving other types of packet, the trailer part decompressor will
   decompress it.  The decompressor MUST verify the correctness of
   // the packet,
   decompressed packet by CRC check.  If this verification succeeds, the next header is istead handled with a control field
   esp_null(next_header_value)
   {
     UNCOMPRESSED {
       spi             [ 32 ];
       sequence_number [ 32 ];
     }

     CONTROL {
       nh_field [ 8
   decompressor passes the decompressed packet to the system's network
   layer.  The decompressor will then use this packet as the reference
   packet.

   The entire set of base headers are defined using the ROHC Formal
   notation [I-D.ietf-rohc-formal-notation] in the remainder of this
   section.

// TODO:
// - PT_0/PT_1 packets? Use "tbc-optimized" or "msn-optimized"

////////////////////////////////////////////
// Constants
////////////////////////////////////////////

// IP-ID behavior constants
IP_ID_BEHAVIOR_SEQUENTIAL         = 0;
IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED = 1;
IP_ID_BEHAVIOR_RANDOM             = 2;
IP_ID_BEHAVIOR_ZERO               = 3;

// UDP-lite checksum coverage behavior constants

UDP_LITE_COVERAGE_INFERRED  = 0;
UDP_LITE_COVERAGE_STATIC    = 1;
UDP_LITE_COVERAGE_IRREGULAR = 2;
UDP_LITE_COVERAGE_RESERVED  = 3;

// Variable reordering offset
REORDERING_NONE          = 0;
REORDERING_QUARTER       = 1;
REORDERING_HALF          = 2;
REORDERING_THREEQUARTERS = 3;

// Profile names and versions
PROFILE_RTP_0101     = 0x0101;
PROFILE_UDP_0102     = 0x0102;
PROFILE_ESP_0103     = 0x0103;
PROFILE_IP_0104      = 0x0104;
PROFILE_RTP_0107     = 0x0107; // With UDP-LITE
PROFILE_UDPLITE_0108 = 0x0108; // Without RTP

////////////////////////////////////////////
// Global control fields
////////////////////////////////////////////

CONTROL {
  msn                 [ 16 ];
  reorder_ratio       [  2 ];
}
     DEFAULT

///////////////////////////////////////////////
// Encoding methods not specified in FN syntax:
///////////////////////////////////////////////

baseheader_extension_headers       "defined in Section X.Y.Z";
baseheader_outer_headers           "defined in Section X.Y.Z";
inferred_udp_length                "defined in Section X.Y.Z";
inferred_ip_v4_header_checksum     "defined in Section X.Y.Z";
inferred_mine_header_checksum      "defined in Section X.Y.Z";
inferred_ip_v4_length              "defined in Section X.Y.Z";
inferred_ip_v6_length              "defined in Section X.Y.Z";
list_csrc(cc_value)                "defined in Section X.Y.Z";
inferred_scaled_field              "defined in Section X.Y.Z";
inferred_sequential_ip_id          "defined in Section X.Y.Z";
control_crc3_encoding              "defined in Section X.Y.Z";
timer_based_lsb(time_stride, k, p) "defined in Section X.Y.Z";

////////////////////////////////////////////
// General encoding methods
////////////////////////////////////////////

reorder_choice
{
       spi             =:= static;
       sequence_number =:= static;
       nh_field        =:= static;
     }

     COMPRESSED esp_static
  UNCOMPRESSED {
       nh_field =:= compressed_value(8, next_header_value)
    ratio [ 8 2 ];
       spi
  }

  DEFAULT {
    ratio =:= irregular(32)                          [ 32 ]; irregular(2);
  }

  COMPRESSED esp_dynamic none {
       sequence_number =:= irregular(32)
    ENFORCE(ratio.UVALUE == REORDERING_NONE);
    ratio [ 32 2 ];
  }

  COMPRESSED esp_irregular quarter {
       sequence_number =:= lsb_7_or_31
    ENFORCE(ratio.UVALUE == REORDERING_QUARTER);
    ratio [ 8, 32 2 ];
  }

  COMPRESSED half {
    ENFORCE(ratio.UVALUE == REORDERING_HALF);
    ratio [ 2 ];
  }

   /////////////////////////////////////////////
   // IPv6 Header
   /////////////////////////////////////////////

   fl_enc

  COMPRESSED three_quarters {
    ENFORCE(ratio.UVALUE == REORDERING_THREEQUARTERS);
    ratio [ 2 ];
  }
}

static_or_irreg(flag, width)
{
  UNCOMPRESSED {
       flow_label
    field [ 20 width ];
  }

  COMPRESSED fl_zero irreg_enc {
       discriminator
    ENFORCE(flag == 1);
    field =:= '0' irregular(width) [ 1 width ];
       flow_label
  }

  COMPRESSED static_enc {
    ENFORCE(flag == 0);
    field =:= uncompressed_value(20, 0) static [ 0 ];
       reserved      =:= '0000'
  }
}

optional_32(flag)
{
  UNCOMPRESSED {
    item [ 4 0, 32 ];
  }

  COMPRESSED fl_non_zero present {
       discriminator
    ENFORCE(flag == 1);
    item =:= '1' irregular(32) [ 1 32 ];
       flow_label
  }

  COMPRESSED not_present {
    ENFORCE(flag == 0);
    item =:= irregular(20) compressed_value(0, 0) [ 20 0 ];
  }
}

   // The is_innermost flag should be true if this is the innermost
   // IP header to be compressed.
   // If extracting the irregular chain for an compressed packet,
   // the TTL&TOS arguments must have the same value as it had when
   // processing co_baseheader. If extracting any other chain
   // items, this argument is not used.

   ipv6(profile, is_innermost,
        ttl_irregular_chain_flag, tos_irregular_chain_flag)

sdvl_or_static(flag)
{
  UNCOMPRESSED {
       version
    field [ 32 ];
  }

  COMPRESSED present_7bit {
    ENFORCE(flag == 1);
    ENFORCE(field.UVALUE < 2^7);
    ENFORCE(field.CVALUE == field.UVALUE);
    discriminator =:= uncompressed_value(4, 6) '0' [ 4 1 ];
       tos_tc
    field                 [ 8 7 ];
       flow_label
  }

  COMPRESSED present_14bit {
    ENFORCE(flag == 1);
    ENFORCE(field.UVALUE < 2^14);
    ENFORCE(field.CVALUE == field.UVALUE);
    discriminator =:= '10'   [ 20 2 ];
       payload_length
    field                    [ 16 14 ];
       next_header
  }

  COMPRESSED present_21bit {
    ENFORCE(flag == 1);
    ENFORCE(field.UVALUE < 2^21);
    ENFORCE(field.CVALUE == field.UVALUE);
    discriminator =:= '110'  [ 8 3 ];
       ttl_hopl
    field                    [ 8 21 ];
       src_addr
  }

  COMPRESSED present_28bit {
    ENFORCE(flag == 1);
    ENFORCE(field.UVALUE < 2^28);
    ENFORCE(field.CVALUE == field.UVALUE);
    discriminator =:= '1110'  [ 128 4 ];
       dst_addr
    field                     [ 128 28 ];
  }

     DEFAULT

  COMPRESSED present_32bit {
       tos_tc         =:= static;
       flow_label     =:= static;
       payload_length =:= inferred_ip_v6_length;
       next_header    =:= static;
       ttl_hopl
    ENFORCE(flag == 1);
    ENFORCE(field.CVALUE == field.UVALUE);
    discriminator =:= static;
       src_addr       =:= static;
       dst_addr       =:= static;
     }

     COMPRESSED ipv6_static {
       version_flag =:= '1'            [ 1 ];
       reserved     =:= '00'           [ 2 ];
       flow_label   =:= fl_enc         [ 5, 21 ];
       next_header  =:= irregular(8) '11111111'  [ 8 ];
       src_addr     =:= irregular(128) [ 128 ];
       dst_addr     =:= irregular(128)
    field                         [ 128 32 ];
  }

  COMPRESSED ipv6_endpoint_dynamic not_present {
       tos_tc        =:= irregular(8)           [ 8 ];
       ttl_hopl      =:= irregular(8)           [ 8 ];
       reserved      =:= compressed_value(6, 0) [ 6 ];
       reorder_ratio
    ENFORCE(flag == 0);
    field =:= reorder_choice static;
  }
}

lsb_7_or_31
{
  UNCOMPRESSED {
    item [ 2 32 ];
       ENFORCE((is_innermost == true) &&
               (profile == PROFILE_IP_0104));
  }

  COMPRESSED ipv6_regular_dynamic lsb_7 {
       tos_tc
    discriminator =:= irregular(8) '0'                       [ 8 1 ];
       ttl_hopl
    item          =:= irregular(8) lsb(7, ((2^7) / 4) - 1)   [ 8 7 ];
       ENFORCE((is_innermost == false) ||
               (profile != PROFILE_IP_0104));
  }

  COMPRESSED ipv6_outer_irregular lsb_31 {
       tos_tc
    discriminator =:=
           static_or_irreg(tos_irregular_chain_flag) '1'                       [ 0, 8 1 ];
       ttl_hopl
    item          =:=
           static_or_irreg(ttl_irregular_chain_flag) lsb(31, ((2^31) / 4) - 1) [ 0, 8 31 ];
       ENFORCE(is_innermost == false);
     }

     COMPRESSED ipv6_innermost_irregular {
       ENFORCE(is_innermost == true);
  }
}

   /////////////////////////////////////////////
   // IPv4 Header
   /////////////////////////////////////////////

   ip_id_enc_dyn(behavior)

crc3(data_value, data_length)
{
  UNCOMPRESSED {
       ip_id [ 16 ];
  }

  COMPRESSED ip_id_seq {
       ip_id
    crc_value =:= irregular(16) crc(3, 0x06, 0x07, data_value, data_length) [ 16 3 ];
       ENFORCE((behavior == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED) ||
               (behavior == IP_ID_BEHAVIOR_RANDOM));
  }
}

crc7(data_value, data_length)

{
  UNCOMPRESSED {
  }

  COMPRESSED ip_id_zero {
       ip_id
    crc_value =:= uncompressed_value(16, 0) crc(7, 0x79, 0x7f, data_value, data_length) [ 0 7 ];
       ENFORCE(behavior == IP_ID_BEHAVIOR_ZERO);
  }
}

   ip_id_enc_irreg(behavior)

// Encoding method for updating a scaled field and its associated
// control fields. Should be used both when the value is scaled
// or unscaled in a compressed format.
field_scaling(stride_value, scaled_value, unscaled_value)
{
  UNCOMPRESSED {
       ip_id
    residue_field [ 16 32 ];
  }

  COMPRESSED ip_id_seq no_scaling {
       ENFORCE(behavior
    ENFORCE(stride_value == IP_ID_BEHAVIOR_SEQUENTIAL);
     }

     COMPRESSED ip_id_seq_swapped {
       ENFORCE(behavior 0);
    ENFORCE(residue_field.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED); unscaled_value);
    ENFORCE(scaled_value == 0);
  }

  COMPRESSED ip_id_rand scaling_used {
       ip_id =:= irregular(16) [ 16 ];
       ENFORCE(behavior
    ENFORCE(stride_value != 0);
    ENFORCE(residue_field.UVALUE == IP_ID_BEHAVIOR_RANDOM);
     }

     COMPRESSED ip_id_zero {
       ip_id =:= uncompressed_value(16, 0) [ 0 ];
       ENFORCE(behavior (unscaled_value % stride_value));
    ENFORCE(unscaled_value == IP_ID_BEHAVIOR_ZERO);
            scaled_value * stride_value + residue_field.UVALUE);
  }
}

   ip_id_behavior_choice

////////////////////////////////////////////
// IPv6 Destination options header
////////////////////////////////////////////

ip_dest_opt(repair_flag)
{
  UNCOMPRESSED {
       behavior
    next_header [ 2 8 ];
    length      [ 8 ];
    value       [ length.UVALUE * 64 + 48 ];
  }

  DEFAULT {
       behavior
    length      =:= irregular(2); static;
    next_header =:= static;
    value       =:= static;
  }

  COMPRESSED sequential dest_opt_static {
       behavior
    next_header =:= irregular(8) [ 2 8 ];
    length      =:= irregular(8) [ 8 ];
       ENFORCE(behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL);
  }

  COMPRESSED sequential_swapped dest_opt_dynamic {
       behavior
    value =:=
      irregular(length.UVALUE * 64 + 48) [ 2 length.UVALUE * 64 + 48 ];
       ENFORCE(behavior.UVALUE ==
               IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED);
  }

  COMPRESSED random dest_opt_irregular {
       behavior [ 2 ];
       ENFORCE(behavior.UVALUE
    ENFORCE(repair_flag == IP_ID_BEHAVIOR_RANDOM); 0);
  }

  COMPRESSED zero dest_opt_repair_irregular {
       behavior
    ENFORCE(repair_flag == 1);
    value =:=
      irregular(length.UVALUE * 64 + 48) [ 2 length.UVALUE * 64 + 48 ];
       ENFORCE(behavior.UVALUE == IP_ID_BEHAVIOR_ZERO);
  }
}

////////////////////////////////////////////
// The is_innermost flag should be true if this is the innermost
   // IP IPv6 Hop-by-Hop options header to be compressed.

   // If extracting the irregular chain for an compressed packet,
   // the TTL&TOS arguments must have the same value as it had when
   // processing co_baseheader. If extracting any other chain
   // items, this argument is not used.
   ipv4(profile, is_innermost,
        ttl_irregular_chain_flag, tos_irregular_chain_flag)
////////////////////////////////////////////

ip_hop_opt(repair_flag)
{
  UNCOMPRESSED {
       version        =:= uncompressed_value(4, 4)  [ 4 ];
       hdr_length     =:= uncompressed_value(4, 5)  [ 4 ];
       tos_tc
    next_header [ 8 ];
    length      [ 16 8 ];
       ip_id
    value       [ 16 length.UVALUE * 64 + 48 ];
       rf
  }

  DEFAULT {
    length      =:= uncompressed_value(1, 0)  [ 1 ];
       df                                           [ 1 ];
       mf static;
    next_header =:= uncompressed_value(1, 0)  [ 1 ];
       frag_offset static;
    value       =:= uncompressed_value(13, 0) [ 13 ];
       ttl_hopl static;
  }

  COMPRESSED hop_opt_static {
    next_header =:= irregular(8) [ 8 ];
       protocol
    length      =:= irregular(8) [ 8 ];
       checksum
  }

  COMPRESSED hop_opt_dynamic {
    value =:=
      irregular(length.UVALUE*64+48) [ 16 length.UVALUE * 64 + 48 ];
       src_addr                                     [ 32 ];
       dst_addr
  }

  COMPRESSED hop_opt_irregular {
    ENFORCE(repair_flag == 0);
  }

  COMPRESSED hop_opt_repair_irregular {
    ENFORCE(repair_flag == 1);
    value =:=
      irregular(length.UVALUE * 64 + 48) [ 32 length.UVALUE * 64 + 48 ];
  }

     CONTROL
}

////////////////////////////////////////////
// IPv6 Routing header
////////////////////////////////////////////

ip_rout_opt
{
       ip_id_behavior
  UNCOMPRESSED {
    next_header [ 2 8 ];
    length      [ 8 ];
    value       [ length.UVALUE * 64 + 48 ];
  }

  DEFAULT {
       tos_tc         =:= static;
    length      =:= inferred_ip_v4_length;
       df             =:= static;
       ttl_hopl       =:= static;
       protocol       =:= static;
       checksum       =:= inferred_ip_v4_header_checksum;
       src_addr       =:= static;
       dst_addr
    next_header =:= static;
       ip_id_behavior
    value       =:= static;
  }

  COMPRESSED ipv4_static rout_opt_static {
       version_flag =:= '0'           [ 1 ];
       reserved
    next_header =:= '0000000' irregular(8)                   [ 7 8 ];
       protocol
    length      =:= irregular(8)                   [ 8 ];
       src_addr
    value       =:= irregular(32)
      irregular(length.UVALUE*64+48) [ length.UVALUE * 64 + 48 ];
  }

  COMPRESSED rout_opt_dynamic {
  }

  COMPRESSED rout_opt_irregular {
  }
}

////////////////////////////////////////////
// GRE Header

////////////////////////////////////////////

optional_lsb_7_or_31(flag)
{
  UNCOMPRESSED {
    item [ 0, 32 ];
       dst_addr
  }

  COMPRESSED present {
    ENFORCE(flag == 1);
    item =:= irregular(32) lsb_7_or_31 [ 8, 32 ];
  }

  COMPRESSED ipv4_endpoint_dynamic not_present {
       reserved
    ENFORCE(flag == 0);
    item =:= '000' compressed_value(0, 0) [ 5 0 ];
       reorder_ratio =:= reorder_choice
  }
}

optional_checksum(flag_value)
{
  UNCOMPRESSED {
    value     [ 2 0, 16 ];
       df             =:= irregular(1)
    reserved1 [ 1 0, 16 ];
       ip_id_behavior
  }

  COMPRESSED cs_present {
    ENFORCE(flag_value == 1);
    value     =:= ip_id_behavior_choice irregular(16)             [ 2 16 ];
       tos_tc
    reserved1 =:= irregular(8) uncompressed_value(16, 0) [ 8 0 ];
       ttl_hopl
  }

  COMPRESSED not_present {
    ENFORCE(flag_value == 0);
    value     =:= irregular(8) compressed_value(0, 0) [ 8 0 ];
       ip_id
    reserved1 =:=
         ip_id_enc_dyn(ip_id_behavior.UVALUE) compressed_value(0, 0) [ 0 ];
  }
}

gre_proto
{
  UNCOMPRESSED {
    protocol [ 0, 16 ];
       ENFORCE((is_innermost == true) &&
               (profile == PROFILE_IP_0104));
  }

  COMPRESSED ipv4_regular_dynamic ether_v4 {
       reserved
    discriminator =:= '00000' compressed_value(1, 0)         [ 5 1 ];
       df
    protocol      =:= irregular(1) uncompressed_value(16, 0x0800) [ 1 0 ];
       ip_id_behavior
  }

  COMPRESSED ether_v6 {
    discriminator =:= ip_id_behavior_choice compressed_value(1, 1)         [ 2 1 ];
       tos_tc
    protocol      =:= irregular(8) uncompressed_value(16, 0x86DD) [ 8 0 ];
       ttl_hopl       =:= irregular(8)
  }
}

gre(repair_flag)
{
  UNCOMPRESSED {
    c_flag                                 [ 8 1 ];
       ip_id
    r_flag    =:=
         ip_id_enc_dyn(ip_id_behavior.UVALUE) uncompressed_value(1, 0) [ 0, 16 1 ];
       ENFORCE((is_innermost == false) ||
               (profile != PROFILE_IP_0104));
     }

     COMPRESSED ipv4_outer_irregular {
       ip_id        =:=
         ip_id_enc_irreg(ip_id_behavior.UVALUE)
    k_flag                                 [ 0, 16 1 ];
       tos_tc       =:=
           static_or_irreg(tos_irregular_chain_flag)
    s_flag                                 [ 0, 8 1 ];
       ttl_hopl
    reserved0 =:=
           static_or_irreg(ttl_irregular_chain_flag) uncompressed_value(9, 0) [ 0, 8 9 ];
       ENFORCE(is_innermost == false);
     }

     COMPRESSED ipv4_innermost_irregular {
       ip_id
    version   =:=
         ip_id_enc_irreg(ip_id_behavior.UVALUE) uncompressed_value(3, 0) [ 0, 16 3 ];
       ENFORCE(is_innermost == true);
     }
   }

   /////////////////////////////////////////////
   // UDP Header
   /////////////////////////////////////////////

   udp(profile)
   {
     UNCOMPRESSED {
       src_port
    protocol                               [ 16 ];
       dst_port
    checksum_and_res                       [ 16 0, 32 ];
       udp_length
    key                                    [ 16 0, 32 ];
       checksum
    sequence_number                        [ 16 0, 32 ];
       ENFORCE((profile == PROFILE_RTP_0101) ||
               (profile == PROFILE_UDP_0102));
  }

  DEFAULT {
       src_port
    c_flag           =:= static;
       dst_port
    k_flag           =:= static;
       udp_length
    s_flag           =:= inferred_udp_length;
       checksum static;
    protocol         =:= irregular(16); static;
    key              =:= static;
    sequence_number  =:= static;
  }

  COMPRESSED udp_static gre_static {
       src_port
    protocol =:= irregular(16) gre_proto                 [ 16 1 ];
       dst_port
    c_flag   =:= irregular(16) irregular(1)              [ 16 1 ];
     }

     COMPRESSED udp_endpoint_dynamic {
       checksum
    k_flag   =:= irregular(1)              [ 16 1 ];
       msn
    s_flag   =:= irregular(16) irregular(1)              [ 16 1 ];
       reserved
    padding  =:= uncompressed_value(6, 0);
       reorder_ratio compressed_value(4, 0)    [ 4 ];
    key      =:= reorder_choice optional_32(k_flag.UVALUE) [ 2 0, 32 ];
       ENFORCE(profile == PROFILE_UDP_0102);
  }

  COMPRESSED udp_regular_dynamic gre_dynamic {
       checksum
    checksum_and_res =:=
      optional_checksum(c_flag.UVALUE)              [ 0, 16 ];
    sequence_number  =:= optional_32(s_flag.UVALUE) [ 0, 32 ];
  }

  COMPRESSED udp_zero_checksum_irregular gre_irregular {
       ENFORCE(checksum.UVALUE
    ENFORCE(repair_flag == 0);
       checksum
    checksum_and_res =:= uncompressed_value(16, 0);
     }

     COMPRESSED udp_with_checksum_irregular {
       ENFORCE(checksum.UVALUE == 1);
       checksum optional_checksum(c_flag.UVALUE) [ 0, 16 ];
     }
   }

   /////////////////////////////////////////////
   // RTP Header
   /////////////////////////////////////////////
   csrc_list_dynchain(presence, cc_value)
   {
     UNCOMPRESSED {
       csrc_list;
     }

     COMPRESSED no_list {
       csrc_list
    sequence_number  =:= uncompressed_value(0, 0)
      optional_lsb_7_or_31(s_flag.UVALUE) [ 0 0, 8, 32 ];
       ENFORCE(cc_value == 0);
       ENFORCE(presence == 0);
  }

  COMPRESSED list_present gre_repair_irregular {
       csrc_list
    ENFORCE(repair_flag == 1);
    checksum_and_res =:= list_csrc(cc_value) optional_checksum(c_flag.UVALUE) [ VARIABLE 0, 16 ];
    sequence_number  =:= optional_32(s_flag.UVALUE) [ 0, 32 ];
       ENFORCE(presence == 1);
  }
}

   rtp(profile, ts_stride_value)

/////////////////////////////////////////////
// MINE header
/////////////////////////////////////////////

mine
{
  UNCOMPRESSED {
       rtp_version =:= uncompressed_value(2, 0)
    next_header [  2 8 ];
       pad_bit
    s_bit       [ 1 ];
       extension
    res_bits    [  1 7 ];
       cc
    checksum    [  4 16 ];
       marker
    orig_dest   [  1 32 ];
       payload_type
    orig_src    [  7 0, 32 ];
       sequence_number
  }

  DEFAULT {
    next_header =:= static;
    s_bit       =:= static;
    res_bits    =:= static;
    checksum    =:= inferred_mine_header_checksum;
    orig_dest   =:= static;
    orig_src    =:= static;
  }

  COMPRESSED mine_static {
    next_header =:= irregular(8)              [ 16 8 ];
       timestamp
    s_bit       =:= irregular(1)              [ 32 1 ];
       ssrc
    // Reserved bits are included to achieve byte-alignment
    res_bits    =:= irregular(7)              [ 7 ];
    orig_dest   =:= irregular(32)             [ 32 ];
       csrc_list
    orig_src    =:= optional_32(s_bit.UVALUE) [ VARIABLE 0, 32 ];
       ENFORCE((profile == PROFILE_RTP_0101) ||
               (profile == PROFILE_RTP_0107));
  }

     CONTROL

  COMPRESSED mine_dynamic {
  }
  COMPRESSED mine_irregular {
  }
}

/////////////////////////////////////////////
// The ts_stride has an initial UVALUE=1, which means that it
       // can be encoded with 'static' even if it has not been
       // previously established in the context.
       ts_stride Authentication Header (AH)
/////////////////////////////////////////////

ah(repair_flag)
{
  UNCOMPRESSED {
    next_header     [ 32 8 ];
       ts_scaled
    length          [ 8 ];
    res_bits        [ 16 ];
    spi             [ 32 ];
       ts_offset =:=
           field_scaling(ts_stride.UVALUE, ts_scaled.UVALUE,
                         timestamp.UVALUE)
    sequence_number [ 32 ];
    auth_data       [ length.UVALUE*32-32 ];
  }

  DEFAULT {
       pad_bit         =:= static;
       extension
    next_header     =:= static;
       cc
    length          =:= static;
       marker
    res_bits        =:= static;
       payload_type
    spi             =:= static;
    sequence_number =:= static;
       timestamp       =:= static;
       ssrc            =:= static;
       csrc_list       =:= static;
     }

     COMPRESSED rtp_static {
       ssrc            =:= irregular(32)  [ 32 ];
  }

  COMPRESSED rtp_dynamic ah_static {
       reserved        =:= compressed_value(1, 0)       [  1 ];
       reorder_ratio
    next_header =:= reorder_choice irregular(8)  [  2 8 ];
       list_present
    length      =:= irregular(1) irregular(8)  [  1 8 ];
       tss_indicator
    spi         =:= irregular(1) irregular(32) [  1 32 ];
       pad_bit
  }

  COMPRESSED ah_dynamic {
    sequence_number =:= irregular(1) irregular(32) [  1 32 ];
       extension
    auth_data       =:= irregular(1)
      irregular(length.UVALUE*32-32)  [  1 length.UVALUE*32-32 ];
       marker
  }

  COMPRESSED ah_irregular {
    ENFORCE(repair_flag == 0);
    sequence_number =:= irregular(1) lsb_7_or_31  [  1 8, 32 ];
       payload_type
    auth_data       =:= irregular(7)
      irregular(length.UVALUE*32-32) [  7 length.UVALUE*32-32 ];
       sequence_number
  }

  COMPRESSED ah_repair_irregular {
    ENFORCE(repair_flag == 1);
    res_bits        =:= irregular(16) [ 16 ];
       timestamp
    sequence_number =:= irregular(32) [ 32 ];
       ts_stride       =:=
           optional_stride(tss_indicator,
                           ts_stride_value)       [ VARIABLE ];
       csrc_list
    auth_data       =:=
           csrc_list_dynchain(list_present, cc.UVALUE)
      irregular(length.UVALUE*32-32)  [ VARIABLE length.UVALUE*32-32 ];
  }

     COMPRESSED rtp_irregular {
     }
}

/////////////////////////////////////////////
// UDP-Lite Header ESP header (NULL encrypted)
/////////////////////////////////////////////

   checksum_coverage_dynchain(behavior)

// The value of the next header field from the trailer
// part of the packet is passed as a parameter.
esp_null(next_header_value, repair_flag)
{
  UNCOMPRESSED {
       checksum_coverage
    spi             [ 16 32 ];
    sequence_number [ 32 ];
  }

  CONTROL {
    nh_field [ 8 ];
  }

  DEFAULT {
    spi             =:= static;
    sequence_number =:= static;
    nh_field        =:= static;
  }

  COMPRESSED inferred_coverage esp_static {
       checksum_coverage
    nh_field =:= inferred_udp_length compressed_value(8, next_header_value) [  0 8 ];
    spi      =:= irregular(32)                          [ 32 ];
       ENFORCE(behavior == UDP_LITE_COVERAGE_INFERRED);
  }

  COMPRESSED static_coverage esp_dynamic {
       checksum_coverage
    sequence_number =:= irregular(16) irregular(32) [ 16 32 ];
       ENFORCE(behavior == UDP_LITE_COVERAGE_STATIC);
  }

  COMPRESSED irregular_coverage esp_irregular {
       checksum_coverage
    ENFORCE(repair_flag == 0);
    sequence_number =:= irregular(16) lsb_7_or_31 [ 16 8, 32 ];
       ENFORCE(behavior
  }

  COMPRESSED esp_repair_irregular {
    ENFORCE(repair_flag == UDP_LITE_COVERAGE_IRREGULAR); 1);
    sequence_number =:= irregular(32) [ 32 ];
  }

}

   checksum_coverage_irregular(behavior)

/////////////////////////////////////////////
// IPv6 Header
/////////////////////////////////////////////

fl_enc
{
  UNCOMPRESSED {
       checksum_coverage
    flow_label [ 16 20 ];
  }

  COMPRESSED inferred_coverage fl_zero {
       checksum_coverage
    discriminator =:= inferred_udp_length '0'                       [  0 1 ];
       ENFORCE(behavior == UDP_LITE_COVERAGE_INFERRED);
     }

     COMPRESSED static_coverage {
       checksum_coverage
    flow_label    =:= static uncompressed_value(20, 0) [ 0 ];
       ENFORCE(behavior == UDP_LITE_COVERAGE_STATIC);
    reserved      =:= '0000'                    [ 4 ];
  }

  COMPRESSED irregular_coverage fl_non_zero {
       checksum_coverage
    discriminator =:= irregular(16) '1'           [ 16 1 ];
    flow_label    =:= irregular(20) [ 20 ];
       ENFORCE(behavior == UDP_LITE_COVERAGE_IRREGULAR);
  }
}

   udp_lite(profile)

ipv6(profile, is_innermost, ip_outer_flag, repair_flag)
{
  UNCOMPRESSED {
       src_port
    version         =:= uncompressed_value(4, 6) [ 16 4 ];
       dst_port
    tos_tc                                       [ 16 8 ];
       checksum_coverage
    flow_label                                   [ 16 20 ];
       checksum
    payload_length                               [ 16 ];
       ENFORCE((profile == PROFILE_RTP_0107) ||
               (profile == PROFILE_UDPLITE_0108));
     }

     CONTROL {
       coverage_behavior
    next_header                                  [ 2 8 ];
    ttl_hopl                                     [ 8 ];
    src_addr                                     [ 128 ];
    dst_addr                                     [ 128 ];
  }

  DEFAULT {
       src_port
    tos_tc         =:= static;
       dst_port
    flow_label     =:= static;
       checksum_coverage
    payload_length =:= irregular(16);
       checksum inferred_ip_v6_length;
    next_header    =:= irregular(16);
     }

     COMPRESSED udp_lite_static {
       src_port static;
    ttl_hopl       =:= irregular(16) [ 16 ];
       dst_port static;
    src_addr       =:= irregular(16) [ 16 ]; static;
    dst_addr       =:= static;
  }

  COMPRESSED udp_lite_endpoint_dynamic ipv6_static {
       reserved
    version_flag        =:= compressed_value(4, 0) '1'            [  4 1 ];
       coverage_behavior
    reserved            =:= irregular(2) '00'           [ 2 ];
       reorder_ratio
    flow_label          =:= reorder_choice fl_enc         [  2 5, 21 ];
       checksum_coverage
    next_header         =:=
           checksum_coverage_dynchain(coverage_behavior.UVALUE) irregular(8)   [ 16 8 ];
       checksum
    src_addr            =:= irregular(128) [ 16 128 ];
       msn
    dst_addr            =:= irregular(16) irregular(128) [ 16 128 ];
       ENFORCE(profile == PROFILE_UDPLITE_0108);
  }

  COMPRESSED udp_lite_regular_dynamic ipv6_endpoint_static {
       coverage_behavior
    ENFORCE((is_innermost == 1) &&
            (profile == PROFILE_IP_0104));
    version_flag        =:= irregular(2) '1'                    [  2 1 ];
       reserved
    innermost_indicator =:= compressed_value(6, 0) compressed_value(1, 1) [  6 1 ];
       checksum_coverage
    reserved            =:=
           checksum_coverage_dynchain(coverage_behavior.UVALUE) [ 16 ];
       checksum '0'                    [ 16 1 ];
     }

     COMPRESSED udp_lite_irregular {
       checksum_coverage
    flow_label          =:=
        checksum_coverage_dynchain(coverage_behavior.UVALUE) [ 0, 16 ];
       checksum fl_enc                 [ 16 5, 21 ];
     }
   }

   /////////////////////////////////////////////
   // ESP Header (Non-NULL encrypted
   // i.e. only used for the ESP profile
   /////////////////////////////////////////////

   esp(profile)
   {
     UNCOMPRESSED {
       spi
    next_header         =:= irregular(8)           [ 32 8 ];
       sequence_number
    src_addr            =:= irregular(128)         [ 32 128 ];
       ENFORCE(profile == PROFILE_ESP_0103);
     }

     DEFAULT {
       spi             =:= static;
       sequence_number =:= static;
     }

     COMPRESSED esp_static {
       spi
    dst_addr            =:= irregular(32) irregular(128)         [ 32 128 ];
  }

  COMPRESSED esp_dynamic ipv6_endpoint_dynamic {
       sequence_number
    ENFORCE((is_innermost == 1) &&
            (profile == PROFILE_IP_0104));
    tos_tc        =:= irregular(32) irregular(8)           [ 32 8 ];
       msn
    ttl_hopl      =:= irregular(16) irregular(8)           [ 16 8 ];
    reserved      =:= uncompressed_value(6, compressed_value(6, 0) [ 6 ];
    reorder_ratio =:= reorder_choice         [ 2 ];
     }

     COMPRESSED esp_irregular {
     }
   }

   ///////////////////////////////////////////////////
   // Encoding methods used in the profiles' CO packets
   ///////////////////////////////////////////////////

   ip_id_lsb(behavior, k, p)
   {
     UNCOMPRESSED {
       ip_id
    msn           =:= irregular(16)          [ 16 ];
  }

     CONTROL

  COMPRESSED ipv6_regular_dynamic {
       ip_id_offset
    ENFORCE((is_innermost == 0) ||
            (profile != PROFILE_IP_0104));
    tos_tc       =:= irregular(8) [ 16 8 ];
       ip_id_nbo
    ttl_hopl     =:= irregular(8) [ 16 8 ];
  }

  COMPRESSED nbo ipv6_outer_irregular {
       ip_id_offset
    ENFORCE(repair_flag == 0);
    ENFORCE(is_innermost == 0);
    tos_tc       =:= lsb(k, p)
        static_or_irreg(ip_outer_flag, 8) [ VARIABLE 0, 8 ];
       ENFORCE(behavior
    ttl_hopl     =:=
        static_or_irreg(ip_outer_flag, 8) [ 0, 8 ];
  }

  COMPRESSED ipv6_innermost_irregular {
    ENFORCE(repair_flag == IP_ID_BEHAVIOR_SEQUENTIAL);
       ENFORCE(ip_id_offset.UVALUE 0);
    ENFORCE(is_innermost == ip_id.UVALUE - msn.UVALUE); 1);
  }

  COMPRESSED non_nbo ipv6_outer_repair_irregular {
       ip_id_offset
    ENFORCE(repair_flag == 1);
    ENFORCE(is_innermost == 0);
    tos_tc =:= lsb(k, p) static_or_irreg(ip_outer_flag, 8) [ VARIABLE 0, 8 ];
       ENFORCE(behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED);
       ENFORCE(ip_id_nbo.UVALUE ==
               (ip_id.UVALUE / 256) + (ip_id.UVALUE % 256) * 256);
       ENFORCE(ip_id_nbo.ULENGTH
    ttl_hopl =:= static_or_irreg(ip_outer_flag, 8) [ 0, 8 ];
  }

  COMPRESSED ipv6_innermost_repair_irregular {
    ENFORCE(repair_flag == 16);
       ENFORCE(ip_id_offset.UVALUE 1);
    ENFORCE(is_innermost == ip_id_nbo.UVALUE - msn.UVALUE); 1);
  }
}

   optional_ip_id_lsb(behavior, indicator)

/////////////////////////////////////////////
// IPv4 Header
/////////////////////////////////////////////

ip_id_enc_dyn(behavior)
{
  UNCOMPRESSED {
    ip_id [ 16 ];
  }

  COMPRESSED short ip_id_seq {
       ip_id =:= ip_id_lsb(behavior, 8, 3) [ 8 ];
    ENFORCE((behavior == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
       ENFORCE(indicator IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED) ||
            (behavior == 0);
     }

     COMPRESSED long { IP_ID_BEHAVIOR_RANDOM));
    ip_id =:= irregular(16) [ 16 ];
       ENFORCE((behavior == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
       ENFORCE(indicator == 1);
  }

  COMPRESSED not_present ip_id_zero {
       ENFORCE((behavior == IP_ID_BEHAVIOR_RANDOM) ||
               (behavior
    ENFORCE(behavior == IP_ID_BEHAVIOR_ZERO)); IP_ID_BEHAVIOR_ZERO);
    ip_id =:= uncompressed_value(16, 0) [ 0 ];
  }
}

   dont_fragment(version)

ip_id_enc_irreg(behavior)
{
  UNCOMPRESSED {
       df
    ip_id [ 1 16 ];
  }

  COMPRESSED v4 ip_id_seq {
       df
    ENFORCE(behavior == IP_ID_BEHAVIOR_SEQUENTIAL);
  }
  COMPRESSED ip_id_seq_swapped {
    ENFORCE(behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED);
  }

  COMPRESSED ip_id_rand {
    ENFORCE(behavior == IP_ID_BEHAVIOR_RANDOM);
    ip_id =:= irregular(1) irregular(16) [ 1 16 ];
       ENFORCE(version == 4);
  }

  COMPRESSED v6 ip_id_zero {
       df
    ENFORCE(behavior == IP_ID_BEHAVIOR_ZERO);
    ip_id =:= compressed_value(1, uncompressed_value(16, 0) [ 1 0 ];
       ENFORCE(version == 6);
  }
}

   ////////////////////////////////////////////
   // RTP profile
   ////////////////////////////////////////////

   // ttl_irregular_chain_flag is set by the user if the TTL/Hop Limit
   // of an outer header. The same value must be passed as an argument
   // to the ipv4/ipv6 encoding methods when extracting the irregular
   // chain items. The same applies to the tos_irregular_chain_flag
   rtp_baseheader(profile, ts_stride_value,
                  ttl_irregular_chain_flag, tos_irregular_chain_flag)

ip_id_behavior_choice(is_inner)
{
  UNCOMPRESSED v4 {
       outer_headers  =:= baseheader_outer_headers
    behavior [ VARIABLE 2 ];
       version
  }

  DEFAULT {
    behavior =:= uncompressed_value(4, 4) irregular(2);
  }

  COMPRESSED sequential {
    ENFORCE(is_inner == 1);
    ENFORCE(behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL);
    behavior [ 4 2 ];
       header_length  =:= uncompressed_value(4, 5)
  }

  COMPRESSED sequential_swapped {
    ENFORCE(is_inner == 1);
    ENFORCE(behavior.UVALUE ==
            IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED);
    behavior [ 4 2 ];
       tos_tc
  }

  COMPRESSED random {
    ENFORCE(behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    behavior [ 8 2 ];
       length
  }

  COMPRESSED zero {
    ENFORCE(behavior.UVALUE == IP_ID_BEHAVIOR_ZERO);
    behavior [ 16 2 ];
       ip_id
  }
}

variable_ipv4_fields(flag)
{
  UNCOMPRESSED {
    df             [ 16 1 ];
       rf             =:= uncompressed_value(1, 0)
    ip_id_behavior [ 2 ];
  }

  COMPRESSED not_present {
    ENFORCE(flag == 0);
    df             =:= static;
    ip_id_behavior =:= static;
  }

  COMPRESSED present {
    ENFORCE(flag == 1);
    reserved       =:= '00000'                  [ 5 ];
    df             =:= irregular(1)             [ 1 ];
    ip_id_behavior =:= ip_id_behavior_choice(0) [ 2 ];
  }
}

ipv4(profile, is_innermost, ip_outer_flag, repair_flag)
{
  UNCOMPRESSED {
    version     =:= uncompressed_value(4, 4)       [ 4 ];
    hdr_length  =:= uncompressed_value(4, 5)       [ 4 ];
    tos_tc                                         [ 8 ];
    length      =:= inferred_ip_v4_length          [ 16 ];
    ip_id                                          [ 16 ];
    rf          =:= uncompressed_value(1, 0)       [ 1 ];
    df                                             [ 1 ];
    mf          =:= uncompressed_value(1, 0)       [ 1 ];
    frag_offset =:= uncompressed_value(13, 0)      [ 13 ];
    ttl_hopl                                       [ 8 ];
       next_header
    protocol                                       [ 8 ];
    checksum    =:= inferred_ip_v4_header_checksum [ 16 ];
    src_addr                                       [ 32 ];
       dest_addr
    dst_addr                                       [ 32 ];
       extension_headers =:= baseheader_extension_headers [ VARIABLE ];
       src_port
  }

  CONTROL {
    ip_id_behavior [ 16 2 ];
       dst_port
  }

  DEFAULT {
    tos_tc         =:= static;
    df             =:= static;
    ttl_hopl       =:= static;
    protocol       =:= static;
    src_addr       =:= static;
    dst_addr       =:= static;
    ip_id_behavior =:= static;
  }

  COMPRESSED ipv4_static {
    version_flag        =:= '0'           [ 16 1 ];
       udp_length
    reserved            =:= '0000000'     [ 16 7 ];
       checksum
    protocol            =:= irregular(8)  [ 16 8 ];
       rtp_version
    src_addr            =:= uncompressed_value(2, 0) irregular(32) [  2 32 ];
       pad_bit
    dst_addr            =:= irregular(32) [  1 32 ];
       extension
  }

  COMPRESSED ipv4_endpoint_static {
    ENFORCE((is_innermost == 1) &&
            (profile == PROFILE_IP_0104));
    version_flag        =:= '0'                    [ 1 ];
       cc                                           [  4 ];
       marker
    innermost_indicator =:= compressed_value(1, 1) [ 1 ];
       payload_type
    reserved            =:= '000000'               [  7 6 ];
       sequence_number
    protocol            =:= irregular(8)           [ 16 8 ];
       timestamp
    src_addr            =:= irregular(32)          [ 32 ];
       ssrc
    dst_addr            =:= irregular(32)          [ 32 ];
       csrc_list                                    [ VARIABLE ];
       ENFORCE(msn.UVALUE == sequence_number.UVALUE);
  }
     UNCOMPRESSED v6

  COMPRESSED ipv4_endpoint_dynamic {
       outer_headers
    ENFORCE((is_innermost == 1) &&
            (profile == PROFILE_IP_0104));
    reserved       =:= baseheader_outer_headers '000'               [ VARIABLE 3 ];
       version
    reorder_ratio  =:= uncompressed_value(4, 6)         [ 4 ];
       tos_tc reorder_choice      [ 8 2 ];
       flow_label
    df             =:= irregular(1)        [ 20 1 ];
       payload_length
    ip_id_behavior =:= ip_id_behavior_choice(is_innermost) [ 16 2 ];
       next_header
    tos_tc         =:= irregular(8)        [ 8 ];
    ttl_hopl       =:= irregular(8)        [ 8 ];
       src_addr
    ip_id =:= ip_id_enc_dyn(ip_id_behavior.UVALUE) [ 128 0, 16 ];
       dest_addr
    msn            =:= irregular(16)       [ 128 16 ];
       extension_headers
  }

  COMPRESSED ipv4_regular_dynamic {
    ENFORCE((is_innermost == 0) ||
            (profile != PROFILE_IP_0104));
    reserved       =:= baseheader_extension_headers '00000'             [ VARIABLE 5 ];
       src_port
    df             =:= irregular(1)        [ 16 1 ];
       dst_port
    ip_id_behavior =:= ip_id_behavior_choice(is_innermost) [ 16 2 ];
       udp_length
    tos_tc         =:= irregular(8)        [ 16 8 ];
       checksum
    ttl_hopl       =:= irregular(8)        [ 16 8 ];
       rtp_version
    ip_id =:= uncompressed_value(2, 0) ip_id_enc_dyn(ip_id_behavior.UVALUE) [  2 0, 16 ];
       pad_bit
  }
  COMPRESSED ipv4_outer_irregular {
    ENFORCE(repair_flag == 0);
    ENFORCE(is_innermost == 0);
    ip_id    =:= ip_id_enc_irreg(ip_id_behavior.UVALUE) [  1 0, 16 ];
       extension
    tos_tc   =:= static_or_irreg(ip_outer_flag, 8) [  1 0, 8 ];
       cc
    ttl_hopl =:= static_or_irreg(ip_outer_flag, 8) [  4 0, 8 ];
       marker
  }

  COMPRESSED ipv4_innermost_irregular {
    // Same format for repair and non-repair
    ip_id =:= ip_id_enc_irreg(ip_id_behavior.UVALUE) [  1 0, 16 ];
       payload_type
    ENFORCE(is_innermost == 1);
  }

  COMPRESSED ipv4_outer_repair_irregular {
    ENFORCE(repair_flag == 1);
    ENFORCE(is_innermost == 0);
    df : ip_id_behavior =:=
      variable_ipv4_fields(outer_flag) [  7 0, 8 ];
       sequence_number
    ip_id =:= ip_id_enc_irreg(ip_id_behavior.UVALUE) [ 0, 16 ];
       timestamp                                    [ 32 ];
       ssrc
    tos_tc   =:= static_or_irreg(ip_outer_flag, 8) [ 32 0, 8 ];
       csrc_list
    ttl_hopl =:= static_or_irreg(ip_outer_flag, 8) [ VARIABLE 0, 8 ];
       ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
       ENFORCE(msn.UVALUE == sequence_number.UVALUE);
  }

     CONTROL {
       // The ts_stride has an initial UVALUE=1, which means that it
       // can be encoded with 'static' even if it has not been

}

/////////////////////////////////////////////
// previously established in the context.
       ts_stride UDP Header
/////////////////////////////////////////////

udp(profile)
{
  UNCOMPRESSED {
    ENFORCE((profile == PROFILE_RTP_0101) ||
            (profile == PROFILE_UDP_0102));
    src_port                           [ 32 16 ];
       ts_scaled
    dst_port                           [ 32 16 ];
       ts_offset
    udp_length =:=
           field_scaling(ts_stride.UVALUE, ts_scaled.UVALUE,
                         timestamp.UVALUE) inferred_udp_length [ 32 16 ];
       ip_id_behavior
    checksum                           [  2 16 ];
       ENFORCE(ts_stride.UVALUE == ts_stride_value);
       ENFORCE(profile == PROFILE_RTP_0101);
  }

  DEFAULT {
       tos_tc          =:= static;
       dest_addr       =:= static;
       version         =:= static;
       ttl_hopl        =:= static;
       src_addr        =:= static;
       df
    src_port   =:= static;
       ip_id_behavior
    dst_port   =:= static;
       payload_length  =:= inferred_ip_v6_length;
    checksum   =:= inferred_ip_v4_header_checksum;
       length          =:= inferred_ip_v4_length;
       flow_label      =:= static;
       next_header     =:= static; irregular(16);
  }

  COMPRESSED udp_static {
    src_port   =:= static;
       dst_port        =:= static;
       udp_length      =:= inferred_udp_length;
       checksum        =:= irregular(16);
       pad_bit         =:= static;
       extension       =:= static;
       cc              =:= static;
       // When marker not present in packets, it is assumed 0
       marker          =:= uncompressed_value(1, 0);
       payload_type    =:= static;
       sequence_number =:= static;
       timestamp       =:= static;
       ssrc            =:= static;
       csrc_list       =:= static;

       ENFORCE(ttl_irregular_chain_flag == 0);
       ENFORCE(tos_irregular_chain_flag == 0);
     }

     // Replacement for UOR-2-ext3
     COMPRESSED co_common {
       discriminator        =:= '1111101' irregular(16) [ 7 16 ];
       marker
    dst_port   =:= irregular(1) irregular(16) [ 1 16 ];
       header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)
  }

  COMPRESSED udp_endpoint_dynamic {
    ENFORCE(profile == PROFILE_UDP_0102);
    checksum                                 [ 7 16 ];
       ip_id_indicator
    msn           =:= irregular(1) irregular(16)          [ 1 16 ];
       ip_id_behavior
    reserved      =:= ip_id_behavior_choice compressed_value(6, 0) [ 2 6 ];
    reorder_ratio =:= reorder_choice         [ 2 ];
       df           =:= dont_fragment(version.UVALUE)
  }

  COMPRESSED udp_regular_dynamic {
    ENFORCE(profile == PROFILE_RTP_0101);
    checksum [ 1 16 ];
       control_crc3
  }

  COMPRESSED udp_zero_checksum_irregular {
    ENFORCE(checksum.UVALUE == 0);
    checksum =:= control_crc3 uncompressed_value(16, 0)   [ 3 0 ];
       ttl_hopl_outer_flag  =:= irregular(1)
  }

  COMPRESSED udp_with_checksum_irregular {
    ENFORCE(checksum.UVALUE != 0);
    checksum [ 1 16 ];
       ttl_hopl_present
  }

}

/////////////////////////////////////////////
// RTP Header
/////////////////////////////////////////////

csrc_list_dynchain(presence, cc_value)
{
  UNCOMPRESSED {
    csrc_list;
  }

  COMPRESSED no_list {
    ENFORCE(cc_value == 0);
    ENFORCE(presence == 0);
    csrc_list =:= irregular(1) uncompressed_value(0, 0) [ 1 0 ];
       tos_tc_outer_flag
  }

  COMPRESSED list_present {
    ENFORCE(presence == 1);
    csrc_list =:= irregular(1) list_csrc(cc_value) [ 1 VARIABLE ];
       tos_tc_present
  }
}

rtp(profile, ts_stride_value, time_stride_value)
{
  UNCOMPRESSED {
    ENFORCE((profile == PROFILE_RTP_0101) ||
            (profile == PROFILE_RTP_0107));
    rtp_version =:= irregular(1) uncompressed_value(2, 0) [ 1  2 ];
       ts_indicator         =:= irregular(1)
    pad_bit                                  [  1 ];
       tss_indicator        =:= irregular(1)
    extension                                [  1 ];
       pt_present           =:= irregular(1)
    cc                                       [ 1  4 ];
       list_present         =:= irregular(1)
    marker                                   [  1 ];
       pad_bit              =:= irregular(1)
    payload_type                             [ 1  7 ];
       extension            =:= irregular(1)
    sequence_number                          [ 1 16 ];
       reserved             =:= compressed_value(6, 0)
    timestamp                                [ 6 32 ];
       ip_id                =:=
         optional_ip_id_lsb(ip_id_behavior.UVALUE,
                            ip_id_indicator.CVALUE)
    ssrc                                     [ 0, 8, 16 32 ];
       tos_tc               =:=
         tos_tc_enc(tos_tc_present.CVALUE)
    csrc_list                                [ 0, 8 cc.UVALUE * 32 ];
       ttl_hopl             =:=
         static_or_irreg(ttl_hopl_present.CVALUE,
                         ttl_hopl.ULENGTH)
  }

  CONTROL {
    ENFORCE(time_stride_value == time_stride.UVALUE);
    ENFORCE(ts_stride_value == ts_stride.UVALUE);
    ts_stride                           [ 0, 8 ];
       sequence_number =:= sdvl(sequence_number.ULENGTH) [ 8, 16 32 ];
       // Either scaled or unscaled timestamp
       ts_scaled            =:=
           optional_scaled_timestamp(tss_indicator,
                                     tsc_indicator)
    time_stride                         [ VARIABLE 32 ];
    ts_scaled            =:=
           optional_scaled_timestamp(tss_indicator,
                                     tsc_indicator)                           [ VARIABLE 32 ];
       payload_type
    ts_offset =:= optional_pt(pt_present)
        field_scaling(ts_stride.UVALUE, ts_scaled.UVALUE,
                      timestamp.UVALUE) [ 0, 8 32 ];
  }

  INITIAL {
    ts_stride     =:=
           optional_stride(tss_indicator,
                           ts_stride_value)             [ VARIABLE ];
       csrc_list uncompressed_value(32, 0);
    time_stride   =:= list_csrc(cc.UVALUE)    [ VARIABLE ];

       ENFORCE(ttl_irregular_chain_flag == ttl_hopl_outer_flag.UVALUE);
       ENFORCE(tos_irregular_chain_flag == tos_tc_outer_flag.UVALUE); uncompressed_value(32, 0);
  }

     // UO-0
     COMPRESSED pt_0_crc3

  DEFAULT {
       discriminator
    ENFORCE(msn.UVALUE == sequence_number.UVALUE);
    pad_bit         =:= '0'                             [ 1 ];
       msn static;
    extension       =:= msn_lsb(4, 4)                   [ 4 ];
       header_crc static;
    cc              =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ]; static;
    marker          =:= static;
    payload_type    =:= static;
    sequence_number =:= static;
    timestamp       =:= inferred_scaled_field           [ 0 ];
       ip_id static;
    ssrc            =:= inferred_sequential_ip_id       [ 0 ]; static;
    csrc_list       =:= static;
  }

     // New format, Type 0 with strong CRC and more SN bits
  COMPRESSED pt_0_crc7 rtp_static {
       discriminator
    ssrc            =:= '100' irregular(32)  [ 3 32 ];
       msn
  }

  COMPRESSED rtp_dynamic {
    reserved        =:= msn_lsb(6, 16) compressed_value(1, 0)       [ 6  1 ];
       header_crc
    reorder_ratio   =:= crc7(THIS.UVALUE, THIS.ULENGTH) reorder_choice               [ 7  2 ];
       timestamp
    list_present    =:= inferred_scaled_field irregular(1)                 [ 0  1 ];
       ip_id
    tss_indicator   =:= inferred_sequential_ip_id irregular(1)                 [ 0  1 ];
     }

     // UO-1 replacement
     COMPRESSED pt_1_rnd {
       discriminator
    tis_indicator   =:= '101' irregular(1)                 [ 3  1 ];
       msn
    pad_bit         =:= msn_lsb(5, 8) irregular(1)                 [ 5  1 ];
       marker
    extension       =:= irregular(1)                 [  1 ];
       ts_scaled
    marker          =:= lsb(4, 3) irregular(1)                 [ 4  1 ];
       header_crc
    payload_type    =:= crc3(THIS.UVALUE, THIS.ULENGTH) irregular(7)                 [ 3  7 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
               (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
     }

     // UO-1-ID replacement
     COMPRESSED pt_1_seq_id {
       discriminator
    sequence_number =:= '1010' irregular(16)                [ 4 16 ];
       header_crc
    timestamp       =:= crc3(THIS.UVALUE, THIS.ULENGTH) irregular(32)                [ 3 32 ];
       msn
    ts_stride   =:= msn_lsb(5, 8) sdvl_or_static(tss_indicator)    [ 5 VARIABLE ];
       ip_id
    time_stride =:= ip_id_lsb(ip_id_behavior.UVALUE, 4, 3) sdvl_or_static(tis_indicator)    [ 4 VARIABLE ];
       timestamp
    csrc_list   =:= inferred_scaled_field
        csrc_list_dynchain(list_present, cc.UVALUE)  [ 0 VARIABLE ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }

     // UO-1-TS replacement

  COMPRESSED pt_1_seq_ts rtp_irregular {
       discriminator =:= '1011'
  }
}

/////////////////////////////////////////////
// UDP-Lite Header
/////////////////////////////////////////////

checksum_coverage_dynchain(behavior)
{
  UNCOMPRESSED {
    checksum_coverage [ 4 16 ];
       marker        =:= irregular(1)
  }

  COMPRESSED inferred_coverage {
    ENFORCE(behavior == UDP_LITE_COVERAGE_INFERRED);
    checksum_coverage =:= inferred_udp_length [ 1  0 ];
       header_crc
  }

  COMPRESSED static_coverage {
    ENFORCE(behavior == UDP_LITE_COVERAGE_STATIC);
    checksum_coverage =:= crc3(THIS.UVALUE, THIS.ULENGTH) irregular(16)       [ 3 16 ];
       msn
  }

  COMPRESSED irregular_coverage {
    ENFORCE(behavior == UDP_LITE_COVERAGE_IRREGULAR);
    checksum_coverage =:= msn_lsb(4, 4) irregular(16)       [ 4 16 ];
       ts_scaled     =:= lsb(4, 3)
  }
}

checksum_coverage_irregular(behavior)
{
  UNCOMPRESSED {
    checksum_coverage [ 4 16 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }

     // UOR-2 replacement

  COMPRESSED pt_2_rnd inferred_coverage {
       discriminator
    ENFORCE(behavior == UDP_LITE_COVERAGE_INFERRED);
    checksum_coverage =:= '110' inferred_udp_length [ 3  0 ];
       msn
  }

  COMPRESSED static_coverage {
    ENFORCE(behavior == UDP_LITE_COVERAGE_STATIC);
    checksum_coverage =:= msn_lsb(7, 32) static              [ 7  0 ];
       ts_scaled
  }

  COMPRESSED irregular_coverage {
    ENFORCE(behavior == UDP_LITE_COVERAGE_IRREGULAR);
    checksum_coverage =:= lsb(6, 15) irregular(16)       [ 6 16 ];
       marker
  }
}

udp_lite(profile)
{
  UNCOMPRESSED {
    ENFORCE((profile == PROFILE_RTP_0107) ||
            (profile == PROFILE_UDPLITE_0108));
    src_port          [ 16 ];
    dst_port          [ 16 ];
    checksum_coverage [ 16 ];
    checksum          [ 16 ];
  }

  CONTROL {
    coverage_behavior [ 2 ];
  }

  DEFAULT {
    src_port          =:= irregular(1) static;
    dst_port          =:= static;
    checksum_coverage =:= irregular(16);
    checksum          =:= irregular(16);
  }
  COMPRESSED udp_lite_static {
    src_port   =:= irregular(16) [ 1 16 ];
       header_crc
    dst_port   =:= crc7(THIS.UVALUE, THIS.ULENGTH) irregular(16) [ 7 16 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
               (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
  }

     // UOR-2-ID replacement

  COMPRESSED pt_2_seq_id udp_lite_endpoint_dynamic {
       discriminator
    ENFORCE(profile == PROFILE_UDPLITE_0108);
    reserved =:= '1100' compressed_value(4, 0)      [  4 ];
       msn
    coverage_behavior =:= msn_lsb(7, 32) irregular(2)       [ 7  2 ];
       ip_id
    reorder_ratio     =:= ip_id_lsb(ip_id_behavior.UVALUE, 6, 3) reorder_choice     [ 6  2 ];
       header_crc
    checksum_coverage =:= crc7(THIS.UVALUE, THIS.ULENGTH)
      checksum_coverage_dynchain(coverage_behavior.UVALUE) [ 7 16 ];
       timestamp
    checksum                                 [ 16 ];
    msn               =:= inferred_scaled_field irregular(16)      [ 0 16 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }

     // UOR-2-TS replacement

  COMPRESSED pt_2_seq_ts udp_lite_regular_dynamic {
       discriminator
    coverage_behavior =:= '1101' irregular(2)       [ 4  2 ];
       msn
    reserved =:= msn_lsb(7, 32) compressed_value(6, 0)      [ 7  6 ];
       ts_scaled
    checksum_coverage =:= lsb(5, 7)
        checksum_coverage_dynchain(coverage_behavior.UVALUE) [ 5 16 ];
       marker        =:= irregular(1)
    checksum                                 [ 1 16 ];
       header_crc
  }

  COMPRESSED udp_lite_irregular {
    checksum_coverage =:= crc7(THIS.UVALUE, THIS.ULENGTH)
      checksum_coverage_dynchain(coverage_behavior.UVALUE) [ 7 0, 16 ];
    checksum          [ 16 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }
}

   ////////////////////////////////////////////
   // UDP profile
   ////////////////////////////////////////////

   // ttl_irregular_chain_flag is set by the user if the TTL/Hop Limit
   // of an outer header. The same value must be passed as an argument

/////////////////////////////////////////////
// to the ipv4/ipv6 encoding methods when extracting the irregular ESP Header (Non-NULL encrypted
// chain items. The same applies to i.e. only used for the tos_irregular_chain_flag
   udp_baseheader(profile,
                  ttl_irregular_chain_flag, tos_irregular_chain_flag) ESP profile)
/////////////////////////////////////////////

esp(profile)
{
  UNCOMPRESSED v4 {
       outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
       version        =:= uncompressed_value(4, 4)  [ 4 ];
       header_length  =:= uncompressed_value(4, 5)  [ 4 ];
       tos_tc                                       [ 8 ];
       length
    ENFORCE(profile == PROFILE_ESP_0103);
    spi             [ 16 32 ];
       ip_id
    sequence_number [ 16 32 ];
       rf
  }

  DEFAULT {
    ENFORCE(msn.UVALUE == sequence_number.UVALUE % 65536);
    spi             =:= uncompressed_value(1, 0)  [ 1 ];
       df                                           [ 1 ];
       mf static;
    sequence_number =:= uncompressed_value(1, 0)  [ 1 ];
       frag_offset static;
  }

  COMPRESSED esp_static {
    // Needs to be discriminated from ESP NULL headers,
    // and therefore we have a dummy protocol field here.
    discriminator =:= uncompressed_value(13, 0) [ 13 ];
       ttl_hopl                                     [ 8 ];
       next_header uncompressed_value(8, 255)  [  8 ];
       checksum                                     [ 16 ];
       src_addr
    spi =:= irregular(32)                         [ 32 ];
       dest_addr
  }

  COMPRESSED esp_dynamic {
    sequence_number =:= irregular(32)             [ 32 ];
       extension_headers
    reserved        =:= baseheader_extension_headers [ VARIABLE ];
       src_port                                     [ 16 ];
       dst_port compressed_value(6, 0)    [ 16  6 ];
       udp_length
    reorder_ratio   =:= reorder_choice            [ 16  2 ];
       checksum
  }

  COMPRESSED esp_irregular {
  }
}

///////////////////////////////////////////////////
// Encoding methods used in the profiles' CO packets
///////////////////////////////////////////////////

// Variable reordering offset used for MSN
msn_lsb(k)
{
  UNCOMPRESSED {
    master [ 16 ];
  }

     UNCOMPRESSED v6

  COMPRESSED none {
       outer_headers
    ENFORCE(reorder_ratio.UVALUE == REORDERING_NONE);
    master =:= baseheader_outer_headers  [ VARIABLE ];
       version lsb(k, 1);
  }

  COMPRESSED quarter {
    ENFORCE(reorder_ratio.UVALUE == REORDERING_QUARTER);
    master =:= uncompressed_value(4, 6)         [ 4 ];
       version                                      [ 4 ];
       tos_tc                                       [ 8 ];
       flow_label lsb(k, ((2^k) / 4) - 1);
  }

  COMPRESSED half {
    ENFORCE(reorder_ratio.UVALUE == REORDERING_HALF);
    master =:= lsb(k, ((2^k) / 2) - 1);
  }

  COMPRESSED threequarters {
    ENFORCE(reorder_ratio.UVALUE == REORDERING_THREEQUARTERS);
    master =:= lsb(k, (((2^k) * 3) / 4) - 1);
  }
}

ip_id_lsb(behavior, k)
{
  UNCOMPRESSED {
    ip_id [ 20 16 ];
       payload_length
  }

  CONTROL {
    ip_id_offset [ 16 ];
       next_header
    ip_id_nbo    [ 8 16 ];
       ttl_hopl
  }

  COMPRESSED nbo {
    ENFORCE(behavior == IP_ID_BEHAVIOR_SEQUENTIAL);
    ENFORCE(ip_id_offset.UVALUE == ip_id.UVALUE - msn.UVALUE);
    ip_id_offset =:= lsb(k, ((2^k) / 4) - 1) [ 8 k ];
       src_addr
  }

  COMPRESSED non_nbo {
    ENFORCE(behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED);
    ENFORCE(ip_id_nbo.UVALUE ==
            (ip_id.UVALUE / 256) + (ip_id.UVALUE % 256) * 256);
    ENFORCE(ip_id_nbo.ULENGTH == 16);
    ENFORCE(ip_id_offset.UVALUE == ip_id_nbo.UVALUE - msn.UVALUE);
    ip_id_offset =:= lsb(k, ((2^k) / 4) - 1) [ 128 k ];
       dest_addr
  }
}

optional_ip_id_lsb(behavior, indicator)
{
  UNCOMPRESSED {
    ip_id [ 128 16 ];
       extension_headers
  }

  COMPRESSED short {
    ENFORCE((behavior == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    ENFORCE(indicator == 0);
    ip_id =:= baseheader_extension_headers ip_id_lsb(behavior, 8) [ VARIABLE 8 ];
       src_port
  }

  COMPRESSED long {
    ENFORCE((behavior == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (behavior == IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    ENFORCE(indicator == 1);
    ip_id =:= irregular(16)  [ 16 ];
       dst_port
  }

  COMPRESSED not_present {
    ENFORCE((behavior == IP_ID_BEHAVIOR_RANDOM) ||
            (behavior == IP_ID_BEHAVIOR_ZERO));
  }
}

dont_fragment(version)
{
  UNCOMPRESSED {
    df [ 16 1 ];
       udp_length
  }

  COMPRESSED v4 {
    ENFORCE(version == 4);
    df =:= irregular(1) [ 16 1 ];
       checksum
  }

  COMPRESSED v6 {
    ENFORCE(version == 6);
    df =:= compressed_value(1, 0) [ 16 1 ];
       ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
  }

     CONTROL
}

optional_pt(flag)
{
       ip_id_behavior
  UNCOMPRESSED {
    payload_type [ 2 7 ];
       ENFORCE(profile == PROFILE_UDP_0102);
  }

     DEFAULT

  COMPRESSED not_present {
       tos_tc         =:= static;
       dest_addr      =:= static;
       version
    ENFORCE(flag == 0);
    payload_type =:= static;
       ttl_hopl       =:= static;
       src_addr       =:= static;
       df             =:= static;
       ip_id_behavior =:= static;
       payload_length =:= inferred_ip_v6_length;
       checksum       =:= inferred_ip_v4_header_checksum;
       length         =:= inferred_ip_v4_length;
       flow_label     =:= static;
       next_header    =:= static;
       src_port       =:= static;
       dst_port       =:= static;
       udp_length     =:= inferred_udp_length;
       checksum       =:= irregular(16);
       ENFORCE(ttl_irregular_chain_flag == 0);
       ENFORCE(tos_irregular_chain_flag == 0); static [ 0 ];
  }

     // Replacement for UOR-2-ext3

  COMPRESSED co_common present {
       discriminator
    ENFORCE(flag == 1);
    reserved     =:= '1111101' compressed_value(1, 0) [ 7 1 ];
       ip_id_indicator
    payload_type =:= irregular(1) irregular(7)           [ 1 7 ];
       reorder_ratio
  }
}

csrc_list_presence(presence, cc_value)
{
  UNCOMPRESSED {
    csrc_list;
  }
  COMPRESSED no_list {
    ENFORCE(presence == 0);
    csrc_list =:= reorder_choice static [ 2 0 ];
       msn
  }

  COMPRESSED list_present {
    ENFORCE(presence == 1);
    csrc_list =:= msn_lsb(6, 16) list_csrc(cc_value) [ 6 VARIABLE ];
       df           =:= dont_fragment(version.UVALUE)
  }
}

scaled_ts_lsb(time_stride_value, k)
{
  UNCOMPRESSED {
    timestamp [ 1 32 ];
       header_crc
  }

  COMPRESSED timerbased {
    ENFORCE(time_stride_value != 0);
    timestamp =:= crc7(THIS.UVALUE, THIS.ULENGTH) timer_based_lsb(time_stride_value, k,
                                  ((2^k) / 4) - 1);
  }

  COMPRESSED regular {
    ENFORCE(time_stride_value == 0);
    timestamp =:= lsb(k, ((2^k) / 4) - 1);
  }
}

irregular_or_nothing(flag)
{
  UNCOMPRESSED {
    field [ 7 32 ];
       ttl_hopl_outer_flag
  }

  COMPRESSED not_present {
    ENFORCE(flag == 0);
  }

  COMPRESSED present {
    ENFORCE(flag == 1);
    field =:= irregular(1) irregular(32);
  }
}

// Self-describing variable length encoding
sdvl_lsb(field_width)
{
  UNCOMPRESSED {
    field [ 1 field_width ];
       ttl_hopl_present
  }

  COMPRESSED lsb7 {
    discriminator =:= irregular(1) '0'               [ 1 ];
       tos_tc_outer_flag
    field =:= irregular(1) lsb(7, ((2^7) / 4) - 1)   [ 1 7 ];
       ip_id_behavior
  }

  COMPRESSED lsb14 {
    discriminator =:= ip_id_behavior_choice '10'              [  2 ];
       control_crc3
    field =:= control_crc3 lsb(14, ((2^14) / 4) - 1) [ 14 ];
  }

  COMPRESSED lsb21 {
    discriminator =:= '110'             [  3 ];
       tos_tc_present
    field =:= irregular(1) lsb(21, ((2^21) / 4) - 1) [ 1 21 ];
       reserved
  }

  COMPRESSED lsb28 {
    discriminator =:= compressed_value(7, 0) '1110'            [ 7  4 ];
       ip_id
    field =:=
         optional_ip_id_lsb(ip_id_behavior.UVALUE,
                            ip_id_indicator.CVALUE) lsb(28, ((2^28) / 4) - 1) [ 0, 8, 16 28 ];
       tos_tc
  }

  COMPRESSED lsb32 {
    discriminator =:=
         tos_tc_enc(tos_tc_present.CVALUE) '11111111'        [ 0,  8 ];
       ttl_hopl
    field =:=
         static_or_irreg(ttl_hopl_present.CVALUE,
                         ttl_hopl.ULENGTH) irregular(field_width)    [ 0, 8 field_width ];

       ENFORCE(ttl_irregular_chain_flag == ttl_hopl_outer_flag.UVALUE);
       ENFORCE(tos_irregular_chain_flag == tos_tc_outer_flag.UVALUE);
  }

     // UO-0
     COMPRESSED pt_0_crc3
}

variable_scaled_timestamp(tss_flag, tsc_flag, ts_stride)
{
       discriminator =:= '0'                             [ 1 ];
       msn           =:= msn_lsb(4, 4)
  UNCOMPRESSED {
    timestamp [ 4 32 ];
       header_crc
  }

  COMPRESSED present {
    ENFORCE((tss_flag == 0) && (tsc_flag == 1));
    ENFORCE(ts_stride != 0);
    timestamp =:= crc3(THIS.UVALUE, THIS.ULENGTH) sdvl_lsb(32) [ 3 VARIABLE ];
       ip_id         =:= inferred_sequential_ip_id
  }

  COMPRESSED not_present {
    ENFORCE(((tss_flag == 1) && (tsc_flag == 0)) ||
            ((tss_flag == 0) && (tsc_flag == 0)));
  }
}

variable_unscaled_timestamp(tss_flag, tsc_flag)
{
  UNCOMPRESSED {
    timestamp [ 0 32 ];
  }

     // New format, Type 0 with strong CRC and more SN bits

  COMPRESSED pt_0_crc7 present {
       discriminator
    ENFORCE(((tss_flag == 1) && (tsc_flag == 0)) ||
            ((tss_flag == 0) && (tsc_flag == 0)));
    timestamp =:= '100' sdvl_lsb(32);
  }

  COMPRESSED not_present {
    ENFORCE((tss_flag == 0) && (tsc_flag == 1));
  }
}

profile_1_7_flags1_enc(flag)
{
  UNCOMPRESSED {
    ip_outer_indicator  [ 3 1 ];
       msn           =:= msn_lsb(6, 16)
    repair_indicator    [ 6 1 ];
       header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)
    ttl_hopl_indicator  [ 7 1 ];
       ip_id         =:= inferred_sequential_ip_id
    tos_tc_indicator    [ 0 1 ];
    ip_id_behavior      [ 2 ];
    reorder_ratio       [ 2 ];
  }

     // UO-1-ID replacement (PT-1 only used for sequential)

  COMPRESSED pt_1_seq_id not_present {
       discriminator
    ENFORCE(flag == 0);
    ENFORCE(ip_outer_indicator.CVALUE == 0);
    ENFORCE(repair_indicator.CVALUE == 0);
    ENFORCE(ttl_hopl_indicator.CVALUE == 0);
    ENFORCE(tos_tc_indicator.CVALUE == 0);
    ip_id_behavior       =:= '101'                           [ 3 ];
       header_crc static;
    reorder_ratio        =:= crc3(THIS.UVALUE, THIS.ULENGTH) static;
  }

  COMPRESSED present {
    ENFORCE(flag == 1);
    ip_outer_indicator  =:= irregular(1)                [ 3 1 ];
       msn
    repair_indicator    =:= msn_lsb(6, 16) irregular(1)                [ 6 1 ];
       ip_id
    ttl_hopl_indicator  =:= ip_id_lsb(ip_id_behavior.UVALUE, 4, 3) irregular(1)                [ 4 1 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     }

     // UOR-2 replacement
     COMPRESSED pt_2_rnd {
       discriminator
    tos_tc_indicator    =:= '110' irregular(1)                [ 3 1 ];
       msn
    ip_id_behavior      =:= msn_lsb(6, 16) ip_id_behavior_choice(1) [ 6 2 ];
       header_crc
    reorder_ratio       =:= crc7(THIS.UVALUE, THIS.ULENGTH) reorder_choice              [ 7 2 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
               (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
  }

     // UOR-2-ID replacement
     COMPRESSED pt_2_seq_id
}

profile_1_flags2_enc(flag, ip_version)
{
       discriminator =:= '1100'
  UNCOMPRESSED {
    list_indicator        [ 4 1 ];
       ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5, 3)
    pt_indicator          [ 5 1 ];
       header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)
    pad_bit               [ 7 1 ];
       msn           =:= msn_lsb(8, 64)
    extension             [ 8 1 ];
       ENFORCE((ip_id_behavior.UVALUE
    df                    [ 1 ];
    time_stride_indicator [ 1 ];
  }

  COMPRESSED not_present{
    ENFORCE(flag == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE 0);
    ENFORCE(list_indicator.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     } 0);
    ENFORCE(pt_indicator.UVALUE == 0);
    ENFORCE(time_stride_indicator.UVALUE == 0);
    pad_bit      =:= static;
    extension    =:= static;
    df           =:= static;
  }

   ////////////////////////////////////////////
   // ESP profile
   ////////////////////////////////////////////

   // ttl_irregular_chain_flag is set by the user if the TTL/Hop Limit
   // of an outer header. The same value must be passed as an argument
   // to the ipv4/ipv6 encoding methods when extracting the irregular
   // chain items. The same applies to the tos_irregular_chain_flag
   esp_baseheader(profile,
                  ttl_irregular_chain_flag, tos_irregular_chain_flag)
   {
     UNCOMPRESSED v4

  COMPRESSED present {
       outer_headers
    ENFORCE(flag == 1);
    list_indicator =:= baseheader_outer_headers irregular(1)                  [ VARIABLE 1 ];
       version
    pt_indicator   =:= uncompressed_value(4, 4) irregular(1)                  [ 4 1 ];
       header_length
    time_stride_indicator =:= uncompressed_value(4, 5)  [ 4 ];
       tos_tc                                       [ 8 ];
       length                                       [ 16 ];
       ip_id irregular(1)           [ 16 1 ];
       rf
    pad_bit        =:= uncompressed_value(1, 0) irregular(1)                  [ 1 ];
       df
    extension      =:= irregular(1)                  [ 1 ];
       mf
    df             =:= uncompressed_value(1, 0) dont_fragment(ip_version)     [ 1 ];
       frag_offset
    reserved       =:= uncompressed_value(13, compressed_value(2, 0)        [ 13 ];
       ttl_hopl                                     [ 8 ];
       next_header                                  [ 8 ];
       checksum                                     [ 16 ];
       src_addr                                     [ 32 2 ];
       dest_addr
  }
}

profile_2_3_4_flags_enc(flag, ip_version)
{
  UNCOMPRESSED {
    ip_outer_indicator [ 32 1 ];
       extension_headers =:= baseheader_extension_headers
    repair_indicator   [ VARIABLE 1 ];
       spi
    df                 [ 32 1 ];
       sequence_number
    ip_id_behavior     [ 32 2 ];
       ENFORCE(msn.UVALUE
  }

  COMPRESSED not_present {
    ENFORCE(flag == sequence_number.UVALUE); 0);
    ENFORCE(ip_outer_indicator.CVALUE == 0);
    ENFORCE(repair_indicator.CVALUE == 0);
    df                 =:= static;
    ip_id_behavior     =:= static;
  }

     UNCOMPRESSED v6

  COMPRESSED present {
       outer_headers
    ENFORCE(flag == 1);
    ip_outer_indicator =:= baseheader_outer_headers irregular(1)              [ VARIABLE 1 ];
       version
    repair_indicator   =:= uncompressed_value(4, 6) irregular(1)              [ 4 1 ];
       version
    df                 =:= dont_fragment(ip_version) [ 4 1 ];
       tos_tc
    ip_id_behavior =:= ip_id_behavior_choice(1)      [ 8 2 ];
       flow_label
    reserved           =:= compressed_value(3, 0)    [ 20 3 ];
       payload_length
  }
}

profile_8_flags_enc(flag)
{
  UNCOMPRESSED {
    ip_outer_indicator  [ 16 1 ];
       next_header
    repair_indicator    [ 8 1 ];
       ttl_hopl
    df                  [ 8 1 ];
       src_addr
    ip_id_behavior      [ 128 2 ];
       dest_addr
    coverage_behavior   [ 128 2 ];
       extension_headers =:= baseheader_extension_headers [ VARIABLE ];
       spi             [ 32 ];
       sequence_number [ 32 ];
       ENFORCE(msn.UVALUE == (sequence_number.UVALUE % 65536));
       ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
  }

     CONTROL

  COMPRESSED not_present {
       ip_id_behavior [ 2 ];
       ENFORCE(profile
    ENFORCE(flag == PROFILE_ESP_0103);
     }

     DEFAULT {
       tos_tc 0);
    ENFORCE(ip_outer_indicator.CVALUE == 0);
    ENFORCE(repair_indicator.CVALUE == 0);
    df                  =:= static;
       dest_addr
    ip_id_behavior      =:= static;
       version
    coverage_behavior   =:= static;
       ttl_hopl
  }

  COMPRESSED present {
    ENFORCE(flag == 1);
    reserved            =:= static;
       src_addr compressed_value(1, 0)      [ 1 ];
    ip_outer_indicator  =:= static; irregular(1)                [ 1 ];
    repair_indicator    =:= irregular(1)                [ 1 ];
    df                  =:= static; dont_fragment(ip_version)   [ 1 ];
    ip_id_behavior      =:= static;
       payload_length  =:= inferred_ip_v6_length;
       checksum        =:= inferred_ip_v4_header_checksum;
       length ip_id_behavior_choice(1)    [ 2 ];
    coverage_behavior   =:= inferred_ip_v4_length;
       flow_label irregular(2)                [ 2 ];
  }
}

profile_7_flags2_enc(flag, ip_version)
{
  UNCOMPRESSED {
    list_indicator          [ 1 ];
    pt_indicator            [ 1 ];
    time_stride_indicator   [ 1 ];
    pad_bit                 [ 1 ];
    extension               [ 1 ];
    df                      [ 1 ];
    coverage_behavior       [ 2 ];
  }

  COMPRESSED not_present{
    ENFORCE(flag == 0);
    ENFORCE(list_indicator.CVALUE == 0);
    ENFORCE(pt_indicator.CVALUE == 0);
    ENFORCE(time_stride_indicator.CVALUE == 0);
    pad_bit             =:= static;
       next_header
    extension           =:= static;
       spi
    df                  =:= static;
       sequence_number
    coverage_behavior   =:= static;
       ENFORCE(ttl_irregular_chain_flag == 0);
       ENFORCE(tos_irregular_chain_flag == 0);
  }

     // Replacement for UOR-2-ext3

  COMPRESSED co_common present {
       discriminator        =:= '1111101'               [ 7 ];
       ip_id_indicator
    ENFORCE(flag == 1);
    list_indicator =:= irregular(1)                [ 1 ];
       df
    pt_indicator   =:= dont_fragment(version.UVALUE) irregular(1)                [ 1 ];
       header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       ttl_hopl_outer_flag
    time_stride_indicator =:= irregular(1)         [ 1 ];
       ttl_hopl_present
    pad_bit        =:= irregular(1)                [ 1 ];
       tos_tc_outer_flag
    extension      =:= irregular(1)                [ 1 ];
       tos_tc_present
    df             =:= irregular(1) dont_fragment(ip_version)   [ 1 ];
       reorder_ratio
    coverage_behavior =:= reorder_choice irregular(2)             [ 2 ];
       ip_id_behavior
  }
}

////////////////////////////////////////////
// RTP profile
////////////////////////////////////////////

rtp_baseheader(profile, ts_stride_value, time_stride_value,
               outer_ip_flag, repair_flag)
{
  UNCOMPRESSED v4 {
    ENFORCE(msn.UVALUE == sequence_number.UVALUE);
    outer_headers  =:= ip_id_behavior_choice baseheader_outer_headers  [ 2 VARIABLE ];
       control_crc3
    ip_version     =:= control_crc3 uncompressed_value(4, 4)  [ 3 4 ];
       reserved
    header_length  =:= compressed_value(5, 0) uncompressed_value(4, 5)  [ 5 4 ];
       sequence_number
    tos_tc                                       [ 8 ];
    length         =:=
           sdvl(sequence_number.ULENGTH) inferred_ip_v4_length     [ 8, 16, 24, 32 16 ];
    ip_id                =:=
         optional_ip_id_lsb(ip_id_behavior.UVALUE,
                            ip_id_indicator.CVALUE)                                        [ 0, 8, 16 ];
       tos_tc
    rf             =:=
         tos_tc_enc(tos_tc_present.CVALUE) uncompressed_value(1, 0)  [ 0, 8 1 ];
       ttl_hopl             =:=
         static_or_irreg(ttl_hopl_present.CVALUE,
                         ttl_hopl.ULENGTH)
    df                                           [ 0, 8 1 ];
       ENFORCE(ttl_irregular_chain_flag == ttl_hopl_outer_flag.UVALUE);
       ENFORCE(tos_irregular_chain_flag == tos_tc_outer_flag.UVALUE);
     }

     // UO-0
     COMPRESSED pt_0_crc3 {
       discriminator
    mf             =:= '0' uncompressed_value(1, 0)  [ 1 ];
       msn
    frag_offset    =:= msn_lsb(4, 4) uncompressed_value(13, 0) [ 4 13 ];
       header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH)
    ttl_hopl                                     [ 3 8 ];
       ip_id         =:= inferred_sequential_ip_id
    next_header                                  [ 0 8 ];
     }

     // New format, Type 0 with strong CRC and more SN bits
     COMPRESSED pt_0_crc7 {
       discriminator
    ip_checksum =:= '100' inferred_ip_v4_header_checksum [ 3 16 ];
       msn           =:= msn_lsb(6, 16)
    src_addr                                     [ 6 32 ];
       header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)
    dest_addr                                    [ 7 32 ];
       ip_id
    extension_headers =:= inferred_sequential_ip_id baseheader_extension_headers [ 0 VARIABLE ];
     }

     // UO-1-ID replacement (PT-1 only used for sequential)
     COMPRESSED pt_1_seq_id {
       discriminator =:= '101'
    src_port                                     [ 3 16 ];
       header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH)
    dst_port                                     [ 3 16 ];
       msn
    udp_length  =:= msn_lsb(6, 16) inferred_udp_length          [ 6 16 ];
       ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 4, 3)
    udp_checksum                                 [ 4 16 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     }

     // UOR-2 replacement
     COMPRESSED pt_2_rnd {
       discriminator
    rtp_version =:= '110' uncompressed_value(2, 2)     [ 3  2 ];
       msn           =:= msn_lsb(6, 16)
    pad_bit                                      [ 6  1 ];
       header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)
    extension                                    [ 7  1 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
               (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
     }

     // UOR-2-ID replacement
     COMPRESSED pt_2_seq_id {
       discriminator =:= '1100'
    cc                                           [  4 ];
       ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5, 3)
    marker                                       [ 5  1 ];
       header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)
    payload_type                                 [  7 ];
       msn           =:= msn_lsb(8, 64)
    sequence_number                              [ 8 16 ];
    timestamp                                    [ 32 ];
    ssrc                                         [ 32 ];
    csrc_list                                    [ VARIABLE ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     }
  }

   ////////////////////////////////////////////
   // IP-only profile
   ////////////////////////////////////////////

   // ttl_irregular_chain_flag is set by the user if the TTL/Hop Limit
   // of an outer header. The same value must be passed as an argument
   // to the ipv4/ipv6 encoding methods when extracting the irregular
   // chain items. The same applies to the tos_irregular_chain_flag
   iponly_baseheader(profile,
                     ttl_irregular_chain_flag, tos_irregular_chain_flag)
   {

  UNCOMPRESSED v4 v6 {
    ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    ENFORCE(msn.UVALUE == sequence_number.UVALUE);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
       version        =:= uncompressed_value(4, 4)  [ 4 ];
       header_length
    ip_version     =:= uncompressed_value(4, 5) 6)  [ 4 ];
    tos_tc                                       [ 8 ];
       length
    flow_label                                   [ 16 20 ];
       ip_id
    payload_length =:= inferred_ip_v6_length     [ 16 ];
       rf             =:= uncompressed_value(1, 0)
    next_header                                  [ 1 8 ];
       df
    ttl_hopl                                     [ 1 8 ];
       mf             =:= uncompressed_value(1, 0)
    src_addr                                     [ 1 128 ];
       frag_offset    =:= uncompressed_value(13, 0)
    dest_addr                                    [ 13 128 ];
       ttl_hopl
    extension_headers =:= baseheader_extension_headers [ 8 VARIABLE ];
       next_header
    src_port                                     [ 8 16 ];
       checksum
    dst_port                                     [ 16 ];
       src_addr
    udp_length     =:= inferred_udp_length       [ 32 16 ];
       dest_addr
    udp_checksum                                 [ 32 16 ];
       extension_headers
    rtp_version    =:= baseheader_extension_headers uncompressed_value(2, 2)  [ VARIABLE  2 ];
     }

     UNCOMPRESSED v6 {
       outer_headers  =:= baseheader_outer_headers
    pad_bit                                      [ VARIABLE  1 ];
       version =:= uncompressed_value(4, 6)
    extension                                    [ 4  1 ];
       version
    cc                                           [  4 ];
       tos_tc
    marker                                       [ 8  1 ];
       flow_label
    payload_type                                 [ 20  7 ];
       payload_length
    sequence_number                              [ 16 ];
       next_header
    timestamp                                    [ 8 32 ];
       ttl_hopl
    ssrc                                         [ 8 32 ];
       src_addr
    csrc_list                                    [ 128 VARIABLE ];
       dest_addr
  }

  CONTROL {
    ENFORCE(time_stride_value == time_stride.UVALUE);
    ENFORCE(ts_stride.UVALUE == ts_stride_value);
    ENFORCE(profile == PROFILE_RTP_0101);
    ts_stride                           [ 128 32 ];
       extension_headers
    time_stride                         [ 32 ];
    ts_scaled                           [ 32 ];
    ts_offset =:= baseheader_extension_headers field_scaling(ts_stride.UVALUE, ts_scaled.UVALUE,
      timestamp.UVALUE) [ VARIABLE 32 ];
       ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
     }

     CONTROL {
    ip_id_behavior                      [  2 ];
       ENFORCE(profile == PROFILE_IP_0104);
  }

  INITIAL {
    ts_stride     =:= uncompressed_value(32, 0);
    time_stride   =:= uncompressed_value(32, 0);
  }

  DEFAULT {
    ENFORCE(outer_ip_flag == 0);
    ENFORCE(repair_flag == 0);
    tos_tc          =:= static;
    dest_addr       =:= static;
       version        =:= static;
    ttl_hopl        =:= static;
    src_addr        =:= static;
    df              =:= static;
    ip_id_behavior  =:= static;
       payload_length
    flow_label      =:= inferred_ip_v6_length;
       checksum static;
    next_header     =:= inferred_ip_v4_header_checksum;
       length static;
    src_port        =:= inferred_ip_v4_length;
       flow_label static;
    dst_port        =:= static;
       next_header
    udp_checksum    =:= irregular(16);
    pad_bit         =:= static;
       ENFORCE(ttl_irregular_chain_flag == 0);
       ENFORCE(tos_irregular_chain_flag ==
    extension       =:= static;
    cc              =:= static;
    // When marker not present in packets, it is assumed 0
    marker          =:= uncompressed_value(1, 0);
    payload_type    =:= static;
    sequence_number =:= static;
    timestamp       =:= static;
    ssrc            =:= static;
    csrc_list       =:= static;
  }

  // Replacement for UOR-2-ext3
  COMPRESSED co_common {
    ENFORCE(repair_flag == 0);
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '1111101' '11111010'               [ 7 8 ];
       ip_id_indicator
    marker               =:= irregular(1)             [ 1 ];
       reorder_ratio        =:= reorder_choice          [ 2 ];
       msn                  =:= msn_lsb(6, 16)          [ 6 ];
       df           =:= dont_fragment(version.UVALUE)   [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
       ttl_hopl_outer_flag
    flags1_indicator     =:= irregular(1)             [ 1 ];
       ttl_hopl_present
    flags2_indicator     =:= irregular(1)             [ 1 ];
       tos_tc_outer_flag
    tsc_indicator        =:= irregular(1)             [ 1 ];
       ip_id_behavior
    tss_indicator        =:= ip_id_behavior_choice irregular(1)             [ 2 1 ];
       control_crc3
    ip_id_indicator      =:= irregular(1)             [ 1 ];
    control_crc3         =:= control_crc3_encoding    [ 3 ];
       tos_tc_present

    outer_ip_indicator : repair_indicator : ttl_hopl_indicator :
      tos_tc_indicator : ip_id_behavior : reorder_ratio =:= irregular(1)
      profile_1_7_flags1_enc(flags1_indicator.CVALUE) [ 1 0, 8 ];
       reserved
    list_indicator : pt_indicator : tis_indicator :pad_bit :
      extension : df =:= compressed_value(7, 0) profile_1_flags2_enc(flags2_indicator.CVALUE,
      ip_version.UVALUE)                              [ 7 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 0, 8, 16 ];
    tos_tc =:=
         tos_tc_enc(tos_tc_present.CVALUE) static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:=
         static_or_irreg(ttl_hopl_present.CVALUE, static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 0, 8 ];

       ENFORCE(ttl_irregular_chain_flag == ttl_hopl_outer_flag.UVALUE);
       ENFORCE(tos_irregular_chain_flag
    payload_type =:= optional_pt(pt_indicator)        [ 0, 8 ];
    sequence_number =:= sdvl_lsb(sequence_number.ULENGTH) [ VARIABLE ];
    ts_scaled =:= variable_scaled_timestamp(tss_indicator.CVALUE,
      tsc_indicator, ts_stride.UVALUE)                    [ VARIABLE ];
    timestamp =:= variable_unscaled_timestamp(tss_indicator.CVALUE,
      tsc_indicator)                                      [ VARIABLE ];
    ts_stride =:= sdvl_or_static(tss_indicator.CVALUE)    [ VARIABLE ];
    time_stride =:= sdvl_or_static(tis_indicator.CVALUE)  [ VARIABLE ];
    csrc_list =:= csrc_list_presence(list_indicator.CVALUE,
      cc.UVALUE)                                          [ VARIABLE ];
  }

  // Context repair (IR-DYN replacement).
  COMPRESSED co_repair {
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == tos_tc_outer_flag.UVALUE); repair_indicator.CVALUE);
    discriminator        =:= '11111011'               [ 8 ];
    marker               =:= irregular(1)             [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
    flags1_indicator     =:= irregular(1)             [ 1 ];
    flags2_indicator     =:= irregular(1)             [ 1 ];
    timestamp_indicator  =:= irregular(1)             [ 1 ];
    tss_indicator        =:= irregular(1)             [ 1 ];
    ip_id_indicator      =:= irregular(1)             [ 1 ];
    control_crc3         =:= control_crc3_encoding    [ 3 ];

    outer_ip_indicator : repair_indicator : ttl_hopl_indicator :
      tos_tc_indicator : ip_id_behavior : reorder_ratio =:=
      profile_1_7_flags1_enc(flags1_indicator.CVALUE) [ 0, 8 ];
    list_indicator : pt_indicator : pad_bit : extension : df :
      tis_indicator =:= profile_1_flags2_enc(flags2_indicator.CVALUE,
      ip_version.UVALUE)                              [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 0, 8, 16 ];
    tos_tc =:=
      static_or_irreg(tos_tc_indicator.CVALUE, 8)     [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 0, 8 ];
    payload_type =:= optional_pt(pt_indicator)        [ 0, 8 ];
    sequence_number      =:= irregular(16)            [ 16 ];
    timestamp            =:=
      irregular_or_nothing(timestamp_indicator)       [ 0, 32 ];
    ts_stride            =:=
      sdvl_or_static(tss_indicator)                   [ VARIABLE ];
    time_stride          =:=
      sdvl_or_static(tis_indicator)                   [ VARIABLE ];
    csrc_list            =:=
      csrc_list_presence(list_indicator.CVALUE, cc.UVALUE) [ VARIABLE ];
  }

  // UO-0
  COMPRESSED pt_0_crc3 {
    discriminator =:= '0'                             [ 1 ];
    msn           =:= msn_lsb(4, 4) msn_lsb(4)                      [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // New format, Type 0 with strong CRC and more SN bits
  COMPRESSED pt_0_crc7 {
    discriminator =:= '100'                           [ 3 ];
    msn           =:= msn_lsb(6, 16) msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // UO-1-ID UO-1 replacement (PT-1 only used for sequential)
  COMPRESSED pt_1_seq_id pt_1_rnd {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '101'                            [ 3 ];
       header_crc
    msn           =:= crc3(THIS.UVALUE, THIS.ULENGTH) msn_lsb(5)                       [ 3 5 ];
       msn
    marker        =:= msn_lsb(6, 16) irregular(1)                     [ 6 1 ];
       ip_id
    ts_scaled     =:= ip_id_lsb(ip_id_behavior.UVALUE, 4, 3) scaled_ts_lsb(time_stride.UVALUE, 4) [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH)  [ 3 ];
  }

  // UO-1-ID replacement
  COMPRESSED pt_1_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     }

     // UOR-2 replacement
     COMPRESSED pt_2_rnd {
    discriminator =:= '110' '1010'                          [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    msn           =:= msn_lsb(6, 16) msn_lsb(5)                      [ 6 5 ];
       header_crc
    ip_id =:= crc7(THIS.UVALUE, ip_id_lsb(ip_id_behavior.UVALUE, 4)     [ 4 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
  }

  // UO-1-TS replacement
  COMPRESSED pt_1_seq_ts {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1011'                           [ 4 ];
    marker        =:= irregular(1)                     [ 1 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH)  [ 7 3 ];
    msn           =:= msn_lsb(4)                       [ 4 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 4) [ 4 ];
  }

  // UOR-2 replacement
  COMPRESSED pt_2_rnd {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '110'                             [ 3 ];
    msn           =:= msn_lsb(7)                        [ 7 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 6) [ 6 ];
    marker        =:= irregular(1)                      [ 1 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)   [ 7 ];
  }

  // UOR-2-ID replacement
  COMPRESSED pt_2_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1100' '11000'                         [ 4 5 ];
    msn           =:= msn_lsb(7)                      [ 7 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5, 3) 5)     [ 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
  }

  // UOR-2-ID-ext1 replacement (both TS and IP-ID)
  COMPRESSED pt_2_seq_both {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '11001'                           [ 5 ];
    msn           =:= msn_lsb(8, 64) msn_lsb(7)                        [ 7 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5)       [ 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)   [ 7 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 8) [ 8 ];
  }

  // UOR-2-TS replacement
  COMPRESSED pt_2_seq_ts {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1101'                           [ 4 ];
    msn           =:= msn_lsb(7)                       [ 7 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 5) [ 5 ];
    marker        =:= irregular(1)                     [ 1 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
  }
}

////////////////////////////////////////////
// UDP-lite/RTP UDP profile
////////////////////////////////////////////

   // ttl_irregular_chain_flag is set by the user if the TTL/Hop Limit
   // of an outer header. The same value must be passed as an argument
   // to the ipv4/ipv6 encoding methods when extracting the irregular
   // chain items. The same applies to the tos_irregular_chain_flag
   udplite_rtp_baseheader(profile, ts_stride_value,
                  ttl_irregular_chain_flag, tos_irregular_chain_flag)

udp_baseheader(profile, outer_ip_flag, repair_flag)
{
  UNCOMPRESSED v4 {
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
       version
    ip_version     =:= uncompressed_value(4, 4)  [ 4 ];
    header_length  =:= uncompressed_value(4, 5)  [ 4 ];
    tos_tc                                       [ 8 ];
    length         =:= inferred_ip_v4_length     [ 16 ];
    ip_id                                        [ 16 ];
    rf             =:= uncompressed_value(1, 0)  [ 1 ];
    df                                           [ 1 ];
    mf             =:= uncompressed_value(1, 0)  [ 1 ];
    frag_offset    =:= uncompressed_value(13, 0) [ 13 ];
    ttl_hopl                                     [ 8 ];
    next_header                                  [ 8 ];
       checksum
    ip_checksum =:= inferred_ip_v4_header_checksum [ 16 ];
    src_addr                                     [ 32 ];
    dest_addr                                    [ 32 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
    src_port                                     [ 16 ];
    dst_port                                     [ 16 ];
       checksum_coverage                    [ 16 ];
       checksum                             [ 16 ];
       version
    udp_length     =:= uncompressed_value(2, 0) [  2 ];
       pad_bit                              [  1 ];
       extension                            [  1 ];
       cc                                   [  4 ];
       marker                               [  1 ];
       payload_type                         [  7 ];
       sequence_number inferred_udp_length       [ 16 ];
       timestamp                            [ 32 ];
       ssrc                                 [ 32 ];
       csrc_list
    udp_checksum                                 [ VARIABLE 16 ];
       ENFORCE(msn.UVALUE == sequence_number.UVALUE);
  }

  UNCOMPRESSED v6 {
    ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
       version
    ip_version     =:= uncompressed_value(4, 6)  [ 4 ];
       version                              [ 4 ];
    tos_tc                                       [ 8 ];
    flow_label                                   [ 20 ];
    payload_length =:= inferred_ip_v6_length     [ 16 ];
    next_header                                  [ 8 ];
    ttl_hopl                                     [ 8 ];
    src_addr                                     [ 128 ];
    dest_addr                                    [ 128 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
    src_port                                     [ 16 ];
    dst_port                                     [ 16 ];
       checksum_coverage                    [ 16 ];
       checksum                             [ 16 ];
       version
    udp_length     =:= uncompressed_value(2, 0) [  2 ];
       pad_bit                              [  1 ];
       extension                            [  1 ];
       cc                                   [  4 ];
       marker                               [  1 ];
       payload_type                         [  7 ];
       sequence_number inferred_udp_length       [ 16 ];
       timestamp                            [ 32 ];
       ssrc                                 [ 32 ];
       csrc_list
    udp_checksum                                 [ VARIABLE 16 ];
       ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
  }

  CONTROL {
    ENFORCE(profile == PROFILE_UDP_0102);
    ip_id_behavior [ 2 ];
       coverage_behavior [  2 ];
       ts_stride                           [ 32 ];
       ts_scaled                           [ 32 ];
       ts_offset =:=
           field_scaling(ts_stride.UVALUE, ts_scaled.UVALUE,
                         timestamp.UVALUE) [ 32 ];
       ENFORCE(ts_stride.UVALUE == ts_stride_value);
       ENFORCE(profile == PROFILE_RTP_0107);
  }

  DEFAULT {
    ENFORCE(outer_ip_flag == 0);
    ENFORCE(repair_flag == 0);
    tos_tc         =:= static;
    dest_addr      =:= static;
       version
    ip_version     =:= static;
    ttl_hopl       =:= static;
    src_addr       =:= static;
    df             =:= static;
    ip_id_behavior =:= static;
       payload_length    =:= inferred_ip_v6_length;
       checksum          =:= inferred_ip_v4_header_checksum;
       length            =:= inferred_ip_v4_length;
    flow_label     =:= static;
    next_header    =:= static;
    src_port       =:= static;
    dst_port       =:= static;
       checksum_coverage =:= irregular(16);
       checksum
    udp_checksum   =:= irregular(16);
       pad_bit           =:= static;
       extension         =:= static;
       cc                =:= static;
       // When marker not present in packets, it is assumed 0
       marker            =:= uncompressed_value(1, 0);
       payload_type      =:= static;
       sequence_number   =:= static;
       timestamp         =:= static;
       ssrc              =:= static;
       csrc_list         =:= static;
       ENFORCE(ttl_irregular_chain_flag == 0);
       ENFORCE(tos_irregular_chain_flag == 0);
  }

  // Replacement for UOR-2-ext3
  COMPRESSED co_common {
    ENFORCE(repair_flag == 0);
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '1111101' '11111010'               [ 7 8 ];
       marker
    ip_id_indicator      =:= irregular(1)             [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
       ip_id_indicator
    flags_indicator      =:= irregular(1)             [ 1 ];
       ip_id_behavior
    ttl_hopl_indicator   =:= ip_id_behavior_choice irregular(1)             [ 2 1 ];
       reorder_ratio
    tos_tc_indicator     =:= reorder_choice irregular(1)             [ 2 1 ];
       df
    reorder_ratio        =:= dont_fragment(version.UVALUE) reorder_choice           [ 1 2 ];
    control_crc3         =:= control_crc3 control_crc3_encoding    [ 3 ];
       ttl_hopl_outer_flag
    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior     =:= irregular(1) profile_2_3_4_flags_enc(
      flags_indicator.CVALUE, ip_version.UVALUE)      [ 1 0, 8 ];
       ttl_hopl_present
    ip_id =:= irregular(1) optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 1 0, 8, 16 ];
       tos_tc_outer_flag
    tos_tc =:= irregular(1) static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 1 0, 8 ];
       tos_tc_present
    ttl_hopl =:= irregular(1) static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 1 0, 8 ];
       ts_indicator
    msn                  =:= irregular(2) msn_lsb(8)               [ 2 8 ];
       tss_indicator
  }

  // Context repair (IR-DYN replacement).
  COMPRESSED co_repair {
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= irregular(2) '11111011'               [ 2 8 ];
       pt_present
    ip_id_indicator      =:= irregular(1)             [ 1 ];
       list_present
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
    flags_indicator      =:= irregular(1)             [ 1 ];
       pad_bit
    ttl_hopl_indicator   =:= irregular(1)             [ 1 ];
       extension
    tos_tc_indicator     =:= irregular(1)             [ 1 ];
       coverage_behavior
    reorder_ratio        =:= irregular(2) reorder_choice           [ 2 ];
       reserved
    control_crc3         =:= compressed_value(4, 0) control_crc3_encoding    [ 4 3 ];
       sequence_number
    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior =:= sdvl(sequence_number.ULENGTH) profile_2_3_4_flags_enc(
      flags_indicator.CVALUE, ip_version.UVALUE)      [ 8, 16 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 0, 8, 16 ];
    tos_tc =:=
         tos_tc_enc(tos_tc_present.CVALUE) static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:=
         static_or_irreg(ttl_hopl_present.CVALUE, static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 0, 8 ];
       // Either scaled or unscaled timestamp
       ts_scaled            =:=
           optional_scaled_timestamp(tss_indicator,
                                     tsc_indicator)     [ VARIABLE ];
       ts_scaled            =:=
           optional_scaled_timestamp(tss_indicator,
                                     tsc_indicator)     [ VARIABLE ];
       payload_type         =:= optional_pt(pt_present) [ 0, 8 ];
       ts_stride            =:=
           optional_stride(tss_indicator,
                           ts_stride_value)             [ VARIABLE ];
       csrc_list
    msn                  =:= list_csrc(cc.UVALUE) irregular(16)            [ VARIABLE 16 ];

       ENFORCE(ttl_irregular_chain_flag == ttl_hopl_outer_flag.UVALUE);
       ENFORCE(tos_irregular_chain_flag == tos_tc_outer_flag.UVALUE);
  }

  // UO-0
  COMPRESSED pt_0_crc3 {
    discriminator =:= '0'                             [ 1 ];
    msn           =:= msn_lsb(4, 4) msn_lsb(4)                      [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
       timestamp     =:= inferred_scaled_field           [ 0 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // New format, Type 0 with strong CRC and more SN bits
  COMPRESSED pt_0_crc7 {
    discriminator =:= '100'                           [ 3 ];
    msn           =:= msn_lsb(6, 16) msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       timestamp     =:= inferred_scaled_field           [ 0 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // UO-1 UO-1-ID replacement (PT-1 only used for sequential)
  COMPRESSED pt_1_rnd pt_1_seq_id {
       discriminator =:= '101'                           [ 3 ];
       msn           =:= msn_lsb(5, 8)                   [ 5 ];
       marker        =:= irregular(1)                    [ 1 ];
       ts_scaled     =:= lsb(4, 3)                       [ 4 ];
       header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
     }

     // UO-1-ID replacement
     COMPRESSED pt_1_seq_id {
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1010' '101'                           [ 4 3 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    msn           =:= msn_lsb(5, 8) msn_lsb(6)                      [ 5 6 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 4, 3) 4)     [ 4 ];
       timestamp     =:= inferred_scaled_field           [ 0 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }

  // UO-1-TS UOR-2 replacement
  COMPRESSED pt_1_seq_ts pt_2_rnd {
       discriminator =:= '1011'                          [ 4 ];
       marker        =:= irregular(1)                    [ 1 ];
       header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
       msn           =:= msn_lsb(4, 4)                   [ 4 ];
       ts_scaled     =:= lsb(4, 3)                       [ 4 ];
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     }

     // UOR-2 replacement
     COMPRESSED pt_2_rnd { IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '110'                           [ 3 ];
    msn           =:= msn_lsb(7, 32)                  [ 7 ];
       ts_scaled     =:= lsb(6, 15) msn_lsb(6)                      [ 6 ];
       marker        =:= irregular(1)                    [ 1 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
               (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
  }

  // UOR-2-ID replacement
  COMPRESSED pt_2_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1100'                          [ 4 ];
       msn           =:= msn_lsb(7, 32)                  [ 7 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 6, 3) 5)     [ 6 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       timestamp
    msn           =:= inferred_scaled_field msn_lsb(8)                      [ 0 8 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
     }

     // UOR-2-TS replacement
     COMPRESSED pt_2_seq_ts {
       discriminator =:= '1101'                          [ 4 ];
       msn           =:= msn_lsb(7, 32)                  [ 7 ];
       ts_scaled     =:= lsb(5, 7)                       [ 5 ];
       marker        =:= irregular(1)                    [ 1 ];
       header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }
}

////////////////////////////////////////////
// UDP-lite ESP profile
////////////////////////////////////////////

   // ttl_irregular_chain_flag is set by the user if the TTL/Hop Limit
   // of an outer header. The same value must be passed as an argument
   // to the ipv4/ipv6 encoding methods when extracting the irregular
   // chain items. The same applies to the tos_irregular_chain_flag
   udplite_baseheader(profile,
                  ttl_irregular_chain_flag, tos_irregular_chain_flag)

esp_baseheader(profile, outer_ip_flag, repair_flag)
{
  UNCOMPRESSED v4 {
    ENFORCE(msn.UVALUE == sequence_number.UVALUE % 65536);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
       version
    ip_version     =:= uncompressed_value(4, 4)  [ 4 ];
    header_length  =:= uncompressed_value(4, 5)  [ 4 ];
    tos_tc                                       [ 8 ];
    length         =:= inferred_ip_v4_length     [ 16 ];
    ip_id                                        [ 16 ];
    rf             =:= uncompressed_value(1, 0)  [ 1 ];
    df                                           [ 1 ];
    mf             =:= uncompressed_value(1, 0)  [ 1 ];
    frag_offset    =:= uncompressed_value(13, 0) [ 13 ];
    ttl_hopl                                     [ 8 ];
    next_header                                  [ 8 ];
       checksum
    ip_checksum =:= inferred_ip_v4_header_checksum [ 16 ];
    src_addr                                     [ 32 ];
    dest_addr                                    [ 32 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
       src_port                                     [ 16 ];
       dst_port                                     [ 16 ];
       checksum_coverage
    spi                                          [ 16 32 ];
       checksum
    sequence_number                              [ 16 32 ];
  }

  UNCOMPRESSED v6 {
    ENFORCE(msn.UVALUE == (sequence_number.UVALUE % 65536));
    ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
       version
    ip_version     =:= uncompressed_value(4, 6)  [ 4 ];
       version                              [ 4 ];
    tos_tc                                       [ 8 ];
    flow_label                                   [ 20 ];
    payload_length =:= inferred_ip_v6_length     [ 16 ];
    next_header                                  [ 8 ];
    ttl_hopl                                     [ 8 ];
    src_addr                                     [ 128 ];
    dest_addr                                    [ 128 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
       src_port                             [ 16 ];
       dst_port                             [ 16 ];
       checksum_coverage
    spi                                          [ 16 32 ];
       checksum
    sequence_number                              [ 16 32 ];
       ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
  }

  CONTROL {
    ENFORCE(profile == PROFILE_ESP_0103);
    ip_id_behavior [ 2 ];
       coverage_behavior [ 2 ];
       ENFORCE(profile == PROFILE_UDPLITE_0108);
  }

  DEFAULT {
    ENFORCE(outer_ip_indicator == 0);
    ENFORCE(repair_flag == 0);
    tos_tc          =:= static;
    dest_addr       =:= static;
       version           =:= static;
    ttl_hopl        =:= static;
    src_addr        =:= static;
    df              =:= static;
    ip_id_behavior  =:= static;
       payload_length    =:= inferred_ip_v6_length;
       checksum          =:= inferred_ip_v4_header_checksum;
       length            =:= inferred_ip_v4_length;
    flow_label      =:= static;
    next_header     =:= static;
       src_port
    spi             =:= static;
       dst_port
    sequence_number =:= static;
       checksum_coverage =:= irregular(16);
       checksum          =:= irregular(16);
       ENFORCE(ttl_irregular_chain_flag == 0);
       ENFORCE(tos_irregular_chain_flag == 0);
  }

  // Replacement for UOR-2-ext3
  COMPRESSED co_common {
    ENFORCE(repair_flag == 0);
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '1111101' '11111010'              [ 7 8 ];
    ip_id_indicator      =:= irregular(1)            [ 1 ];
       reorder_ratio        =:= reorder_choice          [ 2 ];
       msn                  =:= msn_lsb(6, 16)          [ 6 ];
       df            =:= dont_fragment(version.UVALUE)  [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       ttl_hopl_outer_flag
    flags_indicator      =:= irregular(1)            [ 1 ];
       ttl_hopl_present
    ttl_hopl_indicator   =:= irregular(1)            [ 1 ];
       tos_tc_outer_flag
    tos_tc_indicator     =:= irregular(1)            [ 1 ];
       ip_id_behavior
    reorder_ratio        =:= ip_id_behavior_choice reorder_choice          [ 2 ];
    control_crc3         =:= control_crc3 control_crc3_encoding   [ 3 ];
       tos_tc_present       =:= irregular(1)            [ 1 ];
       coverage_behavior    =:= irregular(2)            [ 2 ];
       reserved

    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior =:= compressed_value(5, 0) profile_2_3_4_flags_enc(
      flags_indicator.CVALUE, ip_version.UVALUE)     [ 5 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                        [ 0, 8, 16 ];
    tos_tc =:=
         tos_tc_enc(tos_tc_present.CVALUE) static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:=
         static_or_irreg(ttl_hopl_present.CVALUE, static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                              [ 0, 8 ];

       ENFORCE(ttl_irregular_chain_flag == ttl_hopl_outer_flag.UVALUE);
       ENFORCE(tos_irregular_chain_flag == tos_tc_outer_flag.UVALUE);
    sequence_number =:= sdvl_lsb(sequence_number.ULENGTH) [ VARIABLE ];
  }

  // UO-0 Context repair (IR-DYN replacement).
  COMPRESSED pt_0_crc3 co_repair {
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '0' '11111011'              [ 1 8 ];
       msn
    discriminator        =:= msn_lsb(4, 4) '11111010'              [ 4 8 ];
    ip_id_indicator      =:= irregular(1)            [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    flags_indicator      =:= irregular(1)            [ 1 ];
    ttl_hopl_indicator   =:= irregular(1)            [ 1 ];
    tos_tc_indicator     =:= irregular(1)            [ 1 ];
    reorder_ratio        =:= reorder_choice          [ 2 ];
    control_crc3         =:= control_crc3_encoding   [ 3 ];

    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior =:= profile_2_3_4_flags_enc(
      flags_indicator.CVALUE, ip_version.UVALUE)     [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE) [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                              [ 0, 8 ];
    sequence_number =:= irregular(32)                [ 32 ];
  }

  // UO-0
  COMPRESSED pt_0_crc3 {
    discriminator =:= '0'                             [ 1 ];
    msn           =:= msn_lsb(4)                      [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // New format, Type 0 with strong CRC and more SN bits
  COMPRESSED pt_0_crc7 {
    discriminator =:= '100'                           [ 3 ];
    msn           =:= msn_lsb(6, 16) msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // UO-1-ID replacement (PT-1 only used for sequential)
  COMPRESSED pt_1_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '101'                           [ 3 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    msn           =:= msn_lsb(6, 16) msn_lsb(6)                      [ 6 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 4, 3) 4)     [ 4 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }

  // UOR-2 replacement
  COMPRESSED pt_2_rnd {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '110'                           [ 3 ];
    msn           =:= msn_lsb(6, 16) msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
               (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
  }

  // UOR-2-ID replacement
  COMPRESSED pt_2_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1100'                          [ 4 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5, 3) 5)     [ 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    msn           =:= msn_lsb(8, 64) msn_lsb(8)                      [ 8 ];
       ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
               (ip_id_behavior.UVALUE ==
                IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
  }
}

6.7.  Feedback Formats and Options

6.7.1.  Feedback Formats

   This section describes the feedback format for ROHCv2 profiles, using
   the formats described in section 5.2.3 of
   [I-D.ietf-rohc-rfc3095bis-framework].

   All feedback formats carry a field labelled MSN, which contain LSBs
   of the MSN described in Section 6.2.1.  The sequence number to use is
   the MSN corresponding to the last header that was successfully CRC-8
   validated or CRC verified.

   FEEDBACK-1

        0   1   2   3

////////////////////////////////////////////
// IP-only profile
////////////////////////////////////////////

iponly_baseheader(profile, outer_ip_flag, repair_flag)
{
  UNCOMPRESSED v4 {
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
    ip_version     =:= uncompressed_value(4, 4)  [ 4   5   6   7
      +---+---+---+---+---+---+---+---+
      |              MSN              |
      +---+---+---+---+---+---+---+---+

      MSN: The lsb-encoded master sequence number.

   A FEEDBACK-1 is an ACK.  In order to send a NACK or a STATIC-NACK,
   FEEDBACK-2 must be used.

   FEEDBACK-2

        0 ];
    header_length  =:= uncompressed_value(4, 5)  [ 4 ];
    tos_tc                                       [ 8 ];
    length         =:= inferred_ip_v4_length     [ 16 ];
    ip_id                                        [ 16 ];
    rf             =:= uncompressed_value(1, 0)  [ 1   2   3 ];
    df                                           [ 1 ];
    mf             =:= uncompressed_value(1, 0)  [ 1 ];
    frag_offset    =:= uncompressed_value(13, 0) [ 13 ];
    ttl_hopl                                     [ 8 ];
    next_header                                  [ 8 ];
    ip_checksum =:= inferred_ip_v4_header_checksum [ 16 ];
    src_addr                                     [ 32 ];
    dest_addr                                    [ 32 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
  }

  UNCOMPRESSED v6 {
    ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    outer_headers     =:= baseheader_outer_headers     [ VARIABLE ];
    ip_version        =:= uncompressed_value(4, 6)     [ 4   5   6 ];
    tos_tc                                             [ 8 ];
    flow_label                                         [ 20 ];
    payload_length    =:= inferred_ip_v6_length        [ 16 ];
    next_header                                        [ 8 ];
    ttl_hopl                                           [ 8 ];
    src_addr                                           [ 128 ];
    dest_addr                                          [ 128 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
  }

  CONTROL {
    ENFORCE(profile == PROFILE_IP_0104);
    ip_id_behavior [ 2 ];
  }

  DEFAULT {
    ENFORCE(outer_ip_indicator == 0);
    ENFORCE(repair_flag == 0);
    tos_tc         =:= static;
    dest_addr      =:= static;
    ttl_hopl       =:= static;
    src_addr       =:= static;
    df             =:= static;
    ip_id_behavior =:= static;
    flow_label     =:= static;
    next_header    =:= static;
  }

  // Replacement for UOR-2-ext3
  COMPRESSED co_common {
    ENFORCE(repair_flag == 0);
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '11111010'               [ 8 ];
    ip_id_indicator      =:= irregular(1)             [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7
      +---+---+---+---+---+---+---+---+
      |Acktype|          MSN          |
      +---+---+---+---+---+---+---+---+
      |              MSN              |
      +---+---+---+---+---+---+---+---+
      |              CRC              |
      +---+---+---+---+---+---+---+---+
      /       Feedback options        /
      +---+---+---+---+---+---+---+---+

      Acktype:

         0 = ACK ];
    flags_indicator      =:= irregular(1)             [ 1 = NACK ];
    ttl_hopl_indicator   =:= irregular(1)             [ 1 ];
    tos_tc_indicator     =:= irregular(1)             [ 1 ];
    reorder_ratio        =:= reorder_choice           [ 2 = STATIC-NACK
         3 is reserved (MUST NOT be used for parsability)

      MSN: The lsb-encoded master sequence number.

      CRC: 8-bit CRC computed over the entire feedback payload including
      any CID fields but excluding the packet type, the 'Size' field and
      the 'Code' octet, using the polynomial defined in
      [I-D.ietf-rohc-rfc3095bis-framework].  If the CID is given ];
    control_crc3         =:= control_crc3_encoding    [ 3 ];
    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior     =:= profile_2_3_4_flags_enc(
      flags_indicator.CVALUE, ip_version.UVALUE)      [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:=  static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 0, 8 ];
    msn                  =:= msn_lsb(8)               [ 8 ];
  }

  // Context repair (IR-DYN replacement).
  COMPRESSED co_repair {
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '11111011'               [ 8 ];
    ip_id_indicator      =:= irregular(1)             [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
    flags_indicator      =:= irregular(1)             [ 1 ];
    ttl_hopl_indicator   =:= irregular(1)             [ 1 ];
    tos_tc_indicator     =:= irregular(1)             [ 1 ];
    reorder_ratio        =:= reorder_choice           [ 2 ];
    control_crc3         =:= control_crc3_encoding    [ 3 ];
    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior   =:= profile_2_3_4_flags_enc(
      flags_indicator.CVALUE, ip_version.UVALUE)      [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 0, 8 ];
    msn                  =:= irregular(16)            [ 16 ];
  }

  // UO-0
  COMPRESSED pt_0_crc3 {
    discriminator =:= '0'                             [ 1 ];
    msn           =:= msn_lsb(4)                      [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // New format, Type 0 with an
      Add-CID octet, the Add-CID octet immediately precedes the
      FEEDBACK-1 or FEEDBACK-2 format.  For purposes of computing the
      CRC, the CRC field is zero.

      Feedback options: A variable number of feedback options, see
      Section 6.7.2.  Options may appear in any order.

   A FEEDBACK-2 of type NACK or STATIC-NACK is always implicitely an
   acknowlegement for a successfully decompressed packet, which packet
   corresponds to the MSN of the feedback element, unless the MSN-NOT-
   VALID option Section 6.7.2.2 appears in the feedback element.

   The FEEDBACK-2 format always carry a strong CRC and is thus more robust than
   the FEEDBACK-1 format.  When receiving FEEDBACK-2, the compressor
   MUST verify the information by computing the CRC and comparing the
   result with the CRC carried in the feedback format.  If the two are
   not identical, the feedback element MUST be discarded.

6.7.2.  Feedback Options

   A feedback option has variable length and the following general
   format:

        0   1   2 SN bits
  COMPRESSED pt_0_crc7 {
    discriminator =:= '100'                           [ 3   4   5 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7
      +---+---+---+---+---+---+---+---+
      |   Opt Type    |    Opt Len    |
      +---+---+---+---+---+---+---+---+
      /          option data          /  Opt Length (octets)
      +---+---+---+---+---+---+---+---+

   The CRC option contains an 8-bit CRC computed over the entire
   feedback payload including any CID fields but excluding the packet
   type, the 'Size' field and the 'Code' octet, using the polynomial of
   [I-D.ietf-rohc-rfc3095bis-framework], section 5.3.1.1.

6.7.2.1.  The REJECT option

   The REJECT option informs the compressor that the decompressor does
   not have sufficient resources to handle the flow.

      +---+---+---+---+---+---+---+---+
      |  Opt Type = 2 |  Opt Len = ];
    ip_id         =:= inferred_sequential_ip_id       [ 0  |
      +---+---+---+---+---+---+---+---+

   When receiving a REJECT option, the compressor MUST stop compressing
   the packet flow, and SHOULD refrain from attempting to increase the
   number of compressed packet flows ];
  }

  // UO-1-ID replacement (PT-1 only used for some time.  Any FEEDBACK packet
   carrying a REJECT option MUST also carry a CRC option.  The REJECT
   option MUST NOT appear more than once in the FEEDBACK-2 format,
   otherwise the decompressor MUST discard the entire feedback element.

6.7.2.2.  The MSN-NOT-VALID option

   The MSN-NOT-VALID option indicates that the MSN of the feedback is
   not valid.

      +---+---+---+---+---+---+---+---+
      |  Opt Type = sequential)
  COMPRESSED pt_1_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '101'                           [ 3 |  Opt Len = 0  |
      +---+---+---+---+---+---+---+---+

   A compressor MUST NOT use the MSN of the feedback to find the
   corresponding sent header when this option is present.  Consequently,
   a NACK or a STATIC-NACK feedback type sent with the MSN-NOT-VALID
   option is equivalent to a STATIC-NACK with respect to the type of
   context repair requested by the decompressor.

   The MSN-NOT-VALID option MUST NOT appear more than once in the
   FEEDBACK-2 format and MUST NOT appear in the same feedback element as
   the MSN option, otherwise the decompressor MUST discard the entire
   feedback element.

6.7.2.3.  The MSN option

   The MSN option provides 8 additional bits of MSN.

      +---+---+---+---+---+---+---+---+
      |  Opt Type = ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 4)     [ 4 |  Opt Len = 1  |
      +---+---+---+---+---+---+---+---+
      |              MSN              |
      +---+---+---+---+---+---+---+---+

   the bits in the MSN option are concatenated with the MSN bits in the
   FEEDBACK-2 format, with the bits in the FEEDBACK-2 format being the
   most significant bits.  The MSN option MAY appear more than once in
   the FEEDBACK-2 format, in which case the MSN is given by
   concatenating the MSN fields of each occurance of the MSN option.

   The MSN option MUST NOT appear in the same feedback element as the
   MSN-NOT-VALID option, otherwise the decompressor MUST discard the
   entire feedback element.

6.7.2.4.  The CONTEXT_MEMORY Feedback Option

   The CONTEXT_MEMORY option informs the compressor that the
   decompressor does not have sufficient memory resources to handle the
   context of the packet flow, as the flow is currently compressed.

        0   1   2 ];
  }

  // UOR-2 replacement
  COMPRESSED pt_2_rnd {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '110'                           [ 3 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
  }

  // UOR-2-ID replacement
  COMPRESSED pt_2_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1100'                          [ 4 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5)     [ 5   6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7
      +---+---+---+---+---+---+---+---+
      |  Opt Type = 9 |  Opt Len = 0  |
      +---+---+---+---+---+---+---+---+

   When receiving a CONTEXT_MEMORY option, the compressor SHOULD take
   actions to compress the packet flow in a way that requires less
   decompressor memory resources, or stop compressing the packet flow.
   The CONTEXT_MEMORY option MUST NOT appear more than once in the
   FEEDBACK-2 format, otherwise the decompressor MUST discard the entire
   feedback element.

6.7.2.5.  Unknown option types

   If an option type unknown to the compressor is encountered, it must
   continue parsing the rest of the FEEDBACK packet, which is possible
   since the length of the option is explicit, but MUST otherwise ignore
   the unknown option.

7.  Security Considerations

   Because encryption eliminates the redundancy that header compression
   schemes try to exploit, there is some inducement to forego encryption
   of headers in order to enable operation over low-bandwidth links.
   However, for those cases where encryption of data (and not headers)
   is sufficient, RTP does specify an alternative encryption method in
   which only the RTP payload is encrypted and the headers are left in
   the clear.  That would still allow header compression to be applied.

   ROHC compression is transparent with regard to the RTP Sequence
   Number and RTP Timestamp fields, so the values of those fields can be
   used as the basis of payload encryption schemes (e.g., for
   computation of an initialization vector).

   A malfunctioning or malicious header compressor could cause the
   header decompressor to reconstitute packets that do not match the
   original packets but still have valid IP, UDP and RTP headers and
   possibly also valid UDP checksums.  Such corruption may be detected
   with end-to-end authentication and integrity mechanisms which will
   not be affected by the compression.  Moreover, this header
   compression scheme uses an internal checksum for verification of
   reconstructed headers.  This reduces the probability of producing
   decompressed headers not matching the original ones without this
   being noticed.

   Denial-of-service attacks are possible if an intruder can introduce
   (for example) bogus IR, IR-DYN, IR-PD or FEEDBACK packets onto the
   link and thereby cause compression efficiency to be reduced.
   However, an intruder having the ability to inject arbitrary packets
   at the link layer in this manner raises additional security issues
   that dwarf those related to the use of header compression.

8.  IANA Considerations

   The ROHC profile identifiers 0x00XX <# Editor's Note: To be replaced
   before publication #> has been reserved by the IANA for the profile
   defined in this document.

   <# Editor's Note: To be removed before publication #>

   A ROHC profile identifier must be reserved by the IANA for the
   updated profiles defined in this document.  Profiles 0x0000-0x0004
   have previously been reserved, and since there is no changes to
   profile 0x0000, this document should thus update profiles 0x0001-
   0x0004.  As for previous ROHC profiles, profile numbers 0xnnXX must
   also be reserved for future updates of this profile.  A suggested
   registration in the "RObust Header Compression (ROHC) Profile
   Identifiers" name space would then be:

     Profile           Usage                 Reference
     0x0000            ROHC uncompressed     RFC 3095
     0x0001            ROHC RTP              RFC 3095
     0x0101            ROHCv2 RTP            [RFCXXXX (this)]
     0xn101 - 0xn2nn   Reserved
     0x0002            ROHC UDP              RFC 3095
     0x0102            ROHCv2 UDP            [RFCXXXX (this)]
     0xn102 - 0xn2nn   Reserved
     0x0003            ROHC ESP              RFC 3095
     0x0103            ROHCv2 ESP            [RFCXXXX (this)]
     0xn103 - 0xn2nn   Reserved
     0x0004            ROHC IP               RFC 3843
     0x0104            ROHCv2 IP             [RFCXXXX (this)]
     0xn104 - 0xn7nn   Reserved
     0x0005            ROHC LLA              RFC 3242
     0x0105            ROHC LLA with R-mode  RFC 3408
     0xn105 - 0xn7nn   Reserved
     0x0007            ROHC RTP/UDP-Lite     RFC 4019
     0x0107            ROHCv2 RTP/UDP-Lite   [RFCXXXX (this)]
     0xn107 - 0xn2nn   Reserved
     0x0008            ROHC UDP-Lite         RFC 4019
     0x0108            ROHCv2 UDP-Lite       [RFCXXXX (this)]
     0xn108 - 0xn2nn   Reserved

   Author's note: The list above is incorrect and incomplete.
                  It must be updated before sending to IANA.

9.  Acknowledgements

   The authors would like to thank the many people who have contributed
   to the ROHC specifications.  The sample Perl implementation of
   Appendix A was written by Carsten Bormann.

10.  References

10.1.  Normative References

   [I-D.ietf-rohc-formal-notation]
              Pelletier, G. and R. Finking, "Formal Notation for Robust
              Header Compression (ROHC-FN)",
              draft-ietf-rohc-formal-notation-09 (work in progress),
              June 2005.

   [I-D.ietf-rohc-rfc3095bis-framework]
              Jonsson, L., Pelletier, G., and K. Sandlund, "The RObust
              Header Compression (ROHC) Framework",
              draft-ietf-rohc-rfc3095bis-framework-01 (work in
              progress), December 2005.

   [RFC0768]  Postel, J., "User Datagram Protocol", STD 6, RFC 768,
              August 1980.

   [RFC0791]  Postel, J., "Internet Protocol", STD 5, RFC 791,
              September 1981.

   [RFC2004]  Perkins, C., "Minimal Encapsulation within IP", RFC 2004,
              October 1996.

   [RFC2119]  Bradner, S., "Key words for use ];
    msn           =:= msn_lsb(8)                      [ 8 ];
  }
}

////////////////////////////////////////////
// UDP-lite/RTP profile
////////////////////////////////////////////

udplite_rtp_baseheader(profile, ts_stride_value, time_stride_value,
                       outer_ip_flag, repair_flag)
{
  UNCOMPRESSED v4 {
    ENFORCE(msn.UVALUE == sequence_number.UVALUE);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
    ip_version     =:= uncompressed_value(4, 4)  [ 4 ];
    header_length  =:= uncompressed_value(4, 5)  [ 4 ];
    tos_tc                                       [ 8 ];
    length         =:= inferred_ip_v4_length     [ 16 ];
    ip_id                                        [ 16 ];
    rf             =:= uncompressed_value(1, 0)  [ 1 ];
    df                                           [ 1 ];
    mf             =:= uncompressed_value(1, 0)  [ 1 ];
    frag_offset    =:= uncompressed_value(13, 0) [ 13 ];
    ttl_hopl                                     [ 8 ];
    next_header                                  [ 8 ];
    ip_checksum =:= inferred_ip_v4_header_checksum [ 16 ];
    src_addr                                     [ 32 ];
    dest_addr                                    [ 32 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
    src_port                                     [ 16 ];
    dst_port                                     [ 16 ];
    checksum_coverage                            [ 16 ];
    udp_checksum                                 [ 16 ];
    rtp_version    =:= uncompressed_value(2, 2)  [  2 ];
    pad_bit                                      [  1 ];
    extension                                    [  1 ];
    cc                                           [  4 ];
    marker                                       [  1 ];
    payload_type                                 [  7 ];
    sequence_number                              [ 16 ];
    timestamp                                    [ 32 ];
    ssrc                                         [ 32 ];
    csrc_list                                    [ VARIABLE ];
  }

  UNCOMPRESSED v6 {
    ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
    ip_version     =:= uncompressed_value(4, 6)  [ 4 ];
    tos_tc                                       [ 8 ];
    flow_label                                   [ 20 ];
    payload_length =:= inferred_ip_v6_length     [ 16 ];
    next_header                                  [ 8 ];
    ttl_hopl                                     [ 8 ];
    src_addr                                     [ 128 ];
    dest_addr                                    [ 128 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
    src_port                                     [ 16 ];
    dst_port                                     [ 16 ];
    checksum_coverage                            [ 16 ];
    udp_checksum                                 [ 16 ];
    rtp_version =:= uncompressed_value(2, 2)     [  2 ];
    pad_bit                                      [  1 ];
    extension                                    [  1 ];
    cc                                           [  4 ];
    marker                                       [  1 ];
    payload_type                                 [  7 ];
    sequence_number                              [ 16 ];
    timestamp                                    [ 32 ];
    ssrc                                         [ 32 ];
    csrc_list                                    [ VARIABLE ];
  }

  CONTROL {
    ENFORCE(time_stride_value == time_stride.UVALUE);
    ENFORCE(ts_stride.UVALUE == ts_stride_value);
    ENFORCE(profile == PROFILE_RTP_0107);
    ip_id_behavior                      [  2 ];
    coverage_behavior                   [  2 ];
    ts_stride                           [ 32 ];
    time_stride                         [ 32 ];
    ts_scaled                           [ 32 ];
    ts_offset =:= field_scaling(ts_stride.UVALUE, ts_scaled.UVALUE,
      timestamp.UVALUE) [ 32 ];
  }

  DEFAULT {
    ENFORCE(outer_ip_indicator == 0);
    ENFORCE(repair_flag == 0);
    tos_tc            =:= static;
    dest_addr         =:= static;
    ttl_hopl          =:= static;
    src_addr          =:= static;
    df                =:= static;
    ip_id_behavior    =:= static;
    flow_label        =:= static;
    next_header       =:= static;
    src_port          =:= static;
    dst_port          =:= static;
    checksum_coverage =:= irregular(16);
    udp_checksum      =:= irregular(16);
    pad_bit           =:= static;
    extension         =:= static;
    cc                =:= static;
    // When marker not present in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [RFC2460]  Deering, S. packets, it is assumed 0
    marker            =:= uncompressed_value(1, 0);
    payload_type      =:= static;
    sequence_number   =:= static;
    timestamp         =:= static;
    ssrc              =:= static;
    csrc_list         =:= static;
  }
  // Replacement for UOR-2-ext3
  COMPRESSED co_common {
    ENFORCE(repair_flag == 0);
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '11111010'              [ 8 ];
    marker               =:= irregular(1)            [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    flags1_indicator     =:= irregular(1)            [ 1 ];
    flags2_indicator     =:= irregular(1)            [ 1 ];
    tsc_indicator        =:= irregular(1)            [ 1 ];
    tss_indicator        =:= irregular(1)            [ 1 ];
    ip_id_indicator      =:= irregular(1)            [ 1 ];
    control_crc3         =:= control_crc3_encoding   [ 3 ];

    outer_ip_indicator : repair_indicator : ttl_hopl_indicator :
      tos_tc_indicator : ip_id_behavior : reorder_ratio =:=
      profile_1_7_flags1_enc(flags1_indicator.CVALUE)  [ 0, 8 ];
    list_indicator : tis_indicator : pt_indicator : pad_bit :
      extension : df : coverage_behavior =:=
      profile_7_flags2_enc(flags2_indicator.CVALUE,
      ip_version.UVALUE)                               [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                          [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                                [ 0, 8 ];
    payload_type =:= optional_pt(pt_indicator.CVALUE)  [ 0, 8 ];
    sequence_number =:= sdvl_lsb(sequence_number.ULENGTH) [ 8, 16, 24 ];
    ts_scaled =:= variable_scaled_timestamp(tss_indicator.CVALUE,
      tsc_indicator.CVALUE, ts_stride.UVALUE)          [ VARIABLE ];
    timestamp =:= variable_unscaled_timestamp(tss_indicator.CVALUE,
      tsc_indicator.CVALUE)                            [ VARIABLE ];
    ts_stride =:= sdvl_or_static(tss_indicator.CVALUE) [ VARIABLE ];
    time_stride =:= sdvl_or_static(tis_indicator.CVALUE) [ VARIABLE ];
    csrc_list            =:=
        csrc_list_presence(list_indicator.CVALUE,
          cc.UVALUE)                                   [ VARIABLE ];
  }

  // Context repair (IR-DYN replacement).
  COMPRESSED co_repair {
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '11111011'              [ 8 ];
    marker               =:= irregular(1)            [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    flags1_indicator     =:= irregular(1)            [ 1 ];
    flags2_indicator     =:= irregular(1)            [ 1 ];
    timestamp_indicator  =:= irregular(1)            [ 1 ];
    tss_indicator        =:= irregular(1)            [ 1 ];
    ip_id_indicator      =:= irregular(1)            [ 1 ];
    control_crc3         =:= control_crc3_encoding   [ 3 ];

    outer_ip_indicator : repair_indicator : ttl_hopl_indicator :
      tos_tc_indicator : ip_id_behavior : reorder_ratio =:=
      profile_1_7_flags1_enc(flags1_indicator.CVALUE) [ 0, 8 ];

    list_indicator : tis_indicator : pt_indicator : pad_bit :
      extension : df : coverage_behavior =:=
      profile_7_flags2_enc(flags2_indicator.CVALUE,
      ip_version.UVALUE)                              [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                         [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                               [ 0, 8 ];
    payload_type =:= optional_pt(pt_indicator.CVALUE) [ 0, 8 ];
    sequence_number     =:= irregular(16)             [ 16 ];
    timestamp =:=
      irregular_or_nothing(timestamp_indicator.CVALUE) [ 0, 32 ];
    ts_stride =:= sdvl_or_static(tss_indicator.CVALUE) [ VARIABLE ];
    time_stride =:= sdvl_or_static(tis_indicator.CVALUE) [ VARIABLE ];
    csrc_list =:= csrc_list_presence(list_indicator.CVALUE,
      cc.UVALUE)                                      [ VARIABLE ];
  }

  // UO-0
  COMPRESSED pt_0_crc3 {
    discriminator =:= '0'                             [ 1 ];
    msn           =:= msn_lsb(4)                      [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // New format, Type 0 with strong CRC and R. Hinden, "Internet Protocol, Version more SN bits
  COMPRESSED pt_0_crc7 {
    discriminator =:= '100'                           [ 3 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // UO-1 replacement
  COMPRESSED pt_1_rnd {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '101'                            [ 3 ];
    msn           =:= msn_lsb(5)                       [ 5 ];
    marker        =:= irregular(1)                     [ 1 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 4) [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH)  [ 3 ];
  }

  // UO-1-ID replacement
  COMPRESSED pt_1_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1010'                          [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    msn           =:= msn_lsb(5)                      [ 5 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 4)     [ 4 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
  }

  // UO-1-TS replacement
  COMPRESSED pt_1_seq_ts {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1011'                           [ 4 ];
    marker        =:= irregular(1)                     [ 1 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH)  [ 3 ];
    msn           =:= msn_lsb(4)                       [ 4 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 4) [ 4 ];
  }

  // UOR-2 replacement
  COMPRESSED pt_2_rnd {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '110'                             [ 3 ];
    msn           =:= msn_lsb(7)                        [ 7 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 6) [ 6
              (IPv6) Specification", RFC 2460, December 1998.

   [RFC2784]  Farinacci, D., Li, T., Hanks, S., Meyer, D., and P.
              Traina, "Generic Routing Encapsulation (GRE)", RFC 2784,
              March 2000.

   [RFC2890]  Dommety, G., "Key and Sequence Number Extensions to GRE",
              RFC 2890, September 2000.

   [RFC3550]  Schulzrinne, H., Casner, S., Frederick, R., ];
    marker        =:= irregular(1)                      [ 1 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)   [ 7 ];
  }

  // UOR-2-ID replacement
  COMPRESSED pt_2_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '11000'                         [ 5 ];
    msn           =:= msn_lsb(7)                      [ 7 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5)     [ 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    timestamp     =:= inferred_scaled_field           [ 0 ];
  }

  // UOR-2-ID-ext1 replacement (both TS and V.
              Jacobson, "RTP: A Transport Protocol IP-ID)
  COMPRESSED pt_2_seq_both {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '11001'                           [ 5 ];
    msn           =:= msn_lsb(7)                        [ 7 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5)       [ 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)   [ 7 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 8) [ 8 ];
  }

  // UOR-2-TS replacement
  COMPRESSED pt_2_seq_ts {
    ENFORCE(ts_stride.UVALUE != 0);
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1101'                           [ 4 ];
    msn           =:= msn_lsb(7)                       [ 7 ];
    ts_scaled     =:= scaled_ts_lsb(time_stride.UVALUE, 5) [ 5 ];
    marker        =:= irregular(1)                     [ 1 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH)  [ 7 ];
  }
}

////////////////////////////////////////////
// UDP-lite profile
////////////////////////////////////////////

udplite_baseheader(profile, outer_ip_flag, repair_flag)
{
  UNCOMPRESSED v4 {
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
    ip_version     =:= uncompressed_value(4, 4)  [ 4 ];
    header_length  =:= uncompressed_value(4, 5)  [ 4 ];
    tos_tc                                       [ 8 ];
    length         =:= inferred_ip_v4_length     [ 16 ];
    ip_id                                        [ 16 ];
    rf             =:= uncompressed_value(1, 0)  [ 1 ];
    df                                           [ 1 ];
    mf             =:= uncompressed_value(1, 0)  [ 1 ];
    frag_offset    =:= uncompressed_value(13, 0) [ 13 ];
    ttl_hopl                                     [ 8 ];
    next_header                                  [ 8 ];
    ip_checksum =:= inferred_ip_v4_header_checksum [ 16 ];
    src_addr                                     [ 32 ];
    dest_addr                                    [ 32 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
    src_port                                     [ 16 ];
    dst_port                                     [ 16 ];
    checksum_coverage                            [ 16 ];
    udp_checksum                                 [ 16 ];
  }

  UNCOMPRESSED v6 {
    ENFORCE(ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM);
    outer_headers  =:= baseheader_outer_headers  [ VARIABLE ];
    ip_version     =:= uncompressed_value(4, 6)  [ 4 ];
    tos_tc                                       [ 8 ];
    flow_label                                   [ 20 ];
    payload_length =:= inferred_ip_v6_length     [ 16 ];
    next_header                                  [ 8 ];
    ttl_hopl                                     [ 8 ];
    src_addr                                     [ 128 ];
    dest_addr                                    [ 128 ];
    extension_headers =:= baseheader_extension_headers [ VARIABLE ];
    src_port                                     [ 16 ];
    dst_port                                     [ 16 ];
    checksum_coverage                            [ 16 ];
    udp_checksum                                 [ 16 ];
  }

  CONTROL {
    ENFORCE(profile == PROFILE_UDPLITE_0108);
    ip_id_behavior    [ 2 ];
    coverage_behavior [ 2 ];
  }

  DEFAULT {
    ENFORCE(outer_ip_indicator == 0);
    ENFORCE(repair_flag == 0);
    tos_tc            =:= static;
    dest_addr         =:= static;
    ttl_hopl          =:= static;
    src_addr          =:= static;
    df                =:= static;
    ip_id_behavior    =:= static;
    flow_label        =:= static;
    next_header       =:= static;
    src_port          =:= static;
    dst_port          =:= static;
    checksum_coverage =:= irregular(16);
    udp_checksum      =:= irregular(16);
  }

  // Replacement for Real-Time
              Applications", STD 64, RFC 3550, July 2003.

   [RFC3828]  Larzon, L-A., Degermark, M., Pink, S., Jonsson, L-E., UOR-2-ext3
  COMPRESSED co_common {
    ENFORCE(repair_flag == 0);
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '11111010'              [ 8 ];
    reorder_ratio        =:= reorder_choice          [ 2 ];
    ip_id_indicator      =:= irregular(1)            [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    flags_indicator      =:= irregular(1)            [ 1 ];
    ttl_hopl_indicator   =:= irregular(1)            [ 1 ];
    tos_tc_indicator     =:= irregular(1)            [ 1 ];
    control_crc3         =:= control_crc3_encoding   [ 3 ];
    outer_ip_indicator : repair_indicator : df :
      ip_id_behavior : coverage_behavior =:=
      profile_8_flags_enc(flags_indicator.CVALUE)    [ 0, 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                    [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                              [ 0, 8 ];
    msn                  =:= msn_lsb(8)              [ 8 ];
  }

  // Context repair (IR-DYN replacement).
  COMPRESSED co_repair {
    ENFORCE(outer_ip_flag == outer_ip_indicator.CVALUE);
    ENFORCE(repair_flag == repair_indicator.CVALUE);
    discriminator        =:= '11111011'              [ 8 ];
    reorder_ratio        =:= reorder_choice          [ 2 ];
    ip_id_indicator      =:= irregular(1)            [ 1 ];
    header_crc   =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    flags_indicator      =:= irregular(1)            [ 1 ];
    ttl_hopl_indicator   =:= irregular(1)            [ 1 ];
    tos_tc_indicator     =:= irregular(1)            [ 1 ];
    control_crc3         =:= control_crc3_encoding   [ 3 ];
    outer_ip_indicator : repair_indicator : df :
        ip_id_behavior : coverage_behavior =:=
        profile_8_flags_enc(flags_indicator.CVALUE)  [ 0, 8 ];
    msn                  =:= msn_lsb(16)             [ 8 ];
    ip_id =:= optional_ip_id_lsb(ip_id_behavior.UVALUE,
      ip_id_indicator.CVALUE)                        [ 0, 8, 16 ];
    tos_tc =:= static_or_irreg(tos_tc_indicator.CVALUE, 8) [ 0, 8 ];
    ttl_hopl =:= static_or_irreg(ttl_hopl_indicator.CVALUE,
      ttl_hopl.ULENGTH)                              [ 0, 8 ];
  }

  // UO-0
  COMPRESSED pt_0_crc3 {
    discriminator =:= '0'                             [ 1 ];
    msn           =:= msn_lsb(4)                      [ 4 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // New format, Type 0 with strong CRC and
              G. Fairhurst, "The Lightweight User Datagram Protocol
              (UDP-Lite)", RFC 3828, July 2004.

   [RFC4019]  Pelletier, G., "RObust Header Compression (ROHC): Profiles more SN bits
  COMPRESSED pt_0_crc7 {
    discriminator =:= '100'                           [ 3 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    ip_id         =:= inferred_sequential_ip_id       [ 0 ];
  }

  // UO-1-ID replacement (PT-1 only used for User Datagram Protocol (UDP) Lite", RFC 4019,
              April 2005.

   [RFC4302]  Kent, S., "IP Authentication Header", RFC 4302,
              December 2005.

   [RFC4303]  Kent, S., "IP Encapsulating Security Payload (ESP)",
              RFC 4303, December 2005.

10.2.  Informative References

   [I-D.ietf-rohc-rfc3095bis-improvements]
              Jonsson, L., "Improvements sequential)
  COMPRESSED pt_1_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '101'                           [ 3 ];
    header_crc    =:= crc3(THIS.UVALUE, THIS.ULENGTH) [ 3 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 4)     [ 4 ];
  }

  // UOR-2 replacement
  COMPRESSED pt_2_rnd {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_RANDOM) ||
            (ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_ZERO));
    discriminator =:= '110'                           [ 3 ];
    msn           =:= msn_lsb(6)                      [ 6 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
  }

  // UOR-2-ID replacement
  COMPRESSED pt_2_seq_id {
    ENFORCE((ip_id_behavior.UVALUE == IP_ID_BEHAVIOR_SEQUENTIAL) ||
            (ip_id_behavior.UVALUE ==
             IP_ID_BEHAVIOR_SEQUENTIAL_SWAPPED));
    discriminator =:= '1100'                          [ 4 ];
    ip_id =:= ip_id_lsb(ip_id_behavior.UVALUE, 5)     [ 5 ];
    header_crc    =:= crc7(THIS.UVALUE, THIS.ULENGTH) [ 7 ];
    msn           =:= msn_lsb(8)                      [ 8 ];
  }
}

6.9.  Feedback Formats and Options

6.9.1.  Feedback Formats

   This section describes the feedback format for ROHCv2 profiles, using
   the formats described in section 5.2.3 of
   [I-D.ietf-rohc-rfc3095bis-framework].

   All feedback formats carry a field labelled MSN, which contain LSBs
   of the ROHC Profile Set
              Update", draft-ietf-rohc-rfc3095bis-improvements-02 (work MSN described in progress), March 2006.

   [I-D.ietf-rohc-rtp-impl-guide]
              Jonsson, L., Pelletier, G., and K. Sandlund, "RObust
              Header Compression (ROHC): Corrections and Clarifications Section 6.2.1.  The sequence number to RFC 3095", May 2006.

   [I-D.ietf-rohc-tcp]
              Pelletier, G., Sandlund, K., use is
   the MSN corresponding to the last header that was successfully CRC-8
   validated or CRC verified.

   FEEDBACK-1

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      |              MSN              |
      +---+---+---+---+---+---+---+---+

      MSN: The lsb-encoded master sequence number.

   A FEEDBACK-1 is an ACK.  In order to send a NACK or a STATIC-NACK,
   FEEDBACK-2 must be used.

   FEEDBACK-2

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      |Acktype|          MSN          |
      +---+---+---+---+---+---+---+---+
      |              MSN              |
      +---+---+---+---+---+---+---+---+
      |              CRC              |
      +---+---+---+---+---+---+---+---+
      /       Feedback options        /
      +---+---+---+---+---+---+---+---+
      Acktype:

         0 = ACK
         1 = NACK
         2 = STATIC-NACK
         3 is reserved (MUST NOT be used for parsability)

      MSN: The lsb-encoded master sequence number.

      CRC: 8-bit CRC computed over the entire feedback payload including
      any CID fields but excluding the packet type, the 'Size' field and M. West, "RObust Header
              Compression (ROHC):
      the 'Code' octet, using the polynomial defined in
      [I-D.ietf-rohc-rfc3095bis-framework].  If the CID is given with an
      Add-CID octet, the Add-CID octet immediately precedes the
      FEEDBACK-1 or FEEDBACK-2 format.  For purposes of computing the
      CRC, the CRC field is zero.

      Feedback options: A Profile variable number of feedback options, see
      Section 6.9.2.  Options may appear in any order.

   A FEEDBACK-2 of type NACK or STATIC-NACK is always implicitely an
   acknowlegement for TCP/IP (ROHC-TCP)",
              draft-ietf-rohc-tcp-11 (work a successfully decompressed packet, which packet
   corresponds to the MSN of the feedback element, unless the MSN-NOT-
   VALID option Section 6.9.2.2 appears in progress), January 2006.

   [RFC3095]  Bormann, C., Burmeister, C., Degermark, M., Fukushima, H.,
              Hannu, H., Jonsson, L-E., Hakenberg, R., Koren, T., Le,
              K., Liu, Z., Martensson, A., Miyazaki, A., Svanbro, K.,
              Wiebke, T., Yoshimura, T., and H. Zheng, "RObust Header
              Compression (ROHC): Framework and four profiles: RTP, UDP,
              ESP, the feedback element.

   The FEEDBACK-2 format always carry a CRC and uncompressed", RFC 3095, July 2001.

   [RFC3843]  Jonsson, L-E. is thus more robust than
   the FEEDBACK-1 format.  When receiving FEEDBACK-2, the compressor
   MUST verify the information by computing the CRC and G. Pelletier, "RObust Header Compression
              (ROHC): comparing the
   result with the CRC carried in the feedback format.  If the two are
   not identical, the feedback element MUST be discarded.

6.9.2.  Feedback Options

   A Compression Profile for IP", RFC 3843,
              June 2004.

   [RFC4224]  Pelletier, G., Jonsson, L-E., feedback option has variable length and K. Sandlund, "RObust
              Header Compression (ROHC): ROHC the following general
   format:

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      |   Opt Type    |    Opt Len    |
      +---+---+---+---+---+---+---+---+
      /          option data          /  Opt Length (octets)
      +---+---+---+---+---+---+---+---+

   The CRC option contains an 8-bit CRC computed over Channels That Can
              Reorder Packets", RFC 4224, January 2006.

Appendix A.  Detailed classification of header the entire
   feedback payload including any CID fields

   Header compression is possible thanks but excluding the packet
   type, the 'Size' field and the 'Code' octet, using the polynomial of
   [I-D.ietf-rohc-rfc3095bis-framework], section 5.3.1.1.

6.9.2.1.  The REJECT option

   The REJECT option informs the compressor that the decompressor does
   not have sufficient resources to handle the flow.

      +---+---+---+---+---+---+---+---+
      |  Opt Type = 2 |  Opt Len = 0  |
      +---+---+---+---+---+---+---+---+

   When receiving a REJECT option, the compressor MUST stop compressing
   the packet flow, and SHOULD refrain from attempting to increase the fact
   number of compressed packet flows for some time.  Any FEEDBACK packet
   carrying a REJECT option MUST also carry a CRC option.  The REJECT
   option MUST NOT appear more than once in the FEEDBACK-2 format,
   otherwise the decompressor MUST discard the entire feedback element.

6.9.2.2.  The MSN-NOT-VALID option

   The MSN-NOT-VALID option indicates that most header
   fields do the MSN of the feedback is
   not vary randomly from packet to packet.  Many valid.

      +---+---+---+---+---+---+---+---+
      |  Opt Type = 3 |  Opt Len = 0  |
      +---+---+---+---+---+---+---+---+

   A compressor MUST NOT use the MSN of the
   fields exhibit static behavior or change in feedback to find the
   corresponding sent header when this option is present.  Consequently,
   a more NACK or less
   predictable way.  When designing a header compression scheme, it STATIC-NACK feedback type sent with the MSN-NOT-VALID
   option is
   of fundamental importance equivalent to a STATIC-NACK with respect to understand the behavior type of
   context repair requested by the fields decompressor.

   The MSN-NOT-VALID option MUST NOT appear more than once in
   detail.

   In this appendix, all IP, UDP, UDP-Lite and RTP header fields are
   classified the
   FEEDBACK-2 format and analyzed MUST NOT appear in two steps.  First, we have a general
   classification the same feedback element as
   the MSN option, otherwise the decompressor MUST discard the entire
   feedback element.

6.9.2.3.  The MSN option

   The MSN option provides 8 additional bits of MSN.

      +---+---+---+---+---+---+---+---+
      |  Opt Type = 4 |  Opt Len = 1  |
      +---+---+---+---+---+---+---+---+
      |              MSN              |
      +---+---+---+---+---+---+---+---+

   the bits in [REF] where the fields MSN option are classified on concatenated with the basis
   of stable knowledge and assumptions.  The general classification does
   not take into account MSN bits in the change characteristics of changing fields
   because those will vary more or less depending on
   FEEDBACK-2 format, with the implementation
   and on bits in the application used.  A less stable but FEEDBACK-2 format being the
   most significant bits.  The MSN option MAY appear more detailed
   analysis of than once in
   the change characteristics is then done FEEDBACK-2 format, in [REF].
   Finally, [REF] summarizes this appendix with conclusions about how which case the various header fields should be handled MSN is given by
   concatenating the header compression
   scheme to optimize compression and functionality.

Appendix A.1.  General classification

   INFERRED These MSN fields contain values that can be inferred from other
   values, for example the size of each occurance of the frame carrying MSN option.

   The MSN option MUST NOT appear in the packet, and
   thus do same feedback element as the
   MSN-NOT-VALID option, otherwise the decompressor MUST discard the
   entire feedback element.

6.9.2.4.  The CONTEXT_MEMORY Feedback Option

   The CONTEXT_MEMORY option informs the compressor that the
   decompressor does not have sufficient memory resources to be handled at all by the compression scheme.

   STATIC These fields are expected to be constant throughout handle the
   lifetime
   context of the packet stream.  Static information must in some way
   be communicated once.

   STATIC-DEF STATIC fields whose values define a packet stream.  They
   are in general handled flow, as STATIC.

   STATIC-KNOWN These STATIC fields are expected to have well-known
   values and therefore do not need to be communicated at all.

   CHANGING These fields are expected the flow is currently compressed.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      |  Opt Type = 9 |  Opt Len = 0  |
      +---+---+---+---+---+---+---+---+

   When receiving a CONTEXT_MEMORY option, the compressor SHOULD take
   actions to vary compress the packet flow in some way: randomly,
   within a limited value set or range, way that requires less
   decompressor memory resources, or stop compressing the packet flow.
   The CONTEXT_MEMORY option MUST NOT appear more than once in some other manner.

   In this section, each of the IP, UDP and RTP header fields is
   assigned to one of these classes.  For all fields except those
   classified as CHANGING,
   FEEDBACK-2 format, otherwise the motives for decompressor MUST discard the classification are also
   stated.  In section A.2, CHANGING fields are further examined and
   classified on entire
   feedback element.

6.9.2.5.  The CONTROL_FIELDS_UPDATE Feedback Option

   The CONTROL_FIELDS_UPDATE option informs the basis compressor that the
   decompressor considers its set of their expected change behavior.

Appendix A.1.1.  IPv4 header control fields
   +---------------------+-------------+----------------+
   | Field               | Size (bits) | Class          |
   +---------------------+-------------+----------------+
   | Version             | 4           | STATIC-KNOWN   |
   | Header Length       | 4           | STATIC-KNOWN   |
   | Type Of Service     | 8           | CHANGING       |
   | Packet Length       | 16          | INFERRED       |
   | Identification      | 16          | CHANGING       |
   | Reserved flag       | 1           | STATIC-KNOWN   |
   | Don't Fragment flag | 1           | CHANGING       |
   | More Fragments flag | 1           | STATIC-KNOWN   |
   | Fragment Offset     | 13          | STATIC-KNOWN   |
   | Time To Live        | 8           | CHANGING       |
   | Protocol            | 8           | STATIC         |
   | Header Checksum     | 16          | INFERRED       |
   | Source Address      | 32          | STATIC-DEF     |
   | Destination Address to be invalid, or
   that those have not been established.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 32 Opt Type = 10 | STATIC-DEF  Opt Len = 0  |
   +---------------------+-------------+----------------+

   Version

      The version field states which IP version is used.  Packets with
      different values
      +---+---+---+---+---+---+---+---+

   When receiving the CONTROL_FIELDS_UPDATE option in this field must be handled by different IP
      stacks.  All packets of a feedback
   element, the compressor SHOULD select a packet stream must therefore be of format that can update
   the
      same IP version.  Accordingly, control fields covered by the field is classified as STATIC.

   Header Length

      As long no options are present control_crc3 encoding method
   Section 6.6.11.

   The CONTROL_FIELDS_UPDATE option MUST NOT appear more than once in
   the IP header, FEEDBACK-2 format, otherwise the header length
      is constant and well known. decompressor MUST discard the
   entire feedback element.

6.9.2.6.  Unknown option types

   If there are options, an option type unknown to the fields
      would be STATIC, but it compressor is assumed here that there are no options.
      The field encountered, it must
   continue parsing the rest of the FEEDBACK packet, which is therefore classified as STATIC-KNOWN.

   Packet Length

      Information about packet possible
   since the length is expected to be provided by of the
      link layer.  The field option is therefore classified as INFERRED.

   Flags

      The Reserved flag must be set explicit, but MUST otherwise ignore
   the unknown option.

7.  Security Considerations

   Because encryption eliminates the redundancy that header compression
   schemes try to zero and exploit, there is therefore classified
      as STATIC-KNOWN.  The Don't Fragment (DF) flag will changes rarely
      and some inducement to forego encryption
   of headers in order to enable operation over low-bandwidth links.
   However, for those cases where encryption of data (and not headers)
   is therefore classified as CHANGING.  Finally, sufficient, RTP does specify an alternative encryption method in
   which only the More
      Fragments (MF) flag RTP payload is expected encrypted and the headers are left in
   the clear.  That would still allow header compression to be zero because fragmentation applied.

   ROHC compression is NOT expected, due transparent with regard to the small packet size expected.  The More
      Fragments flag is therefore classified RTP Sequence
   Number and RTP Timestamp fields, so the values of those fields can be
   used as STATIC-KNOWN.

   Fragment Offset
      Under the assumption basis of payload encryption schemes (e.g., for
   computation of an initialization vector).

   A malfunctioning or malicious header compressor could cause the
   header decompressor to reconstitute packets that no fragmentation occurs, do not match the fragment
      offset is always zero.  The field is therefore classified as
      STATIC-KNOWN.

   Protocol

      This field will
   original packets but still have valid IP, UDP and RTP headers and
   possibly also valid UDP checksums.  Such corruption may be detected
   with end-to-end authentication and integrity mechanisms which will
   not be affected by the same value in all packets compression.  Moreover, this header
   compression scheme uses an internal checksum for verification of a packet
      stream.  It encodes
   reconstructed headers.  This reduces the type probability of producing
   decompressed headers not matching the subsequent header.

   Header Checksum

      The header checksum protects individual hops from processing a
      corrupted header.  When almost all IP header information is
      compressed away, there is no point in original ones without this
   being noticed.

   Denial-of-service attacks are possible if an intruder can introduce
   (for example) bogus IR, IR-PD or FEEDBACK packets onto the link and
   thereby cause compression efficiency to be reduced.  However, an
   intruder having the ability to inject arbitrary packets at the link
   layer in this manner raises additional
      checksum; instead it can be regenerated at security issues that dwarf
   those related to the decompressor side.
      The field is therefore classified as INFERRED.

   Source and Destination addresses

      These fields are part use of header compression.

8.  IANA Considerations

   The following ROHC profile identifiers have been reserved by the definition of a stream and IANA
   for the profiles defined in this document:

     Identifier        Profile
     ----------        -------
     0x0101            ROHCv2 RTP
     0x0102            ROHCv2 UDP
     0x0103            ROHCv2 ESP
     0x0104            ROHCv2 IP
     0x0107            ROHCv2 RTP/UDP-Lite
     0x0108            ROHCv2 UDP-Lite

   <# Editor's Note: To be removed before publication #>

   ROHC profile identifiers must thus be constant reserved by the IANA for all packets the updated
   profiles defined in this document.  A suggested registration in the stream.  The fields are
      therefore classified as STATIC-DEF.

Appendix A.1.2.  IPv6 header fields

   +---------------------+-------------+----------------+
   | Field               | Size (bits) | Class          |
   +---------------------+-------------+----------------+
   | Version             | 4           | STATIC-KNOWN   |
   | Traffic Class       | 8           | CHANGING       |
   | Flow Label          | 20          | STATIC-DEF     |
   | Payload Length      | 16          | INFERRED       |
   | Next
   "RObust Header         | 8           | STATIC         |
   | Hop Limit           | 8           | CHANGING       |
   | Source Address      | 128         | STATIC-DEF     |
   | Destination Address | 128         | STATIC-DEF     |
   +---------------------+-------------+----------------+

   Version

      The version field states which Compression (ROHC) Profile Identifiers" name space
   would then be:

     Profile Identifier   Usage                      Reference
     ------------------   ----------------------     ---------
     0x0000               ROHC uncompressed          RFC 3095
     0xnn00               Reserved
     0x0001               ROHC RTP                   RFC 3095
     0x0101               ROHCv2 RTP                 [RFCXXXX (this)]
     0xnn01               Reserved
     0x0002               ROHC UDP                   RFC 3095
     0x0102               ROHCv2 UDP                 [RFCXXXX (this)]
     0xnn02               Reserved
     0x0003               ROHC ESP                   RFC 3095
     0x0103               ROHCv2 ESP                 [RFCXXXX (this)]
     0xnn03               Reserved
     0x0004               ROHC IP version is used.  Packets                    RFC 3843
     0x0104               ROHCv2 IP                  [RFCXXXX (this)]
     0xnn04               Reserved
     0x0005               ROHC LLA                   RFC 4362
     0x0105               ROHC LLA with
      different values in this field must R-mode       RFC 3408
     0xnn05               Reserved
     0xnn06               To be handled Assigned by different IP
      stacks.  All packets of a packet stream must therefore IANA
     0x0007               ROHC RTP/UDP-Lite          RFC 4019
     0x0107               ROHCv2 RTP/UDP-Lite        [RFCXXXX (this)]
     0xnn07               Reserved
     0x0008               ROHC UDP-Lite              RFC 4019
     0x0108               ROHCv2 UDP-Lite            [RFCXXXX (this)]
     0xnn08               Reserved
     0x0009-0xnn7F        To be of the
      same IP version.  Accordingly, the field is classified as STATIC.

   Flow Label
      This field may Assigned by IANA
     0xnn80-0xnnFE        To be used Assigned by IANA
     0xnnFF               Reserved

9.  Acknowledgements

   The authors would like to identify packets belonging thank the many people who have contributed
   to a specific
      packet stream.  If not used, the value should be set ROHC specifications.

10.  References

10.1.  Normative References

   [I-D.ietf-rohc-formal-notation]
              Pelletier, G. and R. Finking, "Formal Notation for Robust
              Header Compression (ROHC-FN)",
              draft-ietf-rohc-formal-notation-13 (work in progress),
              December 2006.

   [I-D.ietf-rohc-rfc3095bis-framework]
              Jonsson, L., "The RObust Header Compression (ROHC)
              Framework", draft-ietf-rohc-rfc3095bis-framework-04 (work
              in progress), November 2006.

   [RFC0768]  Postel, J., "User Datagram Protocol", STD 6, RFC 768,
              August 1980.

   [RFC0791]  Postel, J., "Internet Protocol", STD 5, RFC 791,
              September 1981.

   [RFC2004]  Perkins, C., "Minimal Encapsulation within IP", RFC 2004,
              October 1996.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to zero.
      Otherwise, all packets belonging Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [RFC2460]  Deering, S. and R. Hinden, "Internet Protocol, Version 6
              (IPv6) Specification", RFC 2460, December 1998.

   [RFC2784]  Farinacci, D., Li, T., Hanks, S., Meyer, D., and P.
              Traina, "Generic Routing Encapsulation (GRE)", RFC 2784,
              March 2000.

   [RFC2890]  Dommety, G., "Key and Sequence Number Extensions to the same stream must have the
      same value in this field, it being one of the fields that define
      the stream.  The field is therefore classified as STATIC-DEF. GRE",
              RFC 2890, September 2000.

   [RFC3550]  Schulzrinne, H., Casner, S., Frederick, R., and V.
              Jacobson, "RTP: A Transport Protocol for Real-Time
              Applications", STD 64, RFC 3550, July 2003.

   [RFC3828]  Larzon, L-A., Degermark, M., Pink, S., Jonsson, L-E., and
              G. Fairhurst, "The Lightweight User Datagram Protocol
              (UDP-Lite)", RFC 3828, July 2004.

   [RFC4019]  Pelletier, G., "RObust Header Compression (ROHC): Profiles
              for User Datagram Protocol (UDP) Lite", RFC 4019,
              April 2005.

   [RFC4302]  Kent, S., "IP Authentication Header", RFC 4302,
              December 2005.

   [RFC4303]  Kent, S., "IP Encapsulating Security Payload Length

      Information about packet length (and, consequently, payload
      length) is expected to be provided by the link layer.  The field
      is therefore classified as INFERRED.

   Next (ESP)",
              RFC 4303, December 2005.

10.2.  Informative References

   [RFC3095]  Bormann, C., Burmeister, C., Degermark, M., Fukushima, H.,
              Hannu, H., Jonsson, L-E., Hakenberg, R., Koren, T., Le,
              K., Liu, Z., Martensson, A., Miyazaki, A., Svanbro, K.,
              Wiebke, T., Yoshimura, T., and H. Zheng, "RObust Header
              Compression (ROHC): Framework and four profiles: RTP, UDP,
              ESP, and uncompressed", RFC 3095, July 2001.

   [RFC3843]  Jonsson, L-E. and G. Pelletier, "RObust Header Compression
              (ROHC): A Compression Profile for IP", RFC 3843,
              June 2004.

   [RFC4224]  Pelletier, G., Jonsson, L-E., and K. Sandlund, "RObust
              Header Compression (ROHC): ROHC over Channels That Can
              Reorder Packets", RFC 4224, January 2006.

Appendix A.  Detailed classification of header fields

   Header

      This field will have compression is possible thanks to the same value in all packets of a fact that most header
   fields do not vary randomly from packet
      stream.  It encodes the type to packet.  Many of the subsequent header.

   Source and Destination addresses

      These
   fields are part of the definition of a stream and must thus
      be constant for all packets exhibit static behavior or change in the stream.  The fields are
      therefore classified as STATIC-DEF.

Appendix A.1.3.  UDP a more or less
   predictable way.  When designing a header fields

   +------------------+-------------+-------------+
   | Field            | Size (bits) | Class       |
   +------------------+-------------+-------------+
   | Source Port      | 16          | STATIC-DEF  |
   | Destination Port | 16          | STATIC-DEF  |
   | Length           | 16          | INFERRED    |
   | Checksum         | 16          | CHANGING    |
   +------------------+-------------+-------------+

   Source and Destination ports

      These fields are part compression scheme, it is
   of fundamental importance to understand the definition behavior of a stream and must thus
      be constant for all packets in the stream.  The fields are
      therefore classified as STATIC-DEF.

   Length

      This field is redundant in
   detail.

   In this appendix, all IP, UDP, UDP-Lite, RTP and is therefore classified as INFERRED.

Appendix A.1.4.  UDP-Lite ESP header fields
   +-------------------+-------------+-------------+
   | Field             | Size (bits) | Class       |
   +-------------------+-------------+-------------+
   | Source Port       | 16          | STATIC-DEF  |
   | Destination Port  | 16          | STATIC-DEF  |
   | Checksum Coverage | 16          | INFERRED    |
   |                   |             | STATIC      |
   |                   |             | CHANGING    |
   | Checksum          | 16          | CHANGING    |
   +-------------------+-------------+-------------+

   Source
   are classified and Destination Port

      Same as for UDP analyzed in two steps.  First, we have a general
   classification in Appendix A.1.3.

   Source A.1 where the fields are classified on the
   basis of stable knowledge and Destination ports

      Same as for UDP Appendix A.1.3.

   Checksum Coverage

      This field specifies which part assumptions.  A more detailed analysis
   of the UDP-Lite datagram is
      covered by change characteristics of the checksum.  It may have a value changing fields is then done in
   Appendix A.2.

Appendix A.1.  General classification

   Fields are classified as belonging to one of zero or the following classes:

   INFERRED - These fields contain values that can be equal
      to inferred from
   other values, for example the datagram length if size of the checksum covers frame carrying the entire datagram,
      or it may have any value between eight octets packet,
   and thus do not have to be handled at all by the length of
      the datagram compression scheme.

   STATIC-DEF - These fields are expected to specify be constant throughout the number
   lifetime of octets protected by the
      checksum, calculated from packet stream and whose values can be used to define
   a packet stream.  They are in general communicated only at the first octet
   initialization of the UDP-Lite header.
      The value of this field may vary for each packet, context.

   STATIC-KNOWN - These fields are expected to have well-known values
   and this makes
      the value unpredictable from therefore do not need to be communicated at all.

   CHANGING - These fields are expected to vary in some way: randomly,
   within a header-compression perspective.

   Checksum

      The information used for limited value set or range, or in some other manner.

   In this section, the calculation fields of the UDP-Lite checksum
      is governed by various protocol headers are
   assigned to one of these classes.  For all fields except those
   classified as CHANGING, the value of motives for the checksum coverage classification are also
   stated.  In Appendix A.2, CHANGING fields are further examined and minimally
      includes
   classified on the UDP-Lite header.  The checksum is a changing field
      that must always be sent as-is. basis of their expected change behavior.

Appendix A.1.5.  RTP A.1.1.  IPv4 header fields
   +-----------------+-------------+----------------+

   +---------------------+-------------+----------------+
   | Field               | Size (bits) | Class          |
   +-----------------+-------------+----------------+
   +---------------------+-------------+----------------+
   | Version             | 2 4           | STATIC-KNOWN   |
   | Padding Header Length       | 1 4           | CHANGING STATIC-KNOWN   |
   | Extension Type Of Service     | 1 8           | CHANGING       |
   | CSRC Counter Packet Length       | 16          | INFERRED       | 4
   | Identification      | 16          | CHANGING       |
   | Marker Reserved flag       | 1           | CHANGING STATIC-KNOWN   |
   | Payload Type Don't Fragment flag | 7 1           | CHANGING       |
   | Sequence Number More Fragments flag | 16 1           | CHANGING STATIC-KNOWN   |
   | Timestamp Fragment Offset     | 32 13          | STATIC-KNOWN   |
   | Time To Live        | 8           | CHANGING       |
   | SSRC Protocol            | 8           | STATIC-DEF     |
   | Header Checksum     | 16          | INFERRED       |
   | Source Address      | 32          | STATIC-DEF     |
   | CSRC Destination Address | 0(-480) 32          | CHANGING STATIC-DEF     |
   +-----------------+-------------+----------------+
   +---------------------+-------------+----------------+

   Version

      Only one working RTP version exists, namely version 2.  The field
      is therefore classified as STATIC-KNOWN.

   Padding

      The use of this field is application-dependent, but when payload
      padding is used it is likely to be present in most or all packets.
      The version field states which IP version is classified as CHANGING to allow for the rare case
      where this field is updated.

   Extension

      If RTP extensions are used by the application, these extensions
      are likely to be present in all packets (but the use of extensions
      is very uncommon).  However, for safety's sake this field is
      classified as CHANGING to allow for the rare case where this field
      is changed during the flow.

   SSRC

      This field is part of the definition used.  Packets with
      different values in this field must be handled by different IP
      stacks.  All packets of a packet stream and must thus therefore be
      constant for all packets in of the
      same IP version.  Accordingly, the stream.  The field is therefore classified as STATIC-DEF.

Appendix A.2.  Analysis of change patterns of header fields

   To design suitable mechanisms for efficient compression of all header
   fields, their change patterns must be analyzed.  For this reason, an
   extended classification is done based on the general classification
   in A.1, considering the fields which were labeled CHANGING STATIC-
      KNOWN.

   Header Length

      As long no options are present in that
   classification.  Different applications will use the fields in
   different ways, which may affect their behavior.  For IP header, the fields
   whose behavior header length
      is variable, typical behavior for conversational audio constant and video will be discussed.

   The CHANGING fields are separated into five different subclasses:
      STATIC These well known.  If there are options, the fields that were classified as
      could be CHANGING on a
      general basis, or STATIC-DEF, but are classified as STATIC it is assumed here due to certain
      additional assumptions.
      SEMISTATIC These fields are STATIC most of the time.  However,
      occasionally the value changes but will revert to its original
      value.
      RARELY-CHANGING (RC) These are fields that change their values
      occasionally and then keep their new values.
      ALTERNATING These fields alternate between a small number of
      different values.
      IRREGULAR These, finally, there
      are the fields for which no useful
      change pattern can be identified.

   When the classification options.  The field is done, other details are also stated
   regarding possible additional knowledge therefore classified as STATIC-
      KNOWN.

   Packet Length

      Information about packet length is expected to be provided by the
      link layer.  The field values and/or
   field deltas, according is therefore classified as INFERRED.

   Flags

      The Reserved flag must be set to the classification.  For fields zero and is therefore classified
      as STATIC or SEMISTATIC, STATIC-KNOWN.  The Don't Fragment (DF) flag will changes rarely
      and is therefore classified as CHANGING.  Finally, the case could More
      Fragments (MF) flag is expected to be zero because IP fragments
      will not be compressed by ROHC.  The More Fragments flag is
      therefore classified as STATIC-KNOWN.

   Fragment Offset

      Under the assumption that no fragmentation occurs, the fragment
      offset is always zero.  The field is therefore classified as
      STATIC-KNOWN.

   Protocol

      This field will have the same value in all packets of the
   field a packet
      stream and is not only STATIC but also well KNOWN therefore classified as STATIC-DEF.

   Header Checksum

      The header checksum protects individual hops from processing a priori (two states for
   SEMISTATIC fields).  For fields with non-irregular change behavior,
      corrupted header.  When almost all IP header information is
      compressed away, there is no point in having this additional
      checksum; instead it could can be known that changes usually regenerated at the decompressor side.
      The field is therefore classified as INFERRED.

   Source and Destination addresses
      These fields are within a LIMITED range
   compared to part of the maximal change definition of a stream and must thus
      be constant for the field.  For other fields, the
   values are completely UNKNOWN.

   Table A.1 classifies all packets in the CHANGING stream.  The fields on the basis of their
   expected change patterns, especially for conversational audio and
   video.

   +------------------------+-------------+-------------+-------------+
   | Field                  | Value/Delta | Class       | Knowledge   |
   +========================+=============+=============+=============+
   |             Sequential | Delta       | RC          | LIMITED are
      therefore classified as STATIC-DEF.

Appendix A.1.2.  IPv6 header fields

   +---------------------+-------------+----------------+
   | Field               |             -----------+-------------+-------------+-------------+ Size (bits) | IPv4 Id:    Seq. swap Class          | Delta
   +---------------------+-------------+----------------+
   | RC Version             | LIMITED 4           | STATIC-KNOWN   |             -----------+-------------+-------------+-------------+
   |             Random Traffic Class       | Value 8           | IRREGULAR CHANGING       | UNKNOWN
   | Flow Label          |             -----------+-------------+-------------+-------------+ 20          |             Zero STATIC-DEF     | Value
   | IRREGULAR Payload Length      | UNKNOWN 16          |
   +------------------------+-------------+-------------+-------------+ INFERRED       | IP TOS / Tr. Class
   | Value Next Header         | RC 8           | UNKNOWN STATIC-DEF     |
   +------------------------+-------------+-------------+-------------+
   | IP TTL / Hop Limit           | Value       | ALTERNATING | LIMITED     |
   +------------------------+-------------+-------------+-------------+
   | IP Don't Fragment      | Value       | RC          | KNOWN       |
   +------------------------+-------------+-------------+-------------+
   |               Disabled | Value       | STATIC      | KNOWN       |
   | UDP Checksum: ---------+-------------+-------------+-------------+
   |               Enabled  | Value       | IRREGULAR   | UNKNOWN     |
   +------------------------+-------------+-------------+-------------+
   | UDP-Lite Checksum      | Value       | IRREGULAR   | UNKNOWN     |
   +------------------------+-------------+-------------+-------------+
   |                Case #1 | Value 8           | CHANGING       | INFERRED    |
   | UDP-Lite     ----------+-------------+-------------+-------------+
   | Checksum:      Case #2 | Value       | RC          | UNKNOWN     |
   | Coverage     ----------+-------------+-------------+-------------+
   |                Case #3 | Value       | IRREGULAR   | UNKNOWN     |
   +------------------------+-------------+-------------+-------------+
   |                 No mix | Value       | STATIC      | KNOWN       |
   | RTP CSRC Count: -------+-------------+-------------+-------------+
   |                 Mixed  | Value       | RC          | LIMITED     |
   +------------------------+-------------+-------------+-------------+
   | RTP Marker             | Value       | SEMISTATIC  | KNOWN/KNOWN |
   +------------------------+-------------+-------------+-------------+
   | RTP Payload Type       | Value       | RC          | UNKNOWN     |
   +------------------------+-------------+-------------+-------------+
   | RTP Extension          | Value       | RC          | UNKNOWN     |
   +------------------------+-------------+-------------+-------------+ Source Address      | RTP Padding 128         | Value STATIC-DEF     | RC
   | UNKNOWN Destination Address |
   +------------------------+-------------+-------------+-------------+ 128         | RTP Sequence Number STATIC-DEF     | Delta
   +---------------------+-------------+----------------+

   Version

      The version field states which IP version is used.  Packets with
      different values in this field must be handled by different IP
      stacks.  All packets of a packet stream must therefore be of the
      same IP version.  Accordingly, the field is classified as STATIC-
      KNOWN.

   Flow Label

      This field may be used to identify packets belonging to a specific
      packet stream.  If not used, the value should be set to zero.
      Otherwise, all packets belonging to the same stream must have the
      same value in this field.  The field is therefore classified as
      STATIC-DEF.

   Payload Length

      Information about packet length (and, consequently, payload
      length) is expected to be provided by the link layer.  The field
      is therefore classified as INFERRED.

   Next Header

      This field will have the same value in all packets of a packet
      stream and is therefore classified as STATIC-DEF.

   Source and Destination addresses
      These fields are part of the definition of a stream and must thus
      be constant for all packets in the stream.  The fields are
      therefore classified as STATIC-DEF.

Appendix A.1.3.  UDP header fields

   +------------------+-------------+-------------+
   | STATIC Field            | KNOWN Size (bits) |
   +------------------------+-------------+-------------+-------------+ Class       | RTP Timestamp
   +------------------+-------------+-------------+
   | Delta Source Port      | RC 16          | LIMITED STATIC-DEF  |
   +------------------------+-------------+-------------+-------------+
   |                 No mix Destination Port | - 16          | - STATIC-DEF  | -
   | Length           | RTP CSRC List:  -------+-------------+-------------+-------------+ 16          |                 Mixed INFERRED    | Value
   | RC Checksum         | UNKNOWN 16          |
   +------------------------+-------------+-------------+-------------+
   Table A.1 : Classification of CHANGING header fields

   The following subsections discuss the various header fields in
   detail.  Note that table A.1    |
   +------------------+-------------+-------------+

   Source and the discussions below do not
   consider changes caused by loss or reordering before the compression
   point.

Appendix A.2.1.  IPv4 Identification

   The Identification field (IP ID) Destination ports

      These fields are part of the IPv4 header is there to
   identify which fragments constitute definition of a datagram when reassembling
   fragmented datagrams. stream and must thus
      be constant for all packets in the stream.  The IPv4 specification does not specify
   exactly how this fields are
      therefore classified as STATIC-DEF.

   Length

      This field is to be assigned values, only that each
   packet should get an IP ID that redundant and is unique therefore classified as INFERRED.

Appendix A.1.4.  UDP-Lite header fields

   +-------------------+-------------+-------------+
   | Field             | Size (bits) | Class       |
   +-------------------+-------------+-------------+
   | Source Port       | 16          | STATIC-DEF  |
   | Destination Port  | 16          | STATIC-DEF  |
   | Checksum Coverage | 16          | INFERRED    |
   |                   |             | STATIC-DEF  |
   |                   |             | CHANGING    |
   | Checksum          | 16          | CHANGING    |
   +-------------------+-------------+-------------+

   Source and Destination Port

      Same as for the source-destination
   pair UDP Appendix A.1.3.

   Source and protocol Destination ports
      Same as for the time the datagram (or any of its fragments)
   could be alive in the network. UDP Appendix A.1.3.

   Checksum Coverage

      This means that assignment of IP ID
   values can be done in various ways, field specifies which we have separated into
   three classes.

   Sequential

      In this behavior, part of the IP-ID UDP-Lite datagram is expected to increment
      covered by one for
      most packets, but the checksum.  It may increment by have a value larger than one,
      depending on the behavior of the transmitting IPv4 stack.

   Sequential Swapped

      When using this behavior, the IP-ID behaves as in the Sequential
      bahvior, but the two bytes of IP-ID are byte swapped.  Therefore,
      the IP-ID can zero or be swapped before compression equal
      to make it behave
      exactly as the Sequential behavior.

   Random

      Some IP stacks assign IP ID values using a pseudo-random number
      generator.  There is thus no correlation between datagram length if the ID values of
      subsequent datagrams, and therefore there is no way to predict checksum covers the
      IP ID entire datagram,
      or it may have any value for between eight octets and the next datagram.  For header compression
      purposes, this means that length of
      the IP ID field needs datagram to be sent
      uncompressed with each datagram, resulting in two extra specify the number of octets protected by the
      checksum, calculated from the first octet of the UDP-Lite header.

   Zero

      This behavior, although not a legal implementation
      The value of IPv4 is
      sometimes seen in existing IPv4 stacks.  When this behavior is
      used, all IP packets have field may vary for each packet, and this makes
      the IP-ID value set to zero.

Appendix A.2.2.  IP Traffic Class / Type-Of-Service unpredictable from a header-compression perspective.

   Checksum

      The Traffic-Class (IPv6) or Type-Of-Service (IPv4) field is expected
   to be constant during information used for the lifetime calculation of a packet stream or to change
   relatively seldom.

Appendix A.2.3.  IP Hop-limit / Time-To-Live

   The Hop-Limit (IPv6) or Time-To-Live (IPv4) field the UDP-Lite checksum
      is expected to be
   constant during governed by the lifetime value of the checksum coverage and minimally
      includes the UDP-Lite header.  The checksum is a packet stream or to alternate
   between a limited number of values due to route changes. changing field
      that must always be sent as-is.

Appendix A.2.4.  IPv4 Don't Fragment

   The Don't Fragment flag in IPv4 will seldom change, and A.1.5.  RTP header fields

   +-----------------+-------------+----------------+
   | Field           | Size (bits) | Class          |
   +-----------------+-------------+----------------+
   | Version         | 2           | STATIC-KNOWN   |
   | Padding         | 1           | CHANGING       |
   | Extension       | 1           | CHANGING       |
   | CSRC Counter    | 4           | CHANGING       |
   | Marker          | 1           | CHANGING       |
   | Payload Type    | 7           | CHANGING       |
   | Sequence Number | 16          | CHANGING       |
   | Timestamp       | 32          | CHANGING       |
   | SSRC            | 32          | STATIC-DEF     |
   | CSRC            | 0(-480)     | CHANGING       |
   +-----------------+-------------+----------------+

   Version

      Only one working RTP version exists, namely version 2.  The field
      is therefore classified as RC.

Appendix A.2.5.  UDP Checksum STATIC-KNOWN.

   Padding
      The UDP checksum use of this field is optional.  If disabled, its value application-dependent, but when payload
      padding is constantly
   zero and could be compressed away.  If enabled, its value depends on
   the payload, which for compression purposes used it is equivalent likely to it
   changing randomly with every packet.

Appendix A.2.6.  UDP-Lite Checksum Coverage be present in most or all packets.
      The Checksum Coverage field may behave in different ways: it may have
   a value of zero, it may be equal is classified as CHANGING to allow for the datagram length, or it may
   have any value between eight octets and rare case
      where this field is updated.

   Extension

      If RTP extensions are used by the length of application, these extensions
      are likely to be present in all packets (but the datagram.
   From a compression perspective, use of extensions
      is very uncommon).  However, for safety's sake this field is expected
      classified as CHANGING to either be
   entirely predictable (for allow for the cases rare case where it follows the same
   behavior as this field
      is changed during the UDP Length flow.

   SSRC

      This field or where it takes on is part of the definition of a stream and must thus be
      constant
   value) or either to change randomly for each packet (making the value
   unpredictable from a header-compression perspective).  For all cases, packets in the behavior itself stream.  The field is therefore
      classified as STATIC-DEF.

Appendix A.1.6.  ESP header fields

   +------------------+-------------+-------------+
   | Field            | Size (bits) | Class       |
   +------------------+-------------+-------------+
   | SPI              | 32          | STATIC-DEF  |
   | Sequence Number  | 32          | CHANGING    |
   +------------------+-------------+-------------+

   SPI

      This field is not expected used to identify a specific flow and only changes
      when the sequence number wraps around, and is therefore classified
      as STATIC-DEF.

Appendix A.2.  Analysis of change patterns of header fields

   To design suitable mechanisms for this field during
   the lifetime efficient compression of a packet flow, or to all header
   fields, their change relatively seldom. patterns must be analyzed.  For this reason, an
   extended classification is done based on the general classification
   in Appendix A.2.7.  UDP-Lite Checksum

   As opposed to A.1, considering the UDP checksum, fields which were labeled CHANGING
   in that classification.  Different applications will use the UDP-Lite checksum fields
   in different ways, which may affect their behavior.  For the fields
   whose behavior is not optional variable, typical behavior for conversational audio
   and it cannot video will be disabled.  Its value depends discussed.

   The CHANGING fields are separated into five different subclasses:

      NONCHANGING These are fields that were classified as CHANGING on a
      general basis, but may under some conditions be static throughout
      the payload flow and on therefore be completely compressed away.
      SEMISTATIC These fields are unchanged most of the checksum coverage field, which for compression purposes is
   equivalent time.  However,
      occasionally the value changes but will revert to it changing randomly with every packet.

Appendix A.2.8.  RTP CSRC Counter

   This is a counter indicating its original
      value.
      RARELY-CHANGING (RC) These are fields that change their values
      occasionally and then keep their new values.
      IRREGULAR These, finally, are the number of CSRC items present fields for which no useful
      change pattern can be identified.
      PATTERN These field that change between each packet, but change in
      a predictable pattern.

   Table A.1 classifies all the
   CSRC list.  This number is expected to be almost constant CHANGING fields on a
   packet-to-packet the basis and of their
   expected change by small amounts.  As long as no patterns.

   +------------------------+-------------+
   | Field                  | Class       |
   +========================+=============+
   |             Sequential | PATTERN     |
   |             -----------+-------------+
   | IPv4 Id:    Seq. swap  | PATTERN     |
   |             -----------+-------------+
   |             Random     | IRREGULAR   |
   |             -----------+-------------+
   |             Zero       | NONCHANGING |
   +------------------------+-------------+
   | IP TOS / Tr. Class     | RC          |
   +------------------------+-------------+
   | IP TTL / Hop Limit     | RC          |
   +------------------------+-------------+
   | IP Don't Fragment      | RC          |
   +------------------------+-------------+
   |               Disabled | NONCHANGING |
   | UDP Checksum: ---------+-------------+
   |               Enabled  | IRREGULAR   |
   +------------------------+-------------+
   | UDP-Lite Checksum      | IRREGULAR   |
   +------------------------+-------------+
   |                Case #1 | CHANGING    |
   | UDP-Lite     ----------+-------------+
   | Checksum:      Case #2 | RC          |
   | Coverage     ----------+-------------+
   |                Case #3 | IRREGULAR   |
   +------------------------+-------------+
   | RTP mixer is used, the value of this field is zero.

Appendix A.2.9. CSRC Count         | RC          |
   +------------------------+-------------+
   | RTP Marker

   For audio the marker bit should be set only in the first packet             | SEMISTATIC  |
   +------------------------+-------------+
   | RTP Payload Type       | RC          |
   +------------------------+-------------+
   | RTP Extension          | RC          |
   +------------------------+-------------+
   | RTP Padding            | RC          |
   +------------------------+-------------+
   | RTP Sequence Number    | PATTERN     |
   +------------------------+-------------+
   | RTP Timestamp          | PATTERN     |
   +------------------------+-------------+
   | RTP CSRC List:         | RC          |
   +------------------------+-------------+
   | ESP Sequence Number    | PATTERN     |
   +------------------------+-------------+
   Table A.1 : Classification of a
   talkspurt, while for video it should be set in CHANGING header fields
   The following subsections discuss the last packet of
   every picture.  This means that various header fields in both cases
   detail.  Note that table A.1 and the RTP marker is
   classified as SEMISTATIC with well-known values for both states. discussions below do not
   consider changes caused by loss or reordering before the compression
   point.

Appendix A.2.10.  RTP Padding

   If padding is used, it is expected to be present in most packets, but A.2.1.  IPv4 Identification

   The Identification field (IP ID) of the IPv4 header is classified as RC there to allow efficient compression even
   identify which fragments constitute a datagram when reassembling
   fragmented datagrams.  The IPv4 specification does not specify
   exactly how this field changes.

Appendix A.2.11.  RTP Extension

   If extensions are used, it is expected to be used in most packets,
   but is classified as RC to allow efficient compression even when this
   field changes.

Appendix A.2.12.  RTP Payload Type

   Changes of the RTP payload type within a assigned values, only that each
   packet stream are expected
   to be rare.  Applications could adapt to congestion by changing
   payload type and/or frame sizes, but should get an IP ID that is not expected to happen
   frequently.

Appendix A.2.13.  RTP Sequence Number

   The RTP Sequence Number will be incremented by one unique for each packet
   sent.

Appendix A.2.14.  RTP Timestamp

   In the audio case:

      As long as there are no pauses in source-destination
   pair and protocol for the audio stream, time the RTP
      Timestamp will datagram (or any of its fragments)
   could be incremented by a constant delta, corresponding
      to alive in the number network.  This means that assignment of samples IP ID
   values can be done in various ways, but the speech frame.  It will thus mostly
      follow the RTP Sequence Number.  When there has expected behaviors have
   been a silent
      period and a new talkspurt begins, separated into four classes.

   Sequential

      In this behavior, the timestamp will jump in
      proportion IP-ID is expected to increment by one for
      most packets, but may increment by a value larger than one,
      depending on the length behavior of the silent period.  However, transmitting IPv4 stack.

   Sequential Swapped

      When using this behavior, the
      increment will probably be within a relatively limited range.

   In IP-ID behaves as in the Sequential
      bahvior, but the video case:

      Between two consecutive packets, bytes of IP-ID are byte swapped.  Therefore,
      the timestamp will either IP-ID can be
      unchanged or increase by a multiple of a fixed value corresponding swapped before compression to make it behave
      exactly as the picture clock frequency.  The timestamp can also decrease
      by Sequential behavior.

   Random

      Some IP stacks assign IP ID values using a multiple pseudo-random number
      generator.  There is thus no correlation between the ID values of
      subsequent datagrams, and therefore there is no way to predict the fixed
      IP ID value for certain coding schemes.  The
      delta interval, expressed as the next datagram.  For header compression
      purposes, this means that the IP ID field needs to be sent
      uncompressed with each datagram, resulting in two extra octets of
      header.

   Zero

      This behavior, although not a multiple legal implementation of the picture clock
      frequency, IPv4 is
      sometimes seen in most cases very limited. existing IPv4 stacks.  When this behavior is
      used, all IP packets have the IP-ID value set to zero.

Appendix A.2.15.  RTP Contributing Sources (CSRC) A.2.2.  IP Traffic Class / Type-Of-Service

   The participants in a session, which are identified by Traffic-Class (IPv6) or Type-Of-Service (IPv4) field is expected
   to be constant during the CSRC
   fields, are lifetime of a packet stream or to change
   relatively seldom.

Appendix A.2.3.  IP Hop-limit / Time-To-Live

   The Hop-Limit (IPv6) or Time-To-Live (IPv4) field is expected to be almost
   constant during the same on lifetime of a packet-to-packet
   basis with relatively few additions packet stream or to alternate
   between a limited number of values due to route changes.

Appendix A.2.4.  IPv4 Don't Fragment

   The Don't Fragment flag in IPv4 will seldom change, and removals.  As long is therefore
   classified as RTP
   mixers are not used, no CSRC fields are present at all. RC.

Appendix A.3.  Header compression strategies

   This section elaborates on what has been done in previous sections.
   On the basis of the classifications, recommendations are given A.2.5.  UDP Checksum

   The UDP checksum is optional.  If disabled, its value is constantly
   zero and could be compressed away.  If enabled, its value depends on how
   to handle the various fields in
   the header payload, which for compression process.
   Seven different actions are possible; these are listed together with
   the fields purposes is equivalent to which each action applies. it
   changing randomly with every packet.

Appendix A.3.1.  Do not send at all A.2.6.  UDP-Lite Checksum Coverage

   The fields that Checksum Coverage field may behave in different ways: it may have well known values
   a priori do not value of zero, it may be equal to the datagram length, or it may
   have any value between eight octets and the length of the datagram.
   From a compression perspective, this field is expected to either be
   sent at all.  These are:
   o  IPv6 Payload Length
   o  IPv4 Header Length
   o  IPv4 Reserved Flag
   o  IPv4 Last Fragment Flag
   o  IPv4 Fragment Offset

   o
   entirely predictable (for the cases where it follows the same
   behavior as the UDP Checksum (if disabled)
   o  RTP Version

Appendix A.3.2.  Transmit only initially

   The fields that are Length field or where it takes on a constant throughout
   value) or either to change randomly for each packet (making the value
   unpredictable from a header-compression perspective).  For all cases,
   the behavior itself is not expected to change for this field during
   the lifetime of the a packet
   stream have flow, or to be transmitted and correctly delivered change relatively seldom.

Appendix A.2.7.  UDP-Lite Checksum

   As opposed to the
   decompressor only once.  These are:
   o  IP Version
   o  IPv6 Next Header
   o  IPv4 Protocol
   o  IP Source Address
   o  IP Destination Address
   o  IPv6 Flow Label
   o  UDP Source Port
   o UDP Destination Port
   o  UDP-Lite Source Port
   o checksum, the UDP-Lite Destination Port
   o  RTP SSRC

Appendix A.3.3.  Transmit initially, checksum is not optional
   and it cannot be prepared disabled.  Its value depends on the payload and on
   the checksum coverage field, which for compression purposes is
   equivalent to update

   The fields that are it changing only occasionally must be transmitted
   initially but there must also be randomly with every packet.

Appendix A.2.8.  RTP CSRC Counter

   This is a way counter indicating the number of CSRC items present in the
   CSRC list.  This number is expected to update these fields with
   new values if they change.  These fields are:
   o  IPv6 Traffic Class
   o  IPv4 Don't Fragment Flag
   o  IPv6 Hop Limit
   o  IPv4 Type Of Service (TOS)
   o  IPv4 Time To Live (TTL)
   o  UDP-Lite Checksum Coverage (if be almost constant or assigned to datagram
      length)
   o on a
   packet-to-packet basis and change by small amounts.  As long as no
   RTP mixer is used, the value of this field will be zero.

Appendix A.2.9.  RTP Marker

   For audio the marker bit should be set only in the first packet of a
   talkspurt, while for video it should be set in the last packet of
   every picture.  This means that in both cases the RTP CSRC Counter
   o marker is
   classified as SEMISTATIC..

Appendix A.2.10.  RTP Padding Flag
   o

   If padding is used, it is expected to be present in most packets, but
   is classified as RC to allow efficient compression even when this
   field changes.

Appendix A.2.11.  RTP Extension Flag
   o

   If extensions are used, it is expected to be used in most packets,
   but is classified as RC to allow efficient compression even when this
   field changes.

Appendix A.2.12.  RTP Payload Type
   o

   Changes of the RTP CSRC List

Appendix A.3.4.  Be prepared to update, or send as-is frequently

   For fields that normally either payload type within a packet stream are constant or have values deducible
   from some other field, but that frequently diverge from that
   behavior, there must expected
   to be an efficient way rare.  Applications could adapt to update the field value or
   send it as-is in some packets.  These fields are:
   o  IPv4 Identification (if congestion by changing
   payload type and/or frame sizes, but that is not sequentially assigned)
   o expected to happen
   frequently.

Appendix A.2.13.  RTP Marker
   o Sequence Number

   The RTP Timestamp

Appendix A.3.5.  Guarantee continuous robustness

   For fields that behave like a counter with a fixed delta Sequence Number will be incremented by one for ALL
   packets, each packet
   sent.

Appendix A.2.14.  RTP Timestamp

   In the only requirement on audio case:

      As long as there are no pauses in the transmission encoding is that
   packet losses between compressor and decompressor must be tolerable.
   If several such fields exist, all these can be communicated together.
   Such fields can also audio stream, the RTP
      Timestamp will be used incremented by a constant delta, corresponding
      to interpret the values for fields
   listed number of samples in the previous section.  Fields that have this counter
   behavior are:
   o  IPv4 Identification (if sequentially assigned)
   o speech frame.  It will thus mostly
      follow the RTP Sequence Number

Appendix A.3.6.  Transmit as-is in all packets

   Fields that have completely random values for each packet must be
   included as-is in all compressed headers.  Those fields are:
   o  IPv4 Identification (if randomly assigned)
   o  UDP Checksum (if enabled)
   o  UDP-Lite Checksum
   o  UDP-Lite Checksum Coverage (if randomly assigned)

Appendix A.3.7.  Establish Number.  When there has been a silent
      period and be prepared a new talkspurt begins, the timestamp will jump in
      proportion to update delta

   Finally, there is the length of the silent period.  However, the
      increment will probably be within a field that is usually increasing relatively limited range.

   In the video case:

      Between two consecutive packets, the timestamp will either be
      unchanged or increase by a multiple of a fixed delta
   and is correlated to another field.  For this field it would make
   sense value corresponding
      to make that delta part the picture clock frequency.  The timestamp can also decrease
      by a multiple of the context state. fixed value for certain coding schemes.  The
      delta must
   then be initiated and updated interval, expressed as a multiple of the picture clock
      frequency, is in most cases very limited.

Appendix A.2.15.  RTP Contributing Sources (CSRC)

   The participants in a session, which are identified by the CSRC
   fields, are expected to be almost the same way on a packet-to-packet
   basis with relatively few additions and removals.  As long as the RTP
   mixers are not used, no CSRC fields listed in
   A.3.3. are present at all.

Appendix A.2.16.  ESP Sequence Number

   The field to which this applies is:
   o  RTP Timestamp ESP Sequence Number will be incremented by one for each packet
   sent.

Appendix B.  Differences between RoHCv2 and RFC3095 profiles

   To be Written

   Profiles defined in RFC3095 were designed with the assumption that
   the channel between compressor and decompressor maintains packet
   ordering, i.e., that the decompressor always receive packets in the
   same order as the compressor sent them.  RoHCv2 profiles does not
   make this assumption, i.e. reordering before and after the
   compression point is handled as part of the compression algorithm
   itself.

Appendix C.  Sample CRC algorithm

      #!/usr/bin/perl -w
      use strict;
      #=================================
      #
      # ROHC CRC demo - Carsten Bormann cabo@tzi.org 2001-08-02
      #
      # This little demo shows the three types

   Some of CRC in use in
      # RFC3095, the RoHC Framework and ROHC other technical differences between these specifications
   are:
   o  ROHCv2 profiles that
      # specificy robust header compression.
      # Type your data in hexadecimal form do not contain multiple modes with different
      updating logic and then
      # press Control+D.
      #
      #---------------------------------
      #
      # utility
      #
      sub dump_bytes($) {
          my $x = shift;
          my $i;
          for ($i = 0; $i < length($x); ) {
        printf("%02x ", ord(substr($x, $i, 1)));
        printf("\n") if (++$i % 16 == 0);
          }
          printf("\n") if ($i % 16 != 0);
      }

      #---------------------------------
      #
      # The CRC calculation algorithm.
      #
      sub do_crc($$$) {
          my $nbits = shift;
          my $poly = shift;
          my $string = shift;

          my $crc = ($nbits == 32 ? 0xffffffff : (1 << $nbits) - 1);
          for (my $i = 0; $i < length($string); ++$i) {
            my $byte = ord(substr($string, $i, 1));
            for( my $b = 0; $b < 8; $b++ ) {
              if (($crc & 1) ^ ($byte & 1)) {
                $crc >>= 1;
                $crc ^= $poly;
              } else {
              $crc >>= 1;
              }
              $byte >>= 1;
            }
          }
          printf "%2d bits, ", $nbits;
          printf "CRC: %02x\n", $crc;
      }

      #---------------------------------
      #
      # Test harness
      #
      $/ = undef;
      $_ = <>;         # read until EOF
      my $string = ""; # extract all that looks hex:
      s/([0-9a-fA-F][0-9a-fA-F])/$string .= chr(hex($1)), ""/eg;
      dump_bytes($string);

      #---------------------------------
      #
      # 32-bit segmentation CRC
      # Note different packet format sets.  Insted, ROHCv2
      profiles assume bidirectional opeartion from the time that the text implies this
      first feedback is complemented like received.
   o  Simplified handling of extension headers.
   o  Simplified list compression for PPP
      # (this differs from 8, 7, CSRC lists.
   o  The IR-DYN packet is not used, and 3-bit CRC)
      #
      #      C(x) = x^0 + x^1 + x^2 + x^4 + x^5 + x^7 + x^8 + x^10 +
      #             x^11 + x^12 + x^16 + x^22 + x^23 + x^26 + x^32
      #
      do_crc(32, 0xedb88320, $string);

      #---------------------------------
      #
      # 8-bit IR/IR-DYN CRC
      #
      #      C(x) = x^0 + x^1 + x^2 + x^8
      #
      do_crc(8, 0xe0, $string);

      #---------------------------------
      #
      # instead, each profile contains
      a co_repair packet which is protected by a 7-bit FO/SO CRC
      #
      #      C(x) = x^0 + x^1 + x^2 + x^3 + x^6 + x^7
      #
      do_crc(7, 0x79, $string);

      #---------------------------------
      #
      # 3-bit FO/SO CRC
      #
      #      C(x) = x^0 + x^1 + x^3
      #
      do_crc(3, 0x6, $string); CRC.  This also
      means that profile downgrading via IR-DYN was removed.
   o  Different decompressor state transitions in order to improve
      robustness when initiating the context.
   o  The format of FEEDBACK-2 now includes a CRC, and there have been
      changes in which of feedback options that are used.

Authors' Addresses

   Ghyslain Pelletier
   Ericsson
   Box 920
   Lulea  SE-971 28
   Sweden

   Phone: +46 (0) 8 404 29 43
   Email: ghyslain.pelletier@ericsson.com

   Kristofer Sandlund
   Ericsson
   Box 920
   Lulea  SE-971 28
   Sweden

   Phone: +46 (0) 8 404 41 58
   Email: kristofer.sandlund@ericsson.com

Full Copyright Statement

   Copyright (C) The Internet Society (2006). IETF Trust (2007).

   This document is subject to the rights, licenses and restrictions
   contained in BCP 78, and except as set forth therein, the authors
   retain all their rights.

   This document and the information contained herein are provided on an
   "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
   OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY SOCIETY, THE IETF TRUST AND
   THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF
   THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

Intellectual Property

   The IETF takes no position regarding the validity or scope of any
   Intellectual Property Rights or other rights that might be claimed to
   pertain to the implementation or use of the technology described in
   this document or the extent to which any license under such rights
   might or might not be available; nor does it represent that it has
   made any independent effort to identify any such rights.  Information
   on the procedures with respect to rights in RFC documents can be
   found in BCP 78 and BCP 79.

   Copies of IPR disclosures made to the IETF Secretariat and any
   assurances of licenses to be made available, or the result of an
   attempt made to obtain a general license or permission for the use of
   such proprietary rights by implementers or users of this
   specification can be obtained from the IETF on-line IPR repository at
   http://www.ietf.org/ipr.

   The IETF invites any interested party to bring to its attention any
   copyrights, patents or patent applications, or other proprietary
   rights that may cover technology that may be required to implement
   this standard.  Please address the information to the IETF at
   ietf-ipr@ietf.org.

Acknowledgment

   Funding for the RFC Editor function is provided by the IETF
   Administrative Support Activity (IASA).