Routing algorithms tutorial by mstahiri

VIEWS: 869 PAGES: 44

More Info
In order to forward packets correctly, routers must learn the
direction to remote networks.

Two types of routing:

1.   Dynamic routing - information is learned from other routers,
     and routing protocols adjust routes automatically.
2.   Static routing - network administrator configures
     information about remote networks manually. They are used
     to reduce overhead and for security.

Because of the extra administrative requirements, static routing
    does not have the scalability of dynamic routing.
In most networks static routes are often used in conjunction with a
    dynamic routing protocol.
Routing and Routed Protocols
 Routing Protocols allow the routers to communicate with other
                   routers to update and maintain tables.

 Routed Protocols provide enough information in their network
                   layer address to allow packets to be
                   forwarded from one host to another host
                   based on the addressing scheme.
 IP, IPX, AppleTalk

Main Goals of Routing Protocols

     To fill the routing table with current best, loop-free

     To notice when routes in the table are no longer
      valid and remove them from the routing table

     To add new routes or replace lost routes

Routing Protocols – Path Dertemination

1. Path Determination
      Router uses the routing table to determine the best path.

  Routing protocols create and maintain routing tables:

    Simplified routing table.
  The Default router entry
  sends packets for any
  other destinations out S1.

Routing Protocols – Metrics

The value used to determine the best path to the next hop
The metrics that are most commonly used :

   Bandwidth –        The data capacity of a link.
   Delay –            The length of time required to move a packet
                      along each link from source to destination.
   Load –             The amount of activity on a network resource such
                      as a router or a link.
   Reliability –      Usually a reference to the error rate of each
                      network link.
   Hop count –        The number of routers that a packet must travel
                      through before reaching its destination.

Dynamic Routing
     The success of dynamic routing depends on two basic
     router functions:
1.    Maintenance of a routing table
2.    Timely distribution of knowledge, in the form of routing
      updates, to other routers.
Dynamic routing relies on the routing protocol.
Routing Protocols can be Distant Vector or Link-State.

Hybrid protocols (like EIGRP) contain some elements of both.
Different routing protocols use different metrics to determine
    the best route to a network.

Distance Vector Routing Protocols
   distance-vector routing protocol is one of the two major
  classes of routing protocols used in packet-switched
  networks for computer communications, Distance vector
  algorithm is routing algorithm that has information of the
  routers attached to it.

  A distance-vector routing protocol requires that a router
  informs its neighbors of topology changes periodically
  and, in some cases, when a change is detected in the
  topology of a network. distance-vector routing protocols
  have less computational complexity and message
  overhead, A distance-vector routing protocol uses the
  Bellman-Ford algorithm to calculate paths.

Distance Vector Routing Method
The methods used to calculate the best path for a network are different between
different routing protocols but the fundamental features of distance-vector algorithms
are the same across all DV based protocols.

As the name suggests the DV protocol is based on calculating the direction and
distance to any link in a network. The cost of reaching a destination is calculated
using various route metrics. RIP uses the hop count of the destination whereas IGRP
takes into account other information such as node delay and available bandwidth.

Updates are performed periodically in a distance-vector protocol where all or part of
a router's routing table is sent to all its neighbors that are configured to use the same
distance-vector routing protocol. RIP supports cross-platform distance vector routing
whereas IGRP is a Cisco Systems proprietary distance vector routing protocol. Once a
router has this information it is able to amend its own routing table to reflect the
changes and then inform its neighbors of the changes. This process has been
described as ‘routing by rumor’ because routers are relying on the information they
receive from other routers and cannot determine if the information is actually valid
and true. There are a number of features which can be used to help with instability and
inaccurate routing information.                                                        8
Distance Vector Routing Protocols Operation
A router using a distance vector routing protocol does not have the
knowledge of the entire path to a destination network. The router only
knows the direction or interface in which packets should be forwarded
and the distance or how far it is to the destination network

Periodic Updates are sent at regular intervals (30 seconds for RIP and
90 seconds for IGRP). Even if the topology has not changed in several
days, periodic updates continue to be sent to all neighbors.

Entire Routing Table Updates are sent, periodically to all neighbors.
Neighbors receiving these updates must process the entire update to find
pertinent information and discard the rest.

This method is inefficient because the updates not only consume
bandwidth but also consume router CPU resources to process the
updates.                                                             9
      Distance Vector—Sources of Information and
      Discovering Routes                                   
      E0        A           S0         S0        B           S1         S0     C         E0

        Routing Table                    Routing Table                   Routing Table   E0   0         S0      0   S0        0   S0      0      S1      0   E0        0

 Routers discover the best path to destinations from each neighbor

      Distance Vector—Sources of Information and
      Discovering Routes                                   
      E0        A           S0         S0        B           S1         S0     C         E0

        Routing Table                    Routing Table                   Routing Table   E0   0         S0      0    S0        0   S0      0      S1      0    E0        0   S0      1      S1      1    S0        1
                               S0      1

 Routers discover the best path to destinations from each neighbor

      Distance Vector—Sources of Information and
      Discovering Routes                                   
      E0        A           S0         S0        B           S1         S0     C         E0

        Routing Table                    Routing Table                   Routing Table   E0   0         S0      0    S0        0   S0      0      S1      0    E0        0   S0      1      S1      1    S0        1   S0      2      S0      1    S0        2

Routers discover the best path to destinations from each neighbor

Distance Vector Routing Protocols Algorithm
The algorithm used for the routing protocols defines the following

   1. Mechanism for sending and receiving routing information.

   2. Mechanism for calculating the best paths and installing routes
      in the routing table.

   3. Mechanism for detecting and reacting to topology changes.

   A distance-vector routing protocol uses the Bellman-Ford algorithm
      to calculate paths.

Distance Vector Routing Protocols Algorithm
An efficient algorithm to solve the single-source shortest-path problem
(Find the shortest paths from a specific source vertex to every other
vertex in a weighted, directed graph) Weights may be negative. The
algorithm initializes the distance to the source vertex to 0 and all other
vertices to ∞. It then does V-1 passes (V is the number of vertices) over
all edges relaxing, or updating, the distance to the destination of each

Distance Vector Routing Protocols - Iooping
A routing loop is a condition in which a packet is continuously
transmitted within a series of routers without ever reaching its
intended destination network.
 A routing loop can occur when two or more routers have routing
information that incorrectly indicates that a valid path to an
unreachable destination exists.

The loop may be a result of:
   Incorrectly configured static routes
   Incorrectly configured route redistribution (redistribution is a
   process of handing the routing information from one routing
   protocol to another routing protocol)
   Inconsistent routing tables not being updated due to slow
   convergence in a changing network
   Incorrectly configured or installed discard routes
Distance Vector Routing Protocols - Looping

Distance Vector Routing Protocols - Looping

Distance Vector Routing Protocols
Count to infinity is a condition that exists when inaccurate routing updates
increase the metric value to "infinity" for a network that is no longer exist.

Distance Vector Routing Protocols

Distance Vector Routing Protocols

 Holddown Timers

 Holddown timers are used to prevent regular update messages
 from inappropriately reinstating (replace) a route that may have
 gone bad.

 Holddown timers instruct routers to hold any changes that might
 affect routes for a specified period of time. If a route is identified
 as down or possibly down, any other information for that route
 containing the same status, or worse, is ignored for a predetermined
 amount of time (the holddown period).

Distance Vector Routing Protocols

Distance Vector Routing Protocols

Distance Vector Routing Protocols
The split horizon rule says that a router should not advertise a network
through the interface from which the update came.

Distance Vector Routing Protocols

Distance Vector Routing Protocols
Route poisoning is yet another method employed by distance vector routing
protocols to prevent routing loops. Route poisoning is used to mark the route
as unreachable in a routing update that is sent to other routers. (Unreachable
is interpreted as a metric that is set to the maximum).
     For RIP, a poisoned route has a metric of 16.

Distance Vector Routing Protocols

Distance Vector Routing Protocols

RIP Timers
In addition to the update timer, there are three additional timers for RIP:

Invalid Timer. If an update has not been received to refresh an existing route
after 180 seconds (the default), the route is marked as invalid by setting the
metric to 16. The route is retained in the routing table until the flush timer

Flush Timer. By default, the flush timer is set for 240 seconds, which is 60
seconds longer than the invalid timer. When the flush timer expires, the
route is removed from the routing table.

Holddown Timer. This timer stabilizes routing information and helps prevent
routing loops during periods when the topology is converging on new
    Once a route is marked as unreachable, it must stay in holddown long
    enough for all routers in the topology to learn about the unreachable
    By default, the holddown timer is set for 180 seconds.
   RIPv1 Packet Format
                 IP header UDP header         RIP Message                     1: RIPv1

        1: request
        2: response
                                Command     Version           Set to 00...0
  2: for IP                        address family             Set to 00.00
  0…0: request full rou-

                                                                              one route entry
                                              32-bit address

                                                                                (20 bytes)
  ting table
                                          Unused (Set to 00...0)
 Address of destination                   Unused (Set to 00...0)
                                               metric (1-16)
Cost (measured in hops)
                                   Up to 24 more routes (each 20 bytes)
One RIP message can
have up to 25 route entries
   29                                                                                           29
                                                    32 bits
Routing information protocol v1

Routing information protocol v1
RIP Packet Format
  Command—          Indicates whether the packet is a request or a
  Version number— Version
  Zero—             This field is not actually used by RFC 1058 RIP;
                    it was added solely to provide backward
                    compatibility with prestandard varieties of RIP
  Address-family identifier (AFI)—Address family used. The AFI for
                                     IP is 2.
  IP Address—       IP address for the entry
  Metric—           Indicates how many internetwork hops (routers)
                    have been traversed in the trip to the destination.
                    This value is between 1 and 15 for a valid route,
                    or 16 for an unreachable route.

   RIPv2 Packet Format

                 IP header UDP header         RIP Message                     2: RIPv2

        1: request
        2: response
                                Command     Version           Set to 00...0
  2: for IP
                                   address family             Set to 00.00
  0…0: request full rou-

                                                                              one route entry
  ting table                                  32-bit address

                                                                                (20 bytes)
                                          Unused (Set to 00...0)
 Address of destination
                                          Unused (Set to 00...0)

Cost (measured in hops)                        metric (1-16)

                                   Up to 24 more routes (each 20 bytes)
One RIP message can
have up to 25 route entries
   32                                                                                           32
                                                    32 bits
Routing information protocol v2

Routing information protocol v2
Packet Format
   Command—          Request or a response
   Version—          Version (set to 2)
   Unused—           Has a value set to zero
   Address-family identifier (AFI)—Address family used
   Route tag—        Provides a method for distinguishing between
                     internal routes (learned by RIP) and external
                     routes (learned from other protocols)
   IP address—       IP address for the entry
   Subnet mask— Contains the subnet mask for the entry
   Next hop—         IP address of the next hop to which packets
                     should be forwarded
   Metric—           Indicates how many internetwork hops (routers)
                     have been traversed in the trip to the destination.
                     This value is between 1 and 15 for a valid route,
                     or 16 for an unreachable route.                  34
Link State Routing Protocols
 A Link-state routing is a concept used in routing of packet-switched
    networks in computer communications. Link-state routing works by
    having the routers tell every router on the network about its closest
    neighbors. The entire routing table is not distributed from any router,
    only the part of the table containing its neighbors.
 Link State Routing protocols provide greater flexibility and sophistication.
    They reduce overall broadcast traffic and make better decisions about
    routing by taking characteristics such as bandwidth, delay, reliability,
    and load into consideration.
 The link-state protocol is performed by every switching node (Router) in
    the network . The basic concept of link-state routing is that every node
    constructs a map of the connectivity to the network, in the form of a
    graph, showing which nodes are connected to which other nodes.
    Each node then independently calculates the next best logical hop from it
    to every possible destination in the network. The collection of best next
    hops will then form the node's routing table.
Link State Routing Protocols
    •   To overcome limitations of distance vector routing protocols.
        protocols respond quickly to network changes sending trigger
        updates only when a network change has occurred.
    •   send periodic updates, known as link-state refreshes, at
        longer time intervals, such as every 30 minutes.
    •   Each router establishes a relationship—an adjacency—with each of
        its neighbors.
    •   Each router sends link state advertisements (LSAs)
    •   Each router stores a copy of all the LSAs it has seen in a database.
        If all works well, the databases in all routers should be identical.
    •   The completed topological database, also called the link state
        database, describes a graph of the internetwork. Using the
        Dijkstra algorithm, each router calculates the shortest path to each
        network and enters this information into the route table.
Link State Routing Protocols
    •   When router initialized, it determines link cost on each interface

    •   Advertises set of link costs to all other routers in topology (Not
        just neighbouring routers)

    •   After that, each router monitors its link costs If significant change,
                 router advertises new set of link costs.
    •   In this way, each router builds up a picture of the entire topology

    •   Can calculate shortest path to each destination

    •   In practice, Dijkstra's algorithm

    •   Second generation routing algorithm for ARPANET

    •   Open shortest path first (OSPF) protocol uses link-state routing.
Link State Routing Protocols
Dijkstra's algorithm
Find shortest paths from a given node to all other nodes, by
   developing paths in the order of increasing path length
Proceeds in stages
   • At each stage shortest path from source to one node is

   •     The nodes for which shortest path determined are kept in a
       set called permanent node At each iteration, node not in
       permanent node but has the shortest path from source added to
       permanent node

   •     As each node added to permanent node, path from source to the
       nodes not in permanent node are checked to see whether there
       is a better path through this newly added node
Link State Routing Protocols
    Three main concerns related to link-state protocols:

        Processor overhead
        Memory requirements
        Bandwidth consumption

 Link-state routing requires more memory and processing power than
    distance vector, and bandwidth requirements are often higher as

Link State Routing Protocols
Advantages of Link State–Based Routing Protocols

•   Smaller routing tables.

•    Only a single optimal route for each network ID is stored in the routing

•   Low network overhead.

•    Link state–based routers do not exchange any routing information when
    the         internetwork has converged.

•   Ability to scale. Between the smaller routing tables and low overhead, link
       state–based routing protocols scale well to large & very large networks.

•   Lower convergence time. Link state–based routing protocols have a much
      lower convergence time and the internet work is converged without 40
      routing loops.
Link State Routing Protocols
    Disadvantages of Link State–Based Routing Protocols

        •    Complex.
                Link state–based routing protocols are much more complex
            and         difficult to understand than distance vector–based
            routing protocols.

    •   More difficult to configure.
              A link state–based routing protocol implementation requires
              additional planning and configuration.

    •    Resource intensive.
               For very large internetworks, the database of link state
               advertisements and the calculation of routing table entries
        can be memory and processor intensive.


Distance Vector or Link State?
DV   1.    Use Bellman-Ford algorithms
LS   2.    Flood routing information to all routers
DV   3.    Requests routing information from directly connected neighbors
LS   4.    Complete view of the internetwork topology
DV   5.    Decisions based upon information provided by neighbors
DV   6.    Use fewer system resources
LS   7.    When a network link changes state LSA are flooded through network
LS   8.    Less errors, but they use more system resources
LS   9.    Calculate the shortest path to all known sites on the network
LS   10.   Small update packets contain only changes
DV   11.   Slower convergence
LS   12.   OSPF and IS-IS
DV   13.   Do not scale well to larger systems.
LS   14.   Because they converge more quickly less prone to routing loops
LS   15.   Event-triggered updates, so convergence is fast
DV   16.   Based on finding the number of hops and direction to a link
DV   17.   Passes copies of complete routing table on a periodic basis
DV   18.   Each router simply inform its neighbors of its routing table
DV   19.   RIP and IGRP
LS   20.   more reliable, easier to debug, and less bandwidth-intensive
OSPF Packet Format
Version number—OSPF version
Type— OSPF packet type:
         Hello— Establishes and maintains neighbor
         Database description—Describes the contents of the
         topological database
         Link-state request—Requests pieces of the topological
         database from neighbor routers
         Link-state update—Responds to a link-state request packet
         Link-state acknowledgment—Acknowledges link-state
         update packets
Packet length— Packet length, including the OSPF header, in bytes
Router ID—        Source of the packet
Area ID—          Area to which the packet belongs
Checksum—         Checks the entire packet contents for any damage
Authentication type—Contains the authentication type
Authentication— Contains authentication information
Data—             Contains encapsulated upper-layer information


To top