Search This Blog

Wednesday, 27 August 2014

Link State Routing (OSPF)

Link-state routing is the second major class of intradomain routing protocol. The basic idea behind link-state protocols is very simple: Every node knows how to reach its directly connected neighbors, and if we make sure that the totality of this knowledge is disseminated to every node, then every node will have enough knowledge of the network to build a complete map of the network. This is clearly a sufficient condition (although not a necessary one) for finding the shortest path to any point in the network.

link-state routing protocols rely on two mechanisms: reliable dissemination of link-state information, and the calculation of routes from the sum of all the accumulated link-state knowledge.

Reliable Flooding

Reliable flooding is the process of making sure that all the nodes participating in the routing protocol get a copy of the link-state information from all the other nodes. As the term “flooding” suggests, the basic idea is for a node to send its link-state information out on all of its directly connected links, with each node that receives this information forwarding it out on all of its links. This process continues until the information has reached all the nodes in the network.

each node creates an update packet, also called a link-state packet (LSP), that contains the following information:

  • the ID of the node that created the LSP
  • a list of directly connected neighbors of that node, with the cost of the link to each one
  • a sequence number
  • a time to live for this packet

Consider a node X that receives a copy of an LSP that originated at some other node Y. Note that Y may be any other router in the same routing domain as X. X checks to see if it has already stored a copy of an LSP from Y. If not, it stores the LSP. If it already has a copy, it compares the sequence numbers; if the new LSP has a larger sequence number, it is assumed to be the more recent, and that LSP is stored, replacing the old one. A smaller (or equal) sequence number would imply an LSP older (or not newer) than the one stored, so it would be discarded and no further action would be needed. If the received LSP was the newer one, X then sends a copy of that LSP to all of its neighbors except the neighbor from which the LSP was just received. The fact that the LSP is not sent back to the node from which it was received helps to bring an end to the flooding of an LSP. Since X passes the LSP on to all its neighbors, who then turn around and do the same thing, the most recent copy of the LSP eventually reaches all nodes.

Each node generates LSPs under two circumstances. Either the expiry of a periodic timer or a change in topology can cause a node to generate a new LSP. However, the only topology-based reason for a node to generate an LSP is if one of its directly connected links or immediate neighbors has gone down. The failure of a link can be detected in some cases by the link-layer protocol. The demise of a neighbor or loss of connectivity to that neighbor can be detected using periodic “hello” packets. Each node sends these to its immediate neighbors at defined intervals. If a sufficiently long time passes without receipt of a “hello” from a neighbor, the link to that neighbor will be declared down, and a new LSP will be generated to reflect this fact. One of the important design goals of a link-state protocol’s flooding mechanism is that the newest information must be flooded to all nodes as quickly as possible, while old information must be removed from the network and not allowed to circulate.

Route Calculation

Once a given node has a copy of the LSP from every other node, it is able to compute a complete map for the topology of the network, and from this map it is able to decide the best route to each destination. The question, then, is exactly how it calculates routes from this information. The solution is based on a well-known algorithm from graph theory—Dijkstra’s shortest-path algorithm.

The algorithm is defined as follows:

M = {s}
for each n in N− {s}
C(n) = l(s, n)
while (N = M)
M = M ∪ {w} such that C(w) is the minimum for all w in (N− M)
for each n in (N− M)
C(n) = MIN(C(n), C(w) + l(w, n))

Each switch computes its routing table directly from the LSPs it has collected using a realization of Dijkstra’s algorithm called the forward search algorithm. Specifically, each switch maintains two lists, known as Tentative and Confirmed. Each of these lists contains a set of entries of the form (Destination, Cost, NextHop).

The algorithm works as follows:
  1. Initialize the Confirmed list with an entry for myself; this entry has a cost of 0.
  2. For the node just added to the Confirmed list in the previous step, call it node Next, select its LSP.
  3. For each neighbor (Neighbor) of Next, calculate the cost (Cost) to reach this Neighbor as the sum of the cost from myself to Next and from Next to Neighbor. 
    • If Neighbor is currently on neither the Confirmed nor the Tentative list, then add (Neighbor, Cost, NextHop) to the Tentative list, where NextHop is the direction I go to reach Next. 
    • If Neighbor is currently on the Tentative list, and the Cost is less than the currently listed cost for Neighbor, then replace the current entry with (Neighbor, Cost, NextHop), where NextHop is the direction I go to reach Next.
  4. If the Tentative list is empty, stop. Otherwise, pick the entry from the Tentative list with the lowest cost, move it to the Confirmed list, and return to step 2.

The link-state routing algorithm has many nice properties: It has been proven to stabilize quickly, it does not generate much traffic, and it responds rapidly to topology changes or node failures. On the downside, the amount of information stored at each node (one LSP for every other node in the network) can be quite large.

The Open Shortest Path First Protocol (OSPF)

One of the most widely used link-state routing protocols is OSPF. The first word, “Open,” refers to the fact that it is an open, nonproprietary standard, created under the auspices of the IETF. The “SPF” part comes from an alternative name for linkstate routing.
 


LS age - The time, in seconds, since the LSA was generated. 
LSID (Link State ID) - The ID of the router that generated the LSA. 
Advertising Router - ID of the router that originated the LSA.
LS Seq (Link State Sequence) - The sequence number of the advertisement. Used to detect old or duplicate link state advertisements.  
Flags - Possible values:
  • V - Router is the endpoint of an active virtual link that is using the area as a transit area. 
  • ASBR - Router is an autonomous system boundary router (ASBR). 
  • ABR - Router is an area border router (ABR).

 Link ID - Identifies the object to which this router link connects for each Link Type. Possible values:
  •     If Link Type is PTP, then this is the neighboring router's router ID.
  •     If Link Type is Transit, then this is the address of the designated router.
  •     If Link Type is Stub, then this is the IP network or subnetwork number.
  •     If Link Type is Virtual Link, then this is the neighboring router's router ID.
Link Data - Provides additional link information. Possible values:
  •     If Link Type is PTP, then this is the MIB II index value for an unnumbered point-to-point interface.
  •     If Link Type is Transit, then this is the IP address of the advertising router's interface.
  •     If Link Type is Stub, then this is the network's IP address mask.
  •     If Link Type is Virtual Link, then this is the IP address mask of the neighboring router.
Link Type - A description of the router link. Possible values:
  •    PTP - Connection is point-to-point to another router.
  •    Transit - Connection is to a transit network.
  •    Stub - Connection to a stub network.
  •    Virtual link - Connection is to a far-end router that is the endpoint of a virtual link.
Metric - Cost of using this outbound router link. With the exception of stub networks, this value must be other than 0. 
 
NUM_TOS :TOS information is present to allow OSPF to choose different routes for IP packets based on the value in their TOS field.

Distance-Vector Routing

Each node constructs a one-dimensional array containing the "distances"(costs) to all other nodes and distributes that vector to its immediate neighbors.
  1. The starting assumption for distance-vector routing is that each node knows the cost of the link to each of its directly connected neighbors.
  2. A link that is down is assigned an infinite cost.
To see how a distance-vector routing algorithm works, it is easiest to consider an example 

Distance-vector routing: an example network.

In this example, the cost of each link is set to 1, so that a least-cost path is simply the one with the fewest hops. We can represent each node’s knowledge about the distances to all other nodes as a table like the one given in Table. Note that each node only knows the information in one row of the table. The global view that is presented here is not available at any single point in the network.




Table 1: Initial distances stored at each node (global view).

We may consider each row in Table 1 as a list of distances from one node to all other nodes, representing the current beliefs of that node. Initially, each node sets a cost of 1 to its directly connected neighbors and ∞ to all other nodes. Thus, A initially believes that it can reach B in one hop and that D is unreachable. The routing table stored at A reflects this set of beliefs and includes the name of the next hop that A would use to reach any reachable node. 

Table2: Initial routing table at node A.

Initially, then, A’s routing table would look like Table 2.The next step in distance-vector routing is that every node sends a message to its directly connected neighbors containing its personal list of distances.


Table 3: Final routing table at node A.

For example, node F tells node A that it can reach node G at a cost of 1; A also knows it can reach F at a cost of 1, so it adds these costs to get the cost of reaching G by means of F. This total cost of 2 is less than the current cost of infinity, so A records that it can reach G at a cost of 2 by going through F. Similarly, A learns from C that D can be reached from C at a cost of 1; it adds this to the cost of reaching C (1) and decides that D can be reached via C at a cost of 2, which is better than the old cost of infinity. At the same time, A learns from C that B can be reached from C at a cost of 1, so it concludes that the cost of reaching B via C is 2. Since this is worse than the current cost of reaching B (1), this new information is ignored.

Node A can update its routing table with costs and next hops for all nodes in the network and  The result is shown in Table 3

If there is any topology changes, it only takes a few exchanges of information between neighbors before each node has a complete routing table. The process of getting consistent routing information to all the nodes is called convergence.

There are two different circumstances under which a given node decides to send a routing update to its neighbors.

One of these circumstances is the periodic update. each node automatically sends an update message every time interval, even nothing has changed.The frequency of these periodic updates varies from protocol to protocol.

The second mechanism, sometimes called a triggered update, happens whenever a node receives an update from one of its neighbors that causes it to change one of the routes in its routing table. That is, whenever a node’s routing table changes, it sends an update to its neighbors, which may lead to a change in their tables, causing them to send an update to their neighbors.

Final distances stored at each node (global view).

When a node detects a link failure
  • F detects that link to G has failed
  • F sets distance to G to infinity and sends update to A
  • A sets distance to G to infinity since it uses F to reach G
  • A receives periodic update from C with 2-hop path to G
  • A sets distance to G to 3 and sends update to F
  • F decides it can reach G in 4 hops via A
Slightly different circumstances can prevent the network from stabilizing.Suppose the link from A to E goes down. In the next round of updates, A advertises a distance of infinity to E, but B and C advertise a distance of 2 to E. Depending on the exact timing of events, the following might happen.
  • Node B, upon hearing that E can be reached in 2 hops from C, concludes that it can reach E in 3 hops and advertises this to A
  • Node A concludes that it can reach E in 4 hops and advertises this to C
  • Node C concludes that it can reach E in 5 hops; and so on.
  • This cycle stops only when the distances reach some number that is large enough to be considered infinite
  • This problem is called as Count-to-infinity problem
 There are several partial solutions to this problem. The first one is to use some relatively small number as an approximation of infinity. For example, we might decide that the maximum number of hops to get across a certain network is never going to be more than 16, and so we could pick 16 as the value that represents infinity. This at least bounds the amount of time that it takes to count to infinity.

One technique to improve the time to stabilize routing is called split horizon. The idea is that when a node sends a routing update to its neighbors, it does not send those routes it learned from each neighbor back to that neighbor.For example, if B has the route (E, 2, A) in its table, then it knows it must have learned this route from A, and so whenever B sends a routing update to A, it does not include the route (E, 2) in that update.In a stronger variation of split horizon, called split horizon with poison reverse, B actually sends that route back to A, but it puts negative information in the route to ensure that A will not eventually use B to get to E.



Routing Information Protocol (RIP)

One of the most widely used routing protocols in IP networks is the Routing Information Protocol (RIP). RIP is the canonical example of a routing protocol built on the distance-vector algorithm.

RIP Packet Format

RIP is in fact a fairly straightforward implementation of distance-vector routing. Routers running RIP send their advertisements every 30 seconds; a router also sends an update message whenever an update from another router causes it to change its routing table. One point of interest is that it supports multiple address families, not just IP. The network-address part of the advertisements is actually represented as a family, address pair. RIP version 2 (RIPv2) also has some features related to scalability