home *** CD-ROM | disk | FTP | other *** search
/ Internet Core Protocols / Oreilly-InternetCoreProtocols.iso / RFCs / rfc2507.txt < prev    next >
Encoding:
Text File  |  1999-10-14  |  106.4 KB  |  2,636 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                                       M. Degermark
  8. Request for Comments: 2507           Lulea University of Technology/SICS
  9. Category: Standards Track                                    B. Nordgren
  10.                         Lulea University of Technology/Telia Research AB
  11.                                                                  S. Pink
  12.                                      Lulea University of Technology/SICS
  13.                                                            February 1999
  14.  
  15.  
  16.                          IP Header Compression
  17.  
  18. Status of this Memo
  19.  
  20.    This document specifies an Internet standards track protocol for the
  21.    Internet community, and requests discussion and suggestions for
  22.    improvements.  Please refer to the current edition of the "Internet
  23.    Official Protocol Standards" (STD 1) for the standardization state
  24.    and status of this protocol.  Distribution of this memo is unlimited.
  25.  
  26. Copyright Notice
  27.  
  28.    Copyright (C) The Internet Society (1999).  All Rights Reserved.
  29.  
  30. Abstract
  31.  
  32.    This document describes how to compress multiple IP headers and TCP
  33.    and UDP headers per hop over point to point links. The methods can be
  34.    applied to of IPv6 base and extension headers, IPv4 headers, TCP and
  35.    UDP headers, and encapsulated IPv6 and IPv4 headers.
  36.  
  37.    Headers of typical UDP or TCP packets can be compressed down to 4-7
  38.    octets including the 2 octet UDP or TCP checksum. This largely
  39.    removes the negative impact of large IP headers and allows efficient
  40.    use of bandwidth on low and medium speed links.
  41.  
  42.    The compression algorithms are specifically designed to work well
  43.    over links with nontrivial packet-loss rates. Several wireless and
  44.    modem technologies result in such links.
  45.  
  46. TABLE OF CONTENTS
  47.  
  48.    1.  Introduction..............................................3
  49.    2.  Terminology...............................................5
  50.    3.  Compression method........................................7
  51.         3.1.  Packet types.......................................8
  52.         3.2.  Lost packets in TCP packet streams.................9
  53.         3.3.  Lost packets in UDP and non-TCP packet streams....10
  54.    4.  Grouping packets into packet streams.....................14
  55.  
  56.  
  57.  
  58. Degermark, et. al.          Standards Track                     [Page 1]
  59.  
  60. RFC 2507                 IP Header Compression             February 1999
  61.  
  62.  
  63.         4.1.  Guidelines for grouping packets...................15
  64.    5.  Size Issues..............................................16
  65.         5.1.  Context identifiers...............................16
  66.         5.2.  Size of the context...............................17
  67.         5.3.  Size of full headers..............................18
  68.            5.3.1.  Length fields in full TCP headers............19
  69.            5.3.2.  Length fields in full non-TCP headers........19
  70.    6.  Compressed Header Formats................................20
  71.    7.  Compression of subheaders................................22
  72.         7.1.  IPv6 Header.......................................24
  73.         7.2.  IPv6 Extension Headers............................25
  74.         7.3.  Options...........................................25
  75.         7.4.  Hop-by-hop Options Header.........................26
  76.         7.5.  Routing Header....................................26
  77.         7.6.  Fragment Header...................................27
  78.         7.7.  Destination Options Header........................28
  79.         7.8.  No Next Header....................................29
  80.         7.9.  Authentication Header.............................29
  81.         7.10. Encapsulating Security Payload Header.............29
  82.         7.11. UDP Header........................................30
  83.         7.12. TCP Header........................................30
  84.         7.13. IPv4 Header.......................................33
  85.         7.14  Minimal Encapsulation header......................34
  86.    8.  Changing context identifiers.............................35
  87.    9.  Rules for dropping or temporarily storing packets........35
  88.    10. Low-loss header compression for TCP .....................36
  89.         10.1.  The "twice" algorithm............................37
  90.         10.2.  Header Requests..................................37
  91.    11. Links that reorder packets...............................38
  92.         11.1.  Reordering in non-TCP packet streams.............39
  93.         11.2.  Reordering in TCP packet streams.................39
  94.    12. Hooks for additional header compression..................40
  95.    13. Demultiplexing...........................................41
  96.    14. Configuration Parameters.................................42
  97.    15. Implementation Status....................................43
  98.    16. Acknowledgments..........................................44
  99.    17. Security Considerations..................................44
  100.    18. Authors' Addresses.......................................45
  101.    19. References...............................................46
  102.    20. Full Copyright Statement.................................47
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Degermark, et. al.          Standards Track                     [Page 2]
  115.  
  116. RFC 2507                 IP Header Compression             February 1999
  117.  
  118.  
  119. 1.  Introduction
  120.  
  121.    There are several reasons to do header compression on low- or
  122.    medium-speed links. Header compression can
  123.  
  124.    *  Improve interactive response time
  125.  
  126.       For very low-speed links, echoing of characters may take longer
  127.       than 100-200 ms because of the time required to transmit large
  128.       headers. 100-200 ms is the maximum time people can tolerate
  129.       without feeling that the system is sluggish.
  130.  
  131.    * Allow using small packets for bulk data with good line efficiency
  132.  
  133.       This is important when interactive (for example Telnet) and bulk
  134.       traffic (for example FTP) is mixed because the bulk data should be
  135.       carried in small packets to decrease the waiting time when a
  136.       packet with interactive data is caught behind a bulk data packet.
  137.  
  138.       Using small packet sizes for the FTP traffic in this case is a
  139.       global solution to a local problem. It will increase the load on
  140.       the network as it has to deal with many small packets. A better
  141.       solution might be to locally fragment the large packets over the
  142.       slow link.
  143.  
  144.    * Allow using small packets for delay sensitive low data-rate traffic
  145.  
  146.       For such applications, for example voice, the time to fill a
  147.       packet with data is significant if packets are large.  To get low
  148.       end-to-end delay small packets are preferred.  Without header
  149.       compression, the smallest possible IPv6/UDP headers (48 octets)
  150.       consume 19.2 kbit/s with a packet rate of 50 packets/s.  50
  151.       packets/s is equivalent to having 20 ms worth of voice samples in
  152.       each packet. IPv4/UDP headers consumes 11.2 kbit/s at 50
  153.       packets/s.  Tunneling or routing headers, for example to support
  154.       mobility, will increase the bandwidth consumed by headers by 10-20
  155.       kbit/s.  This should be compared with the bandwidth required for
  156.       the actual sound samples, for example 13 kbit/s with GSM encoding.
  157.       Header compression can reduce the bandwidth needed for headers
  158.       significantly, in the example to about 1.7 kbit/s. This enables
  159.       higher quality voice transmission over 14.4 and 28.8 kbit/s
  160.       modems.
  161.  
  162.    *  Decrease header overhead.
  163.  
  164.       A common size of TCP segments for bulk transfers over medium-speed
  165.       links is 512 octets today. When TCP segments are tunneled, for
  166.       example because Mobile IP is used, the IPv6/IPv6/TCP header is 100
  167.  
  168.  
  169.  
  170. Degermark, et. al.          Standards Track                     [Page 3]
  171.  
  172. RFC 2507                 IP Header Compression             February 1999
  173.  
  174.  
  175.       octets.  Header compression will decrease the header overhead for
  176.       IPv6/TCP from 19.5 per cent to less than 1 per cent, and for
  177.       tunneled IPv4/TCP from 11.7 to less than 1 per cent. This is a
  178.       significant gain for line-speeds as high as a few Mbit/s.
  179.  
  180.       The IPv6 specification prescribes path MTU discovery, so with IPv6
  181.       bulk TCP transfers should use segments larger than 512 octets when
  182.       possible.  Still, with 1400 octet segments (RFC 894 Ethernet
  183.       encapsulation allows 1500 octet payloads, of which 100 octets are
  184.       used for IP headers), header compression reduces IPv6 header
  185.       overhead from 7.1% to 0.4%.
  186.  
  187.    *  Reduce packet loss rate over lossy links.
  188.  
  189.       Because fewer bits are sent per packet, the packet loss rate will
  190.       be lower for a given bit-error rate. This results in higher
  191.       throughput for TCP as the sending window can open up more between
  192.       losses, and in fewer lost packets for UDP.
  193.  
  194.    The mechanisms described here are intended for a point-to-point link.
  195.    However, care has been taken to allow extensions for multi-access
  196.    links and multicast.
  197.  
  198.    Headers that can be compressed include TCP, UDP, IPv4, and IPv6 base
  199.    and extension headers.  For TCP packets, the mechanisms of Van
  200.    Jacobson [RFC-1144] are used to recover from loss. Two additional
  201.    mechanisms that increase the efficiency of VJ header compression over
  202.    lossy links are also described.  For non-TCP packets, compression
  203.    slow-start and periodic header refreshes allow minimal periods of
  204.    packet discard after loss of a header that changes the context. There
  205.    are hooks for adding header compression schemes on top of UDP, for
  206.    example compression of RTP headers.
  207.  
  208.    Header compression relies on many fields being constant or changing
  209.    seldomly in consecutive packets belonging to the same packet stream.
  210.    Fields that do not change between packets need not be transmitted at
  211.    all.  Fields that change often with small and/or predictable values,
  212.    e.g., TCP sequence numbers, can be encoded incrementally so that the
  213.    number of bits needed for these fields decrease significantly.  Only
  214.    fields that change often and randomly, e.g., checksums or
  215.    authentication data, need to be transmitted in every header.
  216.  
  217.    The general principle of header compression is to occasionally send a
  218.    packet with a full header; subsequent compressed headers refer to the
  219.    context established by the full header and may contain incremental
  220.    changes to the context.
  221.  
  222.  
  223.  
  224.  
  225.  
  226. Degermark, et. al.          Standards Track                     [Page 4]
  227.  
  228. RFC 2507                 IP Header Compression             February 1999
  229.  
  230.  
  231.    This header compression scheme does not require that all packets in
  232.    the same stream passes over the compressed link. However, for TCP
  233.    streams the difference between subsequent headers can become more
  234.    irregular and the compression rate can decrease. Neither is it
  235.    required that corresponding TCP data and acknowledgment packets
  236.    traverse the link in opposite directions.
  237.  
  238.    This header compression scheme is useful on first-hop or last-hop
  239.    links as well as links in the middle of the network. When many packet
  240.    streams (several hundred) traverse the link, a phenomenon that could
  241.    be called CID thrashing could occur, where headers seldom can be
  242.    matched with an existing context and have to be sent uncompressed or
  243.    as full headers. It is up to an implementation to use techniques such
  244.    as hysteresis to ensure that the packet streams that give the highest
  245.    compression rates keep their context.  Such techniques are more
  246.    likely to be needed in the middle of the network.
  247.  
  248. 2.  Terminology
  249.  
  250.    This section explains some terms used in this document.
  251.  
  252.    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  253.    "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  254.    document are to be interpreted as described in RFC 2119.
  255.  
  256.    Subheader
  257.  
  258.       An IPv6 base header, an IPv6 extension header, an IPv4 header, a
  259.       UDP header, or a TCP header.
  260.  
  261.    Header
  262.  
  263.       A chain of subheaders.
  264.  
  265.    Compress
  266.  
  267.       The act of reducing the size of a header by removing header fields
  268.       or reducing the size of header fields. This is done in a way such
  269.       that a decompressor can reconstruct the header if its context
  270.       state is identical to the context state used when compressing the
  271.       header.
  272.  
  273.    Decompress
  274.  
  275.       The act of reconstructing a compressed header.
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282. Degermark, et. al.          Standards Track                     [Page 5]
  283.  
  284. RFC 2507                 IP Header Compression             February 1999
  285.  
  286.  
  287.    Context identifier (CID)
  288.  
  289.       A small unique number identifying the context that should be used
  290.       to decompress a compressed header.  Carried in full headers and
  291.       compressed headers.
  292.  
  293.    Context
  294.  
  295.       The state which the compressor uses to compress a header and the
  296.       decompressor uses to decompress a header.  The context is the
  297.       uncompressed version of the last header sent (compressor) or
  298.       received (decompressor) over the link, except for fields in the
  299.       header that are included "as-is" in compressed headers or can be
  300.       inferred from, e.g., the size of the link-level frame.
  301.  
  302.       The context for a packet stream is associated with a context
  303.       identifier.  The context for non-TCP packet streams is also
  304.       associated with a generation.
  305.  
  306.    Generation
  307.  
  308.       For non-TCP packet streams, each new version of the context for a
  309.       given CID is associated with a generation: a small number that is
  310.       incremented whenever the context associated with that CID changes.
  311.       Carried by full and compressed non-TCP headers.
  312.  
  313.    Packet stream
  314.  
  315.       A sequence of packets whose headers are similar and share context.
  316.       For example, headers in a TCP packet stream have the same source
  317.       and final destination address, and the same port numbers in the
  318.       TCP header.  Similarly, headers in a UDP packet stream have the
  319.       same source and destination address, and the same port numbers in
  320.       the UDP header.
  321.  
  322.    Full header (header refresh)
  323.  
  324.       An uncompressed header that updates or refreshes the context for a
  325.       packet stream. It carries a CID that will be used to identify the
  326.       context.
  327.  
  328.       Full headers for non-TCP packet streams also carry the generation
  329.       of the context they update or refresh.
  330.  
  331.    Regular header
  332.  
  333.       A normal, uncompressed, header.  Does not carry CID or generation
  334.       association.
  335.  
  336.  
  337.  
  338. Degermark, et. al.          Standards Track                     [Page 6]
  339.  
  340. RFC 2507                 IP Header Compression             February 1999
  341.  
  342.  
  343.    Incorrect decompression
  344.  
  345.       When a compressed and then decompressed header is different from
  346.       the uncompressed header. Usually due to mismatching context
  347.       between the compressor and decompressor or bit errors during
  348.       transmission of the compressed header.
  349.  
  350.    Differential coding
  351.  
  352.       A compression technique where the compressed value of a header
  353.       field is the difference between the current value of the field and
  354.       the value of the same field in the previous header belonging to
  355.       the same packet stream. A decompressor can thus obtain the value
  356.       of the field by adding the value in the compressed header to its
  357.       context.  This technique is used for TCP streams but not for non-
  358.       TCP streams.
  359.  
  360. 3.  Compression method
  361.  
  362.    Much of the header information stays the same over the life-time of a
  363.    packet stream. For non-TCP packet streams almost all fields of the
  364.    headers are constant. For TCP many fields are constant and others
  365.    change with small and predictable values.
  366.  
  367.    To initiate compression of the headers of a packet stream, a full
  368.    header carrying a context identifier, CID, is transmitted over the
  369.    link.  The compressor and decompressor store most fields of this full
  370.    header as context.  The context consists of the fields of the header
  371.    whose values are constant and thus need not be sent over the link at
  372.    all, or change little between consecutive headers so that it uses
  373.    fewer bits to send the difference from the previous value compared to
  374.    sending the absolute value.
  375.  
  376.    Any change in fields that are expected to be constant in a packet
  377.    stream will cause the compressor to send a full header again to
  378.    update the context at the decompressor. As long as the context is the
  379.    same at compressor and decompressor, headers can be decompressed to
  380.    be exactly as they were before compression. However, if a full header
  381.    or compressed header is lost during transmission, the context of the
  382.    decompressor may become obsolete as it is not updated properly.
  383.    Compressed headers will then be decompressed incorrectly.
  384.  
  385.    IPv6 is not meant to be used over links that can deliver a
  386.    significant fraction of damaged packets to the IPv6 module.  This
  387.    means that links must have a very low bit-error rate or that link-
  388.    level frames must be protected by strong checksums, forward error
  389.    correction or something of that nature.  Header compression SHOULD
  390.    not be used for IPv4 without strong link-level checksums.  Damaged
  391.  
  392.  
  393.  
  394. Degermark, et. al.          Standards Track                     [Page 7]
  395.  
  396. RFC 2507                 IP Header Compression             February 1999
  397.  
  398.  
  399.    frames will thus be discarded by the link layer.  The link layer
  400.    implementation might indicate to the header compression module that a
  401.    frame was damaged, but it cannot say what packet stream it belonged
  402.    to as it might be the CID that is damaged.  Moreover, frames may
  403.    disappear without the link layer implementation's knowledge, for
  404.    example if the link is a multi-hop link where frames can be dropped
  405.    due to congestion at each hop.  The kind of link errors that a header
  406.    compression module should deal with and protect against will thus be
  407.    packet loss.
  408.  
  409.    So a header compression scheme needs mechanisms to update the context
  410.    at the decompressor and to detect or avoid incorrect decompression.
  411.    These mechanisms are very different for TCP and non-TCP streams, and
  412.    are described in sections 3.2 and 3.3.
  413.  
  414.    The compression mechanisms in this document assume that packets are
  415.    not reordered between the compressor and decompressor.  If the link
  416.  
  417.    does reorder, section 11 describes mechanisms for ordering the
  418.    packets before decompression.  It is also assumed that the link-layer
  419.    implementation can provide the length of packets, and that there is
  420.    no padding in UDP packets or tunneled packets.
  421.  
  422. 3.1.  Packet types
  423.  
  424.    This compression method uses four packet types in addition to the
  425.    IPv4 and IPv6 packet types.  The combination of link-level packet
  426.    type and the value of the first four bits of the packet uniquely
  427.    determines the packet type.  Details on how these packet types are
  428.    represented are in section 13.
  429.  
  430.        FULL_HEADER - indicates a packet with an uncompressed header,
  431.        including a CID and, if not a TCP packet, a generation.  It
  432.        establishes or refreshes the context for the packet stream
  433.        identified by the CID.
  434.  
  435.        COMPRESSED_NON_TCP - indicates a non-TCP packet with a compressed
  436.        header. The compressed header consists of a CID identifying what
  437.        context to use for decompression, a generation to detect an
  438.        inconsistent context and the randomly changing fields of the
  439.        header.
  440.  
  441.        COMPRESSED_TCP - indicates a packet with a compressed TCP header,
  442.        containing a CID, a flag octet indentifying what fields have
  443.        changed, and the changed fields encoded as the difference from
  444.        the previous value.
  445.  
  446.  
  447.  
  448.  
  449.  
  450. Degermark, et. al.          Standards Track                     [Page 8]
  451.  
  452. RFC 2507                 IP Header Compression             February 1999
  453.  
  454.  
  455.        COMPRESSED_TCP_NODELTA - indicates a packet with a compressed TCP
  456.        header where all fields that are normally sent as the difference
  457.        to the previous value are instead sent as-is.  This packet type
  458.        is only sent as the response to a header request from the
  459.        decompressor. It must not be sent as the result of a
  460.        retransmission.
  461.  
  462.    In addition to the packet types used for compression, regular IPv4
  463.    and IPv6 packets are used whenever a compressor decides to not
  464.    compress a packet.  An additional packet type may be used to speed up
  465.    repair of TCP streams over links where the decompressor can send
  466.    packets to the compressor.
  467.  
  468.        CONTEXT_STATE - indicates a special packet sent from the
  469.        decompressor to the compressor to communicate a list of (TCP)
  470.        CIDs for which synchronization has been lost. This packet is only
  471.        sent over a single link so it requires no IP header. The format
  472.        is shown in section 10.2.
  473.  
  474. 3.2.  Lost packets in TCP packet streams
  475.  
  476.    Since TCP headers are compressed using the difference from the
  477.    previous TCP header, loss of a packet with a compressed or full
  478.    header will cause subsequent compressed headers to be decompressed
  479.    incorrectly because the context used for decompression was not
  480.    incremented properly.
  481.  
  482.    Loss of a compressed TCP header will cause the TCP sequence numbers
  483.    of subsequently decompressed TCP headers to be off by k, where k is
  484.    the size of the lost segment.  Such incorrectly decompressed TCP
  485.    headers will be discarded by the TCP receiver as the TCP checksum
  486.    reliably catches "off-by-k" errors in the sequence numbers for
  487.    plausible k.
  488.  
  489.    TCP's repair mechanisms will eventually retransmit the discarded
  490.    segment and the compressor peeks into the TCP headers to detect when
  491.    TCP retransmits.  When this happens, the compressor sends a full
  492.    header on the assumption that the retransmission was due to
  493.    mismatching compression state at the decompressor.  [RFC-1144] has a
  494.    good explanation of this mechanism.
  495.  
  496.    The mechanisms of section 10 should be used to speed up the repair of
  497.    the context.  This is important over medium speed links with high
  498.    packet loss rates, for example wireless.  Losing a timeout's worth of
  499.    packets due to inconsistent context after each packet lost over the
  500.    link is not acceptable, especially when the TCP connection is over
  501.    the wide area.
  502.  
  503.  
  504.  
  505.  
  506. Degermark, et. al.          Standards Track                     [Page 9]
  507.  
  508. RFC 2507                 IP Header Compression             February 1999
  509.  
  510.  
  511. 3.3.  Lost packets in UDP and other non-TCP packet streams
  512.  
  513.    Incorrectly decompressed headers of UDP packets and other non-TCP
  514.    packets are not so well-protected by checksums as TCP packets.  There
  515.    are no sequence numbers that become "off-by-k" and virtually
  516.    guarantees a failed checksum as there are for TCP. The UDP checksum
  517.    only covers payload, UDP header, and pseudo header.  The pseudo
  518.    header includes the source and destination addresses, the transport
  519.    protocol type and the length of the transport packet.  Except for
  520.    those fields, large parts of the IPv6 header are not covered by the
  521.    UDP checksum.  Moreover, other non-TCP headers lack checksums
  522.    altogether, for example fragments.
  523.  
  524.    In order to safely avoid incorrect decompression of non-TCP headers,
  525.    each version of the context for non-TCP packet streams is identified
  526.    by a generation, a small number that is carried by the full headers
  527.    that establish and refresh the context.  Compressed headers carry the
  528.    generation value of the context that were used to compress them.
  529.    When a decompressor sees that a compressed header carries a
  530.    generation value other than the generation of its context for that
  531.    packet stream, the context is not up to date and the packet must be
  532.    discarded or stored until a full header establishes correct context.
  533.  
  534.    Differential coding is not used for non-TCP streams, so compressed
  535.    non-TCP headers do not change the context.  Thus, loss of a
  536.    compressed header does not invalidate subsequent packets with
  537.    compressed headers. Moreover, the generation changes only when the
  538.    context of a full header is different from the context of the
  539.    previous full header. This means that losing a full header will make
  540.    the context of the decompressor obsolete only when the full header
  541.    would actually have changed the context.
  542.  
  543.    The generation field is 6 bits long so the generation value repeats
  544.    itself after 64 changes to the context. To avoid incorrect
  545.    decompression after error bursts or other temporary disruptions, the
  546.    compressor must not reuse the same generation value after a shorter
  547.    time than MIN_WRAP seconds. A decompressor which has been
  548.    disconnected MIN_WRAP seconds or more must wait for the next full
  549.    header before decompressing. A compressor must wait at least MIN_WRAP
  550.    seconds after booting before compressing non-TCP headers. Instead of
  551.    reusing a generation value too soon, a compressor may switch to
  552.    another CID or send regular headers until MIN_WRAP seconds have
  553.    passed.  The value of MIN_WRAP is found in section 14.
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562. Degermark, et. al.          Standards Track                    [Page 10]
  563.  
  564. RFC 2507                 IP Header Compression             February 1999
  565.  
  566.  
  567. 3.3.1.  Compression Slow-Start
  568.  
  569.    To allow the decompressor to recover quickly from loss of a full
  570.    header that would have changed the context, full headers are sent
  571.    periodically with an exponentially increasing period after a change
  572.    in the context. This technique avoids an exchange of messages between
  573.    compressor and decompressor used by other compression schemes, such
  574.    as in [RFC-1553]. Such exchanges can be costly for wireless mobiles
  575.    as more power is consumed by the transmitter and delay can be
  576.    introduced by switching between sending and receiving.  Moreover,
  577.    techniques that require an exchange of messages cannot be used over
  578.    simplex links, such as direct-broadcast satellite channels or cable
  579.    TV systems, and are hard to adapt to multicast over multi-access
  580.    links.
  581.  
  582.     |.|..|....|........|................|..............................
  583.     ^
  584.     Change   Sent packets: | with full header, . with compressed header
  585.  
  586.    The picture shows how packets are sent after change.  The compressor
  587.    keeps a variable for each non-TCP packet stream, F_PERIOD, that keeps
  588.    track of how many compressed headers may be sent between full
  589.    headers.  When the headers of a non-TCP packet stream change so that
  590.    its context changes, a full header is sent and F_PERIOD is set to
  591.    one. After sending F_PERIOD compressed headers, a full header is
  592.    sent.  F_PERIOD is doubled each time a full header is sent during
  593.    compression slow-start.
  594.  
  595. 3.3.2.  Periodic Header Refreshes
  596.  
  597.    To avoid losing too many packets if a receiver has lost its context,
  598.    there is an upper limit, F_MAX_PERIOD, on the number of non-TCP
  599.    packets with compressed headers that may be sent between header
  600.    refreshes. If a packet is to be sent and F_MAX_PERIOD compressed
  601.    headers have been sent since the last full header for this packet
  602.    stream was sent, a full header must be sent.
  603.  
  604.    To avoid long periods of disconnection for low data rate packet
  605.    streams, there is also an upper bound, F_MAX_TIME, on the time
  606.    between full headers in a non-TCP packet stream. If a packet is to be
  607.    sent and more than F_MAX_TIME seconds have passed since the last full
  608.    header was sent for this packet stream, a full header must be sent.
  609.    The values of F_MAX_PERIOD and F_MAX_TIME are found in section 14.
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618. Degermark, et. al.          Standards Track                    [Page 11]
  619.  
  620. RFC 2507                 IP Header Compression             February 1999
  621.  
  622.  
  623. 3.3.3. Rules for sending Full Headers
  624.  
  625.    The following pseudo code can be used by the compressor to determine
  626.    when to send a full header for a non-TCP packet stream.  The code
  627.    maintains two variables:
  628.  
  629.          C_NUM       -- a count of the number of compressed headers sent
  630.                         since the last full header was sent.
  631.          F_LAST      -- the time of sending the last full header.
  632.  
  633.    and uses the functions
  634.  
  635.          current_time()       return the current time
  636.          min(a,b)             return the smallest of a and b
  637.  
  638.       the procedures send_full_header(), increment_generation_value(),
  639.       and send_compressed_header()
  640.       do the obvious thing.
  641.  
  642.          if ( <this header changes the context> )
  643.  
  644.              C_NUM := 0;
  645.              F_LAST := current_time();
  646.              F_PERIOD := 1;
  647.              increment_generation_value();
  648.              send_full_header();
  649.  
  650.          elseif ( C_NUM >= F_PERIOD )
  651.  
  652.              C_NUM := 0;
  653.              F_LAST := current_time();
  654.              F_PERIOD := min(2 * F_PERIOD, F_MAX_PERIOD);
  655.              send_full_header();
  656.  
  657.          elseif ( current_time() > F_LAST + F_MAX_TIME )
  658.  
  659.              C_NUM := 0;
  660.              F_LAST := current_time();
  661.              send_full_header();
  662.  
  663.          else
  664.  
  665.              C_NUM := C_NUM + 1
  666.              send_compressed_header();
  667.  
  668.          endif
  669.  
  670.  
  671.  
  672.  
  673.  
  674. Degermark, et. al.          Standards Track                    [Page 12]
  675.  
  676. RFC 2507                 IP Header Compression             February 1999
  677.  
  678.  
  679. 3.3.4.  Cost of sending Header Refreshes
  680.  
  681.    If every f'th packet carries a full header, H is the size of a full
  682.    header, and C is the size of a compressed header, the average header
  683.    size is
  684.  
  685.                  (H-C)/f + C
  686.  
  687.    For f > 1, the average header size is (H-C)/f larger than a
  688.    compressed header.
  689.  
  690.    In a diagram where the average header size is plotted for various f
  691.    values, there is a distinct knee in the curve, i.e., there is a limit
  692.    beyond which further increasing f gives diminishing returns.
  693.    F_MAX_PERIOD should be chosen to be a frequency well to the right of
  694.    the knee of the curve.  For typical sizes of H and C, say 48 octets
  695.    for the full header (IPv6/UDP) and 4 octets for the compressed
  696.    header, setting F_MAX_PERIOD > 44 means that full headers will
  697.    contribute less than an octet to the average header size. With a
  698.    four-address routing header, F_MAX_PERIOD > 115 will have the same
  699.    effect.
  700.  
  701.    The default F_MAX_PERIOD value of 256 (section 14) puts the full
  702.    header frequency well to the right of the knee and means that full
  703.    headers will typically contribute considerably less than an octet to
  704.    the average header size.  For H = 48 and C = 4, full headers
  705.    contribute about 1.4 bits to the average header size after reaching
  706.    the steady-state header refresh frequency determined by the default
  707.  
  708.    F_MAX_PERIOD. 1.4 bits is a very small overhead.
  709.  
  710.    After a change in the context, the exponential backoff scheme will
  711.    initially send full headers frequently.  The default F_MAX_PERIOD
  712.    will be reached after nine full headers and 255 compressed headers
  713.    have been sent.  This is equivalent to a little over 5 seconds for a
  714.    typical voice stream with 20 ms worth of voice samples per packet.
  715.  
  716.    During the whole backoff period, full headers contribute 1.5 octets
  717.    to the average header size when H = 48 and C = 4.  For 20 ms voice
  718.    samples, it takes less than 1.3 seconds until full headers contribute
  719.    less than one octet to the average header size, and during these
  720.    initial 1.3 seconds full headers add less than 4 octets to the
  721.    average header size.  The cost of the exponential backoff is not
  722.    great and as the headers of non-TCP packet streams are expected to
  723.    change seldomly, it will be amortized over a long time.
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. Degermark, et. al.          Standards Track                    [Page 13]
  731.  
  732. RFC 2507                 IP Header Compression             February 1999
  733.  
  734.  
  735.    The cost of header refreshes in terms of bandwidth are higher than
  736.    similar costs for hard state schemes like [RFC-1553] where full
  737.    headers must be acknowledged by the decompressor before compressed
  738.    headers may be sent. Such schemes typically send one full header plus
  739.    a few control messages when the context changes.  Hard state schemes
  740.    require more types of protocol messages and an exchange of messages
  741.    is necessary.  Hard state schemes also need to deal explicitly with
  742.    various error conditions that soft state handles automatically, for
  743.    instance the case of one party disappearing unexpectedly, a common
  744.    situation on wireless links where mobiles may go out of range of the
  745.    base station.
  746.  
  747.    The major advantage of the soft state scheme is that no handshakes
  748.    are needed between compressor and decompressor, so the scheme can be
  749.    used over simplex links.  The costs in terms of bandwidth are higher
  750.    than for hard state schemes, but the simplicity of the decompressor,
  751.    the simplicity of the protocol, and the lack of handshakes between
  752.    compressor and decompressor justifies this small cost. Moreover, soft
  753.    state schemes are more easily extended to multicast over multi-access
  754.    links, for example radio links.
  755.  
  756. 4.  Grouping packets into packet streams
  757.  
  758.    This section explains how packets MAY be grouped together into packet
  759.    streams for compression.  To achieve the best compression rates,
  760.    packets SHOULD be grouped together such that packets in the same
  761.    packet stream have similar headers. If this grouping fails, header
  762.    compression performance will be bad, since the compression algorithm
  763.    can rarely utilize the existing context for the packet stream and
  764.    full headers must be sent frequently.
  765.  
  766.    Grouping is done by the compressor. A compressor may use whatever
  767.    criterion it finds appropriate to group packets into packet streams.
  768.    To determine what packet stream a packet belongs to, a compressor MAY
  769.  
  770.    a) examine the compressible chain of subheaders (see section 7),
  771.  
  772.    b) examine the contents of an upper layer protocol header that
  773.       follows the compressible chain of subheaders, for example ICMP
  774.       headers, DVMRP headers, or tunneled IPX headers,
  775.  
  776.    c) use information obtained from a resource manager, for example if a
  777.       resource manager requests compression for a particular packet
  778.       stream and provides a way to identify packets belonging to that
  779.       packet stream,
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786. Degermark, et. al.          Standards Track                    [Page 14]
  787.  
  788. RFC 2507                 IP Header Compression             February 1999
  789.  
  790.  
  791.    d) use any other relevant information, for example if routes flap and
  792.       the hop limit (TTL) field in a packet stream changes frequently
  793.       between n and n+k, a compressor may choose to group the packets
  794.       into two different packet streams.
  795.  
  796.    A compressor is also free not to group packets into packet streams
  797.    for compression, letting some packets keep their regular headers and
  798.    passing them through unmodified.
  799.  
  800.    As long as the rules for when to send full headers for a non-TCP
  801.    packet stream are followed and subheaders are compressed as specified
  802.    in this document, the decompressor is able to reconstruct a
  803.    compressed header correctly regardless of how packets are grouped
  804.    into packet streams.
  805.  
  806. 4.1  Guidelines for grouping packets
  807.  
  808.    In this section we give OPTIONAL guidelines for how a compressor may
  809.    group packets into packet streams for compression.
  810.  
  811.    Defining fields
  812.  
  813.       The defining fields of a header should be present and identical in
  814.       all packets belonging to the same packet stream.  These fields are
  815.       marked DEF in section 7. The defining fields include the flow
  816.       label, source and destination addresses of IP headers, final
  817.       destination address in routing headers, the next header fields
  818.       (for IPv6), the protocol field (IPv4), port numbers (UDP and TCP),
  819.       and the SPI in authentication and encryption headers.
  820.  
  821.    Fragmented packets
  822.  
  823.       Fragmented and unfragmented packets should never be grouped
  824.       together in the same packet stream. The Identification field of
  825.       the Fragment header or IPv4 header should not be used to identify
  826.       the packet stream. If it was, the first fragment of a new packet
  827.       would cause a compression slow-start.
  828.  
  829.       No field after a Fragment Header, or an IPv4 header for a
  830.       fragment, should be used for grouping purposes.
  831.  
  832.    Upper protocol identification
  833.  
  834.       The first next header field identifying a header not described in
  835.       section 7 should be used for identifying packet streams, i.e., all
  836.       packets with the same DEF fields and the same upper protocol
  837.       should be grouped together.
  838.  
  839.  
  840.  
  841.  
  842. Degermark, et. al.          Standards Track                    [Page 15]
  843.  
  844. RFC 2507                 IP Header Compression             February 1999
  845.  
  846.  
  847.    TTL field (Hop Limit field)
  848.  
  849.       A sophisticated implementation might monitor the TTL (Hop Limit)
  850.       field and if it changes frequently use it as a DEF field. This can
  851.       occur when there are frequent route flaps so that packets traverse
  852.       different paths through the internet.
  853.  
  854.    Traffic Class field (IPv6), Type of Service field (IPv4)
  855.  
  856.       It is possible that the Traffic Class field of the IPv6 header and
  857.       the Type of Service of the IPv4 header will change frequently
  858.       between packets with otherwise identical DEF fields.  A
  859.       sophisticated implementation should watch out for this and be
  860.       prepared to use these fields as defining fields.
  861.  
  862.    When IP packets are tunneled they are encapsulated with an additional
  863.    IP header at the tunnel entry point and then sent to the tunnel
  864.    endpoint. To group such packets into packet streams, the inner
  865.    headers should also be examined to determine the packet stream.  If
  866.    this is not done, full headers will be sent each time the headers of
  867.    the inner IP packet changes.  So when a packet is tunneled, the
  868.    identifying fields of the inner subheaders should be considered in
  869.    addition to the identifying fields of the initial IP header.
  870.  
  871.    An implementation can use other fields for identification than the
  872.    ones described here. If too many fields are used for identification,
  873.    performance might suffer because more CIDs will be used and the wrong
  874.    CIDs might be reused when new flows need CIDs. If too few fields are
  875.    used for identification, performance might suffer because there are
  876.    too frequent changes to the context.
  877.  
  878.    We stress that these guidelines are educated guesses. When IPv6 is
  879.    widely deployed and IPv6 traffic can be analyzed, we might find that
  880.    other grouping algorithms perform better. We also stress that if the
  881.    grouping fails, the result will be bad performance but not incorrect
  882.    decompression. The decompressor can do its task regardless of how the
  883.    grouping algorithm works.
  884.  
  885. 5.  Size Issues
  886.  
  887. 5.1.  Context Identifiers
  888.  
  889.    Context identifiers can be 8 or 16 bits long.  Their size is not
  890.    relevant for finding the context.  An 8-bit CID with value two and a
  891.    16-bit CID with value two are equivalent.
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898. Degermark, et. al.          Standards Track                    [Page 16]
  899.  
  900. RFC 2507                 IP Header Compression             February 1999
  901.  
  902.  
  903.    The CID spaces for TCP and non-TCP are separate, so a TCP CID and a
  904.    non-TCP CID never identify the same context.  Even if they have the
  905.    same value. This doubles the available CID space while using the same
  906.    number of bits for CIDs.  It is always possible to tell whether a
  907.    full or compressed header is for a TCP or non-TCP packet, so no
  908.    mixups can occur.
  909.  
  910.    Non-TCP compressed headers encode the size of the CID using one bit
  911.    in the second octet of the compressed header. The 8-bit CID allows a
  912.    minimum compressed header size of 2 octets for non-TCP packets, the
  913.    CID uses the first octet and the size bit and the 6-bit Generation
  914.    value fit in the second octet.
  915.  
  916.    For TCP the only available CID size is 8 bits as in [RFC-1144].  8
  917.    bits is probably sufficient as TCP connections are always point-to-
  918.    point.
  919.  
  920.    The 16 bit CID size may not be needed for point-to-point links; it is
  921.    intended for use on multi-access links where a larger CID space may
  922.    be needed for efficient selection of CIDs.
  923.  
  924.    The major difficulty with multi-access links is that several
  925.    compressors share the CID space of a decompressor.  CIDs can no
  926.    longer be selected independently by the compressors as collisions may
  927.    occur.  This problem may be resolved by letting the decompressors
  928.    have a separate CID space for each compressor.  Having separate CID
  929.    spaces requires that decompressors can identify which compressor sent
  930.    the compressed packet, perhaps by utilizing link-layer information as
  931.    to who sent the link-layer frame.  If such information is not
  932.    available, all compressors on the multi-access link may be
  933.    enumerated, automatically or otherwise, and supply their number as
  934.    part of the CID. This latter method requires a large CID space.
  935.  
  936. 5.2.  Size of the context
  937.  
  938.    The size of the context SHOULD be limited to simplify implementation
  939.    of compressor and decompressor, and put a limit on their memory
  940.    requirements.  However, there is no upper limit on the size of an
  941.    IPv6 header as the chain of extension headers can be arbitrarily
  942.    long.  This is a problem as the context is essentially a stored
  943.    header.
  944.  
  945.    The configurable parameter MAX_HEADER (see section 14) represents the
  946.    maximum size of the context, expressed as the maximum sized header
  947.    that can be stored as context. When a header is larger than
  948.    MAX_HEADER, only part of it is stored as context.  An implementation
  949.    MUST NOT compress more than the initial MAX_HEADER octets of a
  950.    header.  An implementation MUST NOT partially compress a subheader.
  951.  
  952.  
  953.  
  954. Degermark, et. al.          Standards Track                    [Page 17]
  955.  
  956. RFC 2507                 IP Header Compression             February 1999
  957.  
  958.  
  959.    Thus, the part of the header that is stored as context and is
  960.    compressed is the longest initial sequence of entire subheaders that
  961.    is not larger than MAX_HEADER octets.
  962.  
  963. 5.3.  Size of full headers
  964.  
  965.    It is desirable to avoid increasing the size of packets with full
  966.    headers beyond their original size, as their size may be optimized
  967.    for the MTU of the link. Since we assume that the link layer
  968.    implementation provides the length of packets, we can use the length
  969.    fields in full headers to pass the values of the CID and the
  970.    generation to the decompressor.
  971.  
  972.    This requires that the link-layer must not add padding to the
  973.    payload, at least not padding that can be delivered to the
  974.    destination link user. It is also required that no extra padding is
  975.    added after UDP data or in tunneled packets. This allows values of
  976.    length fields to be calculated from the length of headers and the
  977.    length of the link-layer frame.
  978.  
  979.    The generation requires one octet and the CID may require up to 2
  980.    octets.  There are length fields of 2 octets in the IPv6 Base Header,
  981.    the IPv4 header, and the UDP header.
  982.  
  983.    A full TCP header will thus have at least 2 octets available in the
  984.    IP header to pass the 8 bit CID, which is sufficient. There will be
  985.    more than two octets available if there is more than one IP header.
  986.  
  987.    [RFC-1144] uses the 8 bit Protocol field of the IPv4 header to pass
  988.    the CID. We cannot use the corresponding method as the sequence of
  989.    IPv6 extension headers is not fixed and CID values are not disjoint
  990.    from the legal values of Next Header fields.
  991.  
  992.    An IPv6/UDP or IPv4/UDP packet will have 4 octets available to pass
  993.    the generation and the CID, so all CID sizes may be used. Fragmented
  994.    or encrypted packet streams may have only 2 octets available to pass
  995.    the generation and CID.  Thus, 8-bit CIDs may be the only CID sizes
  996.    that can be used for such packet streams.  When IPv6/IPv4 or
  997.    IPv4/IPv6 tunneling is used, there will be at least 4 octets
  998.    available, and both CID sizes may be used.
  999.  
  1000.    The generation value is passed in the higher order octet of the first
  1001.    length field in the full header. When only one length field is
  1002.    available, the 8-bit CID is passed in the low order octet.  When two
  1003.    length fields are available, the lowest two octets of the CID are
  1004.    passed in the second length field and the low order octet of the
  1005.    first length field carries the highest octet of the CID.
  1006.  
  1007.  
  1008.  
  1009.  
  1010. Degermark, et. al.          Standards Track                    [Page 18]
  1011.  
  1012. RFC 2507                 IP Header Compression             February 1999
  1013.  
  1014.  
  1015. 5.3.1.  Use of length fields in full TCP headers
  1016.  
  1017.    Use of first length field:
  1018.  
  1019.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1020.                         Length field   | LSB of pkt nr |      CID      |
  1021.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1022.  
  1023.    Use of second length field if available:
  1024.  
  1025.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1026.                   Second length field  | MSB of pkt nr |       0       |
  1027.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1028.  
  1029.    Pkt nr is short for packet sequence number, described in section
  1030.    11.2.
  1031.  
  1032. 5.3.2.  Use of length fields in full non-TCP headers
  1033.  
  1034.    Full non-TCP headers with 8-bit CID:
  1035.  
  1036.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1037.                   First length field   |0|D| Generation|      CID      |
  1038.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1039.  
  1040.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1041.    Second length field (if avail.) |       0       | Data (if D=1) |
  1042.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1043.  
  1044.    Full non-TCP headers with 16-bit CID:
  1045.  
  1046.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1047.                   First length field   |1|D| Generation| Data (if D=1) |
  1048.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1049.  
  1050.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1051.                   Second length field  |              CID              |
  1052.                                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1053.  
  1054.    The first bit in the first length field indicates the length of the
  1055.    CID.  The Data field is zero if D is zero. The use of the D bit and
  1056.    Data field is explained in section 12.
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066. Degermark, et. al.          Standards Track                    [Page 19]
  1067.  
  1068. RFC 2507                 IP Header Compression             February 1999
  1069.  
  1070.  
  1071. 6.  Compressed Header Formats
  1072.  
  1073.    This section uses some terminology (DELTA, RANDOM) defined in section
  1074.    7.
  1075.  
  1076.       a) COMPRESSED_TCP format (similar to [RFC 1144]):
  1077.  
  1078.             +-+-+-+-+-+-+-+-+
  1079.             |      CID      |
  1080.             +-+-+-+-+-+-+-+-+
  1081.             |R O I P S A W U|
  1082.             +-+-+-+-+-+-+-+-+
  1083.             |               |
  1084.             +  TCP Checksum +
  1085.             |               |
  1086.             +-+-+-+-+-+-+-+-+
  1087.             | RANDOM fields, if any (see section 7)   (implied)
  1088.              - - - - - - - -
  1089.             | R-octet       |                         (if R=1)
  1090.              - - - - - - - -
  1091.             | Urgent Pointer Value                    (if U=1)
  1092.              - - - - - - - -
  1093.             | Window Delta                            (if W=1)
  1094.              - - - - - - - -
  1095.             | Acknowledgment Number Delta             (if A=1)
  1096.              - - - - - - - -
  1097.             | Sequence Number Delta                   (if S=1)
  1098.              - - - - - - - -
  1099.             | IPv4 Identification Delta               (if I=1)
  1100.              - - - - - - - -
  1101.             |  Options                                (if O=1)
  1102.              - - - - - - - -
  1103.  
  1104.  
  1105.    The latter flags in the second octet (IPSAWU) have the same meaning
  1106.    as in [RFC-1144], regardless of whether the TCP segments are carried
  1107.    by IPv6 or IPv4. The C bit has been eliminated because the CID is
  1108.    always present. The context associated with the CID keeps track of
  1109.    the IP version and what RANDOM fields are present.  The order between
  1110.    delta fields specified here is exactly as in [RFC-1144]. An
  1111.    implementation will typically scan the context from the beginning and
  1112.    insert the RANDOM fields in order. The RANDOM fields are thus placed
  1113.    before the DELTA fields of the TCP header in the same order as they
  1114.    occur in the original uncompressed header.
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122. Degermark, et. al.          Standards Track                    [Page 20]
  1123.  
  1124. RFC 2507                 IP Header Compression             February 1999
  1125.  
  1126.  
  1127.    The I flag is zero unless an IPv4 header immediately precedes the TCP
  1128.    header. The combined IPv4/TCP header is then compressed as a unit as
  1129.    described in [RFC-1144]. Identification fields in IPv4 headers that
  1130.    are not immediately followed by a TCP header are RANDOM.
  1131.  
  1132.    If the O flag is set, the Options of the TCP header were not the same
  1133.    as in the previous header. The entire Option field are placed last in
  1134.    the compressed TCP header.
  1135.  
  1136.    If the R flag is set, there were differences between the context and
  1137.    the Reserved field (6 bits) in the TCP header or bit 6 or 7 of the
  1138.    TOS octet (Traffic Class octet) in a IPv4 header (IPv6 header) that
  1139.    immediately precedes the TCP header.  An octet with the actual values
  1140.    of the Reserved field and bit 6 and 7 of the TOS or Traffic Class
  1141.    field is then placed immediately after the RANDOM fields.  Bits 0-5
  1142.    of the passed octet is the actual value of the Reserved field, and
  1143.    bits 6 and 7 are the actual values of bits 6 and 7 in the TOS or
  1144.    Traffic Class field. If there is no preceding IP header, bits 6 and 7
  1145.    are 0.  The octet passed with the R flag MUST NOT update the context.
  1146.  
  1147.    NOTE: The R-octet does not update the context because if it did, the
  1148.    nTCP checksum would not guard the receiving TCP from erroneously
  1149.    decompressed headers. Bits 6 and 7 of the TOS octet or Traffic Class
  1150.    octet is expected to change frequently due to Explicit Congestion
  1151.    Notification.
  1152.  
  1153.    See section 7.12 and [RFC-1144] for further information on how to
  1154.    compress TCP headers.
  1155.  
  1156.       b) COMPRESSED_TCP_NODELTA header format
  1157.  
  1158.           +-+-+-+-+-+-+-+-+
  1159.           |      CID      |
  1160.           +-+-+-+-+-+-+-+-+
  1161.           |  RANDOM fields, if any (see section 7)   (implied)
  1162.           +-+-+-+-+-+-+-+-+
  1163.           |  Whole TCP header except for Port Numbers
  1164.           +-+-+-+-+-+-+-+-+
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178. Degermark, et. al.          Standards Track                    [Page 21]
  1179.  
  1180. RFC 2507                 IP Header Compression             February 1999
  1181.  
  1182.  
  1183.       c) Compressed non-TCP header, 8 bit CID:
  1184.            0             7
  1185.           +-+-+-+-+-+-+-+-+
  1186.           |      CID      |
  1187.           +-+-+-+-+-+-+-+-+
  1188.           |0|D| Generation|
  1189.           +-+-+-+-+-+-+-+-+
  1190.           |      data     |                      (if D=1)
  1191.            - - - - - - - -
  1192.           | RANDOM fields, if any (section 7)    (implied)
  1193.            - - - - - - - -
  1194.  
  1195.       d) Compressed non-TCP header, 16 bit CID:
  1196.            0             7
  1197.           +-+-+-+-+-+-+-+-+
  1198.           |  msb of CID   |
  1199.           +-+-+-+-+-+-+-+-+
  1200.           |1|D| Generation|
  1201.           +-+-+-+-+-+-+-+-+
  1202.           |  lsb of CID   |
  1203.           +-+-+-+-+-+-+-+-+
  1204.           |      data     |                      (if D=1)
  1205.            - - - - - - - -
  1206.           | RANDOM fields, if any (section 7)    (implied)
  1207.            - - - - - - - -
  1208.  
  1209.    The generation, CID and optional one octet data are followed by
  1210.    relevant RANDOM fields (see section 7) as implied by the compression
  1211.    state, placed in the same order as they occur in the original
  1212.    uncompressed header, followed by the payload.
  1213.  
  1214. 7.  Compression of subheaders
  1215.  
  1216.    This section gives rules for how the compressible chain of subheaders
  1217.    is compressed. These rules MUST be followed.  Subheaders that may be
  1218.    compressed include IPv6 base and extension headers, TCP headers, UDP
  1219.    headers, and IPv4 headers.  The compressible chain of subheaders
  1220.    extends from the beginning of the header
  1221.  
  1222.    a) up to but not including the first header that is not an IPv4
  1223.       header, an IPv6 base or extension header, a TCP header, or a UDP
  1224.       header, or
  1225.  
  1226.    b) up to and including the first TCP header, UDP header, Fragment
  1227.       Header, Encapsulating Security Payload Header, or IPv4 header for
  1228.       a fragment,
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234. Degermark, et. al.          Standards Track                    [Page 22]
  1235.  
  1236. RFC 2507                 IP Header Compression             February 1999
  1237.  
  1238.  
  1239.    whichever gives the shorter chain. For example, rules a) and b) both
  1240.    fit a chain of subheaders that contain a Fragment Header and ends at
  1241.    a tunneled IPX packet. Since rule b) gives a shorter chain, the
  1242.    compressible chain of subheaders stops at the Fragment Header.
  1243.  
  1244.    The following subsections are a systematic classification of how all
  1245.    fields in subheaders are expected to change.
  1246.  
  1247.    NOCHANGE    The field is not expected to change. Any change means
  1248.                that a full header MUST be sent to update the context.
  1249.  
  1250.    DELTA       The field may change often but usually the difference
  1251.                from the field in the previous header is small, so that
  1252.                it is cheaper to send the change from the previous value
  1253.                rather than the current value.  This type of compression
  1254.                is only used for TCP packet streams.
  1255.  
  1256.    RANDOM      The field must be included "as-is" in compressed headers,
  1257.                usually because it changes unpredictably.
  1258.  
  1259.    INFERRED    The field contains a value that can be inferred from
  1260.                other values, for example the size of the frame carrying
  1261.                the packet, and thus must not be included in the
  1262.                compressed header.
  1263.  
  1264.    The classification implies how a compressed header is constructed. No
  1265.    field that is NOCHANGE or INFERRED is present in a compressed header.
  1266.    A compressor obtains the values of NOCHANGE fields from the context
  1267.    identified by the compression identifier, and obtains the values of
  1268.    INFERRED fields from the link-layer implementation, e.g., from the
  1269.    size of the link-layer frame, or from other fields, e.g., by
  1270.    recalculating the IPv4 header checksum.  DELTA fields are encoded as
  1271.    the difference to the value in the previous packet in the same packet
  1272.    stream.  The decompressor must update the context by adding the value
  1273.    in the compressed header to the value in its context. The result is
  1274.    the proper value of the field.  RANDOM fields must be sent "as-is" in
  1275.    the compressed header.  RANDOM fields must occur in the same order in
  1276.    the compressed header as they occur in the full header.
  1277.  
  1278.    Fields that may optionally be used to identify what packet stream a
  1279.    packet belongs to according to section 4.1 are marked with the word
  1280.    DEF.  To a compressor using the optional guidelines from section 4.1,
  1281.    any difference in corresponding DEF fields between two packets
  1282.    implies that they belong to different packet streams. Moreover, if a
  1283.    DEF field is present in one packet but not in another, the packets
  1284.    belong to different packet streams.
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290. Degermark, et. al.          Standards Track                    [Page 23]
  1291.  
  1292. RFC 2507                 IP Header Compression             February 1999
  1293.  
  1294.  
  1295. 7.1.  IPv6 Header [IPv6, section 3]
  1296.  
  1297.       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1298.       |Version| Traffic Class |               Flow Label              |
  1299.       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1300.       |         Payload Length        |  Next Header  |   Hop Limit   |
  1301.       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1302.       |                                                               |
  1303.       +                                                               +
  1304.       |                                                               |
  1305.       +                         Source Address                        +
  1306.       |                                                               |
  1307.       +                                                               +
  1308.       |                                                               |
  1309.       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1310.       |                                                               |
  1311.       +                                                               +
  1312.       |                                                               |
  1313.       +                      Destination Address                      +
  1314.       |                                                               |
  1315.       +                                                               +
  1316.       |                                                               |
  1317.       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1318.  
  1319.          Version                   NOCHANGE (DEF)
  1320.          Traffic Class             NOCHANGE (might be DEF, see sect 4.1)
  1321.                                             (see also sect 6 a)
  1322.          Flow Label                NOCHANGE (DEF)
  1323.          Payload Length            INFERRED
  1324.          Next Header               NOCHANGE
  1325.          Hop Limit                 NOCHANGE (might be DEF, see sect 4.1)
  1326.          Source Address            NOCHANGE (DEF)
  1327.          Destination Address       NOCHANGE (DEF)
  1328.  
  1329.    The Payload Length field of encapsulated headers must correspond to
  1330.    the length value of the encapsulating header. If not, the header
  1331.    chain MUST NOT be compressed.
  1332.  
  1333.    NOTE: If this the IP header closest to a TCP header, bit 7 of the
  1334.    Traffic Class field can be passed using the R-flag of the compressed
  1335.    TCP header. See section 6 a).
  1336.  
  1337.    This classification implies that the entire IPv6 base header will be
  1338.    compressed away.
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346. Degermark, et. al.          Standards Track                    [Page 24]
  1347.  
  1348. RFC 2507                 IP Header Compression             February 1999
  1349.  
  1350.  
  1351. 7.2.  IPv6 Extension Headers [IPv6, section 4]
  1352.  
  1353.    What extension headers are present and the relative order of them is
  1354.    not expected to change in a packet stream.  Whenever there is a
  1355.    change, a full packet header must be sent.  All Next Header fields in
  1356.    IPv6 base header and IPv6 extension headers are NOCHANGE.
  1357.  
  1358. 7.3.  Options [IPv6, section 4.2]
  1359.  
  1360.    The contents of Hop-by-hop Options and Destination Options extension
  1361.    headers are encoded with TLV "options" (see [IPv6]):
  1362.  
  1363.             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
  1364.             |  Option Type  |  Opt Data Len |  Option Data
  1365.             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
  1366.  
  1367.    Option Type and Opt Data Len fields are assumed to be fixed for a
  1368.    given packet stream, so they are classified as NOCHANGE.  The Option
  1369.    data is RANDOM unless specified otherwise below.
  1370.  
  1371.    Padding
  1372.  
  1373.        Pad1 option
  1374.  
  1375.             +-+-+-+-+-+-+-+-+
  1376.             |       0       |
  1377.             +-+-+-+-+-+-+-+-+
  1378.  
  1379.           Entire option is NOCHANGE.
  1380.  
  1381.        PadN option
  1382.  
  1383.             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
  1384.             |       1       |  Opt Data Len |  Option Data
  1385.             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
  1386.  
  1387.           All fields are NOCHANGE.
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402. Degermark, et. al.          Standards Track                    [Page 25]
  1403.  
  1404. RFC 2507                 IP Header Compression             February 1999
  1405.  
  1406.  
  1407. 7.4.  Hop-by-Hop Options Header [IPv6, section 4.3]
  1408.  
  1409.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1410.     |  Next Header  |  Hdr Ext Len  |                               |
  1411.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
  1412.     |                                                               |
  1413.     .                                                               .
  1414.     .                            Options                            .
  1415.     .                                                               .
  1416.     |                                                               |
  1417.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1418.  
  1419.        Next Header          NOCHANGE
  1420.        Hdr Ext Len          NOCHANGE
  1421.  
  1422.        Options              TLV coded values and padding.
  1423.                             Classified according to 7.3 above, unless
  1424.                             being a Jumbo Payload option (see below).
  1425.  
  1426.    Jumbo Payload option
  1427.                                     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1428.                                     |      194      |Opt Data Len=4 |
  1429.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1430.     |                     Jumbo Payload Length                      |
  1431.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1432.  
  1433.    First two fields are NOCHANGE and Jumbo Payload Length INFERRED.
  1434.    (frame length must be supplied by link layer implementation).
  1435.  
  1436.  
  1437.         NOTE: It is silly to compress the headers of a packet carrying a
  1438.         Jumbo Payload Option since the relative header overhead is
  1439.         negligible. Moreover, it is usually a bad idea to send such
  1440.         large packets over low- and medium-speed links.
  1441.  
  1442. 7.5.  Routing Header [IPv6, section 4.4]
  1443.  
  1444.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1445.     |  Next Header  |  Hdr Ext Len  |  Routing Type | Segments Left |
  1446.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1447.     |                                                               |
  1448.     .                                                               .
  1449.     .                       type-specific data                      .
  1450.     .                                                               .
  1451.     |                                                               |
  1452.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1453.  
  1454.    All fields of the Routing Header are NOCHANGE.
  1455.  
  1456.  
  1457.  
  1458. Degermark, et. al.          Standards Track                    [Page 26]
  1459.  
  1460. RFC 2507                 IP Header Compression             February 1999
  1461.  
  1462.  
  1463.    If the Routing Type is not recognized, it is impossible to determine
  1464.    the final Destination Address unless the Segments Left field has the
  1465.    value zero, in which case the Destination Address is the final
  1466.    Destination Address in the basic IPv6 header.
  1467.  
  1468.    In the Type 0 Routing Header, the last address is DEF if (Segments
  1469.    Left > 0).
  1470.  
  1471.    Routing Headers are compressed away completely.  This is a big win as
  1472.    the maximum size of the Routing Header is 392 octets.  Moreover, Type
  1473.    0 Routing Headers with one address, size 24 octets, are used by
  1474.    Mobile IP.
  1475.  
  1476. 7.6.  Fragment Header [IPv6, section 4.5]
  1477.  
  1478.    The first fragment of a packet has Fragment Offset = 0 and the chain
  1479.    of subheaders extends beyond its Fragment Header. If a fragment is
  1480.    not the first (Fragment Offset not 0), there are no subsequent
  1481.    subheaders (unless the chain of subheaders in the first fragment
  1482.    didn't fit entirely in the first fragment).
  1483.  
  1484.    Since packets may be reordered before reaching the compression point,
  1485.    and some fragments may follow other routes through the network, a
  1486.    compressor cannot rely on seeing the first fragment before other
  1487.    fragments. This implies that information in subheaders following the
  1488.    Fragment Header of the first fragment cannot be examined to determine
  1489.    the proper packet stream for other fragments.
  1490.  
  1491.    It is possible to design compression schemes that can compress
  1492.    subheaders after the Fragment Header, at least in the first fragment,
  1493.    but to avoid complicating the rules for sending full headers and the
  1494.    rules for compression and decompression, the chain of subheaders that
  1495.    follow a Fragment Header MUST NOT be compressed.
  1496.  
  1497.    The fields of the Fragment Header are classified as follows.
  1498.  
  1499.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1500.     |  Next Header  |   Reserved    |      Fragment Offset    |Res|M|
  1501.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1502.     |                         Identification                        |
  1503.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1504.  
  1505.           Next Header          NOCHANGE
  1506.           Reserved             NOCHANGE
  1507.           Res                  RANDOM
  1508.           M flag               RANDOM
  1509.           Fragment Offset      RANDOM
  1510.           Identification       RANDOM
  1511.  
  1512.  
  1513.  
  1514. Degermark, et. al.          Standards Track                    [Page 27]
  1515.  
  1516. RFC 2507                 IP Header Compression             February 1999
  1517.  
  1518.  
  1519.    This classification implies that a Fragment Header is compressed down
  1520.    to 6 octets. The minimum IPv6 MTU is 1280 octets so most fragments
  1521.    will be at least 1280 octets. Since the 6 octet overhead of the
  1522.    compressed fragment header is amortized over a fairly large packet,
  1523.    the additional complexity of more sophisticated compression schemes
  1524.    is not justifiable.
  1525.  
  1526.           NOTE: The Identification field is RANDOM instead of NOCHANGE
  1527.           to avoid one compression slow-start per original packet.
  1528.  
  1529.    Grouping of fragments according to the optional guidelines in
  1530.    section4.1:
  1531.  
  1532.        Fragments and unfragmented packets should not be grouped
  1533.        together.
  1534.  
  1535.        Port numbers cannot be used to identify the packet stream because
  1536.        port numbers are not present in every fragment.  To adhere to the
  1537.        uniqueness rules for the Identification value, a fragmented
  1538.        packet stream is identified by the combination of Source Address
  1539.        and (final) Destination Address.
  1540.  
  1541.           NOTE: The Identification value is NOT used to identify the
  1542.           packet stream. This avoids using a new CID for each packet and
  1543.           saves the cost of the associated compression slow-start.  We
  1544.           expect that the unfragmentable part of the headers will not
  1545.           change too frequently, if it does thrashing may occur.
  1546.  
  1547. 7.7.  Destination Options Header [IPv6, section 4.6]
  1548.  
  1549.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1550.     |  Next Header  |  Hdr Ext Len  |                               |
  1551.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
  1552.     |                                                               |
  1553.     .                                                               .
  1554.     .                            Options                            .
  1555.     .                                                               .
  1556.     |                                                               |
  1557.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1558.  
  1559.     Next Header          NOCHANGE
  1560.     Hdr Ext Len          NOCHANGE
  1561.  
  1562.     Options              TLV coded values and padding.
  1563.                            Compressed according to 7.3 above.
  1564.  
  1565.    The only Destination Options defined in [IPv6] are the padding
  1566.    options.
  1567.  
  1568.  
  1569.  
  1570. Degermark, et. al.          Standards Track                    [Page 28]
  1571.  
  1572. RFC 2507                 IP Header Compression             February 1999
  1573.  
  1574.  
  1575. 7.8.  No Next Header [IPv6, section 4.7]
  1576.  
  1577.    Covered by rules for IPv6 Header Extensions (7.2).
  1578.  
  1579. 7.9.  Authentication Header [RFC-2402, section 3.2]
  1580.  
  1581.      1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
  1582.     +---------------+---------------+---------------+---------------+
  1583.     | Next Header   | Length        |           RESERVED            |
  1584.     +---------------+---------------+---------------+---------------+
  1585.     |                Security Parameters Index (SPI)                |
  1586.     +---------------+---------------+---------------+---------------+
  1587.     |                                                               |
  1588.     +     Authentication Data (variable number of 32-bit words)     |
  1589.     |                                                               |
  1590.     +---------------+---------------+---------------+---------------+
  1591.  
  1592.     Next Header          NOCHANGE
  1593.     Length               NOCHANGE
  1594.     Reserved             NOCHANGE
  1595.     SPI                  NOCHANGE (DEF)
  1596.     Authentication Data  RANDOM
  1597.  
  1598.    [RFC-1828] specifies how to do authentication with keyed MD5, the
  1599.    authentication method all IPv6 implementations must support.  For
  1600.    this method, the Authentication Data is 16 octets.
  1601.  
  1602. 7.10.  Encapsulating Security Payload Header [RFC-2406, section 3.1]
  1603.  
  1604.    This header implies that the subsequent parts of the packet are
  1605.    encrypted. Thus, no further header compression is possible on
  1606.    subsequent headers as encryption is typically already performed when
  1607.    the compressor sees the packet.
  1608.  
  1609.    However, when the ESP Header is used in tunnel mode an entire IP
  1610.    packet is encrypted, and the headers of that packet MAY be compressed
  1611.    before the packet is encrypted at the entry point of the tunnel.
  1612.    This means that it must be possible to feed an IP packet and its
  1613.    length to the decompressor, as if it came from the link-layer. The
  1614.    mechanisms for dealing with reordering described in section 11 MUST
  1615.    also be used, as packets can be reordered in a tunnel.
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626. Degermark, et. al.          Standards Track                    [Page 29]
  1627.  
  1628. RFC 2507                 IP Header Compression             February 1999
  1629.  
  1630.  
  1631.     +---------------+---------------+---------------+---------------+
  1632.     |        Security Association Identifier (SPI), 32 bits         |
  1633.     +===============+===============+===============+===============+
  1634.     |            Opaque Transform Data, variable length             |
  1635.     +---------------+---------------+---------------+---------------+
  1636.  
  1637.     SPI                          NOCHANGE (DEF)
  1638.     Opaque Transform Data        RANDOM
  1639.  
  1640.    Everything after the SPI is encrypted and is not compressed.
  1641.  
  1642. 7.11.  UDP Header
  1643.  
  1644.    The UDP header is described in [RFC-768].
  1645.  
  1646.  
  1647.    The Next Header field (IPv6) or Protocol field (IPv4) in the
  1648.    preceding subheader is DEF.
  1649.  
  1650.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1651.     |          Source Port          |       Destination Port        |
  1652.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1653.     |            Length             |           Checksum            |
  1654.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1655.  
  1656.     Source Port          NOCHANGE (DEF)
  1657.     Destination Port     NOCHANGE (DEF)
  1658.     Length               INFERRED
  1659.     Checksum             RANDOM, unless it is zero,
  1660.                            in which case it is NOCHANGE.
  1661.  
  1662.    The Length field of the UDP header MUST match the Length field(s) of
  1663.    preceding subheaders, i.e, there must not be any padding after the
  1664.    UDP payload that is covered by the IP Length.
  1665.  
  1666.    The UDP header is typically compressed down to 2 octets, the UDP
  1667.    checksum.  When the UDP checksum is zero (which it cannot be with
  1668.    IPv6), it is likely to be so for all packets in the flow and is
  1669.    defined to be NOCHANGE. This saves 2 octets in the compressed header.
  1670.  
  1671. 7.12.  TCP Header
  1672.  
  1673.    The TCP header is described in [RFC-793].
  1674.  
  1675.    The Next Header field (IPv6) or Protocol field (IPv4) in the
  1676.    preceding subheader is DEF.
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682. Degermark, et. al.          Standards Track                    [Page 30]
  1683.  
  1684. RFC 2507                 IP Header Compression             February 1999
  1685.  
  1686.  
  1687.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1688.     |          Source Port          |       Destination Port        |
  1689.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1690.     |                        Sequence Number                        |
  1691.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1692.     |                    Acknowledgment Number                      |
  1693.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1694.     | Offset| Reserved  |U|A|P|R|S|F|            Window             |
  1695.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1696.     |           Checksum            |         Urgent Pointer        |
  1697.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1698.     |                    Options                    |    Padding    |
  1699.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1700.  
  1701.     U, A, P, R, S, and F stands for Urg, Ack, Psh, Rst, Syn, and Fin.
  1702.  
  1703.    There are two ways to compress the TCP header.
  1704.  
  1705. 7.12.1. Compressed with differential encoding
  1706.  
  1707.    Source Port           NOCHANGE  (DEF)
  1708.    Destination Port      NOCHANGE  (DEF)
  1709.    Sequence Number       DELTA
  1710.    Acknowledgment Number DELTA
  1711.    Offset                NOCHANGE
  1712.    Reserved              DELTA               (if differs from context,
  1713.                                               set R-flag in flag octet
  1714.                                               and send absolute value
  1715.                                               as described in 6 a.)
  1716.    Urg,Psh               RANDOM              (placed in flag octet)
  1717.    Ack                   INFERRED to be 1
  1718.    Rst,Syn,Fin           INFERRED to be 0
  1719.    Window                DELTA               (if change in Window,
  1720.                                               set W-flag in flag octet
  1721.                                               and send difference)
  1722.    Checksum              RANDOM
  1723.    Urgent Pointer        DELTA               (if Urg is set, send
  1724.                                               absolute value)
  1725.    Options, Padding      DELTA               (if change in Options,
  1726.                                               set O-flag and send
  1727.                                               whole Options, Padding)
  1728.  
  1729.    A packet with a TCP header compressed according to the above must be
  1730.    indicated to be of type COMPRESSED_TCP.  The compressed header is
  1731.    described in section 6.
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738. Degermark, et. al.          Standards Track                    [Page 31]
  1739.  
  1740. RFC 2507                 IP Header Compression             February 1999
  1741.  
  1742.  
  1743.    This method is essentially the differential encoding techniques of
  1744.    Jacobson, described in [RFC-1144], the differences being the placement
  1745.    of the compressed TCP header fields (see section 6), the use of the
  1746.    O-flag, the use of the R-flag, and elimination of the C-flag.  The
  1747.    O-flag allows compression of the TCP header when the Timestamp option
  1748.    is used and the Options fields changes with each header.
  1749.  
  1750.    DELTA values (except for Reserved field and Options, Padding) MUST be
  1751.    coded as in [RFC-1144].  A Reserved field value passed with the R-flag
  1752.    MUST NOT update the context at compressor or decompressor.
  1753.  
  1754. 7.12.2. Without differential encoding
  1755.  
  1756.        Source Port           NOCHANGE  (DEF)
  1757.        Destination Port      NOCHANGE  (DEF)
  1758.  
  1759.        (all the rest)        RANDOM
  1760.  
  1761.    The Identification field in a preceding IPv4 header is RANDOM.
  1762.  
  1763.    A packet with a TCP header compressed according to the above must be
  1764.    indicated to be of type COMPRESSED_TCP_NODELTA.  It uses the same CID
  1765.    space as COMPRESSED_TCP packets, and the header MUST be saved as
  1766.    context. The compressed header is described in section 6.
  1767.  
  1768.    This packet type can be sent as the response to a header request
  1769.    instead of sending a full header, can be used over links that reorder
  1770.    packets, and can be sent instead of a full header when there are
  1771.    changes that cannot be represented by a compressed header. A
  1772.    sophisticated compressor can switch to sending only
  1773.    COMPRESSED_TCP_NODELTA headers when the packet loss frequency is high.
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794. Degermark, et. al.          Standards Track                    [Page 32]
  1795.  
  1796. RFC 2507                 IP Header Compression             February 1999
  1797.  
  1798.  
  1799. 7.13.  IPv4 header [RFC-791, section 3.1]
  1800.  
  1801.      0                   1                   2                   3
  1802.      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1803.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1804.     |Version|  IHL  |Type of Service|          Total Length         |
  1805.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1806.     |         Identification        |Flags|      Fragment Offset    |
  1807.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1808.     |  Time to Live |    Protocol   |         Header Checksum       |
  1809.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1810.     |                       Source Address                          |
  1811.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1812.     |                    Destination Address                        |
  1813.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1814.     |                    Options                    |    Padding    |
  1815.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1816.  
  1817.    There are two ways to compress the IPv4 header
  1818.  
  1819.    a) If the IPv4 header is not for a fragment (MF flag is not set and
  1820.       Fragment Offset is zero) and there are no options (IHL is 5), it
  1821.       is classified as follows
  1822.  
  1823.        Version              NOCHANGE   (DEF)
  1824.        IHL                  NOCHANGE   (DEF, must be 5)
  1825.        Type of Service      NOCHANGE   (might be DEF, see sect 4.1)
  1826.                                        (see also 6 a)
  1827.        Total Length         INFERRED   (from link-layer implementation
  1828.                                         or encapsulating IP header)
  1829.  
  1830.        Identification       DELTA/     (If the Protocol field has the
  1831.                                        (value corresponding to TCP)
  1832.                             RANDOM     (otherwise)
  1833.  
  1834.        Flags                NOCHANGE   (MF flag must not be set)
  1835.        Fragment Offset      NOCHANGE   (must be zero)
  1836.        Time to Live         NOCHANGE   (might be DEF, see sect 4.1)
  1837.        Protocol             NOCHANGE
  1838.        Header Checksum      INFERRED   (calculated from other fields)
  1839.        Source Address       NOCHANGE   (DEF)
  1840.        Destination Address  NOCHANGE   (DEF)
  1841.        Options, Padding                (not present)
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850. Degermark, et. al.          Standards Track                    [Page 33]
  1851.  
  1852. RFC 2507                 IP Header Compression             February 1999
  1853.  
  1854.  
  1855.        Note: When a TCP header immediately follows, the IPv4 and TCP
  1856.        header MUST be compressed as a unit as described in section 6.
  1857.        Bits 6 and 7 of the Type of Service field (bits 14 and 15 of the
  1858.        first word) can then be passed using the R-flag (see section 6
  1859.        a).
  1860.  
  1861.    b) If the IPv4 header is for a fragment (MF bit set or Fragment
  1862.        Offset nonzero), or there are options (IHL > 5), all fields are
  1863.        RANDOM (i.e., if the header is compressed all fields are sent
  1864.        as-is and not compressed). This classification allows compression
  1865.        of the tunnel header, but not the fragment header, when fragments
  1866.        are tunneled. If the IPv4 header is for a fragment it ends the
  1867.        compressible chain of subheaders, i.e., it must be the last
  1868.        subheader to be compressed.  If the IPv4 header has options but
  1869.        is not for a fragment it does not end the compressible chain of
  1870.        subheaders, so subsequent subheaders can be compressed.
  1871.  
  1872.    A compressor that follows the optional guidelines of section 4.1 will
  1873.    in case a) use the Version, Source Address and Destination Address to
  1874.    define the packet stream, together with the fact that there are no
  1875.    IPv4 options and that this is not a fragment.
  1876.  
  1877.    Case b) can define two kinds of packet streams depending on whether
  1878.    the IPv4 header is for a fragment or not.
  1879.  
  1880.    If the IPv4 header in case b) is for a fragment, a compressor
  1881.    following the optional guidelines will use that fact together with
  1882.    the Version, Source Address, and Destination Address to determine the
  1883.    packet stream.
  1884.  
  1885.    If the IPv4 header in case b) is not for a fragment, it must have
  1886.    options. A compressor following the optional guidelines will use that
  1887.    fact, but not the size of the options, together with the Version,
  1888.    Source Address, and Destination Address to determine the packet
  1889.    stream.
  1890.  
  1891. 7.14.  Minimal Encapsulation header [RFC-2004, section 3.1]
  1892.  
  1893.      0                   1                   2                   3
  1894.      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1895.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1896.     |   Protocol    |S|  reserved   |        Header Checksum        |
  1897.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1898.     |                 Original Destination Address                  |
  1899.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1900.     :            (if present) Original Source Address               :
  1901.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1902.  
  1903.  
  1904.  
  1905.  
  1906. Degermark, et. al.          Standards Track                    [Page 34]
  1907.  
  1908. RFC 2507                 IP Header Compression             February 1999
  1909.  
  1910.  
  1911.     Protocol                             NOCHANGE
  1912.     Original Source Address Present (S)  NOCHANGE
  1913.     reserved                             NOCHANGE
  1914.     Header Checksum                      INFERRED (calculated from
  1915.                                            other values)
  1916.     Original Destination Address         NOCHANGE
  1917.     Original Source Address              NOCHANGE (present only
  1918.                                                    if S=1)
  1919.  
  1920.    This header is likely to be used by Mobile IP.
  1921.  
  1922. 8.  Changing context identifiers
  1923.  
  1924.    On a point-to-point link, the compressor has total knowledge of what
  1925.    CIDs are in use at the decompressor and may change what CID a packet
  1926.    stream uses or reuse CIDs at will.
  1927.  
  1928.    Each non-TCP CID is associated with a context with a generation
  1929.    value. To avoid too rapid generation wrap-around and potential
  1930.    incorrect decompression, an implementation MUST avoid wrap-around of
  1931.    the generation value in less than MIN_WRAP seconds (see section 14).
  1932.  
  1933.    To aid in avoiding wrap-around, the generation value associated with
  1934.    a CID MUST NOT be reset when changing to a new packet stream.
  1935.    Instead, a compressor MUST increment the generation value by one when
  1936.    using the CID for a new non-TCP packet stream.
  1937.  
  1938. 9.  Rules for dropping or temporarily storing packets
  1939.  
  1940.    When a decompressor receives a packet with a compressed TCP header
  1941.    with CID C, it MUST be discarded when the context for C has not been
  1942.    initialized by a full header.
  1943.  
  1944.    When a decompressor receives a packet with a compressed non-TCP
  1945.    header with CID C and generation G, the header must not be
  1946.    decompressed using the current context when
  1947.  
  1948.       a) the decompressor has been disconnected from the compressor for
  1949.           more than MIN_WRAP seconds, because the context might be
  1950.           obsolete even if it has generation G.
  1951.  
  1952.       b) the context for C has a generation other than G.
  1953.  
  1954.    In case a) and b) the packet may either be
  1955.  
  1956.       i)  discarded immediately, or else
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962. Degermark, et. al.          Standards Track                    [Page 35]
  1963.  
  1964. RFC 2507                 IP Header Compression             February 1999
  1965.  
  1966.  
  1967.       ii) stored temporarily until the context is updated by a packet
  1968.           with a full non-TCP header with CID C and generation G, after
  1969.           which the header can be decompressed.
  1970.  
  1971.           Packets stored in this manner MUST be discarded when
  1972.  
  1973.             *)  receiving full or compressed non-TCP headers with CID C
  1974.                 and a generation other than G,
  1975.  
  1976.             *)  the decompressor has not received packets with CID C in
  1977.                 the last MIN_WRAP seconds.
  1978.  
  1979.    When full headers are lost, a decompressor can receive compressed
  1980.    non-TCP headers with a generation value other than the generation of
  1981.    its context.  Rule ii) allows the decompressor to store such headers
  1982.    until they can be decompressed using the correct context.
  1983.  
  1984. 10. Low-loss header compression for TCP
  1985.  
  1986.    Since fewer bits are transmitted per packet with header compression,
  1987.    the packet loss rate is lower with header compression than without,
  1988.    for a fixed bit-error rate.  This is beneficial for links with high
  1989.    bit-error rates such as wireless links.
  1990.  
  1991.    However, since TCP headers are compressed using differential
  1992.    encoding, a single lost TCP segment can ruin an entire TCP sending
  1993.    window because the context is not incremented properly at the
  1994.    decompressor.  Subsequent headers will therefore be decompressed to
  1995.    be different than before compression and discarded by the TCP
  1996.    receiver because the TCP checksum fails.
  1997.  
  1998.    A TCP connection in the wide area where the last hop is over a
  1999.    medium-speed lossy link, for example a wireless LAN, will then have
  2000.    poor performance with traditional header compression because the
  2001.    delay-bandwidth product is relatively large and the bit-error rate
  2002.    relatively high. For a 2 Mbit/s wireless LAN and an end-to-end RTT of
  2003.    200 ms, the delay-bandwidth product is 50 kbyte.  That is equivalent
  2004.    to about 97 512-octet segments with compressed headers.  Each loss
  2005.    can thus be multiplied by a factor of 100.
  2006.  
  2007.    This section describes two simple mechanisms for quick repair of the
  2008.    context. With these mechanisms header compression will improve TCP
  2009.    throughput over lossy links as well as links with low bit-error
  2010.    rates.
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018. Degermark, et. al.          Standards Track                    [Page 36]
  2019.  
  2020. RFC 2507                 IP Header Compression             February 1999
  2021.  
  2022.  
  2023. 10.1.  The "twice" algorithm
  2024.  
  2025.    The decompressor may compute the TCP checksum to determine if its
  2026.    context is not updated properly. If the checksum fails, the error is
  2027.    assumed to be caused by a lost segment that did not update the
  2028.    context properly. The delta of the current segment is then added to
  2029.    the context again on the assumption that the lost segment contained
  2030.    the same delta as the current. By decompressing and computing the TCP
  2031.    checksum again, the decompressor checks if the repair succeeded or if
  2032.    the delta should be applied once more.
  2033.  
  2034.    Analysis of traces of various TCP bulk transfers show that applying
  2035.    the delta of the current segment one or two times will repair the
  2036.    context for between 83 and 99 per cent of all single-segment losses
  2037.    in the data stream. For the acknowledgment stream, the success rate
  2038.    is smaller due to the delayed ack mechanism of TCP. The "twice"
  2039.    mechanism repairs the context for 53 to 99 per cent of the losses in
  2040.    the acknowledgment stream.  A sophisticated implementation of this
  2041.    idea would determine whether the TCP stream is an acknowledgment or
  2042.    data stream and determine the segment size by observing the stream of
  2043.    full and compressed headers.  Trying deltas that are small multiples
  2044.    of the segment size will result in even higher rates of successful
  2045.    repairs for acknowledgment streams.
  2046.  
  2047. 10.2.  Header Requests
  2048.  
  2049.    The relatively low success rate for the "twice" algorithm for TCP
  2050.    acknowledgment streams calls for an additional mechanism for
  2051.    repairing the context at the decompressor. When the decompressor
  2052.    fails to repair the context after a loss, the decompressor may
  2053.    optionally request a full header from the compressor.  This is
  2054.    possible on links where the decompressor can identify the compressor
  2055.    and send packets to it.
  2056.  
  2057.    On such links, a decompressor may send a CONTEXT_STATE packet back to
  2058.    the compressor to indicate that one or more contexts are invalid.  A
  2059.    decompressor SHOULD NOT transmit a CONTEXT_STATE packet every time a
  2060.    compressed packet refers to an invalid context, but instead should
  2061.    limit the rate of transmission of CONTEXT_STATE packets to avoid
  2062.    flooding the reverse channel. A CONTEXT_STATE packet can indicate
  2063.    that several contexts are out of date, this technique SHOULD be used
  2064.    instead of sending several separate packets. The following diagram
  2065.    shows the format of a CONTEXT_STATE packet.
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074. Degermark, et. al.          Standards Track                    [Page 37]
  2075.  
  2076. RFC 2507                 IP Header Compression             February 1999
  2077.  
  2078.  
  2079.                            0   1   2   3   4   5   6   7
  2080.                         +---+---+---+---+---+---+---+---+
  2081.                         |     TCP header request = 3    |
  2082.                         +---+---+---+---+---+---+---+---+
  2083.                         |           CID count           |
  2084.                         +---+---+---+---+---+---+---+---+
  2085.                         |              CID              |
  2086.                         +---+---+---+---+---+---+---+---+
  2087.                         |              CID              |
  2088.                         +---+---+---+---+---+---+---+---+
  2089.                                                ...
  2090.                         +---+---+---+---+---+---+---+---+
  2091.                         |              CID              |
  2092.                         +---+---+---+---+---+---+---+---+
  2093.  
  2094.    The first octet is a type code to allow the CONTEXT_STATE packet type
  2095.    to be shared for other compression protocols that are (see [CRTP]) or
  2096.    may be defined in parallel with this one. When used for TCP header
  2097.    requests the type code has the value 3, and the remainder of the
  2098.    packet is a sequence of CIDs preceded by a one-octet count of the
  2099.    number of CIDs.
  2100.  
  2101.    On receipt of a CONTEXT_STATE packet, the compressor MUST mark the
  2102.    CIDs invalid to ensure that the next packet emitted in those packet
  2103.    streams are FULL_HEADER or COMPRESSED_TCP_NODELTA packets.
  2104.  
  2105.    Header requests are an optimization, so loss of a CONTEXT_STATE
  2106.    packet does not affect the correct operation of TCP header
  2107.    compression.  When a CONTEXT_STATE packet is lost, eventually a new
  2108.    one will be transmitted or TCP will timeout and retransmit.  The big
  2109.    advantage of using header requests is that TCP acknowledgment streams
  2110.    can be repaired after a roundtrip-time over the lossy link.  This
  2111.    will typically avoid a TCP timeout and unnecessary retransmissions.
  2112.    The lower packet loss rate due to smaller packets will then result in
  2113.    higher throughput because the TCP window can grow larger between
  2114.    losses.
  2115.  
  2116. 11.  Links that reorder packets
  2117.  
  2118.    Some links reorder packets, for example multi-hop radio links that
  2119.    use deflection routing to route around congested nodes.  Packets
  2120.    routed different ways can then arrive at the destination in a
  2121.    different order than they were sent.
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130. Degermark, et. al.          Standards Track                    [Page 38]
  2131.  
  2132. RFC 2507                 IP Header Compression             February 1999
  2133.  
  2134.  
  2135. 11.1.  Reordering in non-TCP packet streams
  2136.  
  2137.    Compressed non-TCP headers do not change the context, and neither do
  2138.    full headers that refresh it.  There can be problems only when a full
  2139.    header that changes the context arrives out of order.  There are two
  2140.    cases:
  2141.  
  2142.        - A packet with a full header with generation G arrives *after*
  2143.          a packet with a compressed header with generation G.  This case
  2144.          is covered by rule b) ii) in section 9.
  2145.  
  2146.        - A packet with a full header with generation G arrives *before*
  2147.          a packet with a compressed header with generation G-1 (modulo
  2148.          64).  The decompressor MAY then keep both versions of the
  2149.          context around for a while to be able to decompress subsequent
  2150.          compressed headers with generation G-1 (modulo 64).  The old
  2151.          context MUST be discarded after MIN_WRAP seconds.
  2152.  
  2153. 11.2.  Reordering in TCP packet streams
  2154.  
  2155.    A compressor may avoid sending COMPRESSED_TCP headers and only send
  2156.    COMPRESSED_TCP_NODELTA headers when there is reordering over the
  2157.    link.  Compressed headers will typically be 17 octets with that
  2158.    method, significantly larger than the usual 4-7 octets.
  2159.  
  2160.    To achieve better compression rates the following method, adding only
  2161.    two octets to the compressed header for a total of 6-9 octets, may be
  2162.    used.  A packet sequence number, incremented by one for every packet
  2163.    in the TCP stream, is then associated with each compressed and full
  2164.    header.  This allows the decompressor to place the packets in the
  2165.    correct sequence and apply their deltas to the context in the correct
  2166.    order.  A simple sliding window scheme is used to place the packets
  2167.    in the correct order.
  2168.  
  2169.    Two octets are needed for the packet sequence numbers.  One octet
  2170.    gives only 256 sequence numbers.  In a sliding window scheme the
  2171.    window should be no larger than half of the sequence number space, so
  2172.    packets can not arrive more than 127 positions out-of-sequence. This
  2173.    is equivalent to a delay of 260 ms on 2 Mbit/s links with 512 octet
  2174.    segments.  Delays of that order are not uncommon over wide-area
  2175.    Internet connections.  However, two octets giving 2^16 = 65536 values
  2176.    should be sufficient.
  2177.  
  2178.    Full TCP/IP headers will only have space for one octet of sequence
  2179.    number when there is no tunneling. It is not feasible to increase the
  2180.    size of full headers since the packet size might be optimized for the
  2181.    MTU of the link. Therefore only the least significant octet of the
  2182.    packet sequence number can be placed in such full headers. We believe
  2183.  
  2184.  
  2185.  
  2186. Degermark, et. al.          Standards Track                    [Page 39]
  2187.  
  2188. RFC 2507                 IP Header Compression             February 1999
  2189.  
  2190.  
  2191.    that such full headers can be positioned correctly frequently enough
  2192.    with only the least significant octet of the packet sequence number
  2193.    available.
  2194.  
  2195.    The packet sequence number zero MUST be skipped over.  Avoiding zero
  2196.    takes care of a problem that can occur when the TCP window scale
  2197.    option is used to enlarge the TCP window. When exactly 2^16 octets of
  2198.    TCP data is lost, a compressed header will be decompressed
  2199.    incorrectly without being detected by the TCP checksum. TCP segment
  2200.    sizes are often a power of two.  So by using a packet sequence number
  2201.    space that is not a power of two either the TCP sequence number or
  2202.    the packet sequence number will differ when 2^16 octets are lost.
  2203.    Whenever a compressor sees the window scale option on a SYN segment,
  2204.    it MUST use packet sequence numbers when subsequently compressing
  2205.    that packet stream.
  2206.  
  2207.    In compressed TCP headers the two octet packet sequence number MUST
  2208.    be placed immediately after the TCP Checksum.  See section 5.3 for
  2209.    placement of packet sequence numbers in full headers.
  2210.  
  2211. 12.  Hooks for additional header compression
  2212.  
  2213.    The following hook is supplied to allow additional header compression
  2214.    schemes for headers on top of UDP. The initial chain of subheaders is
  2215.    then compressed as described here, and the other header compression
  2216.    scheme is applied to the header above the UDP header. An example of
  2217.    such additional header compression is Compressed RTP by Casner and
  2218.    Jacobson [CRTP]. To allow some error detection, such schemes
  2219.    typically need a sequence number that may need to be passed in full
  2220.    headers as well as compressed UDP headers.
  2221.  
  2222.    The D-bit and Data octet (see section 6) provides the necessary
  2223.    mechanism. When a sequence number, say, needs to be passed in a
  2224.    FULL_HEADER or COMPRESSED_NON_TCP header, the D-bit is set and the
  2225.    sequence number is placed in the Data field. The decompressor must
  2226.    then extract and make the Data field available to the additional
  2227.    header compression scheme.
  2228.  
  2229.    Use of additional header compression schemes like CRTP must be
  2230.    negotiated. The D-bit and Data octet mechanism must automatically be
  2231.    enabled whenever use of additional header compression schemes has
  2232.    been negotiated.
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242. Degermark, et. al.          Standards Track                    [Page 40]
  2243.  
  2244. RFC 2507                 IP Header Compression             February 1999
  2245.  
  2246.  
  2247. 13.  Demultiplexing
  2248.  
  2249.    For each link layer, there must be a document specifying how the
  2250.    various packet types used by IP header compression is indicated.
  2251.    Such a document exists for PPP [PPP-HC].  This section gives OPTIONAL
  2252.    guidelines on how packet types may be indicated by a specific link-
  2253.    layer.
  2254.  
  2255.    It is necessary to distinguish packets with regular IPv4 headers,
  2256.    regular IPv6 headers, full IPv6 packets, full IPv4 packets,
  2257.    compressed TCP packets, compressed non-TCP packets, and CONTEXT_STATE
  2258.    packets.
  2259.  
  2260.    The decision to use a distinct ethertype (or equivalent) for IPv6 has
  2261.    already been taken, which means that link-layers must be able to
  2262.    indicate that a packet is an IPv6 packet.
  2263.  
  2264.    IP header compression requires that the link-layer implementation can
  2265.    indicate four kinds of packets: COMPRESSED_TCP for format a) in
  2266.    section 6, COMPRESSED_TCP_NODELTA for format b), COMPRESSED_NON_TCP
  2267.    for formats c) and d), and CONTEXT_STATE as described in section
  2268.    11.2.  It is also desirable to indicate FULL_HEADERS at the link
  2269.    layer.
  2270.  
  2271.    Full headers can be indicated by setting the first bit of the Version
  2272.    field in a packet indicated to be an IPv6 packet.  In addition, one
  2273.    bit of the Version field is used to indicate if the first subheader
  2274.    is an IPv6 or an IPv4 header, and one bit is used to indicate if this
  2275.    full header carries a TCP CID or a non-TCP CID. The first four bits
  2276.    are encoded as follows:
  2277.  
  2278.       Version  Meaning
  2279.       -------  -------
  2280.  
  2281.       0110     regular IPv6 header
  2282.  
  2283.       1T*0     T=1 indicates a TCP header, T=0 indicates a non-TCP header
  2284.       1*V0     V=1 indicates a IPv6 header, V=0 indicates a IPv4 header
  2285.  
  2286.    If a link-layer cannot indicate the packet types for the compressed
  2287.    headers or CONTEXT_STATE, packet types that cannot be indicated could
  2288.    start with an octet indicating the packet type, followed by the
  2289.    header.
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298. Degermark, et. al.          Standards Track                    [Page 41]
  2299.  
  2300. RFC 2507                 IP Header Compression             February 1999
  2301.  
  2302.  
  2303.        First octet  Type of compressed header
  2304.        -----------   -------------------------
  2305.  
  2306.            0        COMPRESSED_TCP
  2307.            1        COMPRESSED_TCP_NODELTA
  2308.            2        COMPRESSED_NON_TCP
  2309.            3        CONTEXT_STATE
  2310.  
  2311.    The currently assigned CONTEXT_STATE type values are
  2312.  
  2313.        Value   Type                       Reference
  2314.        -----   -----                      ----------
  2315.          0     Reserved                   -
  2316.          1     IP/UDP/RTP w. 8-bit CID    [CRTP]
  2317.          2     IP/UDP/RTP w. 16-bit CID   [CRTP]
  2318.          3     TCP header request         Section 10.2
  2319.  
  2320. 14.  Configuration Parameters
  2321.  
  2322.    Header compression parameters are negotiated in a way specific to the
  2323.    link-layer implementation. Such procedures for link-layer xxx needs
  2324.    to be specified in a document "IP header compression over xxx". Such
  2325.    a document exists for PPP [PPP-HC].
  2326.  
  2327.    The following parameter is fixed for all implementations of this
  2328.    header compression scheme.
  2329.  
  2330.      MIN_WRAP     - minimum time of generation value wrap around
  2331.  
  2332.           3 seconds.
  2333.  
  2334.    The following parameters can be negotiated between the compressor and
  2335.    decompressor. If not negotiated their values must be as specified by
  2336.    DEFAULT.
  2337.  
  2338.      F_MAX_PERIOD - Largest number of compressed non-TCP headers that
  2339.                     may be sent without sending a full header.
  2340.  
  2341.           DEFAULT is 256
  2342.  
  2343.           F_MAX_PERIOD must be at least 1 and at most 65535.
  2344.  
  2345.  
  2346.      F_MAX_TIME   - Compressed headers may not be sent more than
  2347.                     F_MAX_TIME seconds after sending last full header.
  2348.  
  2349.           DEFAULT is 5
  2350.  
  2351.  
  2352.  
  2353.  
  2354. Degermark, et. al.          Standards Track                    [Page 42]
  2355.  
  2356. RFC 2507                 IP Header Compression             February 1999
  2357.  
  2358.  
  2359.           F_MAX_TIME must be at least 1 and at most 255.
  2360.  
  2361.           NOTE:  F_MAX_PERIOD and F_MAX_TIME should be lower when it is
  2362.                  likely that a decompressor loses its state.
  2363.  
  2364.  
  2365.      MAX_HEADER   - The largest header size in octets that may
  2366.                     be compressed.
  2367.  
  2368.           DEFAULT is 168 octets, which covers
  2369.  
  2370.                           - Two IPv6 base headers
  2371.                           - A Keyed MD5 Authentication Header
  2372.                           - A maximum-sized TCP header
  2373.  
  2374.           MAX_HEADER must be at least 60 octets and
  2375.                   at most 65535 octets.
  2376.  
  2377.  
  2378.      TCP_SPACE    - Maximum CID value for TCP.
  2379.  
  2380.           DEFAULT is 15   (which gives 16 CID values)
  2381.  
  2382.           TCP_SPACE must be at least 3 and at most 255.
  2383.  
  2384.  
  2385.      NON_TCP_SPACE    - Maximum CID value for non-TCP.
  2386.  
  2387.           DEFAULT is 15   (which gives 16 CID values)
  2388.  
  2389.           NON_TCP_SPACE must be at least 3 and at most 65535.
  2390.  
  2391.  
  2392.      EXPECT_REORDERING       - The mechanisms in section 11 are used.
  2393.  
  2394.           DEFAULT no.
  2395.  
  2396. 15. Implementation Status
  2397.  
  2398.    A prototype using UDP as the link layer has been operational since
  2399.    March 1996. A NetBSD implementation for PPP has been operational
  2400.    since October 1996.
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410. Degermark, et. al.          Standards Track                    [Page 43]
  2411.  
  2412. RFC 2507                 IP Header Compression             February 1999
  2413.  
  2414.  
  2415. 16.  Acknowledgments
  2416.  
  2417.    This protocol uses many ideas originated by Van Jacobson in the
  2418.    design of header compression for TCP/IP over slow-speed links [RFC-
  2419.    1144]. It has benefited from discussions with Stephen Casner and
  2420.    Carsten Bormann.
  2421.  
  2422.    We thank Craig Partridge for pointing out a problem that can occur
  2423.    when the TCP window scale option is used.  A solution to this problem
  2424.    relying on the packet sequence numbers used for reordering is
  2425.    described in section 11.2.
  2426.  
  2427. 17.  Security Considerations
  2428.  
  2429.    The compression protocols in this document run on top of a link-layer
  2430.    protocol. The compression protocols themselves introduce no new
  2431.    additional vulnerabilities beyond those associated with the specific
  2432.    link-layer technology being used.
  2433.  
  2434.    Denial-of-service attacks are possible if an intruder can introduce
  2435.    (for example) bogus Full Header packets onto the link.  However, an
  2436.    intruder having the ability to inject arbitrary packets at the link-
  2437.    layer in this manner raises additional security issues that dwarf
  2438.    those related to the use of header compression.
  2439.  
  2440.    We advise implementors against identifying packet streams with the
  2441.    aid of information that is encrypted, even if such information
  2442.    happens to be available to the compressor. Doing so may expose
  2443.    traffic patterns.
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466. Degermark, et. al.          Standards Track                    [Page 44]
  2467.  
  2468. RFC 2507                 IP Header Compression             February 1999
  2469.  
  2470.  
  2471. 18.  Authors' Addresses
  2472.  
  2473.    Mikael Degermark
  2474.    Department of Computer Science and Electrical Engineering
  2475.    Lulea University of Technology
  2476.    SE-971 87 Lulea, Sweden
  2477.  
  2478.    Phone: +46 920 91188
  2479.    Fax: +46 920 72831
  2480.    Mobile: +46 70 833 8933
  2481.    EMail: micke@sm.luth.se
  2482.  
  2483.  
  2484.    Bjorn Nordgren
  2485.    CDT/Telia Research AB
  2486.    Aurorum 6
  2487.    S-977 75 Lulea, Sweden
  2488.  
  2489.    Phone: +46 920 75400
  2490.    Fax: +46 920 75490
  2491.    EMail: bcn@lulea.trab.se, bcn@cdt.luth.se
  2492.  
  2493.  
  2494.    Stephen Pink
  2495.    Department of Computer Science and Electrical Engineering
  2496.    Lulea University of Technology
  2497.    SE-971 87 Lulea, Sweden
  2498.  
  2499.    Phone: +46 920 752 29
  2500.    Fax: +46 920 728 31
  2501.    Mobile: +46 70 532 0007
  2502.    EMail: steve@sm.luth.se
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522. Degermark, et. al.          Standards Track                    [Page 45]
  2523.  
  2524. RFC 2507                 IP Header Compression             February 1999
  2525.  
  2526.  
  2527. 19.  References
  2528.  
  2529.    [RFC-768]       Postel, J., "User Datagram Protocol", STD 6, RFC 768,
  2530.                    August 1980.
  2531.  
  2532.    [RFC-791]       Postel, J., "Internet Protocol", STD 5, RFC 791,
  2533.                    September 1981.
  2534.  
  2535.    [RFC-793]       Postel, J., "Transmission Control Protocol", STD 7,
  2536.                    RFC 793, September 1981.
  2537.  
  2538.    [RFC-1144]      Jacobson, V., "Compressing TCP/IP Headers for Low-
  2539.                    Speed Serial Links", RFC 1144, February 1990.
  2540.  
  2541.    [RFC-1553]      Mathur, A. and M. Lewis, "Compressing IPX Headers
  2542.                    Over WAN Media (CIPX)", RFC 1553, December 1993.
  2543.  
  2544.    [RFC-1700]      Reynolds, J. and J. Postel, "Assigned Numbers", STD
  2545.                    2, RFC 1700, October 1994.  See also:
  2546.                    http://www.iana.org/numbers.html
  2547.  
  2548.    [RFC-2402]      Kent, S. and R. Atkinson, "IP Authentication Header",
  2549.                    RFC 2402, November 1998.
  2550.  
  2551.    [RFC-2406]      Kent, S. and R. Atkinson, "IP Encapsulating Security
  2552.                    Protocol (ESP)", RFC 2406, November 1998.
  2553.  
  2554.    [RFC-1828]      Metzger, W., "IP Authentication using Keyed MD5", RFC
  2555.                    1828, August 1995.
  2556.  
  2557.    [IPv6]          Deering, S. and R. Hinden, "Internet Protocol,
  2558.                    Version 6 (IPv6) Specification", RFC 2460, December
  2559.                    1998.
  2560.  
  2561.    [ICMPv6]        Conta, A. and S. Deering, "Internet Control Message
  2562.                    Protocol (ICMPv6) for the Internet Protocol Version 6
  2563.                    (IPv6) Specification.", RFC 2463, December 1998.
  2564.  
  2565.    [RFC-2004]      Perkins, C., "Minimal Encapsulation within IP", RFC
  2566.                    2004, October 1996.
  2567.  
  2568.    [CRTP]          Casner, S. and V. Jacobson, "Compressing IP/UDP/RTP
  2569.                    Headers for Low-Speed Serial Links", RFC 2508,
  2570.                    February 1999.
  2571.  
  2572.    [PPP-HC]        Engan, M., Casner, S. and C. Bormann, "IP Header
  2573.                    Compression for PPP", RFC 2509, February 1999.
  2574.  
  2575.  
  2576.  
  2577.  
  2578. Degermark, et. al.          Standards Track                    [Page 46]
  2579.  
  2580. RFC 2507                 IP Header Compression             February 1999
  2581.  
  2582.  
  2583. 20.  Full Copyright Statement
  2584.  
  2585.    Copyright (C) The Internet Society (1999).  All Rights Reserved.
  2586.  
  2587.    This document and translations of it may be copied and furnished to
  2588.    others, and derivative works that comment on or otherwise explain it
  2589.    or assist in its implementation may be prepared, copied, published
  2590.    and distributed, in whole or in part, without restriction of any
  2591.    kind, provided that the above copyright notice and this paragraph are
  2592.    included on all such copies and derivative works.  However, this
  2593.    document itself may not be modified in any way, such as by removing
  2594.    the copyright notice or references to the Internet Society or other
  2595.    Internet organizations, except as needed for the purpose of
  2596.    developing Internet standards in which case the procedures for
  2597.    copyrights defined in the Internet Standards process must be
  2598.    followed, or as required to translate it into languages other than
  2599.    English.
  2600.  
  2601.    The limited permissions granted above are perpetual and will not be
  2602.    revoked by the Internet Society or its successors or assigns.
  2603.  
  2604.    This document and the information contained herein is provided on an
  2605.    "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
  2606.    TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
  2607.    BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
  2608.    HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
  2609.    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  .fi
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634. Degermark, et. al.          Standards Track                    [Page 47]
  2635.  
  2636.