IP routing by OSPF
IP routing by OSPF
Quadrant 1 – e-text
Starting from the previous module, we have started to understand how routing protocols
work. Routing is all about finding a path from a source network to a destination network
that are connected by a number of routers. Routing algorithms work by modelling the
network as a graph, with the routers representing the vertices (nodes) and the links
representing the edges. The edges may have a weight or cost associated with them.
Thus finding the best path in the network boils down to finding a least cost path on the
graph. We looked at one algorithm called the distance vector routing algorithm. We now
go into the details of another standard algorithm called the link-state routing algorithm,
and the protocol OSPF – Open Shortest Path First, which is based on it.
Learning Objectives:
There are two routing algorithms that are widely used – Distance Vector (DV) routing,
and Link State routing algorithms. Of these, the DV routing uses local information, and
is a distributed protocol. In DV, every node identifies its neighbors, and exchanges its
distance to different nodes with its neighbors. Over a few exchanges, information to
reach all the nodes are available at each node, and it constructs its routing table. It
identifies the next-hop to reach a destination, from the information it gets from its
neighbors. Depending on which neighbor reports a lower cost to reach a destination, it
marks that neighbor as the next hop to reach that destination. It does not know t he
actual path through which the destination can be reached. That is, it does not have a
global view of the network, and just trusts information coming from its neighbors. As a
result, there are situations where the algorithm may not converge quickly. We have
seen that it suffers from a problem known as count-to-infinity problem which indicates
slow convergence. The reason for such slow convergence, is basically the lack of a
complete view of the network.
It is this disadvantage that the link state algorithm seeks to overcome. Hence, in the link
state algorithm, the basic goal is to get a complete view (graph) of the network. Once,
each node has the complete graph, each node runs a shortest path algorithm -
Dijkstra’s shortest path algorithm - on the graph, to obtain the least cost path between
any two nodes. Since all nodes have the same graph, and hence a consistent view of
the network, the shortest paths identified by all nodes are consistent, and they use that
information to build their routing tables.
19.2 Link State Routing – Strategy
The key to this algorithm is to get a global view of the network. The strategy used for
this purpose is that each node should send information about directly connected links (not
entire routing table), to all nodes (not just neighbors). Once this information is available at
each node, it runs the Dijkstra’s shortest path algorithm to identify the path from itself to
all other nodes.
19.2.1 Link State Information
The first step therefore, is to get information about the directly connected nodes, which
is obtained by exchanging “hello” messages on each of the interfaces connected to a
link. This information called the “link state” information is sent in what is called as a “Link
State Packet” – LSP to all the nodes. The LSP has information :
The next step is to send this LSP to all nodes. A process called “reliable flooding” is
used to broadcast this information. The SEQNO and TTL fields in the LSP help in this
reliable flooding. The steps involved in reliable flooding are:
Start at SEQNO 0 when booting/rebooting;
Generate new LSP periodically; increment SEQNO;
Send LSP to all neighbors.
On receiving LSP, store most recent LSP from each node;
Forward LSP to all neighbors other than the one that sent it;
Decrement TTL of each stored LSP; discard when TTL=0.
The SEQNO field is used to identify the most recent information from a node. The TTL
field is used to remove LSPs that may be circulating in the network due to some error.
Let us understand this with an example. Consider the network fragment shown in Fig.
19.1. Assume that an LSP arrives at node x (Fig.19.1 a). It is sent to nodes A and C, on
the links other than the one on which it was received (Fig. 19.1 b).
A and C flood LSP to B, but not X (Fig. 19.1 c). B finds that both have same SEQNO,
and keeps the first copy and discards the second. It then sends it on the link towards D.
All the nodes have now received the LSP (Fig. 19.1 d).
Thus in reliable flooding, sending of duplicate packets and unnecessary flooding of
packets which could result in loading the network are avoided.
19.2.3 Shortest path calculation
All nodes send their LSPs to all other nodes in this fashion. When a node receives the
LSPs, it constructs the graph of the network from the LSPs, and runs the Dijkstra’s
shortest path algorithm to identify the paths from that node to all other nodes in the
graph. It is run iteratively for each destination node. Thus, at the end of ‘k’ iterations,
least cost path to k destinations is known.
The network topology and link costs are known to all nodes, and all nodes have the
same information, and have the complete graph. Thus, all of them compute the paths in
a consistent manner, and build their routing tables from this shortest path.
Let us look at how Dijkstra’s algorithm is used in this context.
19.3 Dijkstra’s Shortest path algorithm
Initialization:
1 N' = {u}
2 for all nodes v
3 if v adjacent to u
4 then D(v) = c(u,v)
5 else D(v) = ∞
Let us understand this with an example. Consider the network graph shown in Figure
19.2.
Initially, N’ is set to u. The distances to the immediate neighbors v,w, and x are set as 7,
3 and 5 respectively, and the predecessor node for all 3 are set as u. The distances to y
and z are set to infinity. The next step – step 1 - is to choose the node with the smallest
distance – so w with a distance of 3 is chosen and added to N’. Now the distances of
the nodes reachable through w, namely v, x and y are recalculated. It can be seen that
the distance to v through w is 6, which is less than the direct link cost of 7. Hence D(v)
is updated to 6, and p(v) is set to w. D(y) is set to 11 (3+8) through w. Other values do
not change. Node with smallest distance x (5) is added to N’.
In the next iteration, step 2, LS of x is examined. It gives a distance of 9 to z, and D(z) is
updated to 9+5= 14. Other distances are not changed by information from x. v with the
least distance of 6 is added to N’.
In step 5, all nodes are in N’, and that completes the process. The ones circled are the
shortest distances, and the predecessor nodes to the respective nodes.
The routing table can now be constructed from this information.
1 Initialize the Confirmed list of each node with an entry for itself with 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 self to Next and from Next to Neighbor.
4 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 to
go to reach Next.
5 If Neighbor is currently on the Tentative list, and the Cost is less than the
currently listed cost for the Neighbor, then replace the current entry with
(Neighbor, Cost, Nexthop), where Nexthop is the direction to go to reach Next.
6 If the Tentative list is empty, stop. Other wise, pick the entry from the Tentative list
with the lowest cost, move it to the Confirmed list, and return to Step 2.
These steps as applied to the node D in the network graph shown in Fig. 19.4 are given
in Fig. 19.5.
Now that we have looked at the details of both the DV and the LS algorithms, we can do
a comparison of these two techniques on various factors as shown in Table 19.1.
LS DV
The OSPF protocol which implements the LS algorithm is an open, publicly available
protocol with 3 versions - OSPF v2: RFC 2328, and OSPF v3: RFC 2740. It is an intra-
domain routing protocol. It has mechanisms for LSP dissemination throughout the
network, topology construction at each node, and route computation using Dijkstra’s
algorithm. LSPs are flooded through OSPF advertisements to the entire domain. They
are carried in OSPF messages directly over IP (rather than TCP or UDP).
A look at the OSPF message format is enough to understand how the LS algorithm is
implemented. There are different types of OSPF messages – for sending the Hello
messages, and to send LS advertisements. The header of the OSPF message is given
in Fig. 19.6.
It is interesting to note that OSPF provides support for many interesting features
associated with routing. Some of these are mentioned below:
Support for equal-cost multipath routing – If there exist more than one path to a
destination with the same cost, it supports sending of packets along the multiple paths.
Integrated unicast and multicast support: Multicast OSPF (MOSPF) uses the same
topology database as OSPF.
Support for two levels of hierarchy : An area is a group of contiguous networks and
hosts. OSPF allows for the entire AS to be split into multiple “areas”, to provide
scalability – We can route to an area - inter-area routing , and then route within the area
– intra-area routing. Dividing into areas helps in reducing the number of networks that
each router will have to handle for an entire AS. The topology of an area is invisible
from the outside. With this support for areas a typical OSPF hierarchy-based network
would be as shown in Fig. 19.8.
The entire AS is divided into areas, which connect to a backbone network inside the AS,
which in turn connects to the AS boundary router which connects to other ASes. Area
border routers “summarize” distances to networks of that area, and advertise that
information to other Area Border routers. Area internal routers only participate in intra-
area routing, and LSA’s are sent only within the area. They receive external routes
broadcasted by area border router, and integrate that information. The backbone
routers run OSPF routing limited to backbone. The AS Boundary routers connect to
other AS’s.
19.5.2 OSPF vs RIP
Many of these features of OSPF are not present in RIP making OSPF a more
sophisticated protocol:
Security: all OSPF messages are authenticated to prevent malicious intrusion. There is
no such support in RIP.
Multiple same-cost paths are allowed, whereas only one path in RIP.
For each link, multiple cost metrics for different TOS (e.g., satellite link cost set “low” for
best effort ToS; high for real time ToS), which is not supported in RIP.
Integrated uni- and multicast support, which again is not supported by RIP.
Hierarchical OSPF in large domains helps scalability, which does not feature in RIP.
RIP is mostly used in small networks.
19.6 Summary
In summary, we have looked at the Link State Routing algorithm in detail, covering
LSPs, LSAs, reliable flooding, the Dijkstra’s algorithm, its implementation in networks.
We then had a glimpse of the OSPF protocol and its features. We have also compared
this algorithm and protocol with the DV algorithm and its protocol, and we can see that
LS and OSPF are more sophisticated protocols that are scalable. With this we have
looked at both the intra-domain routing techniques. We will next go into inter-domain
routing.
1. Computer Networking: A Top Down Approach Featuring the Internet, 6th edition.
Jim Kurose, Keith Ross
Addison-Wesley, 2012.
2. Computer Networks: A systems Approach, 4 th edition, David Peterson, Davie,
Morgan Kauffman, 2012.