home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 1000s / rfc1058.txt < prev    next >
Text File  |  1988-06-29  |  91KB  |  1,851 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                                         C. Hedrick
  8. Request for Comments: 1058                            Rutgers University
  9.                                                                June 1988
  10.  
  11.  
  12.                       Routing Information Protocol
  13.  
  14.  
  15. Status of this Memo
  16.  
  17.    This RFC describes an existing protocol for exchanging routing
  18.    information among gateways and other hosts.  It is intended to be
  19.    used as a basis for developing gateway software for use in the
  20.    Internet community.  Distribution of this memo is unlimited.
  21.  
  22.                              Table of Contents
  23.  
  24.    1. Introduction                                                     2
  25.         1.1. Limitations of the protocol                               4
  26.         1.2. Organization of this document                             4
  27.    2. Distance Vector Algorithms                                       5
  28.         2.1. Dealing with changes in topology                         11
  29.         2.2. Preventing instability                                   12
  30.              2.2.1. Split horizon                                     14
  31.              2.2.2. Triggered updates                                 15
  32.    3. Specifications for the protocol                                 16
  33.         3.1. Message formats                                          18
  34.         3.2. Addressing considerations                                20
  35.         3.3. Timers                                                   23
  36.         3.4. Input processing                                         24
  37.              3.4.1. Request                                           25
  38.              3.4.2. Response                                          26
  39.         3.5. Output Processing                                        28
  40.         3.6. Compatibility                                            31
  41.    4. Control functions                                               31
  42.  
  43. Overview
  44.  
  45.    This memo is intended to do the following things:
  46.  
  47.       - Document a protocol and algorithms that are currently in
  48.         wide use for routing, but which have never been formally
  49.         documented.
  50.  
  51.       - Specify some improvements in the algorithms which will
  52.         improve stability of the routes in large networks.  These
  53.         improvements do not introduce any incompatibility with
  54.         existing implementations.  They are to be incorporated into
  55.  
  56.  
  57.  
  58. Hedrick                                                         [Page 1]
  59.  
  60. RFC 1058              Routing Information Protocol             June 1988
  61.  
  62.  
  63.         all implementations of this protocol.
  64.  
  65.       - Suggest some optional features to allow greater
  66.         configurability and control.  These features were developed
  67.         specifically to solve problems that have shown up in actual
  68.         use by the NSFnet community.  However, they should have more
  69.         general utility.
  70.  
  71.    The Routing Information Protocol (RIP) described here is loosely
  72.    based on the program "routed", distributed with the 4.3 Berkeley
  73.    Software Distribution.  However, there are several other
  74.    implementations of what is supposed to be the same protocol.
  75.    Unfortunately, these various implementations disagree in various
  76.    details.  The specifications here represent a combination of features
  77.    taken from various implementations.  We believe that a program
  78.    designed according to this document will interoperate with routed,
  79.    and with all other implementations of RIP of which we are aware.
  80.  
  81.    Note that this description adopts a different view than most existing
  82.    implementations about when metrics should be incremented.  By making
  83.    a corresponding change in the metric used for a local network, we
  84.    have retained compatibility with other existing implementations.  See
  85.    section 3.6 for details on this issue.
  86.  
  87. 1. Introduction
  88.  
  89.    This memo describes one protocol in a series of routing protocols
  90.    based on the Bellman-Ford (or distance vector) algorithm.  This
  91.    algorithm has been used for routing computations in computer networks
  92.    since the early days of the ARPANET.  The particular packet formats
  93.    and protocol described here are based on the program "routed", which
  94.    is included with the Berkeley distribution of Unix.  It has become a
  95.    de facto standard for exchange of routing information among gateways
  96.    and hosts.  It is implemented for this purpose by most commercial
  97.    vendors of IP gateways.  Note, however, that many of these vendors
  98.    have their own protocols which are used among their own gateways.
  99.  
  100.    This protocol is most useful as an "interior gateway protocol".  In a
  101.    nationwide network such as the current Internet, it is very unlikely
  102.    that a single routing protocol will used for the whole network.
  103.    Rather, the network will be organized as a collection of "autonomous
  104.    systems".  An autonomous system will in general be administered by a
  105.    single entity, or at least will have some reasonable degree of
  106.    technical and administrative control.  Each autonomous system will
  107.    have its own routing technology.  This may well be different for
  108.    different autonomous systems.  The routing protocol used within an
  109.    autonomous system is referred to as an interior gateway protocol, or
  110.    "IGP".  A separate protocol is used to interface among the autonomous
  111.  
  112.  
  113.  
  114. Hedrick                                                         [Page 2]
  115.  
  116. RFC 1058              Routing Information Protocol             June 1988
  117.  
  118.  
  119.    systems.  The earliest such protocol, still used in the Internet, is
  120.    "EGP" (exterior gateway protocol).  Such protocols are now usually
  121.    referred to as inter-AS routing protocols.  RIP was designed to work
  122.    with moderate-size networks using reasonably homogeneous technology.
  123.    Thus it is suitable as an IGP for many campuses and for regional
  124.    networks using serial lines whose speeds do not vary widely.  It is
  125.    not intended for use in more complex environments.  For more
  126.    information on the context into which RIP is expected to fit, see
  127.    Braden and Postel [3].
  128.  
  129.    RIP is one of a class of algorithms known as "distance vector
  130.    algorithms".  The earliest description of this class of algorithms
  131.    known to the author is in Ford and Fulkerson [6].  Because of this,
  132.    they are sometimes known as Ford-Fulkerson algorithms.  The term
  133.    Bellman-Ford is also used.  It comes from the fact that the
  134.    formulation is based on Bellman's equation, the basis of "dynamic
  135.    programming".  (For a standard introduction to this area, see [1].)
  136.    The presentation in this document is closely based on [2].  This text
  137.    contains an introduction to the mathematics of routing algorithms.
  138.    It describes and justifies several variants of the algorithm
  139.    presented here, as well as a number of other related algorithms.  The
  140.    basic algorithms described in this protocol were used in computer
  141.    routing as early as 1969 in the ARPANET.  However, the specific
  142.    ancestry of this protocol is within the Xerox network protocols.  The
  143.    PUP protocols (see [4]) used the Gateway Information Protocol to
  144.    exchange routing information.  A somewhat updated version of this
  145.    protocol was adopted for the Xerox Network Systems (XNS)
  146.    architecture, with the name Routing Information Protocol.  (See [7].)
  147.    Berkeley's routed is largely the same as the Routing Information
  148.    Protocol, with XNS addresses replaced by a more general address
  149.    format capable of handling IP and other types of address, and with
  150.    routing updates limited to one every 30 seconds.  Because of this
  151.    similarity, the term Routing Information Protocol (or just RIP) is
  152.    used to refer to both the XNS protocol and the protocol used by
  153.    routed.
  154.  
  155.    RIP is intended for use within the IP-based Internet.  The Internet
  156.    is organized into a number of networks connected by gateways.  The
  157.    networks may be either point-to-point links or more complex networks
  158.    such as Ethernet or the ARPANET.  Hosts and gateways are presented
  159.    with IP datagrams addressed to some host.  Routing is the method by
  160.    which the host or gateway decides where to send the datagram.  It may
  161.    be able to send the datagram directly to the destination, if that
  162.    destination is on one of the networks that are directly connected to
  163.    the host or gateway.  However, the interesting case is when the
  164.    destination is not directly reachable.  In this case, the host or
  165.    gateway attempts to send the datagram to a gateway that is nearer the
  166.    destination.  The goal of a routing protocol is very simple: It is to
  167.  
  168.  
  169.  
  170. Hedrick                                                         [Page 3]
  171.  
  172. RFC 1058              Routing Information Protocol             June 1988
  173.  
  174.  
  175.    supply the information that is needed to do routing.
  176.  
  177. 1.1. Limitations of the protocol
  178.  
  179.    This protocol does not solve every possible routing problem.  As
  180.    mentioned above, it is primary intended for use as an IGP, in
  181.    reasonably homogeneous networks of moderate size.  In addition, the
  182.    following specific limitations should be mentioned:
  183.  
  184.       - The protocol is limited to networks whose longest path
  185.         involves 15 hops.  The designers believe that the basic
  186.         protocol design is inappropriate for larger networks.  Note
  187.         that this statement of the limit assumes that a cost of 1
  188.         is used for each network.  This is the way RIP is normally
  189.         configured.  If the system administrator chooses to use
  190.         larger costs, the upper bound of 15 can easily become a
  191.         problem.
  192.  
  193.       - The protocol depends upon "counting to infinity" to resolve
  194.         certain unusual situations.  (This will be explained in the
  195.         next section.)  If the system of networks has several
  196.         hundred networks, and a routing loop was formed involving
  197.         all of them, the resolution of the loop would require
  198.         either much time (if the frequency of routing updates were
  199.         limited) or bandwidth (if updates were sent whenever
  200.         changes were detected).  Such a loop would consume a large
  201.         amount of network bandwidth before the loop was corrected.
  202.         We believe that in realistic cases, this will not be a
  203.         problem except on slow lines.  Even then, the problem will
  204.         be fairly unusual, since various precautions are taken that
  205.         should prevent these problems in most cases.
  206.  
  207.       - This protocol uses fixed "metrics" to compare alternative
  208.         routes.  It is not appropriate for situations where routes
  209.         need to be chosen based on real-time parameters such a
  210.         measured delay, reliability, or load.  The obvious
  211.         extensions to allow metrics of this type are likely to
  212.         introduce instabilities of a sort that the protocol is not
  213.         designed to handle.
  214.  
  215. 1.2. Organization of this document
  216.  
  217.    The main body of this document is organized into two parts, which
  218.    occupy the next two sections:
  219.  
  220.       2   A conceptual development and justification of distance vector
  221.           algorithms in general.
  222.  
  223.  
  224.  
  225.  
  226. Hedrick                                                         [Page 4]
  227.  
  228. RFC 1058              Routing Information Protocol             June 1988
  229.  
  230.  
  231.       3   The actual protocol description.
  232.  
  233.    Each of these two sections can largely stand on its own.  Section 2
  234.    attempts to give an informal presentation of the mathematical
  235.    underpinnings of the algorithm.  Note that the presentation follows a
  236.    "spiral" method.  An initial, fairly simple algorithm is described.
  237.    Then refinements are added to it in successive sections.  Section 3
  238.    is the actual protocol description.  Except where specific references
  239.    are made to section 2, it should be possible to implement RIP
  240.    entirely from the specifications given in section 3.
  241.  
  242. 2. Distance Vector Algorithms
  243.  
  244.    Routing is the task of finding a path from a sender to a desired
  245.    destination.  In the IP "Catenet model" this reduces primarily to a
  246.    matter of finding gateways between networks.  As long as a message
  247.    remains on a single network or subnet, any routing problems are
  248.    solved by technology that is specific to the network.  For example,
  249.    the Ethernet and the ARPANET each define a way in which any sender
  250.    can talk to any specified destination within that one network.  IP
  251.    routing comes in primarily when messages must go from a sender on one
  252.    such network to a destination on a different one.  In that case, the
  253.    message must pass through gateways connecting the networks.  If the
  254.    networks are not adjacent, the message may pass through several
  255.    intervening networks, and the gateways connecting them.  Once the
  256.    message gets to a gateway that is on the same network as the
  257.    destination, that network's own technology is used to get to the
  258.    destination.
  259.  
  260.    Throughout this section, the term "network" is used generically to
  261.    cover a single broadcast network (e.g., an Ethernet), a point to
  262.    point line, or the ARPANET.  The critical point is that a network is
  263.    treated as a single entity by IP.  Either no routing is necessary (as
  264.    with a point to point line), or that routing is done in a manner that
  265.    is transparent to IP, allowing IP to treat the entire network as a
  266.    single fully-connected system (as with an Ethernet or the ARPANET).
  267.    Note that the term "network" is used in a somewhat different way in
  268.    discussions of IP addressing.  A single IP network number may be
  269.    assigned to a collection of networks, with "subnet" addressing being
  270.    used to describe the individual networks.  In effect, we are using
  271.    the term "network" here to refer to subnets in cases where subnet
  272.    addressing is in use.
  273.  
  274.    A number of different approaches for finding routes between networks
  275.    are possible.  One useful way of categorizing these approaches is on
  276.    the basis of the type of information the gateways need to exchange in
  277.    order to be able to find routes.  Distance vector algorithms are
  278.    based on the exchange of only a small amount of information.  Each
  279.  
  280.  
  281.  
  282. Hedrick                                                         [Page 5]
  283.  
  284. RFC 1058              Routing Information Protocol             June 1988
  285.  
  286.  
  287.    entity (gateway or host) that participates in the routing protocol is
  288.    assumed to keep information about all of the destinations within the
  289.    system.  Generally, information about all entities connected to one
  290.    network is summarized by a single entry, which describes the route to
  291.    all destinations on that network.  This summarization is possible
  292.    because as far as IP is concerned, routing within a network is
  293.    invisible.  Each entry in this routing database includes the next
  294.    gateway to which datagrams destined for the entity should be sent.
  295.    In addition, it includes a "metric" measuring the total distance to
  296.    the entity.  Distance is a somewhat generalized concept, which may
  297.    cover the time delay in getting messages to the entity, the dollar
  298.    cost of sending messages to it, etc.  Distance vector algorithms get
  299.    their name from the fact that it is possible to compute optimal
  300.    routes when the only information exchanged is the list of these
  301.    distances.  Furthermore, information is only exchanged among entities
  302.    that are adjacent, that is, entities that share a common network.
  303.  
  304.    Although routing is most commonly based on information about
  305.    networks, it is sometimes necessary to keep track of the routes to
  306.    individual hosts.  The RIP protocol makes no formal distinction
  307.    between networks and hosts.  It simply describes exchange of
  308.    information about destinations, which may be either networks or
  309.    hosts.  (Note however, that it is possible for an implementor to
  310.    choose not to support host routes.  See section 3.2.)  In fact, the
  311.    mathematical developments are most conveniently thought of in terms
  312.    of routes from one host or gateway to another.  When discussing the
  313.    algorithm in abstract terms, it is best to think of a routing entry
  314.    for a network as an abbreviation for routing entries for all of the
  315.    entities connected to that network.  This sort of abbreviation makes
  316.    sense only because we think of networks as having no internal
  317.    structure that is visible at the IP level.  Thus, we will generally
  318.    assign the same distance to every entity in a given network.
  319.  
  320.    We said above that each entity keeps a routing database with one
  321.    entry for every possible destination in the system.  An actual
  322.    implementation is likely to need to keep the following information
  323.    about each destination:
  324.  
  325.       - address: in IP implementations of these algorithms, this
  326.         will be the IP address of the host or network.
  327.  
  328.       - gateway: the first gateway along the route to the
  329.         destination.
  330.  
  331.       - interface: the physical network which must be used to reach
  332.         the first gateway.
  333.  
  334.       - metric: a number, indicating the distance to the
  335.  
  336.  
  337.  
  338. Hedrick                                                         [Page 6]
  339.  
  340. RFC 1058              Routing Information Protocol             June 1988
  341.  
  342.  
  343.         destination.
  344.  
  345.       - timer: the amount of time since the entry was last updated.
  346.  
  347.    In addition, various flags and other internal information will
  348.    probably be included.  This database is initialized with a
  349.    description of the entities that are directly connected to the
  350.    system.  It is updated according to information received in messages
  351.    from neighboring gateways.
  352.  
  353.    The most important information exchanged by the hosts and gateways is
  354.    that carried in update messages.  Each entity that participates in
  355.    the routing scheme sends update messages that describe the routing
  356.    database as it currently exists in that entity.  It is possible to
  357.    maintain optimal routes for the entire system by using only
  358.    information obtained from neighboring entities.  The algorithm used
  359.    for that will be described in the next section.
  360.  
  361.    As we mentioned above, the purpose of routing is to find a way to get
  362.    datagrams to their ultimate destinations.  Distance vector algorithms
  363.    are based on a table giving the best route to every destination in
  364.    the system.  Of course, in order to define which route is best, we
  365.    have to have some way of measuring goodness.  This is referred to as
  366.    the "metric".
  367.  
  368.    In simple networks, it is common to use a metric that simply counts
  369.    how many gateways a message must go through.  In more complex
  370.    networks, a metric is chosen to represent the total amount of delay
  371.    that the message suffers, the cost of sending it, or some other
  372.    quantity which may be minimized.  The main requirement is that it
  373.    must be possible to represent the metric as a sum of "costs" for
  374.    individual hops.
  375.  
  376.    Formally, if it is possible to get from entity i to entity j directly
  377.    (i.e., without passing through another gateway between), then a cost,
  378.    d(i,j), is associated with the hop between i and j.  In the normal
  379.    case where all entities on a given network are considered to be the
  380.    same, d(i,j) is the same for all destinations on a given network, and
  381.    represents the cost of using that network.  To get the metric of a
  382.    complete route, one just adds up the costs of the individual hops
  383.    that make up the route.  For the purposes of this memo, we assume
  384.    that the costs are positive integers.
  385.  
  386.    Let D(i,j) represent the metric of the best route from entity i to
  387.    entity j.  It should be defined for every pair of entities.  d(i,j)
  388.    represents the costs of the individual steps.  Formally, let d(i,j)
  389.    represent the cost of going directly from entity i to entity j.  It
  390.    is infinite if i and j are not immediate neighbors. (Note that d(i,i)
  391.  
  392.  
  393.  
  394. Hedrick                                                         [Page 7]
  395.  
  396. RFC 1058              Routing Information Protocol             June 1988
  397.  
  398.  
  399.    is infinite.  That is, we don't consider there to be a direct
  400.    connection from a node to itself.)  Since costs are additive, it is
  401.    easy to show that the best metric must be described by
  402.  
  403.              D(i,i) = 0,                      all i
  404.              D(i,j) = min [d(i,k) + D(k,j)],  otherwise
  405.                        k
  406.  
  407.    and that the best routes start by going from i to those neighbors k
  408.    for which d(i,k) + D(k,j) has the minimum value.  (These things can
  409.    be shown by induction on the number of steps in the routes.)  Note
  410.    that we can limit the second equation to k's that are immediate
  411.    neighbors of i.  For the others, d(i,k) is infinite, so the term
  412.    involving them can never be the minimum.
  413.  
  414.    It turns out that one can compute the metric by a simple algorithm
  415.    based on this.  Entity i gets its neighbors k to send it their
  416.    estimates of their distances to the destination j.  When i gets the
  417.    estimates from k, it adds d(i,k) to each of the numbers.  This is
  418.    simply the cost of traversing the network between i and k.  Now and
  419.    then i compares the values from all of its neighbors and picks the
  420.    smallest.
  421.  
  422.    A proof is given in [2] that this algorithm will converge to the
  423.    correct estimates of D(i,j) in finite time in the absence of topology
  424.    changes.  The authors make very few assumptions about the order in
  425.    which the entities send each other their information, or when the min
  426.    is recomputed.  Basically, entities just can't stop sending updates
  427.    or recomputing metrics, and the networks can't delay messages
  428.    forever.  (Crash of a routing entity is a topology change.)  Also,
  429.    their proof does not make any assumptions about the initial estimates
  430.    of D(i,j), except that they must be non-negative.  The fact that
  431.    these fairly weak assumptions are good enough is important.  Because
  432.    we don't have to make assumptions about when updates are sent, it is
  433.    safe to run the algorithm asynchronously.  That is, each entity can
  434.    send updates according to its own clock.  Updates can be dropped by
  435.    the network, as long as they don't all get dropped.  Because we don't
  436.    have to make assumptions about the starting condition, the algorithm
  437.    can handle changes.  When the system changes, the routing algorithm
  438.    starts moving to a new equilibrium, using the old one as its starting
  439.    point.  It is important that the algorithm will converge in finite
  440.    time no matter what the starting point.  Otherwise certain kinds of
  441.    changes might lead to non-convergent behavior.
  442.  
  443.    The statement of the algorithm given above (and the proof) assumes
  444.    that each entity keeps copies of the estimates that come from each of
  445.    its neighbors, and now and then does a min over all of the neighbors.
  446.    In fact real implementations don't necessarily do that.  They simply
  447.  
  448.  
  449.  
  450. Hedrick                                                         [Page 8]
  451.  
  452. RFC 1058              Routing Information Protocol             June 1988
  453.  
  454.  
  455.    remember the best metric seen so far, and the identity of the
  456.    neighbor that sent it.  They replace this information whenever they
  457.    see a better (smaller) metric.  This allows them to compute the
  458.    minimum incrementally, without having to store data from all of the
  459.    neighbors.
  460.  
  461.    There is one other difference between the algorithm as described in
  462.    texts and those used in real protocols such as RIP: the description
  463.    above would have each entity include an entry for itself, showing a
  464.    distance of zero.  In fact this is not generally done.  Recall that
  465.    all entities on a network are normally summarized by a single entry
  466.    for the network.  Consider the situation of a host or gateway G that
  467.    is connected to network A.  C represents the cost of using network A
  468.    (usually a metric of one).  (Recall that we are assuming that the
  469.    internal structure of a network is not visible to IP, and thus the
  470.    cost of going between any two entities on it is the same.)  In
  471.    principle, G should get a message from every other entity H on
  472.    network A, showing a cost of 0 to get from that entity to itself.  G
  473.    would then compute C + 0 as the distance to H.  Rather than having G
  474.    look at all of these identical messages, it simply starts out by
  475.    making an entry for network A in its table, and assigning it a metric
  476.    of C.  This entry for network A should be thought of as summarizing
  477.    the entries for all other entities on network A.  The only entity on
  478.    A that can't be summarized by that common entry is G itself, since
  479.    the cost of going from G to G is 0, not C.  But since we never need
  480.    those 0 entries, we can safely get along with just the single entry
  481.    for network A.  Note one other implication of this strategy: because
  482.    we don't need to use the 0 entries for anything, hosts that do not
  483.    function as gateways don't need to send any update messages.  Clearly
  484.    hosts that don't function as gateways (i.e., hosts that are connected
  485.    to only one network) can have no useful information to contribute
  486.    other than their own entry D(i,i) = 0.  As they have only the one
  487.    interface, it is easy to see that a route to any other network
  488.    through them will simply go in that interface and then come right
  489.    back out it.  Thus the cost of such a route will be greater than the
  490.    best cost by at least C.  Since we don't need the 0 entries, non-
  491.    gateways need not participate in the routing protocol at all.
  492.  
  493.    Let us summarize what a host or gateway G does.  For each destination
  494.    in the system, G will keep a current estimate of the metric for that
  495.    destination (i.e., the total cost of getting to it) and the identity
  496.    of the neighboring gateway on whose data that metric is based.  If
  497.    the destination is on a network that is directly connected to G, then
  498.    G simply uses an entry that shows the cost of using the network, and
  499.    the fact that no gateway is needed to get to the destination.  It is
  500.    easy to show that once the computation has converged to the correct
  501.    metrics, the neighbor that is recorded by this technique is in fact
  502.    the first gateway on the path to the destination.  (If there are
  503.  
  504.  
  505.  
  506. Hedrick                                                         [Page 9]
  507.  
  508. RFC 1058              Routing Information Protocol             June 1988
  509.  
  510.  
  511.    several equally good paths, it is the first gateway on one of them.)
  512.    This combination of destination, metric, and gateway is typically
  513.    referred to as a route to the destination with that metric, using
  514.    that gateway.
  515.  
  516.    The method so far only has a way to lower the metric, as the existing
  517.    metric is kept until a smaller one shows up.  It is possible that the
  518.    initial estimate might be too low.  Thus, there must be a way to
  519.    increase the metric.  It turns out to be sufficient to use the
  520.    following rule: suppose the current route to a destination has metric
  521.    D and uses gateway G.  If a new set of information arrived from some
  522.    source other than G, only update the route if the new metric is
  523.    better than D.  But if a new set of information arrives from G
  524.    itself, always update D to the new value.  It is easy to show that
  525.    with this rule, the incremental update process produces the same
  526.    routes as a calculation that remembers the latest information from
  527.    all the neighbors and does an explicit minimum.  (Note that the
  528.    discussion so far assumes that the network configuration is static.
  529.    It does not allow for the possibility that a system might fail.)
  530.  
  531.    To summarize, here is the basic distance vector algorithm as it has
  532.    been developed so far.  (Note that this is not a statement of the RIP
  533.    protocol.  There are several refinements still to be added.)  The
  534.    following procedure is carried out by every entity that participates
  535.    in the routing protocol.  This must include all of the gateways in
  536.    the system.  Hosts that are not gateways may participate as well.
  537.  
  538.        - Keep a table with an entry for every possible destination
  539.         in the system.  The entry contains the distance D to the
  540.         destination, and the first gateway G on the route to that
  541.         network.  Conceptually, there should be an entry for the
  542.         entity itself, with metric 0, but this is not actually
  543.         included.
  544.  
  545.       - Periodically, send a routing update to every neighbor.  The
  546.         update is a set of messages that contain all of the
  547.         information from the routing table.  It contains an entry
  548.         for each destination, with the distance shown to that
  549.         destination.
  550.  
  551.       - When a routing update arrives from a neighbor G', add the
  552.         cost associated with the network that is shared with G'.
  553.         (This should be the network over which the update arrived.)
  554.         Call the resulting distance D'.  Compare the resulting
  555.         distances with the current routing table entries.  If the
  556.         new distance D' for N is smaller than the existing value D,
  557.         adopt the new route.  That is, change the table entry for N
  558.         to have metric D' and gateway G'.  If G' is the gateway
  559.  
  560.  
  561.  
  562. Hedrick                                                        [Page 10]
  563.  
  564. RFC 1058              Routing Information Protocol             June 1988
  565.  
  566.  
  567.         from which the existing route came, i.e., G' = G, then use
  568.         the new metric even if it is larger than the old one.
  569.  
  570. 2.1. Dealing with changes in topology
  571.  
  572.    The discussion above assumes that the topology of the network is
  573.    fixed.  In practice, gateways and lines often fail and come back up.
  574.    To handle this possibility, we need to modify the algorithm slightly.
  575.    The theoretical version of the algorithm involved a minimum over all
  576.    immediate neighbors.  If the topology changes, the set of neighbors
  577.    changes.  Therefore, the next time the calculation is done, the
  578.    change will be reflected.  However, as mentioned above, actual
  579.    implementations use an incremental version of the minimization.  Only
  580.    the best route to any given destination is remembered.  If the
  581.    gateway involved in that route should crash, or the network
  582.    connection to it break, the calculation might never reflect the
  583.    change.  The algorithm as shown so far depends upon a gateway
  584.    notifying its neighbors if its metrics change.  If the gateway
  585.    crashes, then it has no way of notifying neighbors of a change.
  586.  
  587.    In order to handle problems of this kind, distance vector protocols
  588.    must make some provision for timing out routes.  The details depend
  589.    upon the specific protocol.  As an example, in RIP every gateway that
  590.    participates in routing sends an update message to all its neighbors
  591.    once every 30 seconds.  Suppose the current route for network N uses
  592.    gateway G.  If we don't hear from G for 180 seconds, we can assume
  593.    that either the gateway has crashed or the network connecting us to
  594.    it has become unusable.  Thus, we mark the route as invalid.  When we
  595.    hear from another neighbor that has a valid route to N, the valid
  596.    route will replace the invalid one.  Note that we wait for 180
  597.    seconds before timing out a route even though we expect to hear from
  598.    each neighbor every 30 seconds.  Unfortunately, messages are
  599.    occasionally lost by networks.  Thus, it is probably not a good idea
  600.    to invalidate a route based on a single missed message.
  601.  
  602.    As we will see below, it is useful to have a way to notify neighbors
  603.    that there currently isn't a valid route to some network.  RIP, along
  604.    with several other protocols of this class, does this through a
  605.    normal update message, by marking that network as unreachable.  A
  606.    specific metric value is chosen to indicate an unreachable
  607.    destination; that metric value is larger than the largest valid
  608.    metric that we expect to see.  In the existing implementation of RIP,
  609.    16 is used.  This value is normally referred to as "infinity", since
  610.    it is larger than the largest valid metric.  16 may look like a
  611.    surprisingly small number.  It is chosen to be this small for reasons
  612.    that we will see shortly.  In most implementations, the same
  613.    convention is used internally to flag a route as invalid.
  614.  
  615.  
  616.  
  617.  
  618. Hedrick                                                        [Page 11]
  619.  
  620. RFC 1058              Routing Information Protocol             June 1988
  621.  
  622.  
  623. 2.2. Preventing instability
  624.  
  625.    The algorithm as presented up to this point will always allow a host
  626.    or gateway to calculate a correct routing table.  However, that is
  627.    still not quite enough to make it useful in practice.  The proofs
  628.    referred to above only show that the routing tables will converge to
  629.    the correct values in finite time.  They do not guarantee that this
  630.    time will be small enough to be useful, nor do they say what will
  631.    happen to the metrics for networks that become inaccessible.
  632.  
  633.    It is easy enough to extend the mathematics to handle routes becoming
  634.    inaccessible.  The convention suggested above will do that.  We
  635.    choose a large metric value to represent "infinity".  This value must
  636.    be large enough that no real metric would ever get that large.  For
  637.    the purposes of this example, we will use the value 16.  Suppose a
  638.    network becomes inaccessible.  All of the immediately neighboring
  639.    gateways time out and set the metric for that network to 16.  For
  640.    purposes of analysis, we can assume that all the neighboring gateways
  641.    have gotten a new piece of hardware that connects them directly to
  642.    the vanished network, with a cost of 16.  Since that is the only
  643.    connection to the vanished network, all the other gateways in the
  644.    system will converge to new routes that go through one of those
  645.    gateways.  It is easy to see that once convergence has happened, all
  646.    the gateways will have metrics of at least 16 for the vanished
  647.    network.  Gateways one hop away from the original neighbors would end
  648.    up with metrics of at least 17; gateways two hops away would end up
  649.    with at least 18, etc.  As these metrics are larger than the maximum
  650.    metric value, they are all set to 16.  It is obvious that the system
  651.    will now converge to a metric of 16 for the vanished network at all
  652.    gateways.
  653.  
  654.    Unfortunately, the question of how long convergence will take is not
  655.    amenable to quite so simple an answer.  Before going any further, it
  656.    will be useful to look at an example (taken from [2]).  Note, by the
  657.    way, that what we are about to show will not happen with a correct
  658.    implementation of RIP.  We are trying to show why certain features
  659.    are needed.  Note that the letters correspond to gateways, and the
  660.    lines to networks.
  661.  
  662.             A-----B
  663.              \   / \
  664.               \ /  |
  665.                C  /    all networks have cost 1, except
  666.                | /     for the direct link from C to D, which
  667.                |/      has cost 10
  668.                D
  669.                |<=== target network
  670.  
  671.  
  672.  
  673.  
  674. Hedrick                                                        [Page 12]
  675.  
  676. RFC 1058              Routing Information Protocol             June 1988
  677.  
  678.  
  679.    Each gateway will have a table showing a route to each network.
  680.  
  681.    However, for purposes of this illustration, we show only the routes
  682.    from each gateway to the network marked at the bottom of the diagram.
  683.  
  684.             D:  directly connected, metric 1
  685.             B:  route via D, metric 2
  686.             C:  route via B, metric 3
  687.             A:  route via B, metric 3
  688.  
  689.    Now suppose that the link from B to D fails.  The routes should now
  690.    adjust to use the link from C to D.  Unfortunately, it will take a
  691.    while for this to this to happen.  The routing changes start when B
  692.    notices that the route to D is no longer usable.  For simplicity, the
  693.    chart below assumes that all gateways send updates at the same time.
  694.    The chart shows the metric for the target network, as it appears in
  695.    the routing table at each gateway.
  696.  
  697.         time ------>
  698.  
  699.         D: dir, 1   dir, 1   dir, 1   dir, 1  ...  dir, 1   dir, 1
  700.         B: unreach  C,   4   C,   5   C,   6       C,  11   C,  12
  701.         C: B,   3   A,   4   A,   5   A,   6       A,  11   D,  11
  702.         A: B,   3   C,   4   C,   5   C,   6       C,  11   C,  12
  703.  
  704.         dir = directly connected
  705.         unreach = unreachable
  706.  
  707.    Here's the problem:  B is able to get rid of its failed route using a
  708.    timeout mechanism.  But vestiges of that route persist in the system
  709.    for a long time.  Initially, A and C still think they can get to D
  710.    via B.  So, they keep sending updates listing metrics of 3.  In the
  711.    next iteration, B will then claim that it can get to D via either A
  712.    or C.  Of course, it can't.  The routes being claimed by A and C are
  713.    now gone, but they have no way of knowing that yet.  And even when
  714.    they discover that their routes via B have gone away, they each think
  715.    there is a route available via the other.  Eventually the system
  716.    converges, as all the mathematics claims it must.  But it can take
  717.    some time to do so.  The worst case is when a network becomes
  718.    completely inaccessible from some part of the system.  In that case,
  719.    the metrics may increase slowly in a pattern like the one above until
  720.    they finally reach infinity.  For this reason, the problem is called
  721.    "counting to infinity".
  722.  
  723.    You should now see why "infinity" is chosen to be as small as
  724.    possible.  If a network becomes completely inaccessible, we want
  725.    counting to infinity to be stopped as soon as possible.  Infinity
  726.    must be large enough that no real route is that big.  But it
  727.  
  728.  
  729.  
  730. Hedrick                                                        [Page 13]
  731.  
  732. RFC 1058              Routing Information Protocol             June 1988
  733.  
  734.  
  735.    shouldn't be any bigger than required.  Thus the choice of infinity
  736.    is a tradeoff between network size and speed of convergence in case
  737.    counting to infinity happens.  The designers of RIP believed that the
  738.    protocol was unlikely to be practical for networks with a diameter
  739.    larger than 15.
  740.  
  741.    There are several things that can be done to prevent problems like
  742.    this.  The ones used by RIP are called "split horizon with poisoned
  743.    reverse", and "triggered updates".
  744.  
  745. 2.2.1. Split horizon
  746.  
  747.    Note that some of the problem above is caused by the fact that A and
  748.    C are engaged in a pattern of mutual deception.  Each claims to be
  749.    able to get to D via the other.  This can be prevented by being a bit
  750.    more careful about where information is sent.  In particular, it is
  751.    never useful to claim reachability for a destination network to the
  752.    neighbor(s) from which the route was learned.  "Split horizon" is a
  753.    scheme for avoiding problems caused by including routes in updates
  754.    sent to the gateway from which they were learned.  The "simple split
  755.    horizon" scheme omits routes learned from one neighbor in updates
  756.    sent to that neighbor.  "Split horizon with poisoned reverse"
  757.    includes such routes in updates, but sets their metrics to infinity.
  758.  
  759.    If A thinks it can get to D via C, its messages to C should indicate
  760.    that D is unreachable.  If the route through C is real, then C either
  761.    has a direct connection to D, or a connection through some other
  762.    gateway.  C's route can't possibly go back to A, since that forms a
  763.    loop.  By telling C that D is unreachable, A simply guards against
  764.    the possibility that C might get confused and believe that there is a
  765.    route through A.  This is obvious for a point to point line.  But
  766.    consider the possibility that A and C are connected by a broadcast
  767.    network such as an Ethernet, and there are other gateways on that
  768.    network.  If A has a route through C, it should indicate that D is
  769.    unreachable when talking to any other gateway on that network.  The
  770.    other gateways on the network can get to C themselves.  They would
  771.    never need to get to C via A.  If A's best route is really through C,
  772.    no other gateway on that network needs to know that A can reach D.
  773.    This is fortunate, because it means that the same update message that
  774.    is used for C can be used for all other gateways on the same network.
  775.    Thus, update messages can be sent by broadcast.
  776.  
  777.    In general, split horizon with poisoned reverse is safer than simple
  778.    split horizon.  If two gateways have routes pointing at each other,
  779.    advertising reverse routes with a metric of 16 will break the loop
  780.    immediately.  If the reverse routes are simply not advertised, the
  781.    erroneous routes will have to be eliminated by waiting for a timeout.
  782.    However, poisoned reverse does have a disadvantage: it increases the
  783.  
  784.  
  785.  
  786. Hedrick                                                        [Page 14]
  787.  
  788. RFC 1058              Routing Information Protocol             June 1988
  789.  
  790.  
  791.    size of the routing messages.  Consider the case of a campus backbone
  792.    connecting a number of different buildings.  In each building, there
  793.    is a gateway connecting the backbone to a local network.  Consider
  794.    what routing updates those gateways should broadcast on the backbone
  795.    network.  All that the rest of the network really needs to know about
  796.    each gateway is what local networks it is connected to.  Using simple
  797.    split horizon, only those routes would appear in update messages sent
  798.    by the gateway to the backbone network.  If split horizon with
  799.    poisoned reverse is used, the gateway must mention all routes that it
  800.    learns from the backbone, with metrics of 16.  If the system is
  801.    large, this can result in a large update message, almost all of whose
  802.    entries indicate unreachable networks.
  803.  
  804.    In a static sense, advertising reverse routes with a metric of 16
  805.    provides no additional information.  If there are many gateways on
  806.    one broadcast network, these extra entries can use significant
  807.    bandwidth.  The reason they are there is to improve dynamic behavior.
  808.    When topology changes, mentioning routes that should not go through
  809.    the gateway as well as those that should can speed up convergence.
  810.    However, in some situations, network managers may prefer to accept
  811.    somewhat slower convergence in order to minimize routing overhead.
  812.    Thus implementors may at their option implement simple split horizon
  813.    rather than split horizon with poisoned reverse, or they may provide
  814.    a configuration option that allows the network manager to choose
  815.    which behavior to use.  It is also permissible to implement hybrid
  816.    schemes that advertise some reverse routes with a metric of 16 and
  817.    omit others.  An example of such a scheme would be to use a metric of
  818.    16 for reverse routes for a certain period of time after routing
  819.    changes involving them, and thereafter omitting them from updates.
  820.  
  821. 2.2.2. Triggered updates
  822.  
  823.    Split horizon with poisoned reverse will prevent any routing loops
  824.    that involve only two gateways.  However, it is still possible to end
  825.    up with patterns in which three gateways are engaged in mutual
  826.    deception.  For example, A may believe it has a route through B, B
  827.    through C, and C through A.  Split horizon cannot stop such a loop.
  828.    This loop will only be resolved when the metric reaches infinity and
  829.    the network involved is then declared unreachable.  Triggered updates
  830.    are an attempt to speed up this convergence.  To get triggered
  831.    updates, we simply add a rule that whenever a gateway changes the
  832.    metric for a route, it is required to send update messages almost
  833.    immediately, even if it is not yet time for one of the regular update
  834.    message.  (The timing details will differ from protocol to protocol.
  835.    Some distance vector protocols, including RIP, specify a small time
  836.    delay, in order to avoid having triggered updates generate excessive
  837.    network traffic.)  Note how this combines with the rules for
  838.    computing new metrics.  Suppose a gateway's route to destination N
  839.  
  840.  
  841.  
  842. Hedrick                                                        [Page 15]
  843.  
  844. RFC 1058              Routing Information Protocol             June 1988
  845.  
  846.  
  847.    goes through gateway G.  If an update arrives from G itself, the
  848.    receiving gateway is required to believe the new information, whether
  849.    the new metric is higher or lower than the old one.  If the result is
  850.    a change in metric, then the receiving gateway will send triggered
  851.    updates to all the hosts and gateways directly connected to it.  They
  852.    in turn may each send updates to their neighbors.  The result is a
  853.    cascade of triggered updates.  It is easy to show which gateways and
  854.    hosts are involved in the cascade.  Suppose a gateway G times out a
  855.    route to destination N.  G will send triggered updates to all of its
  856.    neighbors.  However, the only neighbors who will believe the new
  857.    information are those whose routes for N go through G.  The other
  858.    gateways and hosts will see this as information about a new route
  859.    that is worse than the one they are already using, and ignore it.
  860.    The neighbors whose routes go through G will update their metrics and
  861.    send triggered updates to all of their neighbors.  Again, only those
  862.    neighbors whose routes go through them will pay attention.  Thus, the
  863.    triggered updates will propagate backwards along all paths leading to
  864.    gateway G, updating the metrics to infinity.  This propagation will
  865.    stop as soon as it reaches a portion of the network whose route to
  866.    destination N takes some other path.
  867.  
  868.    If the system could be made to sit still while the cascade of
  869.    triggered updates happens, it would be possible to prove that
  870.    counting to infinity will never happen.  Bad routes would always be
  871.    removed immediately, and so no routing loops could form.
  872.  
  873.    Unfortunately, things are not so nice.  While the triggered updates
  874.    are being sent, regular updates may be happening at the same time.
  875.    Gateways that haven't received the triggered update yet will still be
  876.    sending out information based on the route that no longer exists.  It
  877.    is possible that after the triggered update has gone through a
  878.    gateway, it might receive a normal update from one of these gateways
  879.    that hasn't yet gotten the word.  This could reestablish an orphaned
  880.    remnant of the faulty route.  If triggered updates happen quickly
  881.    enough, this is very unlikely.  However, counting to infinity is
  882.    still possible.
  883.  
  884. 3. Specifications for the protocol
  885.  
  886.    RIP is intended to allow hosts and gateways to exchange information
  887.    for computing routes through an IP-based network.  RIP is a distance
  888.    vector protocol.  Thus, it has the general features described in
  889.    section 2.  RIP may be implemented by both hosts and gateways.  As in
  890.    most IP documentation, the term "host" will be used here to cover
  891.    either.  RIP is used to convey information about routes to
  892.    "destinations", which may be individual hosts, networks, or a special
  893.    destination used to convey a default route.
  894.  
  895.  
  896.  
  897.  
  898. Hedrick                                                        [Page 16]
  899.  
  900. RFC 1058              Routing Information Protocol             June 1988
  901.  
  902.  
  903.    Any host that uses RIP is assumed to have interfaces to one or more
  904.    networks.  These are referred to as its "directly-connected
  905.    networks".  The protocol relies on access to certain information
  906.    about each of these networks.  The most important is its metric or
  907.    "cost".  The metric of a network is an integer between 1 and 15
  908.    inclusive.  It is set in some manner not specified in this protocol.
  909.    Most existing implementations always use a metric of 1.  New
  910.    implementations should allow the system administrator to set the cost
  911.    of each network.  In addition to the cost, each network will have an
  912.    IP network number and a subnet mask associated with it.  These are to
  913.    be set by the system administrator in a manner not specified in this
  914.    protocol.
  915.  
  916.    Note that the rules specified in section 3.2 assume that there is a
  917.    single subnet mask applying to each IP network, and that only the
  918.    subnet masks for directly-connected networks are known.  There may be
  919.    systems that use different subnet masks for different subnets within
  920.    a single network.  There may also be instances where it is desirable
  921.    for a system to know the subnets masks of distant networks.  However,
  922.    such situations will require modifications of the rules which govern
  923.    the spread of subnet information.  Such modifications raise issues of
  924.    interoperability, and thus must be viewed as modifying the protocol.
  925.  
  926.    Each host that implements RIP is assumed to have a routing table.
  927.    This table has one entry for every destination that is reachable
  928.    through the system described by RIP.  Each entry contains at least
  929.    the following information:
  930.  
  931.       - The IP address of the destination.
  932.  
  933.       - A metric, which represents the total cost of getting a
  934.         datagram from the host to that destination.  This metric is
  935.         the sum of the costs associated with the networks that
  936.         would be traversed in getting to the destination.
  937.  
  938.       - The IP address of the next gateway along the path to the
  939.         destination.  If the destination is on one of the
  940.         directly-connected networks, this item is not needed.
  941.  
  942.       - A flag to indicate that information about the route has
  943.         changed recently.  This will be referred to as the "route
  944.         change flag."
  945.  
  946.       - Various timers associated with the route.  See section 3.3
  947.         for more details on them.
  948.  
  949.    The entries for the directly-connected networks are set up by the
  950.    host, using information gathered by means not specified in this
  951.  
  952.  
  953.  
  954. Hedrick                                                        [Page 17]
  955.  
  956. RFC 1058              Routing Information Protocol             June 1988
  957.  
  958.  
  959.    protocol.  The metric for a directly-connected network is set to the
  960.    cost of that network.  In existing RIP implementations, 1 is always
  961.    used for the cost.  In that case, the RIP metric reduces to a simple
  962.    hop-count.  More complex metrics may be used when it is desirable to
  963.    show preference for some networks over others, for example because of
  964.    differences in bandwidth or reliability.
  965.  
  966.    Implementors may also choose to allow the system administrator to
  967.    enter additional routes.  These would most likely be routes to hosts
  968.    or networks outside the scope of the routing system.
  969.  
  970.    Entries for destinations other these initial ones are added and
  971.    updated by the algorithms described in the following sections.
  972.  
  973.    In order for the protocol to provide complete information on routing,
  974.    every gateway in the system must participate in it.  Hosts that are
  975.    not gateways need not participate, but many implementations make
  976.    provisions for them to listen to routing information in order to
  977.    allow them to maintain their routing tables.
  978.  
  979. 3.1. Message formats
  980.  
  981.    RIP is a UDP-based protocol.  Each host that uses RIP has a routing
  982.    process that sends and receives datagrams on UDP port number 520.
  983.    All communications directed at another host's RIP processor are sent
  984.    to port 520.  All routing update messages are sent from port 520.
  985.    Unsolicited routing update messages have both the source and
  986.    destination port equal to 520.  Those sent in response to a request
  987.    are sent to the port from which the request came.  Specific queries
  988.    and debugging requests may be sent from ports other than 520, but
  989.    they are directed to port 520 on the target machine.
  990.  
  991.    There are provisions in the protocol to allow "silent" RIP processes.
  992.    A silent process is one that normally does not send out any messages.
  993.    However, it listens to messages sent by others.  A silent RIP might
  994.    be used by hosts that do not act as gateways, but wish to listen to
  995.    routing updates in order to monitor local gateways and to keep their
  996.    internal routing tables up to date.  (See [5] for a discussion of
  997.    various ways that hosts can keep track of network topology.)  A
  998.    gateway that has lost contact with all but one of its networks might
  999.    choose to become silent, since it is effectively no longer a gateway.
  1000.  
  1001.    However, this should not be done if there is any chance that
  1002.    neighboring gateways might depend upon its messages to detect that
  1003.    the failed network has come back into operation.  (The 4BSD routed
  1004.    program uses routing packets to monitor the operation of point-to-
  1005.    point links.)
  1006.  
  1007.  
  1008.  
  1009.  
  1010. Hedrick                                                        [Page 18]
  1011.  
  1012. RFC 1058              Routing Information Protocol             June 1988
  1013.  
  1014.  
  1015.    The packet format is shown in Figure 1.
  1016.  
  1017.       Format of datagrams containing network information.  Field sizes
  1018.       are given in octets.  Unless otherwise specified, fields contain
  1019.       binary integers, in normal Internet order with the most-significant
  1020.       octet first.  Each tick mark represents one bit.
  1021.  
  1022.        0                   1                   2                   3 3
  1023.        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
  1024.       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1025.       | command (1)   | version (1)   |      must be zero (2)         |
  1026.       +---------------+---------------+-------------------------------+
  1027.       | address family identifier (2) |      must be zero (2)         |
  1028.       +-------------------------------+-------------------------------+
  1029.       |                         IP address (4)                        |
  1030.       +---------------------------------------------------------------+
  1031.       |                        must be zero (4)                       |
  1032.       +---------------------------------------------------------------+
  1033.       |                        must be zero (4)                       |
  1034.       +---------------------------------------------------------------+
  1035.       |                          metric (4)                           |
  1036.       +---------------------------------------------------------------+
  1037.                                       .
  1038.                                       .
  1039.                                       .
  1040.       The portion of the datagram from address family identifier through
  1041.       metric may appear up to 25 times.  IP address is the usual 4-octet
  1042.       Internet address, in network order.
  1043.  
  1044.                           Figure 1.   Packet format
  1045.  
  1046.    Every datagram contains a command, a version number, and possible
  1047.    arguments.  This document describes version 1 of the protocol.
  1048.    Details of processing the version number are described in section
  1049.    3.4.  The command field is used to specify the purpose of this
  1050.    datagram.  Here is a summary of the commands implemented in version
  1051.    1:
  1052.  
  1053.    1 - request     A request for the responding system to send all or
  1054.                    part of its routing table.
  1055.  
  1056.    2 - response    A message containing all or part of the sender's
  1057.                    routing table.  This message may be sent in response
  1058.                    to a request or poll, or it may be an update message
  1059.                    generated by the sender.
  1060.  
  1061.    3 - traceon     Obsolete.  Messages containing this command are to be
  1062.                    ignored.
  1063.  
  1064.  
  1065.  
  1066. Hedrick                                                        [Page 19]
  1067.  
  1068. RFC 1058              Routing Information Protocol             June 1988
  1069.  
  1070.  
  1071.    4 - traceoff    Obsolete.  Messages containing this command are to be
  1072.                    ignored.
  1073.  
  1074.    5 - reserved    This value is used by Sun Microsystems for its own
  1075.                    purposes.  If new commands are added in any
  1076.                    succeeding version, they should begin with 6.
  1077.                    Messages containing this command may safely be
  1078.                    ignored by implementations that do not choose to
  1079.                    respond to it.
  1080.  
  1081.    For request and response, the rest of the datagram contains a list of
  1082.    destinations, with information about each.  Each entry in this list
  1083.    contains a destination network or host, and the metric for it.  The
  1084.    packet format is intended to allow RIP to carry routing information
  1085.    for several different protocols.  Thus, each entry has an address
  1086.    family identifier to indicate what type of address is specified in
  1087.    that entry.  This document only describes routing for Internet
  1088.    networks.  The address family identifier for IP is 2.  None of the
  1089.    RIP implementations available to the author implement any other type
  1090.    of address.  However, to allow for future development,
  1091.    implementations are required to skip entries that specify address
  1092.    families that are not supported by the implementation.  (The size of
  1093.    these entries will be the same as the size of an entry specifying an
  1094.    IP address.) Processing of the message continues normally after any
  1095.    unsupported entries are skipped.  The IP address is the usual
  1096.    Internet address, stored as 4 octets in network order.  The metric
  1097.    field must contain a value between 1 and 15 inclusive, specifying the
  1098.    current metric for the destination, or the value 16, which indicates
  1099.    that the destination is not reachable.  Each route sent by a gateway
  1100.    supercedes any previous route to the same destination from the same
  1101.    gateway.
  1102.  
  1103.    The maximum datagram size is 512 octets.  This includes only the
  1104.    portions of the datagram described above.  It does not count the IP
  1105.    or UDP headers.  The commands that involve network information allow
  1106.    information to be split across several datagrams.  No special
  1107.    provisions are needed for continuations, since correct results will
  1108.    occur if the datagrams are processed individually.
  1109.  
  1110. 3.2. Addressing considerations
  1111.  
  1112.    As indicated in section 2, distance vector routing can be used to
  1113.    describe routes to individual hosts or to networks.  The RIP protocol
  1114.    allows either of these possibilities.  The destinations appearing in
  1115.    request and response messages can be networks, hosts, or a special
  1116.    code used to indicate a default address.  In general, the kinds of
  1117.    routes actually used will depend upon the routing strategy used for
  1118.    the particular network.  Many networks are set up so that routing
  1119.  
  1120.  
  1121.  
  1122. Hedrick                                                        [Page 20]
  1123.  
  1124. RFC 1058              Routing Information Protocol             June 1988
  1125.  
  1126.  
  1127.    information for individual hosts is not needed.  If every host on a
  1128.    given network or subnet is accessible through the same gateways, then
  1129.    there is no reason to mention individual hosts in the routing tables.
  1130.    However, networks that include point to point lines sometimes require
  1131.    gateways to keep track of routes to certain hosts.  Whether this
  1132.    feature is required depends upon the addressing and routing approach
  1133.    used in the system.  Thus, some implementations may choose not to
  1134.    support host routes.  If host routes are not supported, they are to
  1135.    be dropped when they are received in response messages.  (See section
  1136.    3.4.2.)
  1137.  
  1138.    The RIP packet formats do not distinguish among various types of
  1139.    address.  Fields that are labeled "address" can contain any of the
  1140.    following:
  1141.  
  1142.       host address
  1143.       subnet number
  1144.       network number
  1145.       0, indicating a default route
  1146.  
  1147.    Entities that use RIP are assumed to use the most specific
  1148.    information available when routing a datagram.  That is, when routing
  1149.    a datagram, its destination address must first be checked against the
  1150.    list of host addresses.  Then it must be checked to see whether it
  1151.    matches any known subnet or network number.  Finally, if none of
  1152.    these match, the default route is used.
  1153.  
  1154.    When a host evaluates information that it receives via RIP, its
  1155.    interpretation of an address depends upon whether it knows the subnet
  1156.    mask that applies to the net.  If so, then it is possible to
  1157.    determine the meaning of the address.  For example, consider net
  1158.    128.6.  It has a subnet mask of 255.255.255.0.  Thus 128.6.0.0 is a
  1159.    network number, 128.6.4.0 is a subnet number, and 128.6.4.1 is a host
  1160.    address.  However, if the host does not know the subnet mask,
  1161.    evaluation of an address may be ambiguous.  If there is a non-zero
  1162.    host part, there is no clear way to determine whether the address
  1163.    represents a subnet number or a host address.  As a subnet number
  1164.    would be useless without the subnet mask, addresses are assumed to
  1165.    represent hosts in this situation.  In order to avoid this sort of
  1166.    ambiguity, hosts must not send subnet routes to hosts that cannot be
  1167.    expected to know the appropriate subnet mask.  Normally hosts only
  1168.    know the subnet masks for directly-connected networks.  Therefore,
  1169.    unless special provisions have been made, routes to a subnet must not
  1170.    be sent outside the network of which the subnet is a part.
  1171.  
  1172.    This filtering is carried out by the gateways at the "border" of the
  1173.    subnetted network.  These are gateways that connect that network with
  1174.    some other network.  Within the subnetted network, each subnet is
  1175.  
  1176.  
  1177.  
  1178. Hedrick                                                        [Page 21]
  1179.  
  1180. RFC 1058              Routing Information Protocol             June 1988
  1181.  
  1182.  
  1183.    treated as an individual network.  Routing entries for each subnet
  1184.    are circulated by RIP.  However, border gateways send only a single
  1185.    entry for the network as a whole to hosts in other networks.  This
  1186.    means that a border gateway will send different information to
  1187.    different neighbors.  For neighbors connected to the subnetted
  1188.    network, it generates a list of all subnets to which it is directly
  1189.    connected, using the subnet number.  For neighbors connected to other
  1190.    networks, it makes a single entry for the network as a whole, showing
  1191.    the metric associated with that network.  (This metric would normally
  1192.    be the smallest metric for the subnets to which the gateway is
  1193.    attached.)
  1194.  
  1195.    Similarly, border gateways must not mention host routes for hosts
  1196.    within one of the directly-connected networks in messages to other
  1197.    networks.  Those routes will be subsumed by the single entry for the
  1198.    network as a whole.  We do not specify what to do with host routes
  1199.    for "distant" hosts (i.e., hosts not part of one of the directly-
  1200.    connected networks).  Generally, these routes indicate some host that
  1201.    is reachable via a route that does not support other hosts on the
  1202.    network of which the host is a part.
  1203.  
  1204.    The special address 0.0.0.0 is used to describe a default route.  A
  1205.    default route is used when it is not convenient to list every
  1206.    possible network in the RIP updates, and when one or more closely-
  1207.    connected gateways in the system are prepared to handle traffic to
  1208.    the networks that are not listed explicitly.  These gateways should
  1209.    create RIP entries for the address 0.0.0.0, just as if it were a
  1210.    network to which they are connected.  The decision as to how gateways
  1211.    create entries for 0.0.0.0 is left to the implementor.  Most
  1212.    commonly, the system administrator will be provided with a way to
  1213.    specify which gateways should create entries for 0.0.0.0.  However,
  1214.    other mechanisms are possible.  For example, an implementor might
  1215.    decide that any gateway that speaks EGP should be declared to be a
  1216.    default gateway.  It may be useful to allow the network administrator
  1217.    to choose the metric to be used in these entries.  If there is more
  1218.    than one default gateway, this will make it possible to express a
  1219.    preference for one over the other.  The entries for 0.0.0.0 are
  1220.    handled by RIP in exactly the same manner as if there were an actual
  1221.    network with this address.  However, the entry is used to route any
  1222.    datagram whose destination address does not match any other network
  1223.    in the table.  Implementations are not required to support this
  1224.    convention.  However, it is strongly recommended.  Implementations
  1225.    that do not support 0.0.0.0 must ignore entries with this address.
  1226.    In such cases, they must not pass the entry on in their own RIP
  1227.    updates.  System administrators should take care to make sure that
  1228.    routes to 0.0.0.0 do not propagate further than is intended.
  1229.    Generally, each autonomous system has its own preferred default
  1230.    gateway.  Thus, routes involving 0.0.0.0 should generally not leave
  1231.  
  1232.  
  1233.  
  1234. Hedrick                                                        [Page 22]
  1235.  
  1236. RFC 1058              Routing Information Protocol             June 1988
  1237.  
  1238.  
  1239.    the boundary of an autonomous system.  The mechanisms for enforcing
  1240.    this are not specified in this document.
  1241.  
  1242. 3.3. Timers
  1243.  
  1244.    This section describes all events that are triggered by timers.
  1245.  
  1246.    Every 30 seconds, the output process is instructed to generate a
  1247.    complete response to every neighboring gateway.  When there are many
  1248.    gateways on a single network, there is a tendency for them to
  1249.    synchronize with each other such that they all issue updates at the
  1250.    same time.  This can happen whenever the 30 second timer is affected
  1251.    by the processing load on the system.  It is undesirable for the
  1252.    update messages to become synchronized, since it can lead to
  1253.    unnecessary collisions on broadcast networks.  Thus, implementations
  1254.    are required to take one of two precautions.
  1255.  
  1256.       - The 30-second updates are triggered by a clock whose rate
  1257.         is not affected by system load or the time required to
  1258.         service the previous update timer.
  1259.  
  1260.       - The 30-second timer is offset by addition of a small random
  1261.         time each time it is set.
  1262.  
  1263.    There are two timers associated with each route, a "timeout" and a
  1264.    "garbage-collection time".  Upon expiration of the timeout, the route
  1265.    is no longer valid.  However, it is retained in the table for a short
  1266.    time, so that neighbors can be notified that the route has been
  1267.    dropped.  Upon expiration of the garbage-collection timer, the route
  1268.    is finally removed from the tables.
  1269.  
  1270.    The timeout is initialized when a route is established, and any time
  1271.    an update message is received for the route.  If 180 seconds elapse
  1272.    from the last time the timeout was initialized, the route is
  1273.    considered to have expired, and the deletion process which we are
  1274.    about to describe is started for it.
  1275.  
  1276.    Deletions can occur for one of two reasons: (1) the timeout expires,
  1277.    or (2) the metric is set to 16 because of an update received from the
  1278.    current gateway.  (See section 3.4.2 for a discussion processing
  1279.    updates from other gateways.)  In either case, the following events
  1280.    happen:
  1281.  
  1282.       - The garbage-collection timer is set for 120 seconds.
  1283.  
  1284.       - The metric for the route is set to 16 (infinity).  This
  1285.         causes the route to be removed from service.
  1286.  
  1287.  
  1288.  
  1289.  
  1290. Hedrick                                                        [Page 23]
  1291.  
  1292. RFC 1058              Routing Information Protocol             June 1988
  1293.  
  1294.  
  1295.       - A flag is set noting that this entry has been changed, and
  1296.         the output process is signalled to trigger a response.
  1297.  
  1298.    Until the garbage-collection timer expires, the route is included in
  1299.    all updates sent by this host, with a metric of 16 (infinity).  When
  1300.    the garbage-collection timer expires, the route is deleted from the
  1301.    tables.
  1302.  
  1303.    Should a new route to this network be established while the garbage-
  1304.    collection timer is running, the new route will replace the one that
  1305.    is about to be deleted.  In this case the garbage-collection timer
  1306.    must be cleared.
  1307.  
  1308.    See section 3.5 for a discussion of a delay that is required in
  1309.    carrying out triggered updates.  Although implementation of that
  1310.    delay will require a timer, it is more natural to discuss it in
  1311.    section 3.5 than here.
  1312.  
  1313. 3.4. Input processing
  1314.  
  1315.    This section will describe the handling of datagrams received on UDP
  1316.    port 520.  Before processing the datagrams in detail, certain general
  1317.    format checks must be made.  These depend upon the version number
  1318.    field in the datagram, as follows:
  1319.  
  1320.       0   Datagrams whose version number is zero are to be ignored.
  1321.           These are from a previous version of the protocol, whose
  1322.           packet format was machine-specific.
  1323.  
  1324.       1   Datagrams whose version number is one are to be processed
  1325.           as described in the rest of this specification.  All fields
  1326.           that are described above as "must be zero" are to be checked.
  1327.           If any such field contains a non-zero value, the entire
  1328.           message is to be ignored.
  1329.  
  1330.       >1  Datagrams whose version number are greater than one are
  1331.           to be processed as described in the rest of this
  1332.           specification.  All fields that are described above as
  1333.           "must be zero" are to be ignored.  Future versions of the
  1334.           protocol may put data into these fields.  Version 1
  1335.           implementations are to ignore this extra data and process
  1336.           only the fields specified in this document.
  1337.  
  1338.    After checking the version number and doing any other preliminary
  1339.    checks, processing will depend upon the value in the command field.
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346. Hedrick                                                        [Page 24]
  1347.  
  1348. RFC 1058              Routing Information Protocol             June 1988
  1349.  
  1350.  
  1351. 3.4.1. Request
  1352.  
  1353.    Request is used to ask for a response containing all or part of the
  1354.    host's routing table.  [Note that the term host is used for either
  1355.    host or gateway, in most cases it would be unusual for a non-gateway
  1356.    host to send RIP messages.]  Normally, requests are sent as
  1357.    broadcasts, from a UDP source port of 520.  In this case, silent
  1358.    processes do not respond to the request.  Silent processes are by
  1359.    definition processes for which we normally do not want to see routing
  1360.    information.  However, there may be situations involving gateway
  1361.    monitoring where it is desired to look at the routing table even for
  1362.    a silent process.  In this case, the request should be sent from a
  1363.    UDP port number other than 520.  If a request comes from port 520,
  1364.    silent processes do not respond.  If the request comes from any other
  1365.    port, processes must respond even if they are silent.
  1366.  
  1367.    The request is processed entry by entry.  If there are no entries, no
  1368.    response is given.  There is one special case.  If there is exactly
  1369.    one entry in the request, with an address family identifier of 0
  1370.    (meaning unspecified), and a metric of infinity (i.e., 16 for current
  1371.    implementations), this is a request to send the entire routing table.
  1372.    In that case, a call is made to the output process to send the
  1373.    routing table to the requesting port.
  1374.  
  1375.    Except for this special case, processing is quite simple.  Go down
  1376.    the list of entries in the request one by one.  For each entry, look
  1377.    up the destination in the host's routing database.  If there is a
  1378.    route, put that route's metric in the metric field in the datagram.
  1379.    If there isn't a route to the specified destination, put infinity
  1380.    (i.e., 16) in the metric field in the datagram.  Once all the entries
  1381.    have been filled in, set the command to response and send the
  1382.    datagram back to the port from which it came.
  1383.  
  1384.    Note that there is a difference in handling depending upon whether
  1385.    the request is for a specified set of destinations, or for a complete
  1386.    routing table.  If the request is for a complete host table, normal
  1387.    output processing is done.  This includes split horizon (see section
  1388.    2.2.1) and subnet hiding (section 3.2), so that certain entries from
  1389.    the routing table will not be shown.  If the request is for specific
  1390.    entries, they are looked up in the host table and the information is
  1391.    returned.  No split horizon processing is done, and subnets are
  1392.    returned if requested.  We anticipate that these requests are likely
  1393.    to be used for different purposes.  When a host first comes up, it
  1394.    broadcasts requests on every connected network asking for a complete
  1395.    routing table.  In general, we assume that complete routing tables
  1396.    are likely to be used to update another host's routing table.  For
  1397.    this reason, split horizon and all other filtering must be used.
  1398.    Requests for specific networks are made only by diagnostic software,
  1399.  
  1400.  
  1401.  
  1402. Hedrick                                                        [Page 25]
  1403.  
  1404. RFC 1058              Routing Information Protocol             June 1988
  1405.  
  1406.  
  1407.    and are not used for routing.  In this case, the requester would want
  1408.    to know the exact contents of the routing database, and would not
  1409.    want any information hidden.
  1410.  
  1411. 3.4.2. Response
  1412.  
  1413.    Responses can be received for several different reasons:
  1414.  
  1415.       response to a specific query
  1416.       regular updates
  1417.       triggered updates triggered by a metric change
  1418.  
  1419.    Processing is the same no matter how responses were generated.
  1420.  
  1421.    Because processing of a response may update the host's routing table,
  1422.    the response must be checked carefully for validity.  The response
  1423.    must be ignored if it is not from port 520.  The IP source address
  1424.    should be checked to see whether the datagram is from a valid
  1425.    neighbor.  The source of the datagram must be on a directly-connected
  1426.    network.  It is also worth checking to see whether the response is
  1427.    from one of the host's own addresses.  Interfaces on broadcast
  1428.    networks may receive copies of their own broadcasts immediately.  If
  1429.    a host processes its own output as new input, confusion is likely,
  1430.    and such datagrams must be ignored (except as discussed in the next
  1431.    paragraph).
  1432.  
  1433.    Before actually processing a response, it may be useful to use its
  1434.    presence as input to a process for keeping track of interface status.
  1435.    As mentioned above, we time out a route when we haven't heard from
  1436.    its gateway for a certain amount of time.  This works fine for routes
  1437.    that come from another gateway.  It is also desirable to know when
  1438.    one of our own directly-connected networks has failed.  This document
  1439.    does not specify any particular method for doing this, as such
  1440.    methods depend upon the characteristics of the network and the
  1441.    hardware interface to it.  However, such methods often involve
  1442.    listening for datagrams arriving on the interface.  Arriving
  1443.    datagrams can be used as an indication that the interface is working.
  1444.    However, some caution must be used, as it is possible for interfaces
  1445.    to fail in such a way that input datagrams are received, but output
  1446.    datagrams are never sent successfully.
  1447.  
  1448.    Now that the datagram as a whole has been validated, process the
  1449.    entries in it one by one.  Again, start by doing validation.  If the
  1450.    metric is greater than infinity, ignore the entry.  (This should be
  1451.    impossible, if the other host is working correctly.  Incorrect
  1452.    metrics and other format errors should probably cause alerts or be
  1453.    logged.)  Then look at the destination address.  Check the address
  1454.    family identifier.  If it is not a value which is expected (e.g., 2
  1455.  
  1456.  
  1457.  
  1458. Hedrick                                                        [Page 26]
  1459.  
  1460. RFC 1058              Routing Information Protocol             June 1988
  1461.  
  1462.  
  1463.    for Internet addresses), ignore the entry.  Now check the address
  1464.    itself for various kinds of inappropriate addresses.  Ignore the
  1465.    entry if the address is class D or E, if it is on net 0 (except for
  1466.    0.0.0.0, if we accept default routes) or if it is on net 127 (the
  1467.    loopback network).  Also, test for a broadcast address, i.e.,
  1468.    anything whose host part is all ones on a network that supports
  1469.    broadcast, and ignore any such entry.  If the implementor has chosen
  1470.    not to support host routes (see section 3.2), check to see whether
  1471.    the host portion of the address is non-zero; if so, ignore the entry.
  1472.  
  1473.    Recall that the address field contains a number of unused octets.  If
  1474.    the version number of the datagram is 1, they must also be checked.
  1475.    If any of them is nonzero, the entry is to be ignored.  (Many of
  1476.    these cases indicate that the host from which the message came is not
  1477.    working correctly.  Thus some form of error logging or alert should
  1478.    be triggered.)
  1479.  
  1480.    Update the metric by adding the cost of the network on which the
  1481.    message arrived.  If the result is greater than 16, use 16.  That is,
  1482.  
  1483.       metric = MIN (metric + cost, 16)
  1484.  
  1485.    Now look up the address to see whether this is already a route for
  1486.    it.  In general, if not, we want to add one.  However, there are
  1487.    various exceptions.  If the metric is infinite, don't add an entry.
  1488.    (We would update an existing one, but we don't add new entries with
  1489.    infinite metric.)  We want to avoid adding routes to hosts if the
  1490.    host is part of a net or subnet for which we have at least as good a
  1491.    route.  If neither of these exceptions applies, add a new entry to
  1492.    the routing database.  This includes the following actions:
  1493.  
  1494.       - Set the destination and metric to those from the datagram.
  1495.  
  1496.       - Set the gateway to be the host from which the datagram
  1497.         came.
  1498.  
  1499.       - Initialize the timeout for the route. If the garbage-
  1500.         collection timer is running for this route, stop it. (See
  1501.         section 3.3 for a discussion of the timers.)
  1502.  
  1503.       - Set the route change flag, and signal the output process to
  1504.         trigger an update (see 3.5).
  1505.  
  1506.    If there is an existing route, first compare gateways.  If this
  1507.    datagram is from the same gateway as the existing route, reinitialize
  1508.    the timeout.  Next compare metrics.  If the datagram is from the same
  1509.    gateway as the existing route and the new metric is different than
  1510.    the old one, or if the new metric is lower than the old one, do the
  1511.  
  1512.  
  1513.  
  1514. Hedrick                                                        [Page 27]
  1515.  
  1516. RFC 1058              Routing Information Protocol             June 1988
  1517.  
  1518.  
  1519.    following actions:
  1520.  
  1521.       - adopt the route from the datagram.  That is, put the new
  1522.         metric in, and set the gateway to be the host from which
  1523.         the datagram came.
  1524.  
  1525.       - Initialize the timeout for the route.
  1526.  
  1527.       - Set the route change flag, and signal the output process to
  1528.         trigger an update (see 3.5).
  1529.  
  1530.       - If the new metric is 16 (infinity), the deletion process is
  1531.         started.
  1532.  
  1533.    If the new metric is 16 (infinity), this starts the process for
  1534.    deleting the route.  The route is no longer used for routing packets,
  1535.    and the deletion timer is started (see section 3.3).  Note that a
  1536.    deletion is started only when the metric is first set to 16.  If the
  1537.    metric was already 16, then a new deletion is not started.  (Starting
  1538.    a deletion sets a timer.  The concern is that we do not want to reset
  1539.    the timer every 30 seconds, as new messages arrive with an infinite
  1540.    metric.)
  1541.  
  1542.    If the new metric is the same as the old one, it is simplest to do
  1543.    nothing further (beyond reinitializing the timeout, as specified
  1544.    above).  However, the 4BSD routed uses an additional heuristic here.
  1545.    Normally, it is senseless to change to a route with the same metric
  1546.    as the existing route but a different gateway.  If the existing route
  1547.    is showing signs of timing out, though, it may be better to switch to
  1548.    an equally-good alternative route immediately, rather than waiting
  1549.    for the timeout to happen.  (See section 3.3 for a discussion of
  1550.    timeouts.)  Therefore, if the new metric is the same as the old one,
  1551.    routed looks at the timeout for the existing route.  If it is at
  1552.    least halfway to the expiration point, routed switches to the new
  1553.    route.  That is, the gateway is changed to the source of the current
  1554.    message.  This heuristic is optional.
  1555.  
  1556.    Any entry that fails these tests is ignored, as it is no better than
  1557.    the current route.
  1558.  
  1559. 3.5. Output Processing
  1560.  
  1561.    This section describes the processing used to create response
  1562.    messages that contain all or part of the routing table.  This
  1563.    processing may be triggered in any of the following ways:
  1564.  
  1565.       - by input processing when a request is seen.  In this case,
  1566.         the resulting message is sent to only one destination.
  1567.  
  1568.  
  1569.  
  1570. Hedrick                                                        [Page 28]
  1571.  
  1572. RFC 1058              Routing Information Protocol             June 1988
  1573.  
  1574.  
  1575.       - by the regular routing update.  Every 30 seconds, a
  1576.         response containing the whole routing table is sent to
  1577.         every neighboring gateway.  (See section 3.3.)
  1578.  
  1579.       - by triggered updates.  Whenever the metric for a route is
  1580.         changed, an update is triggered.  (The update may be
  1581.         delayed; see below.)
  1582.  
  1583.    Before describing the way a message is generated for each directly-
  1584.    connected network, we will comment on how the destinations are chosen
  1585.    for the latter two cases.  Normally, when a response is to be sent to
  1586.    all destinations (that is, either the regular update or a triggered
  1587.    update is being prepared), a response is sent to the host at the
  1588.    opposite end of each connected point-to-point link, and a response is
  1589.    broadcast on all connected networks that support broadcasting.  Thus,
  1590.    one response is prepared for each directly-connected network and sent
  1591.    to the corresponding (destination or broadcast) address.  In most
  1592.    cases, this reaches all neighboring gateways.  However, there are
  1593.    some cases where this may not be good enough.  This may involve a
  1594.    network that does not support broadcast (e.g., the ARPANET), or a
  1595.    situation involving dumb gateways.  In such cases, it may be
  1596.    necessary to specify an actual list of neighboring hosts and
  1597.    gateways, and send a datagram to each one explicitly.  It is left to
  1598.    the implementor to determine whether such a mechanism is needed, and
  1599.    to define how the list is specified.
  1600.  
  1601.    Triggered updates require special handling for two reasons.  First,
  1602.    experience shows that triggered updates can cause excessive loads on
  1603.    networks with limited capacity or with many gateways on them.  Thus
  1604.    the protocol requires that implementors include provisions to limit
  1605.    the frequency of triggered updates.  After a triggered update is
  1606.    sent, a timer should be set for a random time between 1 and 5
  1607.    seconds.  If other changes that would trigger updates occur before
  1608.    the timer expires, a single update is triggered when the timer
  1609.    expires, and the timer is then set to another random value between 1
  1610.    and 5 seconds.  Triggered updates may be suppressed if a regular
  1611.    update is due by the time the triggered update would be sent.
  1612.  
  1613.    Second, triggered updates do not need to include the entire routing
  1614.    table.  In principle, only those routes that have changed need to be
  1615.    included.  Thus messages generated as part of a triggered update must
  1616.    include at least those routes that have their route change flag set.
  1617.    They may include additional routes, or all routes, at the discretion
  1618.    of the implementor; however, when full routing updates require
  1619.    multiple packets, sending all routes is strongly discouraged.  When a
  1620.    triggered update is processed, messages should be generated for every
  1621.    directly-connected network.  Split horizon processing is done when
  1622.    generating triggered updates as well as normal updates (see below).
  1623.  
  1624.  
  1625.  
  1626. Hedrick                                                        [Page 29]
  1627.  
  1628. RFC 1058              Routing Information Protocol             June 1988
  1629.  
  1630.  
  1631.    If, after split horizon processing, a changed route will appear
  1632.    identical on a network as it did previously, the route need not be
  1633.    sent; if, as a result, no routes need be sent, the update may be
  1634.    omitted on that network.  (If a route had only a metric change, or
  1635.    uses a new gateway that is on the same network as the old gateway,
  1636.    the route will be sent to the network of the old gateway with a
  1637.    metric of infinity both before and after the change.)  Once all of
  1638.    the triggered updates have been generated, the route change flags
  1639.    should be cleared.
  1640.  
  1641.    If input processing is allowed while output is being generated,
  1642.    appropriate interlocking must be done.  The route change flags should
  1643.    not be changed as a result of processing input while a triggered
  1644.    update message is being generated.
  1645.  
  1646.    The only difference between a triggered update and other update
  1647.    messages is the possible omission of routes that have not changed.
  1648.    The rest of the mechanisms about to be described must all apply to
  1649.    triggered updates.
  1650.  
  1651.    Here is how a response datagram is generated for a particular
  1652.    directly-connected network:
  1653.  
  1654.    The IP source address must be the sending host's address on that
  1655.    network.  This is important because the source address is put into
  1656.    routing tables in other hosts.  If an incorrect source address is
  1657.    used, other hosts may be unable to route datagrams.  Sometimes
  1658.    gateways are set up with multiple IP addresses on a single physical
  1659.    interface.  Normally, this means that several logical IP networks are
  1660.    being carried over one physical medium.  In such cases, a separate
  1661.    update message must be sent for each address, with that address as
  1662.    the IP source address.
  1663.  
  1664.    Set the version number to the current version of RIP.  (The version
  1665.    described in this document is 1.)  Set the command to response.  Set
  1666.    the bytes labeled "must be zero" to zero.  Now start filling in
  1667.    entries.
  1668.  
  1669.    To fill in the entries, go down all the routes in the internal
  1670.    routing table.  Recall that the maximum datagram size is 512 bytes.
  1671.    When there is no more space in the datagram, send the current message
  1672.    and start a new one.  If a triggered update is being generated, only
  1673.    entries whose route change flags are set need be included.
  1674.  
  1675.    See the description in Section 3.2 for a discussion of problems
  1676.    raised by subnet and host routes.  Routes to subnets will be
  1677.    meaningless outside the network, and must be omitted if the
  1678.    destination is not on the same subnetted network; they should be
  1679.  
  1680.  
  1681.  
  1682. Hedrick                                                        [Page 30]
  1683.  
  1684. RFC 1058              Routing Information Protocol             June 1988
  1685.  
  1686.  
  1687.    replaced with a single route to the network of which the subnets are
  1688.    a part.  Similarly, routes to hosts must be eliminated if they are
  1689.    subsumed by a network route, as described in the discussion in
  1690.    Section 3.2.
  1691.  
  1692.    If the route passes these tests, then the destination and metric are
  1693.    put into the entry in the output datagram.  Routes must be included
  1694.    in the datagram even if their metrics are infinite.  If the gateway
  1695.    for the route is on the network for which the datagram is being
  1696.    prepared, the metric in the entry is set to 16, or the entire entry
  1697.    is omitted.  Omitting the entry is simple split horizon.  Including
  1698.    an entry with metric 16 is split horizon with poisoned reverse.  See
  1699.    Section 2.2 for a more complete discussion of these alternatives.
  1700.  
  1701. 3.6. Compatibility
  1702.  
  1703.    The protocol described in this document is intended to interoperate
  1704.    with routed and other existing implementations of RIP.  However, a
  1705.    different viewpoint is adopted about when to increment the metric
  1706.    than was used in most previous implementations.  Using the previous
  1707.    perspective, the internal routing table has a metric of 0 for all
  1708.    directly-connected networks.  The cost (which is always 1) is added
  1709.    to the metric when the route is sent in an update message.  By
  1710.    contrast, in this document directly-connected networks appear in the
  1711.    internal routing table with metrics equal to their costs; the metrics
  1712.    are not necessarily 1.  In this document, the cost is added to the
  1713.    metrics when routes are received in update messages.  Metrics from
  1714.    the routing table are sent in update messages without change (unless
  1715.    modified by split horizon).
  1716.  
  1717.    These two viewpoints result in identical update messages being sent.
  1718.    Metrics in the routing table differ by a constant one in the two
  1719.    descriptions.  Thus, there is no difference in effect.  The change
  1720.    was made because the new description makes it easier to handle
  1721.    situations where different metrics are used on directly-attached
  1722.    networks.
  1723.  
  1724.    Implementations that only support network costs of one need not
  1725.    change to match the new style of presentation.  However, they must
  1726.    follow the description given in this document in all other ways.
  1727.  
  1728. 4. Control functions
  1729.  
  1730.    This section describes administrative controls.  These are not part
  1731.    of the protocol per se.  However, experience with existing networks
  1732.    suggests that they are important.  Because they are not a necessary
  1733.    part of the protocol, they are considered optional.  However, we
  1734.    strongly recommend that at least some of them be included in every
  1735.  
  1736.  
  1737.  
  1738. Hedrick                                                        [Page 31]
  1739.  
  1740. RFC 1058              Routing Information Protocol             June 1988
  1741.  
  1742.  
  1743.    implementation.
  1744.  
  1745.    These controls are intended primarily to allow RIP to be connected to
  1746.    networks whose routing may be unstable or subject to errors.  Here
  1747.    are some examples:
  1748.  
  1749.    It is sometimes desirable to limit the hosts and gateways from which
  1750.    information will be accepted.  On occasion, hosts have been
  1751.    misconfigured in such a way that they begin sending inappropriate
  1752.    information.
  1753.  
  1754.    A number of sites limit the set of networks that they allow in update
  1755.    messages.  Organization A may have a connection to organization B
  1756.    that they use for direct communication.  For security or performance
  1757.    reasons A may not be willing to give other organizations access to
  1758.    that connection.  In such cases, A should not include B's networks in
  1759.    updates that A sends to third parties.
  1760.  
  1761.    Here are some typical controls.  Note, however, that the RIP protocol
  1762.    does not require these or any other controls.
  1763.  
  1764.       - a neighbor list - the network administrator should be able
  1765.         to define a list of neighbors for each host.  A host would
  1766.         accept response messages only from hosts on its list of
  1767.         neighbors.
  1768.  
  1769.       - allowing or disallowing specific destinations - the network
  1770.         administrator should be able to specify a list of
  1771.         destination addresses to allow or disallow.  The list would
  1772.         be associated with a particular interface in the incoming
  1773.         or outgoing direction.  Only allowed networks would be
  1774.         mentioned in response messages going out or processed in
  1775.         response messages coming in.  If a list of allowed
  1776.         addresses is specified, all other addresses are disallowed.
  1777.         If a list of disallowed addresses is specified, all other
  1778.         addresses are allowed.
  1779.  
  1780. REFERENCES and BIBLIOGRAPHY
  1781.  
  1782.    [1] Bellman, R. E., "Dynamic Programming", Princeton University
  1783.        Press, Princeton, N.J., 1957.
  1784.  
  1785.    [2] Bertsekas, D. P., and Gallaher, R. G., "Data Networks",
  1786.        Prentice-Hall, Englewood Cliffs, N.J., 1987.
  1787.  
  1788.    [3] Braden, R., and Postel, J., "Requirements for Internet Gateways",
  1789.        USC/Information Sciences Institute, RFC-1009, June 1987.
  1790.  
  1791.  
  1792.  
  1793.  
  1794. Hedrick                                                        [Page 32]
  1795.  
  1796. RFC 1058              Routing Information Protocol             June 1988
  1797.  
  1798.  
  1799.    [4] Boggs, D. R., Shoch, J. F., Taft, E. A., and Metcalfe, R. M.,
  1800.        "Pup: An Internetwork Architecture", IEEE Transactions on
  1801.        Communications, April 1980.
  1802.  
  1803.    [5] Clark, D. D., "Fault Isolation and Recovery," MIT-LCS, RFC-816,
  1804.        July 1982.
  1805.  
  1806.    [6] Ford, L. R. Jr., and Fulkerson, D. R., "Flows in Networks",
  1807.        Princeton University Press, Princeton, N.J., 1962.
  1808.  
  1809.    [7] Xerox Corp., "Internet Transport Protocols", Xerox System
  1810.        Integration Standard XSIS 028112, December 1981.
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850. Hedrick                                                        [Page 33]
  1851.