[ RFC Index | RFC Search | Usenet FAQs | Web FAQs | Documents | Cities ]

Alternate Formats: rfc4728.txt | rfc4728.txt.pdf

RFC 4728 - The Dynamic Source Routing Protocol (DSR) for Mobile Ad Hoc Networks for IPv4


    Search the Archives
Display RFC by number
    


RFC4728 - The Dynamic Source Routing Protocol (DSR) for Mobile


Network Working Group                                         D. Johnson
Request for Comments: 4728                               Rice University
Category: Experimental                                             Y. Hu
                                                                    UIUC
                                                                D. Maltz
                                                      Microsoft Research
                                                           February 2007

               The Dynamic Source Routing Protocol (DSR)
                  for Mobile Ad Hoc Networks for IPv4

Status of This Memo

   This memo defines an Experimental Protocol for the Internet
   community.  It does not specify an Internet standard of any kind.
   Discussion and suggestions for improvement are requested.
   Distribution of this memo is unlimited.

Copyright Notice

   Copyright (C) The IETF Trust (2007).

Abstract

   The Dynamic Source Routing protocol (DSR) is a simple and efficient
   routing protocol designed specifically for use in multi-hop wireless
   ad hoc networks of mobile nodes.  DSR allows the network to be
   completely self-organizing and self-configuring, without the need for
   any existing network infrastructure or administration.  The protocol
   is composed of the two main mechanisms of "Route Discovery" and
   "Route Maintenance", which work together to allow nodes to discover
   and maintain routes to arbitrary destinations in the ad hoc network.
   All aspects of the protocol operate entirely on demand, allowing the
   routing packet overhead of DSR to scale automatically to only what is
   needed to react to changes in the routes currently in use.  The
   protocol allows multiple routes to any destination and allows each
   sender to select and control the routes used in routing its packets,
   for example, for use in load balancing or for increased robustness.
   Other advantages of the DSR protocol include easily guaranteed loop-
   free routing, operation in networks containing unidirectional links,
   use of only "soft state" in routing, and very rapid recovery when
   routes in the network change.  The DSR protocol is designed mainly
   for mobile ad hoc networks of up to about two hundred nodes and is
   designed to work well even with very high rates of mobility.  This
   document specifies the operation of the DSR protocol for routing
   unicast IPv4 packets.

Table of Contents

   1. Introduction ....................................................5
   2. Assumptions .....................................................7
   3. DSR Protocol Overview ...........................................9
      3.1. Basic DSR Route Discovery .................................10
      3.2. Basic DSR Route Maintenance ...............................12
      3.3. Additional Route Discovery Features .......................14
           3.3.1. Caching Overheard Routing Information ..............14
           3.3.2. Replying to Route Requests Using Cached Routes .....15
           3.3.3. Route Request Hop Limits ...........................16
      3.4. Additional Route Maintenance Features .....................17
           3.4.1. Packet Salvaging ...................................17
           3.4.2. Queued Packets Destined over a Broken Link .........18
           3.4.3. Automatic Route Shortening .........................19
           3.4.4. Increased Spreading of Route Error Messages ........20
      3.5. Optional DSR Flow State Extension .........................20
           3.5.1. Flow Establishment .................................21
           3.5.2. Receiving and Forwarding Establishment Packets .....22
           3.5.3. Sending Packets along Established Flows ............22
           3.5.4. Receiving and Forwarding Packets Sent along
                  Established Flows ..................................23
           3.5.5. Processing Route Errors ............................24
           3.5.6. Interaction with Automatic Route Shortening ........24
           3.5.7. Loop Detection .....................................25
           3.5.8. Acknowledgement Destination ........................25
           3.5.9. Crash Recovery .....................................25
           3.5.10. Rate Limiting .....................................25
           3.5.11. Interaction with Packet Salvaging .................26
   4. Conceptual Data Structures .....................................26
      4.1. Route Cache ...............................................26
      4.2. Send Buffer ...............................................30
      4.3. Route Request Table .......................................30
      4.4. Gratuitous Route Reply Table ..............................31
      4.5. Network Interface Queue and Maintenance Buffer ............32
      4.6. Blacklist .................................................33
   5. Additional Conceptual Data Structures for Flow State
      Extension ......................................................34
      5.1. Flow Table ................................................34
      5.2. Automatic Route Shortening Table ..........................35
      5.3. Default Flow ID Table .....................................36
   6. DSR Options Header Format ......................................36
      6.1. Fixed Portion of DSR Options Header .......................37
      6.2. Route Request Option ......................................40
      6.3. Route Reply Option ........................................42

      6.4. Route Error Option ........................................44
           6.4.1. Node Unreachable Type-Specific Information .........46
           6.4.2. Flow State Not Supported Type-Specific
                  Information ........................................46
           6.4.3. Option Not Supported Type-Specific Information .....46
      6.5. Acknowledgement Request Option ............................46
      6.6. Acknowledgement Option ....................................47
      6.7. DSR Source Route Option ...................................48
      6.8. Pad1 Option ...............................................50
      6.9. PadN Option ...............................................50
   7. Additional Header Formats and Options for Flow State
      Extension ......................................................51
      7.1. DSR Flow State Header .....................................52
      7.2. New Options and Extensions in DSR Options Header ..........52
           7.2.1. Timeout Option .....................................52
           7.2.2. Destination and Flow ID Option .....................53
      7.3. New Error Types for Route Error Option ....................54
           7.3.1. Unknown Flow Type-Specific Information .............54
           7.3.2. Default Flow Unknown Type-Specific Information .....55
      7.4. New Acknowledgement Request Option Extension ..............55
           7.4.1. Previous Hop Address Extension .....................55
   8. Detailed Operation .............................................56
      8.1. General Packet Processing .................................56
           8.1.1. Originating a Packet ...............................56
           8.1.2. Adding a DSR Options Header to a Packet ............57
           8.1.3. Adding a DSR Source Route Option to a Packet .......57
           8.1.4. Processing a Received Packet .......................58
           8.1.5. Processing a Received DSR Source Route Option ......60
           8.1.6. Handling an Unknown DSR Option .....................63
      8.2. Route Discovery Processing ................................64
           8.2.1. Originating a Route Request ........................65
           8.2.2. Processing a Received Route Request Option .........66
           8.2.3. Generating a Route Reply Using the Route Cache .....68
           8.2.4. Originating a Route Reply ..........................71
           8.2.5. Preventing Route Reply Storms ......................72
           8.2.6. Processing a Received Route Reply Option ...........74
      8.3. Route Maintenance Processing ..............................74
           8.3.1. Using Link-Layer Acknowledgements ..................75
           8.3.2. Using Passive Acknowledgements .....................76
           8.3.3. Using Network-Layer Acknowledgements ...............77
           8.3.4. Originating a Route Error ..........................80
           8.3.5. Processing a Received Route Error Option ...........81
           8.3.6. Salvaging a Packet .................................82
      8.4. Multiple Network Interface Support ........................84
      8.5. IP Fragmentation and Reassembly ...........................84
      8.6. Flow State Processing .....................................85
           8.6.1. Originating a Packet ...............................85
           8.6.2. Inserting a DSR Flow State Header ..................88

           8.6.3. Receiving a Packet .................................88
           8.6.4. Forwarding a Packet Using Flow IDs .................93
           8.6.5. Promiscuously Receiving a Packet ...................93
           8.6.6. Operation Where the Layer below DSR
                  Decreases the IP TTL ...............................94
           8.6.7. Salvage Interactions with DSR ......................94
   9. Protocol Constants and Configuration Variables .................95
   10. IANA Considerations ...........................................96
   11. Security Considerations .......................................96
   Appendix A. Link-MaxLife Cache Description ........................97
   Appendix B. Location of DSR in the ISO Network Reference Model ....99
   Appendix C. Implementation and Evaluation Status .................100
   Acknowledgements .................................................101
   Normative References .............................................102
   Informative References ...........................................102

1.  Introduction

   The Dynamic Source Routing protocol (DSR) [JOHNSON94, JOHNSON96a] is
   a simple and efficient routing protocol designed specifically for use
   in multi-hop wireless ad hoc networks of mobile nodes.  Using DSR,
   the network is completely self-organizing and self-configuring,
   requiring no existing network infrastructure or administration.
   Network nodes cooperate to forward packets for each other to allow
   communication over multiple "hops" between nodes not directly within
   wireless transmission range of one another.  As nodes in the network
   move about or join or leave the network, and as wireless transmission
   conditions such as sources of interference change, all routing is
   automatically determined and maintained by the DSR routing protocol.
   Since the number or sequence of intermediate hops needed to reach any
   destination may change at any time, the resulting network topology
   may be quite rich and rapidly changing.

   In designing DSR, we sought to create a routing protocol that had
   very low overhead yet was able to react very quickly to changes in
   the network.  The DSR protocol provides highly reactive service in
   order to help ensure successful delivery of data packets in spite of
   node movement or other changes in network conditions.

   The DSR protocol is composed of two main mechanisms that work
   together to allow the discovery and maintenance of source routes in
   the ad hoc network:

   -  Route Discovery is the mechanism by which a node S wishing to send
      a packet to a destination node D obtains a source route to D.
      Route Discovery is used only when S attempts to send a packet to D
      and does not already know a route to D.

   -  Route Maintenance is the mechanism by which node S is able to
      detect, while using a source route to D, if the network topology
      has changed such that it can no longer use its route to D because
      a link along the route no longer works.  When Route Maintenance
      indicates a source route is broken, S can attempt to use any other
      route it happens to know to D, or it can invoke Route Discovery
      again to find a new route for subsequent packets to D.  Route
      Maintenance for this route is used only when S is actually sending
      packets to D.

   In DSR, Route Discovery and Route Maintenance each operate entirely
   "on demand".  In particular, unlike other protocols, DSR requires no
   periodic packets of any kind at any layer within the network.  For
   example, DSR does not use any periodic routing advertisement, link
   status sensing, or neighbor detection packets and does not rely on
   these functions from any underlying protocols in the network.  This

   entirely on-demand behavior and lack of periodic activity allows the
   number of overhead packets caused by DSR to scale all the way down to
   zero, when all nodes are approximately stationary with respect to
   each other and all routes needed for current communication have
   already been discovered.  As nodes begin to move more or as
   communication patterns change, the routing packet overhead of DSR
   automatically scales to only what is needed to track the routes
   currently in use.  Network topology changes not affecting routes
   currently in use are ignored and do not cause reaction from the
   protocol.

   All state maintained by DSR is "soft state" [CLARK88], in that the
   loss of any state will not interfere with the correct operation of
   the protocol; all state is discovered as needed and can easily and
   quickly be rediscovered if needed after a failure without significant
   impact on the protocol.  This use of only soft state allows the
   routing protocol to be very robust to problems such as dropped or
   delayed routing packets or node failures.  In particular, a node in
   DSR that fails and reboots can easily rejoin the network immediately
   after rebooting; if the failed node was involved in forwarding
   packets for other nodes as an intermediate hop along one or more
   routes, it can also resume this forwarding quickly after rebooting,
   with no or minimal interruption to the routing protocol.

   In response to a single Route Discovery (as well as through routing
   information from other packets overheard), a node may learn and cache
   multiple routes to any destination.  This support for multiple routes
   allows the reaction to routing changes to be much more rapid, since a
   node with multiple routes to a destination can try another cached
   route if the one it has been using should fail.  This caching of
   multiple routes also avoids the overhead of needing to perform a new
   Route Discovery each time a route in use breaks.  The sender of a
   packet selects and controls the route used for its own packets,
   which, together with support for multiple routes, also allows
   features such as load balancing to be defined.  In addition, all
   routes used are easily guaranteed to be loop-free, since the sender
   can avoid duplicate hops in the routes selected.

   The operation of both Route Discovery and Route Maintenance in DSR
   are designed to allow unidirectional links and asymmetric routes to
   be supported.  In particular, as noted in Section 2, in wireless
   networks, it is possible that a link between two nodes may not work
   equally well in both directions, due to differing transmit power
   levels or sources of interference.

   It is possible to interface a DSR network with other networks,
   external to this DSR network.  Such external networks may, for
   example, be the Internet or may be other ad hoc networks routed with

   a routing protocol other than DSR.  Such external networks may also
   be other DSR networks that are treated as external networks in order
   to improve scalability.  The complete handling of such external
   networks is beyond the scope of this document.  However, this
   document specifies a minimal set of requirements and features
   necessary to allow nodes only implementing this specification to
   interoperate correctly with nodes implementing interfaces to such
   external networks.

   This document specifies the operation of the DSR protocol for routing
   unicast IPv4 packets in multi-hop wireless ad hoc networks.
   Advanced, optional features, such as Quality of Service (QoS) support
   and efficient multicast routing, and operation of DSR with IPv6
   [RFC2460], will be covered in other documents.  The specification of
   DSR in this document provides a compatible base on which such
   features can be added, either independently or by integration with
   the DSR operation specified here.  As described in Appendix C, the
   design of DSR has been extensively studied through detailed
   simulations and testbed implementation and demonstration; this
   document encourages additional implementation and experimentation
   with the protocol.

   The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in RFC 2119 [RFC2119].

2.  Assumptions

   As described here, the DSR protocol is designed mainly for mobile ad
   hoc networks of up to about two hundred nodes and is designed to work
   well even with very high rates of mobility.  Other protocol features
   and enhancements that may allow DSR to scale to larger networks are
   outside the scope of this document.

   We assume in this document that all nodes wishing to communicate with
   other nodes within the ad hoc network are willing to participate
   fully in the protocols of the network.  In particular, each node
   participating in the ad hoc network SHOULD also be willing to forward
   packets for other nodes in the network.

   The diameter of an ad hoc network is the minimum number of hops
   necessary for a packet to reach from any node located at one extreme
   edge of the ad hoc network to another node located at the opposite
   extreme.  We assume that this diameter will often be small (e.g.,
   perhaps 5 or 10 hops), but it may often be greater than 1.

   Packets may be lost or corrupted in transmission on the wireless
   network.  We assume that a node receiving a corrupted packet can
   detect the error, such as through a standard link-layer checksum or
   Cyclic Redundancy Check (CRC), and discard the packet.

   Nodes within the ad hoc network MAY move at any time without notice
   and MAY even move continuously, but we assume that the speed with
   which nodes move is moderate with respect to the packet transmission
   latency and wireless transmission range of the particular underlying
   network hardware in use.  In particular, DSR can support very rapid
   rates of arbitrary node mobility, but we assume that nodes do not
   continuously move so rapidly as to make the flooding of every
   individual data packet the only possible routing protocol.

   A common feature of many network interfaces, including most current
   LAN hardware for broadcast media such as wireless, is the ability to
   operate the network interface in "promiscuous" receive mode.  This
   mode causes the hardware to deliver every received packet to the
   network driver software without filtering based on link-layer
   destination address.  Although we do not require this facility, some
   of our optimizations can take advantage of its availability.  Use of
   promiscuous mode does increase the software overhead on the CPU, but
   we believe that wireless network speeds and capacity are more the
   inherent limiting factors to performance in current and future
   systems; we also believe that portions of the protocol are suitable
   for implementation directly within a programmable network interface
   unit to avoid this overhead on the CPU [JOHNSON96a].  Use of
   promiscuous mode may also increase the power consumption of the
   network interface hardware, depending on the design of the receiver
   hardware, and in such cases, DSR can easily be used without the
   optimizations that depend on promiscuous receive mode or can be
   programmed to only periodically switch the interface into promiscuous
   mode.  Use of promiscuous receive mode is entirely optional.

   Wireless communication ability between any pair of nodes may at times
   not work equally well in both directions, due, for example, to
   transmit power levels or sources of interference around the two nodes
   [BANTZ94, LAUER95].  That is, wireless communications between each
   pair of nodes will in many cases be able to operate bidirectionally,
   but at times the wireless link between two nodes may be only
   unidirectional, allowing one node to successfully send packets to the
   other while no communication is possible in the reverse direction.
   Some Medium Access Control (MAC) protocols, however, such as MACA
   [KARN90], MACAW [BHARGHAVAN94], or IEEE 802.11 [IEEE80211], limit
   unicast data packet transmission to bidirectional links, due to the
   required bidirectional exchange of request to send (RTS) and clear to
   send (CTS) packets in these protocols and to the link-layer
   acknowledgement feature in IEEE 802.11.  When used on top of MAC

   protocols such as these, DSR can take advantage of additional
   optimizations, such as the ability to reverse a source route to
   obtain a route back to the origin of the original route.

   The IP address used by a node using the DSR protocol MAY be assigned
   by any mechanism (e.g., static assignment or use of Dynamic Host
   Configuration Protocol (DHCP) for dynamic assignment [RFC2131]),
   although the method of such assignment is outside the scope of this
   specification.

   A routing protocol such as DSR chooses a next-hop for each packet and
   provides the IP address of that next-hop.  When the packet is
   transmitted, however, the lower-layer protocol often has a separate,
   MAC-layer address for the next-hop node.  DSR uses the Address
   Resolution Protocol (ARP) [RFC826] to translate from next-hop IP
   addresses to next-hop MAC addresses.  In addition, a node MAY add an
   entry to its ARP cache based on any received packet, when the IP
   address and MAC address of the transmitting node are available in the
   packet; for example, the IP address of the transmitting node is
   present in a Route Request option (in the Address list being
   accumulated) and any packets containing a source route.  Adding
   entries to the ARP cache in this way avoids the overhead of ARP in
   most cases.

3.  DSR Protocol Overview

   This section provides an overview of the operation of the DSR
   protocol.  The basic version of DSR uses explicit "source routing",
   in which each data packet sent carries in its header the complete,
   ordered list of nodes through which the packet will pass.  This use
   of explicit source routing allows the sender to select and control
   the routes used for its own packets, supports the use of multiple
   routes to any destination (for example, for load balancing), and
   allows a simple guarantee that the routes used are loop-free.  By
   including this source route in the header of each data packet, other
   nodes forwarding or overhearing any of these packets can also easily
   cache this routing information for future use.  Section 3.1 describes
   this basic operation of Route Discovery, Section 3.2 describes basic
   Route Maintenance, and Sections 3.3 and 3.4 describe additional
   features of these two parts of DSR's operation.  Section 3.5 then
   describes an optional, compatible extension to DSR, known as "flow
   state", that allows the routing of most packets without an explicit
   source route header in the packet, while the fundamental properties
   of DSR's operation are preserved.

3.1.  Basic DSR Route Discovery

   When some source node originates a new packet addressed to some
   destination node, the source node places in the header of the packet
   a "source route" giving the sequence of hops that the packet is to
   follow on its way to the destination.  Normally, the sender will
   obtain a suitable source route by searching its "Route Cache" of
   routes previously learned; if no route is found in its cache, it will
   initiate the Route Discovery protocol to dynamically find a new route
   to this destination node.  In this case, we call the source node the
   "initiator" and the destination node the "target" of the Route
   Discovery.

   For example, suppose a node A is attempting to discover a route to
   node E.  The Route Discovery initiated by node A in this example
   would proceed as follows:

            ^    "A"    ^   "A,B"   ^  "A,B,C"  ^ "A,B,C,D"
            |   id=2    |   id=2    |   id=2    |   id=2
         +-----+     +-----+     +-----+     +-----+     +-----+
         |  A  |---->|  B  |---->|  C  |---->|  D  |---->|  E  |
         +-----+     +-----+     +-----+     +-----+     +-----+
            |           |           |           |
            v           v           v           v

   To initiate the Route Discovery, node A transmits a "Route Request"
   as a single local broadcast packet, which is received by
   (approximately) all nodes currently within wireless transmission
   range of A, including node B in this example.  Each Route Request
   identifies the initiator and target of the Route Discovery, and also
   contains a unique request identification (2, in this example),
   determined by the initiator of the Request.  Each Route Request also
   contains a record listing the address of each intermediate node
   through which this particular copy of the Route Request has been
   forwarded.  This route record is initialized to an empty list by the
   initiator of the Route Discovery.  In this example, the route record
   initially lists only node A.

   When another node receives this Route Request (such as node B in this
   example), if it is the target of the Route Discovery, it returns a
   "Route Reply" to the initiator of the Route Discovery, giving a copy
   of the accumulated route record from the Route Request; when the
   initiator receives this Route Reply, it caches this route in its
   Route Cache for use in sending subsequent packets to this
   destination.

   Otherwise, if this node receiving the Route Request has recently seen
   another Route Request message from this initiator bearing this same
   request identification and target address, or if this node's own
   address is already listed in the route record in the Route Request,
   this node discards the Request.  (A node considers a Request recently
   seen if it still has information about that Request in its Route
   Request Table, which is described in Section 4.3.)  Otherwise, this
   node appends its own address to the route record in the Route Request
   and propagates it by transmitting it as a local broadcast packet
   (with the same request identification).  In this example, node B
   broadcast the Route Request, which is received by node C; nodes C and
   D each also, in turn, broadcast the Request, resulting in receipt of
   a copy of the Request by node E.

   In returning the Route Reply to the initiator of the Route Discovery,
   such as in this example, node E replying back to node A, node E will
   typically examine its own Route Cache for a route back to A and, if
   one is found, will use it for the source route for delivery of the
   packet containing the Route Reply.  Otherwise, E SHOULD perform its
   own Route Discovery for target node A, but to avoid possible infinite
   recursion of Route Discoveries, it MUST in this case piggyback this
   Route Reply on the packet containing its own Route Request for A.  It
   is also possible to piggyback other small data packets, such as a TCP
   SYN packet [RFC793], on a Route Request using this same mechanism.

   Node E could instead simply reverse the sequence of hops in the route
   record that it is trying to send in the Route Reply and use this as
   the source route on the packet carrying the Route Reply itself.  For
   MAC protocols, such as IEEE 802.11, that require a bidirectional
   frame exchange for unicast packets as part of the MAC protocol
   [IEEE80211], the discovered source route MUST be reversed in this way
   to return the Route Reply, since this route reversal tests the
   discovered route to ensure that it is bidirectional before the Route
   Discovery initiator begins using the route.  This route reversal also
   avoids the overhead of a possible second Route Discovery.

   When initiating a Route Discovery, the sending node saves a copy of
   the original packet (that triggered the discovery) in a local buffer
   called the "Send Buffer".  The Send Buffer contains a copy of each
   packet that cannot be transmitted by this node because it does not
   yet have a source route to the packet's destination.  Each packet in
   the Send Buffer is logically associated with the time that it was
   placed into the Send Buffer and is discarded after residing in the
   Send Buffer for some timeout period SendBufferTimeout; if necessary
   for preventing the Send Buffer from overflowing, a FIFO or other
   replacement strategy MAY also be used to evict packets even before
   they expire.

   While a packet remains in the Send Buffer, the node SHOULD
   occasionally initiate a new Route Discovery for the packet's
   destination address.  However, the node MUST limit the rate at which
   such new Route Discoveries for the same address are initiated (as
   described in Section 4.3), since it is possible that the destination
   node is not currently reachable.  In particular, due to the limited
   wireless transmission range and the movement of the nodes in the
   network, the network may at times become partitioned, meaning that
   there is currently no sequence of nodes through which a packet could
   be forwarded to reach the destination.  Depending on the movement
   pattern and the density of nodes in the network, such network
   partitions may be rare or common.

   If a new Route Discovery was initiated for each packet sent by a node
   in such a partitioned network, a large number of unproductive Route
   Request packets would be propagated throughout the subset of the ad
   hoc network reachable from this node.  In order to reduce the
   overhead from such Route Discoveries, a node SHOULD use an
   exponential back-off algorithm to limit the rate at which it
   initiates new Route Discoveries for the same target, doubling the
   timeout between each successive discovery initiated for the same
   target.  If the node attempts to send additional data packets to this
   same destination node more frequently than this limit, the subsequent
   packets SHOULD be buffered in the Send Buffer until a Route Reply is
   received giving a route to this destination, but the node MUST NOT
   initiate a new Route Discovery until the minimum allowable interval
   between new Route Discoveries for this target has been reached.  This
   limitation on the maximum rate of Route Discoveries for the same
   target is similar to the mechanism required by Internet nodes to
   limit the rate at which ARP Requests are sent for any single target
   IP address [RFC1122].

3.2.  Basic DSR Route Maintenance

   When originating or forwarding a packet using a source route, each
   node transmitting the packet is responsible for confirming that data
   can flow over the link from that node to the next hop.  For example,
   in the situation shown below, node A has originated a packet for node
   E using a source route through intermediate nodes B, C, and D:

         +-----+     +-----+     +-----+     +-----+     +-----+
         |  A  |---->|  B  |---->|  C  |-->? |  D  |     |  E  |
         +-----+     +-----+     +-----+     +-----+     +-----+

   In this case, node A is responsible for the link from A to B, node B
   is responsible for the link from B to C, node C is responsible for
   the link from C to D, and node D is responsible for the link from D
   to E.

   An acknowledgement can provide confirmation that a link is capable of
   carrying data, and in wireless networks, acknowledgements are often
   provided at no cost, either as an existing standard part of the MAC
   protocol in use (such as the link-layer acknowledgement frame defined
   by IEEE 802.11 [IEEE80211]), or by a "passive acknowledgement"
   [JUBIN87] (in which, for example, B confirms receipt at C by
   overhearing C transmit the packet when forwarding it on to D).

   If a built-in acknowledgement mechanism is not available, the node
   transmitting the packet can explicitly request that a DSR-specific
   software acknowledgement be returned by the next node along the
   route; this software acknowledgement will normally be transmitted
   directly to the sending node, but if the link between these two nodes
   is unidirectional (Section 4.6), this software acknowledgement could
   travel over a different, multi-hop path.

   After an acknowledgement has been received from some neighbor, a node
   MAY choose not to require acknowledgements from that neighbor for a
   brief period of time, unless the network interface connecting a node
   to that neighbor always receives an acknowledgement in response to
   unicast traffic.

   When a software acknowledgement is used, the acknowledgement request
   SHOULD be retransmitted up to a maximum number of times.  A
   retransmission of the acknowledgement request can be sent as a
   separate packet, piggybacked on a retransmission of the original data
   packet, or piggybacked on any packet with the same next-hop
   destination that does not also contain a software acknowledgement.

   After the acknowledgement request has been retransmitted the maximum
   number of times, if no acknowledgement has been received, then the
   sender treats the link to this next-hop destination as currently
   "broken".  It SHOULD remove this link from its Route Cache and SHOULD
   return a "Route Error" to each node that has sent a packet routed
   over that link since an acknowledgement was last received.  For
   example, in the situation shown above, if C does not receive an
   acknowledgement from D after some number of requests, it would return
   a Route Error to A, as well as any other node that may have used the
   link from C to D since C last received an acknowledgement from D.
   Node A then removes this broken link from its cache; any
   retransmission of the original packet can be performed by upper layer
   protocols such as TCP, if necessary.  For sending such a
   retransmission or other packets to this same destination E, if A has
   in its Route Cache another route to E (for example, from additional
   Route Replies from its earlier Route Discovery, or from having
   overheard sufficient routing information from other packets), it can

   send the packet using the new route immediately.  Otherwise, it
   SHOULD perform a new Route Discovery for this target (subject to the
   back-off described in Section 3.1).

3.3.  Additional Route Discovery Features

3.3.1.  Caching Overheard Routing Information

   A node forwarding or otherwise overhearing any packet SHOULD add all
   usable routing information from that packet to its own Route Cache.
   The usefulness of routing information in a packet depends on the
   directionality characteristics of the physical medium (Section 2), as
   well as on the MAC protocol being used.  Specifically, three distinct
   cases are possible:

   -  Links in the network frequently are capable of operating only
      unidirectionally (not bidirectionally), and the MAC protocol in
      use in the network is capable of transmitting unicast packets over
      unidirectional links.

   -  Links in the network occasionally are capable of operating only
      unidirectionally (not bidirectionally), but this unidirectional
      restriction on any link is not persistent; almost all links are
      physically bidirectional, and the MAC protocol in use in the
      network is capable of transmitting unicast packets over
      unidirectional links.

   -  The MAC protocol in use in the network is not capable of
      transmitting unicast packets over unidirectional links; only
      bidirectional links can be used by the MAC protocol for
      transmitting unicast packets.  For example, the IEEE 802.11
      Distributed Coordination Function (DCF) MAC protocol [IEEE80211]
      is capable of transmitting a unicast packet only over a
      bidirectional link, since the MAC protocol requires the return of
      a link-level acknowledgement packet from the receiver and also
      optionally requires the bidirectional exchange of an RTS and CTS
      packet between the transmitter and receiver nodes.

   In the first case above, for example, the source route used in a data
   packet, the accumulated route record in a Route Request, or the route
   being returned in a Route Reply SHOULD all be cached by any node in
   the "forward" direction.  Any node SHOULD cache this information from
   any such packet received, whether the packet was addressed to this
   node, sent to a broadcast (or multicast) MAC address, or overheard
   while the node's network interface is in promiscuous mode.  However,
   the "reverse" direction of the links identified in such packet
   headers SHOULD NOT be cached.

   For example, in the situation shown below, node A is using a source
   route to communicate with node E:

      +-----+     +-----+     +-----+     +-----+     +-----+
      |  A  |---->|  B  |---->|  C  |---->|  D  |---->|  E  |
      +-----+     +-----+     +-----+     +-----+     +-----+

   As node C forwards a data packet along the route from A to E, it
   SHOULD add to its cache the presence of the "forward" direction links
   that it learns from the headers of these packets, from itself to D
   and from D to E.  Node C SHOULD NOT, in this case, cache the
   "reverse" direction of the links identified in these packet headers,
   from itself back to B and from B to A, since these links might be
   unidirectional.

   In the second case above, in which links may occasionally operate
   unidirectionally, the links described above SHOULD be cached in both
   directions.  Furthermore, in this case, if node X overhears (e.g.,
   through promiscuous mode) a packet transmitted by node C that is
   using a source route from node A to E, node X SHOULD cache all of
   these links as well, also including the link from C to X over which
   it overheard the packet.

   In the final case, in which the MAC protocol requires physical
   bidirectionality for unicast operation, links from a source route
   SHOULD be cached in both directions, except when the packet also
   contains a Route Reply, in which case only the links already
   traversed in this source route SHOULD be cached.  However, the links
   not yet traversed in this route SHOULD NOT be cached.

3.3.2.  Replying to Route Requests Using Cached Routes

   A node receiving a Route Request for which it is not the target
   searches its own Route Cache for a route to the target of the
   Request.  If it is found, the node generally returns a Route Reply to
   the initiator itself rather than forward the Route Request.  In the
   Route Reply, this node sets the route record to list the sequence of
   hops over which this copy of the Route Request was forwarded to it,
   concatenated with the source route to this target obtained from its
   own Route Cache.

   However, before transmitting a Route Reply packet that was generated
   using information from its Route Cache in this way, a node MUST
   verify that the resulting route being returned in the Route Reply,
   after this concatenation, contains no duplicate nodes listed in the
   route record.  For example, the figure below illustrates a case in
   which a Route Request for target E has been received by node F, and
   node F already has in its Route Cache a route from itself to E:

         +-----+     +-----+                 +-----+     +-----+
         |  A  |---->|  B  |-               >|  D  |---->|  E  |
         +-----+     +-----+ \             / +-----+     +-----+
                              \           /
                               \ +-----+ /
                                >|  C  |-
                                 +-----+
                                   | ^
                                   v |
           Route Request         +-----+
           Route: A - B - C - F  |  F  |  Cache: C - D - E
                                 +-----+

   The concatenation of the accumulated route record from the Route
   Request and the cached route from F's Route Cache would include a
   duplicate node in passing from C to F and back to C.

   Node F in this case could attempt to edit the route to eliminate the
   duplication, resulting in a route from A to B to C to D and on to E,
   but in this case, node F would not be on the route that it returned
   in its own Route Reply.  DSR Route Discovery prohibits node F from
   returning such a Route Reply from its cache; this prohibition
   increases the probability that the resulting route is valid, since
   node F in this case should have received a Route Error if the route
   had previously stopped working.  Furthermore, this prohibition means
   that a future Route Error traversing the route is very likely to pass
   through any node that sent the Route Reply for the route (including
   node F), which helps to ensure that stale data is removed from caches
   (such as at F) in a timely manner; otherwise, the next Route
   Discovery initiated by A might also be contaminated by a Route Reply
   from F containing the same stale route.  If, due to this restriction
   on returning a Route Reply based on information from its Route Cache,
   node F does not return such a Route Reply, it propagates the Route
   Request normally.

3.3.3.  Route Request Hop Limits

   Each Route Request message contains a "hop limit" that may be used to
   limit the number of intermediate nodes allowed to forward that copy
   of the Route Request.  This hop limit is implemented using the Time-
   to-Live (TTL) field in the IP header of the packet carrying the Route
   Request.  As the Request is forwarded, this limit is decremented, and
   the Request packet is discarded if the limit reaches zero before
   finding the target.  This Route Request hop limit can be used to
   implement a variety of algorithms for controlling the spread of a
   Route Request during a Route Discovery attempt.

   For example, a node MAY use this hop limit to implement a "non-
   propagating" Route Request as an initial phase of a Route Discovery.
   A node using this technique sends its first Route Request attempt for
   some target node using a hop limit of 1, such that any node receiving
   the initial transmission of the Route Request will not forward the
   Request to other nodes by re-broadcasting it.  This form of Route
   Request is called a "non-propagating" Route Request; it provides an
   inexpensive method for determining if the target is currently a
   neighbor of the initiator or if a neighbor node has a route to the
   target cached (effectively using the neighbors' Route Caches as an
   extension of the initiator's own Route Cache).  If no Route Reply is
   received after a short timeout, then the node sends a "propagating"
   Route Request for the target node (i.e., with hop limit as defined by
   the value of the DiscoveryHopLimit configuration variable).

   As another example, a node MAY use this hop limit to implement an
   "expanding ring" search for the target [JOHNSON96a].  A node using
   this technique sends an initial non-propagating Route Request as
   described above; if no Route Reply is received for it, the node
   originates another Route Request with a hop limit of 2.  For each
   Route Request originated, if no Route Reply is received for it, the
   node doubles the hop limit used on the previous attempt, to
   progressively explore for the target node without allowing the Route
   Request to propagate over the entire network.  However, this
   expanding ring search approach could increase the average latency of
   Route Discovery, since multiple Discovery attempts and timeouts may
   be needed before discovering a route to the target node.

3.4.  Additional Route Maintenance Features

3.4.1.  Packet Salvaging

   When an intermediate node forwarding a packet detects through Route
   Maintenance that the next hop along the route for that packet is
   broken, if the node has another route to the packet's destination in
   its Route Cache, the node SHOULD "salvage" the packet rather than
   discard it.  To salvage a packet, the node replaces the original
   source route on the packet with a route from its Route Cache.  The
   node then forwards the packet to the next node indicated along this
   source route.  For example, in the situation shown in the example of
   Section 3.2, if node C has another route cached to node E, it can
   salvage the packet by replacing the original route in the packet with
   this new route from its own Route Cache rather than discarding the
   packet.

   When salvaging a packet, a count is maintained in the packet of the
   number of times that it has been salvaged, to prevent a single packet
   from being salvaged endlessly.  Otherwise, since the TTL is

   decremented only once by each node, a single node could salvage a
   packet an unbounded number of times.  Even if we chose to require the
   TTL to be decremented on each salvage attempt, packet salvaging is an
   expensive operation, so it is desirable to bound the maximum number
   of times a packet can be salvaged independently of the maximum number
   of hops a packet can traverse.

   As described in Section 3.2, an intermediate node, such as in this
   case, that detects through Route Maintenance that the next hop along
   the route for a packet that it is forwarding is broken, the node also
   SHOULD return a Route Error to the original sender of the packet,
   identifying the link over which the packet could not be forwarded.
   If the node sends this Route Error, it SHOULD originate the Route
   Error before salvaging the packet.

3.4.2.  Queued Packets Destined over a Broken Link

   When an intermediate node forwarding a packet detects through Route
   Maintenance that the next-hop link along the route for that packet is
   broken, in addition to handling that packet as defined for Route
   Maintenance, the node SHOULD also handle in a similar way any pending
   packets that it has queued that are destined over this new broken
   link.  Specifically, the node SHOULD search its Network Interface
   Queue and Maintenance Buffer (Section 4.5) for packets for which the
   next-hop link is this new broken link.  For each such packet
   currently queued at this node, the node SHOULD process that packet as
   follows:

   -  Remove the packet from the node's Network Interface Queue and
      Maintenance Buffer.

   -  Originate a Route Error for this packet to the original sender of
      the packet, using the procedure described in Section 8.3.4, as if
      the node had already reached the maximum number of retransmission
      attempts for that packet for Route Maintenance.  However, in
      sending such Route Errors for queued packets in response to
      detection of a single, new broken link, the node SHOULD send no
      more than one Route Error to each original sender of any of these
      packets.

   -  If the node has another route to the packet's IP Destination
      Address in its Route Cache, the node SHOULD salvage the packet as
      described in Section 8.3.6.  Otherwise, the node SHOULD discard
      the packet.

3.4.3.  Automatic Route Shortening

   Source routes in use MAY be automatically shortened if one or more
   intermediate nodes in the route become no longer necessary.  This
   mechanism of automatically shortening routes in use is somewhat
   similar to the use of passive acknowledgements [JUBIN87].  In
   particular, if a node is able to overhear a packet carrying a source
   route (e.g., by operating its network interface in promiscuous
   receive mode), then this node examines the unexpended portion of that
   source route.  If this node is not the intended next-hop destination
   for the packet but is named in the later unexpended portion of the
   packet's source route, then it can infer that the intermediate nodes
   before itself in the source route are no longer needed in the route.
   For example, the figure below illustrates an example in which node D
   has overheard a data packet being transmitted from B to C, for later
   forwarding to D and to E:

         +-----+     +-----+     +-----+     +-----+     +-----+
         |  A  |---->|  B  |---->|  C  |     |  D  |     |  E  |
         +-----+     +-----+     +-----+     +-----+     +-----+
                        \                       ^
                         \                     /
                          ---------------------

   In this case, this node (node D) SHOULD return a "gratuitous" Route
   Reply to the original sender of the packet (node A).  The Route Reply
   gives the shorter route as the concatenation of the portion of the
   original source route up through the node that transmitted the
   overheard packet (node B), plus the suffix of the original source
   route beginning with the node returning the gratuitous Route Reply
   (node D).  In this example, the route returned in the gratuitous
   Route Reply message sent from D to A gives the new route as the
   sequence of hops from A to B to D to E.

   When deciding whether to return a gratuitous Route Reply in this way,
   a node MAY factor in additional information beyond the fact that it
   was able to overhear the packet.  For example, the node MAY decide to
   return the gratuitous Route Reply only when the overheard packet is
   received with a signal strength or signal-to-noise ratio above some
   specific threshold.  In addition, each node maintains a Gratuitous
   Route Reply Table, as described in Section 4.4, to limit the rate at
   which it originates gratuitous Route Replies for the same returned
   route.

3.4.4.  Increased Spreading of Route Error Messages

   When a source node receives a Route Error for a data packet that it
   originated, this source node propagates this Route Error to its
   neighbors by piggybacking it on its next Route Request.  In this way,
   stale information in the caches of nodes around this source node will
   not generate Route Replies that contain the same invalid link for
   which this source node received the Route Error.

   For example, in the situation shown in the example of Section 3.2,
   node A learns from the Route Error message from C that the link from
   C to D is currently broken.  It thus removes this link from its own
   Route Cache and initiates a new Route Discovery (if it has no other
   route to E in its Route Cache).  On the Route Request packet
   initiating this Route Discovery, node A piggybacks a copy of this
   Route Error, ensuring that the Route Error spreads well to other
   nodes, and guaranteeing that any Route Reply that it receives
   (including those from other node's Route Caches) in response to this
   Route Request does not contain a route that assumes the existence of
   this broken link.

3.5.  Optional DSR Flow State Extension

   This section describes an optional, compatible extension to the DSR
   protocol, known as "flow state", that allows the routing of most
   packets without an explicit source route header in the packet.  The
   DSR flow state extension further reduces the overhead of the protocol
   yet still preserves the fundamental properties of DSR's operation.
   Once a sending node has discovered a source route such as through
   DSR's Route Discovery mechanism, the flow state mechanism allows the
   sending node to establish hop-by-hop forwarding state within the
   network, based on this source route, to enable each node along the
   route to forward the packet to the next hop based on the node's own
   local knowledge of the flow along which this packet is being routed.
   Flow state is dynamically initialized by the first packet using a
   source route and is then able to route subsequent packets along the
   same flow without use of a source route header in the packet.  The
   state established at each hop along a flow is "soft state" and thus
   automatically expires when no longer needed and can be quickly
   recreated as necessary.  Extending DSR's basic operation based on an
   explicit source route in the header of each packet routed, the flow
   state extension operates as a form of "implicit source routing" by
   preserving DSR's basic operation but removing the explicit source
   route from packets.

3.5.1.  Flow Establishment

   A source node sending packets to some destination node MAY use the
   DSR flow state extension described here to establish a route to that
   destination as a flow.  A "flow" is a route from the source to the
   destination represented by hop-by-hop forwarding state within the
   nodes along the route.  Each flow is uniquely identified by a
   combination of the source node address, the destination node address,
   and a flow identifier (flow ID) chosen by the source node.

   Each flow ID is a 16-bit unsigned integer.  Comparison between
   different flow IDs MUST be performed modulo 2**16.  For example,
   using an implementation in the C programming language, a flow ID
   value (a) is greater than another flow ID value (b) if
   ((short)((a) - (b)) > 0), if a C language "short" data type is
   implemented as a 16-bit signed integer.

   A DSR Flow State header in a packet identifies the flow ID to be
   followed in forwarding that packet.  From a given source to some
   destination, any number of different flows MAY exist and be in use,
   for example, following different sequences of hops to reach the
   destination.  One of these flows MAY be considered the "default" flow
   from that source to that destination.  If a node receives a packet
   with neither a DSR Options header specifying the route to be taken
   (with a Source Route option in the DSR Options header) nor a DSR Flow
   State header specifying the flow ID to be followed, it is forwarded
   along the default flow for the source and destination addresses
   specified in the packet's IP header.

   In establishing a new flow, the source node generates a nonzero
   16-bit flow ID greater than any unexpired flow IDs for this (source,
   destination) pair.  If the source wishes for this flow to become the
   default flow, the low bit of the flow ID MUST be set (the flow ID is
   an odd number); otherwise, the low bit MUST NOT be set (the flow ID
   is an even number).

   The source node establishing the new flow then transmits a packet
   containing a DSR Options header with a Source Route option.  To
   establish the flow, the source node also MUST include in the packet a
   DSR Flow State header, with the Flow ID field set to the chosen flow
   ID for the new flow, and MUST include a Timeout option in the DSR
   Options header, giving the lifetime after which state information
   about this flow is to expire.  This packet will generally be a normal
   data packet being sent from this sender to the destination (for
   example, the first packet sent after discovering the new route) but
   is also treated as a "flow establishment" packet.

   The source node records this flow in its Flow Table for future use,
   setting the TTL in this Flow Table entry to the value used in the TTL
   field in the packet's IP header and setting the Lifetime in this
   entry to the lifetime specified in the Timeout option in the DSR
   Options header.  The TTL field is used for Default Flow Forwarding,
   as described in Sections 3.5.3 and 3.5.4.

   Any further packets sent with this flow ID before the timeout that
   also contain a DSR Options header with a Source Route option MUST use
   this same source route in the Source Route option.

3.5.2.  Receiving and Forwarding Establishment Packets

   Packets intended to establish a flow, as described in Section 3.5.1,
   contain a DSR Options header with a Source Route option and are
   forwarded along the indicated route.  A node implementing the DSR
   flow state extension, when receiving and forwarding such a DSR
   packet, also keeps some state in its own Flow Table to enable it to
   forward future packets that are sent along this flow with only the
   flow ID specified.  Specifically, if the packet also contains a DSR
   Flow State header, this packet SHOULD cause an entry to be
   established for this flow in the Flow Table of each node along the
   packet's route.

   The Hop Count field of the DSR Flow State header is also stored in
   the Flow Table, as is the lifetime specified in the Timeout option
   specified in the DSR Options header.

   If the Flow ID is odd and there is no flow in the Flow Table with
   Flow ID greater than the received Flow ID, set the default Flow ID
   for this (IP Source Address, IP Destination Address) pair to the
   received Flow ID, and the TTL of the packet is recorded.

   The Flow ID option is removed before final delivery of the packet.

3.5.3.  Sending Packets along Established Flows

   When a flow is established as described in Section 3.5.1, a packet is
   sent that establishes state in each node along the route.  This state
   is soft; that is, the protocol contains mechanisms for recovering
   from the loss of this state.  However, the use of these mechanisms
   may result in reduced performance for packets sent along flows with
   forgotten state.  As a result, it is desirable to differentiate
   behavior based on whether or not the sender is reasonably certain
   that the flow state exists on each node along the route.  We define a
   flow's state to be "established end-to-end" if the Flow Tables of all
   nodes on the route contains forwarding information for that flow.
   While it is impossible to detect whether or not a flow's state has

   been established end-to-end without sending packets, implementations
   may make reasonable assumptions about the retention of flow state and
   the probability that an establishment packet has been seen by all
   nodes on the route.

   A source wishing to send a packet along an established flow
   determines if the flow state has been established end-to-end.  If it
   has not, a DSR Options header with Source Route option with this
   flow's route is added to the packet.  The source SHOULD set the Flow
   ID field of the DSR Flow State header either to the flow ID
   previously associated with this flow's route or to zero.  If it sets
   the Flow ID field to any other value, it MUST follow the processing
   steps in Section 3.5.1 for establishing a new flow ID.  If it sets
   the Flow ID field to a nonzero value, it MUST include a Timeout
   option with a value not greater than the timeout remaining in the
   node's Flow Table, and if its TTL is not equal to that specified in
   the Flow Table, the flow MUST NOT be used as a default flow in the
   future.

   Once flow state has been established end-to-end for non-default
   flows, a source adds a DSR Flow State header to each packet it wishes
   to send along that flow, setting the Flow ID field to the flow ID of
   that flow.  A Source Route option SHOULD NOT be added to the packet,
   though if one is, then the steps for processing flows that have not
   been established end-to-end MUST be followed.

   Once flow state has been established end-to-end for default flows,
   sources sending packets with IP TTL equal to the TTL value in the
   local Flow Table entry for this flow then transmit the packet to the
   next hop.  In this case, a DSR Flow State header SHOULD NOT be added
   to the packet and a DSR Options header likewise SHOULD NOT be added
   to the packet; though if one is, the steps for sending packets along
   non-default flows MUST be followed.  If the IP TTL is not equal to
   the TTL value in the local Flow Table, then the steps for processing
   a non-default flow MUST be followed.

3.5.4.  Receiving and Forwarding Packets Sent along Established Flows

   The handling of packets containing a DSR Options header with both a
   nonzero Flow ID and a Source Route option is described in Section
   3.5.2.  The Flow ID is ignored when it is equal to zero.  This
   section only describes handling of packets without a Source Route
   option.

   If a node receives a packet with a Flow ID in the DSR Options header
   that indicates an unexpired flow in the node's Flow Table, it
   increments the Hop Count in the DSR Options header and forwards the
   packet to the next hop indicated in the Flow Table.

   If a node receives a packet with a Flow ID that indicates a flow not
   currently in the node's Flow Table, it returns a Route Error of type
   UNKNOWN_FLOW with Error Destination and IP Destination addresses
   copied from the IP Source of the packet triggering the error.  This
   error packet SHOULD be MAC-destined to the node from which the packet
   was received; if it cannot confirm reachability of the previous node
   using Route Maintenance, it MUST send the error as described in
   Section 8.1.1.  The node sending the error SHOULD attempt to salvage
   the packet triggering the Route Error.  If it does salvage the
   packet, it MUST zero the Flow ID in the packet.

   If a node receives a packet with no DSR Options header and no DSR
   Flow State header, it checks the Default Flow Table.  If there is a
   matching entry, it forwards to the next hop indicated in the Flow
   Table for the default flow.  Otherwise, it returns a Route Error of
   type DEFAULT_FLOW_UNKNOWN with Error Destination and IP Destination
   addresses copied from the IP Source Address of the packet triggering
   the error.  This error packet SHOULD be MAC-destined to the node from
   which it was received; if this node cannot confirm reachability of
   the previous node using Route Maintenance, it MUST send the error as
   described in Section 8.1.1.  The node sending the error SHOULD
   attempt to salvage the packet triggering the Route Error.  If it does
   salvage the packet, it MUST zero the Flow ID in the packet.

3.5.5.  Processing Route Errors

   When a node receives a Route Error of type UNKNOWN_FLOW, it marks the
   flow to indicate that it has not been established end-to-end.  When a
   node receives a Route Error of type DEFAULT_FLOW_UNKNOWN, it marks
   the default flow to indicate that it has not been established end-
   to-end.

3.5.6.  Interaction with Automatic Route Shortening

   Because a full source route is not carried in every packet, an
   alternative method for performing automatic route shortening is
   necessary for packets using the flow state extension.  Instead, nodes
   promiscuously listen to packets, and if a node receives a packet with
   (IP Source, IP Destination, Flow ID) found in the Flow Table but the
   MAC-layer (next hop) destination address of the packet is not this
   node, the node determines whether the packet was sent by an upstream
   or downstream node by examining the Hop Count field in the DSR Flow
   State header.  If the Hop Count field is less than the expected Hop
   Count at this node (that is, the expected Hop Count field in the Flow
   Table described in Section 5.1), the node assumes that the packet was
   sent by an upstream node and adds an entry for the packet to its
   Automatic Route Shortening Table, possibly evicting an earlier entry
   added to this table.  When the packet is then sent to that node for

   forwarding, the node finds that it has previously received the packet
   by checking its Automatic Route Shortening Table and returns a
   gratuitous Route Reply to the source of the packet.

3.5.7.  Loop Detection

   If a node receives a packet for forwarding with TTL lower than
   expected and default flow forwarding is being used, it sends a Route
   Error of type DEFAULT_FLOW_UNKNOWN back to the IP source.  It can
   attempt delivery of the packet by normal salvaging (subject to
   constraints described in Section 8.6.7).

3.5.8.  Acknowledgement Destination

   In packets sent using Flow State, the previous hop is not necessarily
   known.  In order to allow nodes that have lost flow state to
   determine the previous hop, the address of the previous hop can
   optionally be stored in the Acknowledgement Request.  This extension
   SHOULD NOT be used when a Source Route option is present, MAY be used
   when flow state routing is used without a Source Route option, and
   SHOULD be used before Route Maintenance determines that the next-hop
   destination is unreachable.

3.5.9.  Crash Recovery

   Each node has a maximum Timeout value that it can possibly generate.
   This can be based on the largest number that can be set in a timeout
   option (2**16 - 1 seconds) or may be less than this, set in system
   software.  When a node crashes, it does not establish new flows for a
   period equal to this maximum Timeout value, in order to avoid
   colliding with its old Flow IDs.

3.5.10.  Rate Limiting

   Flow IDs can be assigned with a counter.  More specifically, the
   "Current Flow ID" is kept.  When a new default Flow ID needs to be
   assigned, if the Current Flow ID is odd, the Current Flow ID is
   assigned as the Flow ID and the Current Flow ID is incremented by
   one; if the Current Flow ID is even, one plus the Current Flow ID is
   assigned as the Flow ID and the Current Flow ID is incremented by
   two.

   If Flow IDs are assigned in this way, one algorithm for avoiding
   duplicate, unexpired Flow IDs is to rate limit new Flow IDs to an
   average rate of n assignments per second, where n is 2**15 divided by
   the maximum Timeout value.  This can be averaged over any period not
   exceeding the maximum Timeout value.

3.5.11.  Interaction with Packet Salvaging

   Salvaging is modified to zero the Flow ID field in the packet.  Also,
   anytime this document refers to the Salvage field in the Source Route
   option in a DSR Options header, packets without a Source Route option
   are considered to have the value zero in the Salvage field.

4.  Conceptual Data Structures

   This document describes the operation of the DSR protocol in terms of
   a number of conceptual data structures.  This section describes each
   of these data structures and provides an overview of its use in the
   protocol.  In an implementation of the protocol, these data
   structures MUST be implemented in a manner consistent with the
   external behavior described in this document, but the choice of
   implementation used is otherwise unconstrained.  Additional
   conceptual data structures are required for the optional flow state
   extensions to DSR; these data structures are described in Section 5.

4.1.  Route Cache

   Each node implementing DSR MUST maintain a Route Cache, containing
   routing information needed by the node.  A node adds information to
   its Route Cache as it learns of new links between nodes in the ad hoc
   network; for example, a node may learn of new links when it receives
   a packet carrying a Route Request, Route Reply, or DSR source route.
   Likewise, a node removes information from its Route Cache as it
   learns that existing links in the ad hoc network have broken.  For
   example, a node may learn of a broken link when it receives a packet
   carrying a Route Error or through the link-layer retransmission
   mechanism reporting a failure in forwarding a packet to its next-hop
   destination.

   Anytime a node adds new information to its Route Cache, the node
   SHOULD check each packet in its own Send Buffer (Section 4.2) to
   determine whether a route to that packet's IP Destination Address now
   exists in the node's Route Cache (including the information just
   added to the Cache).  If so, the packet SHOULD then be sent using
   that route and removed from the Send Buffer.

   It is possible to interface a DSR network with other networks,
   external to this DSR network.  Such external networks may, for
   example, be the Internet or may be other ad hoc networks routed with
   a routing protocol other than DSR.  Such external networks may also
   be other DSR networks that are treated as external networks in order
   to improve scalability.  The complete handling of such external
   networks is beyond the scope of this document.  However, this
   document specifies a minimal set of requirements and features

   necessary to allow nodes only implementing this specification to
   interoperate correctly with nodes implementing interfaces to such
   external networks.  This minimal set of requirements and features
   involve the First Hop External (F) and Last Hop External (L) bits in
   a DSR Source Route option (Section 6.7) and a Route Reply option
   (Section 6.3) in a packet's DSR Options header (Section 6).  These
   requirements also include the addition of an External flag bit
   tagging each link in the Route Cache, copied from the First Hop
   External (F) and Last Hop External (L) bits in the DSR Source Route
   option or Route Reply option from which this link was learned.

   The Route Cache SHOULD support storing more than one route to each
   destination.  In searching the Route Cache for a route to some
   destination node, the Route Cache is searched by destination node
   address.  The following properties describe this searching function
   on a Route Cache:

   -  Each implementation of DSR at any node MAY choose any appropriate
      strategy and algorithm for searching its Route Cache and selecting
      a "best" route to the destination from among those found.  For
      example, a node MAY choose to select the shortest route to the
      destination (the shortest sequence of hops), or it MAY use an
      alternate metric to select the route from the Cache.

   -  However, if there are multiple cached routes to a destination, the
      selection of routes when searching the Route Cache SHOULD prefer
      routes that do not have the External flag set on any link.  This
      preference will select routes that lead directly to the target
      node over routes that attempt to reach the target via any external
      networks connected to the DSR ad hoc network.

   -  In addition, any route selected when searching the Route Cache
      MUST NOT have the External bit set for any links other than
      possibly the first link, the last link, or both; the External bit
      MUST NOT be set for any intermediate hops in the route selected.

   An implementation of a Route Cache MAY provide a fixed capacity for
   the cache, or the cache size MAY be variable.  The following
   properties describe the management of available space within a node's
   Route Cache:

   -  Each implementation of DSR at each node MAY choose any appropriate
      policy for managing the entries in its Route Cache, such as when
      limited cache capacity requires a choice of which entries to
      retain in the Cache.  For example, a node MAY chose a "least
      recently used" (LRU) cache replacement policy, in which the entry

      last used longest ago is discarded from the cache if a decision
      needs to be made to allow space in the cache for some new entry
      being added.

   -  However, the Route Cache replacement policy SHOULD allow routes to
      be categorized based upon "preference", where routes with a higher
      preferences are less likely to be removed from the cache.  For
      example, a node could prefer routes for which it initiated a Route
      Discovery over routes that it learned as the result of promiscuous
      snooping on other packets.  In particular, a node SHOULD prefer
      routes that it is presently using over those that it is not.

   Any suitable data structure organization, consistent with this
   specification, MAY be used to implement the Route Cache in any node.
   For example, the following two types of organization are possible:

   -  In DSR, the route returned in each Route Reply that is received by
      the initiator of a Route Discovery (or that is learned from the
      header of overhead packets, as described in Section 8.1.4)
      represents a complete path (a sequence of links) leading to the
      destination node.  By caching each of these paths separately, a
      "path cache" organization for the Route Cache can be formed.  A
      path cache is very simple to implement and easily guarantees that
      all routes are loop-free, since each individual route from a Route
      Reply or Route Request or used in a packet is loop-free.  To
      search for a route in a path cache data structure, the sending
      node can simply search its Route Cache for any path (or prefix of
      a path) that leads to the intended destination node.

      This type of organization for the Route Cache in DSR has been
      extensively studied through simulation [BROCH98, HU00,
      JOHANSSON99, MALTZ99a] and through implementation of DSR in a
      mobile outdoor testbed under significant workload [MALTZ99b,
      MALTZ00, MALTZ01].

   -  Alternatively, a "link cache" organization could be used for the
      Route Cache, in which each individual link (hop) in the routes
      returned in Route Reply packets (or otherwise learned from the
      header of overhead packets) is added to a unified graph data
      structure of this node's current view of the network topology.  To
      search for a route in link cache, the sending node must use a more
      complex graph search algorithm, such as the well-known Dijkstra's
      shortest-path algorithm, to find the current best path through the
      graph to the destination node.  Such an algorithm is more
      difficult to implement and may require significantly more CPU time
      to execute.

      However, a link cache organization is more powerful than a path
      cache organization, in its ability to effectively utilize all of
      the potential information that a node might learn about the state
      of the network.  In particular, links learned from different Route
      Discoveries or from the header of any overheard packets can be
      merged together to form new routes in the network, but this is not
      possible in a path cache due to the separation of each individual
      path in the cache.

      This type of organization for the Route Cache in DSR, including
      the effect of a range of implementation choices, has been studied
      through detailed simulation [HU00].

   The choice of data structure organization to use for the Route Cache
   in any DSR implementation is a local matter for each node and affects
   only performance; any reasonable choice of organization for the Route
   Cache does not affect either correctness or interoperability.

   Each entry in the Route Cache SHOULD have a timeout associated with
   it, to allow that entry to be deleted if not used within some time.
   The particular choice of algorithm and data structure used to
   implement the Route Cache SHOULD be considered in choosing the
   timeout for entries in the Route Cache.  The configuration variable
   RouteCacheTimeout defined in Section 9 specifies the timeout to be
   applied to entries in the Route Cache, although it is also possible
   to instead use an adaptive policy in choosing timeout values rather
   than using a single timeout setting for all entries.  For example,
   the Link-MaxLife cache design (below) uses an adaptive timeout
   algorithm and does not use the RouteCacheTimeout configuration
   variable.

   As guidance to implementers, Appendix A describes a type of link
   cache known as "Link-MaxLife" that has been shown to outperform other
   types of link caches and path caches studied in detailed simulation
   [HU00].  Link-MaxLife is an adaptive link cache in which each link in
   the cache has a timeout that is determined dynamically by the caching
   node according to its observed past behavior of the two nodes at the
   ends of the link.  In addition, when selecting a route for a packet
   being sent to some destination, among cached routes of equal length
   (number of hops) to that destination, Link-MaxLife selects the route
   with the longest expected lifetime (highest minimum timeout of any
   link in the route).  Use of the Link-MaxLife design for the Route
   Cache is recommended in implementations of DSR.

4.2.  Send Buffer

   The Send Buffer of a node implementing DSR is a queue of packets that
   cannot be sent by that node because it does not yet have a source
   route to each such packet's destination.  Each packet in the Send
   Buffer is logically associated with the time that it was placed into
   the buffer and SHOULD be removed from the Send Buffer and silently
   discarded after a period of SendBufferTimeout after initially being
   placed in the buffer.  If necessary, a FIFO strategy SHOULD be used
   to evict packets before they time out to prevent the buffer from
   overflowing.

   Subject to the rate limiting defined in Section 4.3, a Route
   Discovery SHOULD be initiated as often as allowed for the destination
   address of any packets residing in the Send Buffer.

4.3.  Route Request Table

   The Route Request Table of a node implementing DSR records
   information about Route Requests that have been recently originated
   or forwarded by this node.  The table is indexed by IP address.

   The Route Request Table on a node records the following information
   about nodes to which this node has initiated a Route Request:

   -  The Time-to-Live (TTL) field used in the IP header of the Route
      Request for the last Route Discovery initiated by this node for
      that target node.  This value allows the node to implement a
      variety of algorithms for controlling the spread of its Route
      Request on each Route Discovery initiated for a target.  As
      examples, two possible algorithms for this use of the TTL field
      are described in Section 3.3.3.

   -  The time that this node last originated a Route Request for that
      target node.

   -  The number of consecutive Route Discoveries initiated for this
      target since receiving a valid Route Reply giving a route to that
      target node.

   -  The remaining amount of time before which this node MAY next
      attempt at a Route Discovery for that target node.  When the node
      initiates a new Route Discovery for this target node, this field
      in the Route Request Table entry for that target node is
      initialized to the timeout for that Route Discovery, after which
      the node MAY initiate a new Discovery for that target.  Until a
      valid Route Reply is received for this target node address, a node
      MUST implement a back-off algorithm in determining this timeout

      value for each successive Route Discovery initiated for this
      target using the same Time-to-Live (TTL) value in the IP header of
      the Route Request packet.  The timeout between such consecutive
      Route Discovery initiations SHOULD increase by doubling the
      timeout value on each new initiation.

   In addition, the Route Request Table on a node also records the
   following information about initiator nodes from which this node has
   received a Route Request:

   -  A FIFO cache of size RequestTableIds entries containing the
      Identification value and target address from the most recent Route
      Requests received by this node from that initiator node.

   Nodes SHOULD use an LRU policy to manage the entries in their Route
   Request Table.

   The number of Identification values to retain in each Route Request
   Table entry, RequestTableIds, MUST NOT be unlimited, since, in the
   worst case, when a node crashes and reboots, the first
   RequestTableIds Route Discoveries it initiates after rebooting could
   appear to be duplicates to the other nodes in the network.  In
   addition, a node SHOULD base its initial Identification value, used
   for Route Discoveries after rebooting, on a battery backed-up clock
   or other persistent memory device, if available, in order to help
   avoid any possible such delay in successfully discovering new routes
   after rebooting; if no such source of initial Identification value is
   available, a node after rebooting SHOULD base its initial
   Identification value on a random number.

4.4.  Gratuitous Route Reply Table

   The Gratuitous Route Reply Table of a node implementing DSR records
   information about "gratuitous" Route Replies sent by this node as
   part of automatic route shortening.  As described in Section 3.4.3, a
   node returns a gratuitous Route Reply when it overhears a packet
   transmitted by some node, for which the node overhearing the packet
   was not the intended next-hop node but was named later in the
   unexpended hops of the source route in that packet; the node
   overhearing the packet returns a gratuitous Route Reply to the
   original sender of the packet, listing the shorter route (not
   including the hops of the source route "skipped over" by this
   packet).  A node uses its Gratuitous Route Reply Table to limit the
   rate at which it originates gratuitous Route Replies to the same
   original sender for the same node from which it overheard a packet to
   trigger the gratuitous Route Reply.

   Each entry in the Gratuitous Route Reply Table of a node contains the
   following fields:

   -  The address of the node to which this node originated a gratuitous
      Route Reply.

   -  The address of the node from which this node overheard the packet
      triggering that gratuitous Route Reply.

   -  The remaining time before which this entry in the Gratuitous Route
      Reply Table expires and SHOULD be deleted by the node.  When a
      node creates a new entry in its Gratuitous Route Reply Table, the
      timeout value for that entry SHOULD be initialized to the value
      GratReplyHoldoff.

   When a node overhears a packet that would trigger a gratuitous Route
   Reply, if a corresponding entry already exists in the node's
   Gratuitous Route Reply Table, then the node SHOULD NOT send a
   gratuitous Route Reply for that packet.  Otherwise (i.e., if no
   corresponding entry already exists), the node SHOULD create a new
   entry in its Gratuitous Route Reply Table to record that gratuitous
   Route Reply, with a timeout value of GratReplyHoldoff.

4.5.  Network Interface Queue and Maintenance Buffer

   Depending on factors such as the structure and organization of the
   operating system, protocol stack implementation, network interface
   device driver, and network interface hardware, a packet being
   transmitted could be queued in a variety of ways.  For example,
   outgoing packets from the network protocol stack might be queued at
   the operating system or link layer, before transmission by the
   network interface.  The network interface might also provide a
   retransmission mechanism for packets, such as occurs in IEEE 802.11
   [IEEE80211]; the DSR protocol, as part of Route Maintenance, requires
   limited buffering of packets already transmitted for which the
   reachability of the next-hop destination has not yet been determined.
   The operation of DSR is defined here in terms of two conceptual data
   structures that, together, incorporate this queuing behavior.

   The Network Interface Queue of a node implementing DSR is an output
   queue of packets from the network protocol stack waiting to be
   transmitted by the network interface; for example, in the 4.4BSD Unix
   network protocol stack implementation, this queue for a network
   interface is represented as a "struct ifqueue" [WRIGHT95].  This
   queue is used to hold packets while the network interface is in the
   process of transmitting another packet.

   The Maintenance Buffer of a node implementing DSR is a queue of
   packets sent by this node that are awaiting next-hop reachability
   confirmation as part of Route Maintenance.  For each packet in the
   Maintenance Buffer, a node maintains a count of the number of
   retransmissions and the time of the last retransmission.  Packets are
   added to the Maintenance buffer after the first transmission attempt
   is made.  The Maintenance Buffer MAY be of limited size; when adding
   a new packet to the Maintenance Buffer, if the buffer size is
   insufficient to hold the new packet, the new packet SHOULD be
   silently discarded.  If, after MaxMaintRexmt attempts to confirm
   next-hop reachability of some node, no confirmation is received, all
   packets in this node's Maintenance Buffer with this next-hop
   destination SHOULD be removed from the Maintenance Buffer.  In this
   case, the node also SHOULD originate a Route Error for this packet to
   each original source of a packet removed in this way (Section 8.3)
   and SHOULD salvage each packet removed in this way (Section 8.3.6) if
   it has another route to that packet's IP Destination Address in its
   Route Cache.  The definition of MaxMaintRexmt conceptually includes
   any retransmissions that might be attempted for a packet at the link
   layer or within the network interface hardware.  The timeout value to
   use for each transmission attempt for an acknowledgement request
   depends on the type of acknowledgement mechanism used by Route
   Maintenance for that attempt, as described in Section 8.3.

4.6.  Blacklist

   When a node using the DSR protocol is connected through a network
   interface that requires physically bidirectional links for unicast
   transmission, the node MUST maintain a blacklist.  The blacklist is a
   table, indexed by neighbor node address, that indicates that the link
   between this node and the specified neighbor node may not be
   bidirectional.  A node places another node's address in this list
   when it believes that broadcast packets from that other node reach
   this node, but that unicast transmission between the two nodes is not
   possible.  For example, if a node forwarding a Route Reply discovers
   that the next hop is unreachable, it places that next hop in the
   node's blacklist.

   Once a node discovers that it can communicate bidirectionally with
   one of the nodes listed in the blacklist, it SHOULD remove that node
   from the blacklist.  For example, if node A has node B listed in its
   blacklist, but after transmitting a Route Request, node A hears B
   forward the Route Request with a route record indicating that the
   broadcast from A to B was successful, then A SHOULD remove the entry
   for node B from its blacklist.

   A node MUST associate a state with each node listed in its blacklist,
   specifying whether the unidirectionality of the link to that node is
   "questionable" or "probable".  Each time the unreachability is
   positively determined, the node SHOULD set the state to "probable".
   After the unreachability has not been positively determined for some
   amount of time, the state SHOULD revert to "questionable".  A node
   MAY expire entries for nodes from its blacklist after a reasonable
   amount of time.

5.  Additional Conceptual Data Structures for Flow State Extension

   This section defines additional conceptual data structures used by
   the optional "flow state" extension to DSR.  In an implementation of
   the protocol, these data structures MUST be implemented in a manner
   consistent with the external behavior described in this document, but
   the choice of implementation used is otherwise unconstrained.

5.1.  Flow Table

   A node implementing the flow state extension MUST implement a Flow
   Table or other data structure consistent with the external behavior
   described in this section.  A node not implementing the flow state
   extension SHOULD NOT implement a Flow Table.

   The Flow Table records information about flows from which packets
   recently have been sent or forwarded by this node.  The table is
   indexed by a triple (IP Source Address, IP Destination Address, Flow
   ID), where Flow ID is a 16-bit number assigned by the source as
   described in Section 3.5.1.  Each entry in the Flow Table contains
   the following fields:

   -  The MAC address of the next-hop node along this flow.

   -  An indication of the outgoing network interface on this node to be
      used in transmitting packets along this flow.

   -  The MAC address of the previous-hop node along this flow.

   -  An indication of the network interface on this node from which
      packets from that previous-hop node are received.

   -  A timeout after which this entry in the Flow Table MUST be
      deleted.

   -  The expected value of the Hop Count field in the DSR Flow State
      header for packets received for forwarding along this field (for
      use with packets containing a DSR Flow State header).

   -  An indication of whether or not this flow can be used as a default
      flow for packets originated by this node (the Flow ID of a default
      flow MUST be odd).

   -  The entry SHOULD record the complete source route for the flow.
      (Nodes not recording the complete source route cannot participate
      in Automatic Route Shortening.)

   -  The entry MAY contain a field recording the time this entry was
      last used.

   The entry MUST be deleted when its timeout expires.

5.2.  Automatic Route Shortening Table

   A node implementing the flow state extension SHOULD implement an
   Automatic Route Shortening Table or other data structure consistent
   with the external behavior described in this section.  A node not
   implementing the flow state extension SHOULD NOT implement an
   Automatic Route Shortening Table.

   The Automatic Route Shortening Table records information about
   received packets for which Automatic Route Shortening may be
   possible.  The table is indexed by a triple (IP Source Address, IP
   Destination Address, Flow ID).  Each entry in the Automatic Route
   Shortening Table contains a list of (packet identifier, Hop Count)
   pairs for that flow.  The packet identifier in the list may be any
   unique identifier for the received packet; for example, for IPv4
   packets, the combination of the following fields from the packet's IP
   header MAY be used as a unique identifier for the packet:  Source
   Address, Destination Address, Identification, Protocol, Fragment
   Offset, and Total Length.  The Hop Count in the list in the entry is
   copied from the Hop Count field in the DSR Flow State header of the
   received packet for which this table entry was created.  Any packet
   identifier SHOULD appear at most once in an entry's list, and this
   list item SHOULD record the minimum Hop Count value received for that
   packet (if the wireless signal strength or signal-to-noise ratio at
   which a packet is received is available to the DSR implementation in
   a node, the node MAY, for example, remember instead in this list the
   minimum Hop Count value for which the received packet's signal
   strength or signal-to-noise ratio exceeded some threshold).

   Space in the Automatic Route Shortening Table of a node MAY be
   dynamically managed by any local algorithm at the node.  For example,
   in order to limit the amount of memory used to store the table, any
   existing entry MAY be deleted at any time, and the number of packets
   listed in each entry MAY be limited.  However, when reclaiming space
   in the table, nodes SHOULD favor retaining information about more

   flows in the table rather than about more packets listed in each
   entry in the table, as long as at least the listing of some small
   number of packets (e.g., 3) can be retained in each entry.

5.3.  Default Flow ID Table

   A node implementing the flow state extension MUST implement a Default
   Flow Table or other data structure consistent with the external
   behavior described in this section.  A node not implementing the flow
   state extension SHOULD NOT implement a Default Flow Table.

   For each (IP Source Address, IP Destination Address) pair for which a
   node forwards packets, the node MUST record:

   -  The largest odd Flow ID value seen.

   -  The time at which all the corresponding flows that are forwarded
      by this node expire.

   -  The current default Flow ID.

   -  A flag indicating whether or not the current default Flow ID is
      valid.

   If a node deletes this record for an (IP Source Address, IP
   Destination Address) pair, it MUST also delete all Flow Table entries
   for that pair.  Nodes MUST delete table entries if all of this (IP
   Source Address, IP Destination Address) pair's flows that are
   forwarded by this node expire.

6.  DSR Options Header Format

   The Dynamic Source Routing protocol makes use of a special header
   carrying control information that can be included in any existing IP
   packet.  This DSR Options header in a packet contains a small fixed-
   sized, 4-octet portion, followed by a sequence of zero or more DSR
   options carrying optional information.  The end of the sequence of
   DSR options in the DSR Options header is implied by the total length
   of the DSR Options header.

   For IPv4, the DSR Options header MUST immediately follow the IP
   header in the packet.  (If a Hop-by-Hop Options extension header, as
   defined in IPv6 [RFC2460], becomes defined for IPv4, the DSR Options
   header MUST immediately follow the Hop-by-Hop Options extension
   header, if one is present in the packet, and MUST otherwise
   immediately follow the IP header.)

   To add a DSR Options header to a packet, the DSR Options header is
   inserted following the packet's IP header, before any following
   header such as a traditional (e.g., TCP or UDP) transport layer
   header.  Specifically, the Protocol field in the IP header is used to
   indicate that a DSR Options header follows the IP header, and the
   Next Header field in the DSR Options header is used to indicate the
   type of protocol header (such as a transport layer header) following
   the DSR Options header.

   If any headers follow the DSR Options header in a packet, the total
   length of the DSR Options header (and thus the total, combined length
   of all DSR options present) MUST be a multiple of 4 octets.  This
   requirement preserves the alignment of these following headers in the
   packet.

6.1.  Fixed Portion of DSR Options Header

   The fixed portion of the DSR Options header is used to carry
   information that must be present in any DSR Options header.  This
   fixed portion of the DSR Options header has the following format:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Next Header  |F|   Reserved  |        Payload Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   .                                                               .
   .                            Options                            .
   .                                                               .
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Next Header

         8-bit selector.  Identifies the type of header immediately
         following the DSR Options header.  Uses the same values as the
         IPv4 Protocol field [RFC1700].  If no header follows, then Next
         Header MUST have the value 59, "No Next Header" [RFC2460].

      Flow State Header (F)

         Flag bit.  MUST be set to 0.  This bit is set in a DSR Flow
         State header (Section 7.1) and clear in a DSR Options header.

      Reserved

         MUST be sent as 0 and ignored on reception.

      Payload Length

         The length of the DSR Options header, excluding the 4-octet
         fixed portion.  The value of the Payload Length field defines
         the total length of all options carried in the DSR Options
         header.

      Options

         Variable-length field; the length of the Options field is
         specified by the Payload Length field in this DSR Options
         header.  Contains one or more pieces of optional information
         (DSR options), encoded in type-length-value (TLV) format (with
         the exception of the Pad1 option described in Section 6.8).

   The placement of DSR options following the fixed portion of the DSR
   Options header MAY be padded for alignment.  However, due to the
   typically limited available wireless bandwidth in ad hoc networks,
   this padding is not required, and receiving nodes MUST NOT expect
   options within a DSR Options header to be aligned.

   Each DSR option is assigned a unique Option Type code.  The most
   significant 3 bits (that is, Option Type & 0xE0) allow a node not
   implementing processing for this Option Type value to behave in the
   manner closest to correct for that type:

   -  The most significant bit in the Option Type value (that is, Option
      Type & 0x80) represents whether or not a node receiving this
      Option Type (when the node does not implement processing for this
      Option Type) SHOULD respond to such a DSR option with a Route
      Error of type OPTION_NOT_SUPPORTED, except that such a Route Error
      SHOULD never be sent in response to a packet containing a Route
      Request option.

   -  The two following bits in the Option Type value (that is, Option
      Type & 0x60) are a two-bit field indicating how such a node that
      does not support this Option Type MUST process the packet:

         00 = Ignore Option
         01 = Remove Option
         10 = Mark Option
         11 = Drop Packet

      When these 2 bits are 00 (that is, Option Type & 0x60 == 0), a
      node not implementing processing for that Option Type MUST use the
      Opt Data Len field to skip over the option and continue
      processing.  When these 2 bits are 01 (that is, Option Type & 0x60
      == 0x20), a node not implementing processing for that Option Type

      MUST use the Opt Data Len field to remove the option from the
      packet and continue processing as if the option had not been
      included in the received packet.  When these 2 bits are 10 (that
      is, Option Type & 0x60 == 0x40), a node not implementing
      processing for that Option Type MUST set the most significant bit
      following the Opt Data Len field, MUST ignore the contents of the
      option using the Opt Data Len field, and MUST continue processing
      the packet.  Finally, when these 2 bits are 11 (that is, Option
      Type & 0x60 == 0x60), a node not implementing processing for that
      Option Type MUST drop the packet.

   The following types of DSR options are defined in this document for
   use within a DSR Options header:

   -  Route Request option (Section 6.2)

   -  Route Reply option (Section 6.3)

   -  Route Error option (Section 6.4)

   -  Acknowledgement Request option (Section 6.5)

   -  Acknowledgement option (Section 6.6)

   -  DSR Source Route option (Section 6.7)

   -  Pad1 option (Section 6.8)

   -  PadN option (Section 6.9)

   In addition, Section 7 specifies further DSR options for use with the
   optional DSR flow state extension.

6.2.  Route Request Option

   The Route Request option in a DSR Options header is encoded as
   follows:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  |  Opt Data Len |         Identification        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                         Target Address                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[1]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[2]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                              ...                              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[n]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

   IP fields:

      Source Address

         MUST be set to the address of the node originating this packet.
         Intermediate nodes that retransmit the packet to propagate the
         Route Request MUST NOT change this field.

      Destination Address

         MUST be set to the IP limited broadcast address
         (255.255.255.255).

      Hop Limit (TTL)

         MAY be varied from 1 to 255, for example, to implement non-
         propagating Route Requests and Route Request expanding-ring
         searches (Section 3.3.3).

   Route Request fields:

      Option Type

         1.  Nodes not understanding this option will ignore this
         option.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.  MUST be set
         equal to (4 * n) + 6, where n is the number of addresses in the
         Route Request Option.

      Identification

         A unique value generated by the initiator (original sender) of
         the Route Request.  Nodes initiating a Route Request generate a
         new Identification value for each Route Request, for example
         based on a sequence number counter of all Route Requests
         initiated by the node.

         This value allows a receiving node to determine whether it has
         recently seen a copy of this Route Request.  If this
         Identification value (for this IP Source address and Target
         Address) is found by this receiving node in its Route Request
         Table (in the cache of Identification values in the entry there
         for this initiating node), this receiving node MUST discard the
         Route Request.  When a Route Request is propagated, this field
         MUST be copied from the received copy of the Route Request
         being propagated.

      Target Address

         The address of the node that is the target of the Route
         Request.

      Address[1..n]

         Address[i] is the IPv4 address of the i-th node recorded in the
         Route Request option.  The address given in the Source Address
         field in the IP header is the address of the initiator of the
         Route Discovery and MUST NOT be listed in the Address[i]
         fields; the address given in Address[1] is thus the IPv4
         address of the first node on the path after the initiator.  The
         number of addresses present in this field is indicated by the
         Opt Data Len field in the option (n = (Opt Data Len - 6) / 4).
         Each node propagating the Route Request adds its own address to
         this list, increasing the Opt Data Len value by 4 octets.

   The Route Request option MUST NOT appear more than once within a DSR
   Options header.

6.3.  Route Reply Option

   The Route Reply option in a DSR Options header is encoded as follows:

    0                   1                   2                   3
    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
                   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                   |  Option Type  |  Opt Data Len |L|   Reserved  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[1]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[2]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                              ...                              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[n]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

   IP fields:

      Source Address

         Set to the address of the node sending the Route Reply.  In the
         case of a node sending a reply from its Route Cache (Section
         3.3.2) or sending a gratuitous Route Reply (Section 3.4.3),
         this address can differ from the address that was the target of
         the Route Discovery.

      Destination Address

         MUST be set to the address of the source node of the route
         being returned.  Copied from the Source Address field of the
         Route Request generating the Route Reply or, in the case of a
         gratuitous Route Reply, copied from the Source Address field of
         the data packet triggering the gratuitous Reply.

   Route Reply fields:

      Option Type

         2.  Nodes not understanding this option will ignore this
         option.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.  MUST be set
         equal to (4 * n) + 1, where n is the number of addresses in the
         Route Reply Option.

      Last Hop External (L)

         Set to indicate that the last hop given by the Route Reply (the
         link from Address[n-1] to Address[n]) is actually an arbitrary
         path in a network external to the DSR network; the exact route
         outside the DSR network is not represented in the Route Reply.
         Nodes caching this hop in their Route Cache MUST flag the
         cached hop with the External flag.  Such hops MUST NOT be
         returned in a cached Route Reply generated from this Route
         Cache entry, and selection of routes from the Route Cache to
         route a packet being sent SHOULD prefer routes that contain no
         hops flagged as External.

      Reserved

         MUST be sent as 0 and ignored on reception.

      Address[1..n]

         The source route being returned by the Route Reply.  The route
         indicates a sequence of hops, originating at the source node
         specified in the Destination Address field of the IP header of
         the packet carrying the Route Reply, through each of the
         Address[i] nodes in the order listed in the Route Reply, ending
         at the node indicated by Address[n].  The number of addresses
         present in the Address[1..n] field is indicated by the Opt Data
         Len field in the option (n = (Opt Data Len - 1) / 4).

   A Route Reply option MAY appear one or more times within a DSR
   Options header.

6.4.  Route Error Option

   The Route Error option in a DSR Options header is encoded as follows:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  |  Opt Data Len |   Error Type  |Reservd|Salvage|
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                      Error Source Address                     |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                   Error Destination Address                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   .                                                               .
   .                   Type-Specific Information                   .
   .                                                               .
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Option Type

         3.  Nodes not understanding this option will ignore this
         option.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.

         For the current definition of the Route Error option,
         this field MUST be set to 10, plus the size of any
         Type-Specific Information present in the Route Error.  Further
         extensions to the Route Error option format may also be
         included after the Type-Specific Information portion of the
         Route Error option specified above.  The presence of such
         extensions will be indicated by the Opt Data Len field.
         When the Opt Data Len is greater than that required for
         the fixed portion of the Route Error plus the necessary
         Type-Specific Information as indicated by the Option Type
         value in the option, the remaining octets are interpreted as
         extensions.  Currently, no such further extensions have been
         defined.

      Error Type

         The type of error encountered.  Currently, the following type
         values are defined:

            1 = NODE_UNREACHABLE
            2 = FLOW_STATE_NOT_SUPPORTED
            3 = OPTION_NOT_SUPPORTED

         Other values of the Error Type field are reserved for future
         use.

      Reservd

         Reserved.  MUST be sent as 0 and ignored on reception.

      Salvage

         A 4-bit unsigned integer.  Copied from the Salvage field in the
         DSR Source Route option of the packet triggering the Route
         Error.

         The "total salvage count" of the Route Error option is derived
         from the value in the Salvage field of this Route Error option
         and all preceding Route Error options in the packet as follows:
         the total salvage count is the sum of, for each such Route
         Error option, one plus the value in the Salvage field of that
         Route Error option.

      Error Source Address

         The address of the node originating the Route Error (e.g., the
         node that attempted to forward a packet and discovered the link
         failure).

      Error Destination Address

         The address of the node to which the Route Error must be
         delivered.  For example, when the Error Type field is set to
         NODE_UNREACHABLE, this field will be set to the address of the
         node that generated the routing information claiming that the
         hop from the Error Source Address to Unreachable Node Address
         (specified in the Type-Specific Information) was a valid hop.

      Type-Specific Information

         Information specific to the Error Type of this Route Error
         message.

   A Route Error option MAY appear one or more times within a DSR
   Options header.

6.4.1.  Node Unreachable Type-Specific Information

   When the Route Error is of type NODE_UNREACHABLE, the Type-Specific
   Information field is defined as follows:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Unreachable Node Address                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Unreachable Node Address

         The IP address of the node that was found to be unreachable
         (the next-hop neighbor to which the node with address
         Error Source Address was attempting to transmit the packet).

6.4.2.  Flow State Not Supported Type-Specific Information

   When the Route Error is of type FLOW_STATE_NOT_SUPPORTED, the
   Type-Specific Information field is empty.

6.4.3.  Option Not Supported Type-Specific Information

   When the Route Error is of type OPTION_NOT_SUPPORTED, the
   Type-Specific Information field is defined as follows:

   0 1 2 3 4 5 6 7
   +-+-+-+-+-+-+-+-+
   |Unsupported Opt|
   +-+-+-+-+-+-+-+-+

      Unsupported Opt

         The Option Type of option triggering the Route Error.

6.5.  Acknowledgement Request Option

   The Acknowledgement Request option in a DSR Options header is encoded
   as follows:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  |  Opt Data Len |         Identification        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Option Type

         160.  Nodes not understanding this option will remove the
         option and return a Route Error.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.

      Identification

         The Identification field is set to a unique value and is copied
         into the Identification field of the Acknowledgement option
         when returned by the node receiving the packet over this hop.

   An Acknowledgement Request option MUST NOT appear more than once
   within a DSR Options header.

6.6.  Acknowledgement Option

   The Acknowledgement option in a DSR Options header is encoded as
   follows:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  |  Opt Data Len |         Identification        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       ACK Source Address                      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     ACK Destination Address                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Option Type

         32.  Nodes not understanding this option will remove the
         option.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.

      Identification

         Copied from the Identification field of the Acknowledgement
         Request option of the packet being acknowledged.

      ACK Source Address

         The address of the node originating the acknowledgement.

      ACK Destination Address

         The address of the node to which the acknowledgement is to be
         delivered.

   An Acknowledgement option MAY appear one or more times within a DSR
   Options header.

6.7.  DSR Source Route Option

   The DSR Source Route option in a DSR Options header is encoded as
   follows:

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  |  Opt Data Len |F|L|Reservd|Salvage| Segs Left |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[1]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[2]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                              ...                              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Address[n]                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Option Type

         96.  Nodes not understanding this option will drop the packet.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.  For the
         format of the DSR Source Route option defined here, this field
         MUST be set to the value (n * 4) + 2, where n is the number of
         addresses present in the Address[i] fields.

      First Hop External (F)

         Set to indicate that the first hop indicated by the DSR Source
         Route option is actually an arbitrary path in a network
         external to the DSR network; the exact route outside the DSR

         network is not represented in the DSR Source Route option.
         Nodes caching this hop in their Route Cache MUST flag the
         cached hop with the External flag.  Such hops MUST NOT be
         returned in a Route Reply generated from this Route Cache
         entry, and selection of routes from the Route Cache to route a
         packet being sent SHOULD prefer routes that contain no hops
         flagged as External.

      Last Hop External (L)

         Set to indicate that the last hop indicated by the DSR Source
         Route option is actually an arbitrary path in a network
         external to the DSR network; the exact route outside the DSR
         network is not represented in the DSR Source Route option.
         Nodes caching this hop in their Route Cache MUST flag the
         cached hop with the External flag.  Such hops MUST NOT be
         returned in a Route Reply generated from this Route Cache
         entry, and selection of routes from the Route Cache to route a
         packet being sent SHOULD prefer routes that contain no hops
         flagged as External.

      Reserved

         MUST be sent as 0 and ignored on reception.

      Salvage

         A 4-bit unsigned integer.  Count of number of times that this
         packet has been salvaged as a part of DSR routing (Section
         3.4.1).

      Segments Left (Segs Left)

         Number of route segments remaining, i.e., number of explicitly
         listed intermediate nodes still to be visited before reaching
         the final destination.

      Address[1..n]

         The sequence of addresses of the source route.  In routing and
         forwarding the packet, the source route is processed as
         described in Sections 8.1.3 and 8.1.5.  The number of addresses
         present in the Address[1..n] field is indicated by the Opt Data
         Len field in the option (n = (Opt Data Len - 2) / 4).

   When forwarding a packet along a DSR source route using a DSR Source
   Route option in the packet's DSR Options header, the Destination
   Address field in the packet's IP header is always set to the address

   of the packet's ultimate destination.  A node receiving a packet
   containing a DSR Options header with a DSR Source Route option MUST
   examine the indicated source route to determine if it is the intended
   next-hop node for the packet and how to forward the packet, as
   defined in Sections 8.1.4 and 8.1.5.

6.8.  Pad1 Option

   The Pad1 option in a DSR Options header is encoded as follows:

   +-+-+-+-+-+-+-+-+
   |  Option Type  |
   +-+-+-+-+-+-+-+-+

      Option Type

         224.  Nodes not understanding this option will drop the packet
         and return a Route Error.

   A Pad1 option MAY be included in the Options field of a DSR Options
   header in order to align subsequent DSR options, but such alignment
   is not required and MUST NOT be expected by a node receiving a packet
   containing a DSR Options header.

   If any headers follow the DSR Options header in a packet, the total
   length of a DSR Options header, indicated by the Payload Length field
   in the DSR Options header MUST be a multiple of 4 octets.  In this
   case, when building a DSR Options header in a packet, sufficient Pad1
   or PadN options MUST be included in the Options field of the DSR
   Options header to make the total length a multiple of 4 octets.

   If more than one consecutive octet of padding is being inserted in
   the Options field of a DSR Options header, the PadN option described
   next, SHOULD be used, rather than multiple Pad1 options.

   Note that the format of the Pad1 option is a special case; it does
   not have an Opt Data Len or Option Data field.

6.9.  PadN Option

   The PadN option in a DSR Options header is encoded as follows:

   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
   |  Option Type  |  Opt Data Len |   Option Data
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -

      Option Type

         0.  Nodes not understanding this option will ignore this
         option.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.  The size of
         the Option Data field.

      Option Data

         A number of zero-valued octets equal to the Opt Data Len.

   A PadN option MAY be included in the Options field of a DSR Options
   header in order to align subsequent DSR options, but such alignment
   is not required and MUST NOT be expected by a node receiving a packet
   containing a DSR Options header.

   If any headers follow the DSR Options header in a packet, the total
   length of a DSR Options header, indicated by the Payload Length field
   in the DSR Options header, MUST be a multiple of 4 octets.  In this
   case, when building a DSR Options header in a packet, sufficient Pad1
   or PadN options MUST be included in the Options field of the DSR
   Options header to make the total length a multiple of 4 octets.

7.  Additional Header Formats and Options for Flow State Extension

   The optional DSR flow state extension requires a new header type, the
   DSR Flow State header.

   In addition, the DSR flow state extension adds the following options
   for the DSR Options header defined in Section 6:

   -  Timeout option (Section 7.2.1)

   -  Destination and Flow ID option (Section 7.2.2)

   Two new Error Type values are also defined for use in the Route Error
   option in a DSR Options header:

   -  UNKNOWN_FLOW

   -  DEFAULT_FLOW_UNKNOWN

   Finally, an extension to the Acknowledgement Request option in a DSR
   Options header is also defined:

   -  Previous Hop Address

   This section defines each of these new header, option, or extension
   formats.

7.1.  DSR Flow State Header

   The DSR Flow State header is a small 4-byte header optionally used to
   carry the flow ID and hop count for a packet being sent along a DSR
   flow.  It is distinguished from the fixed DSR Options header (Section
   6.1) in that the Flow State Header (F) bit is set in the DSR Flow
   State header and is clear in the fixed DSR Options header.

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Next Header  |F|  Hop Count  |        Flow Identifier        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Next Header

         8-bit selector.  Identifies the type of header immediately
         following the DSR Flow State header.  Uses the same values as
         the IPv4 Protocol field [RFC1700].

      Flow State Header (F)

         Flag bit.  MUST be set to 1.  This bit is set in a DSR Flow
         State header and clear in a DSR Options header (Section 6.1).

      Hop Count

         7-bit unsigned integer.  The number of hops through which this
         packet has been forwarded.

      Flow Identification

         The flow ID for this flow, as described in Section 3.5.1.

7.2.  New Options and Extensions in DSR Options Header

7.2.1.  Timeout Option

   The Timeout option is defined for use in a DSR Options header to
   indicate the amount of time before the expiration of the flow ID
   along which the packet is being sent.

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  | Opt Data Len  |            Timeout            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Option Type

         128.  Nodes not understanding this option will ignore the
         option and return a Route Error.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.

         When no extensions are present, the Opt Data Len of a Timeout
         option is 2.  Further extensions to DSR may include additional
         data in a Timeout option.  The presence of such extensions is
         indicated by an Opt Data Len greater than 2.  Currently, no
         such extensions have been defined.

      Timeout

         The number of seconds for which this flow remains valid.

   The Timeout option MUST NOT appear more than once within a DSR
   Options header.

7.2.2.  Destination and Flow ID Option

   The Destination and Flow ID option is defined for use in a DSR
   Options header to send a packet to an intermediate host along one
   flow, for eventual forwarding to the final destination along a
   different flow.  This option enables the aggregation of the state of
   multiple flows.

    0                   1                   2                   3
    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Option Type  | Opt Data Len  |      New Flow Identifier      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                   New IP Destination Address                  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

      Option Type

         129.  Nodes not understanding this option will ignore the
         option and return a Route Error.

      Opt Data Len

         8-bit unsigned integer.  Length of the option, in octets,
         excluding the Option Type and Opt Data Len fields.

         When no extensions are present, the Opt Data Len of a
         Destination and Flow ID option is 6.  Further extensions to DSR
         may include additional data in a Destination and Flow ID
         option.  The presence of such extensions is indicated by an Opt
         Data Len greater than 6.  Currently, no such extensions have
         been defined.

      New Flow Identifier

         Indicates the next identifier to store in the Flow ID field of
         the DSR Options header.

      New IP Destination