0% found this document useful (0 votes)
3 views

IP routing by OSPF

The document discusses IP routing with a focus on the OSPF (Open Shortest Path First) protocol, which utilizes the link-state routing algorithm to determine the least cost path in a network. It contrasts link-state routing with distance vector routing, highlighting the advantages of having a complete view of the network and faster convergence. Additionally, it outlines the features of OSPF, including support for equal-cost multipath routing, TOS-based routing, and hierarchical area management.

Uploaded by

Raghav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

IP routing by OSPF

The document discusses IP routing with a focus on the OSPF (Open Shortest Path First) protocol, which utilizes the link-state routing algorithm to determine the least cost path in a network. It contrasts link-state routing with distance vector routing, highlighting the advantages of having a complete view of the network and faster convergence. Additionally, it outlines the features of OSPF, including support for equal-cost multipath routing, TOS-based routing, and hierarchical area management.

Uploaded by

Raghav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

e-PG Pathshala

Subject : Computer Science

Paper: Computer Networks

Module: IP Routing - OSPF


Module No: CS/CN/19

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:

 To understand link state routing algorithm

 To examine how the OSPF protocol is built to use this algorithm


19.1 Link State routing : Introduction

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 :

 to identify the node that created it – “id”;


 id, and cost of link to each directly connected neighbor;
 sequence number (SEQNO) for this packet; and
 time-to-live (TTL) for this packet.

19.2.2 Reliable flooding

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).

Figure 19.1 Reliable Flooding – An example

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

The Dijkstra’s shortest path algorithm is given below.

Let c(x,y): be the link cost from node x to y;


D(v): be the current value of cost of path from source to destination v;
p(v): the predecessor node along path from source to v; and
N': set of nodes whose least cost path is definitively known.

The steps involved are as follows:

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) = ∞

6 Loop until all nodes in N' {


7 find w not in N' such that D(w) is a minimum
8 add w to N'

9 update D(v) for all v adjacent to w and not in N' :


10 D(v) = min( D(v), D(w) + c(w,v) ) /* new cost to v is either old cost to v or
known shortest path cost to w plus cost from w to v
11 }

Let us understand this with an example. Consider the network graph shown in Figure
19.2.

Figure 19.2 Example network graph for Dijkstra’s algorithm


The steps at node ‘u’ are given in Figure 19.3.
Figure 19.3 Dijkstra’s algorithm Example – Steps

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 3, LS of v is examined. It gives a shorter distance of 10 (6+4) to y, and D(y) and


p(y) are updated. The node y with the least distance of 10 is added to N’.
In step 4, LS of y is examined. It results in a shorter distance of 12 to z. z is now 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.

This algorithm is actually implemented as a forward search algorithm in practice. This is


because the graph is updated as and when LSPs are received from various nodes. We
will now look at how that is done.
19.3.1 Dijkstra’s algorithm in practice
Each node maintains two lists, known as Tentative and Confirmed. Each of these lists
contains a set of entries of the form (Destination, Cost, NextHop). The steps involved
are as follows:

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.

Figure 19.4 Example Graph 2


Figure 19.5 Dijkstra’s algorithm steps for network in Fig. 19.4

19.4 Comparison of LS and DV algorithms

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.

Table 19.1 LS vs DV algorithms

LS DV

No. of Messages – With n nodes, E links, Message exchange


complexity O(nE) msgs sent between neighbors only

Speed of convergence O(n2), algorithm requires Convergence time varies,


O(nE) msgs May have routing loops,
Count-to-infinity problem
May have oscillations
exists
Robustness (to router Node can advertise Node can advertise
malfunctions) incorrect link cost incorrect path cost

Each node computes only Each node’s table used by


its own table others, hence error
propagates through the
n/w
We can see that both algorithms have merits and demerits. LS scores on most aspects,
but its complexity is higher. Both algorithms are used in the Internet today as part of the
RIP and OSPF protocols.
19.5 OSPF - Open Shortest Path First protocol

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.

Figure 19.6 OSPF message header


The SourceAddr is the address of the router sending the message, areaId is the ID of
the area to which the router belongs – (the domain or autonomous system (AS) is
divided into areas for easy manageability). Checksum is the usual IP -like checksum.
Authentication type and authentication information are used to provide some level of
security in sending the OSPF messages.
The format of the LSA message is shown in Fig. 19.7.
Figure 19.7 OSPF LSA message format
The fields in the LSA message are pretty much self-explanatory. LSAge is the TTL
information for the LSA packet. Link-state ID and Advertising router give the address of
the router sending the LSP. LS sequence number is the SEQNO in the LS algorithm.
Every LSA, can carry information about more than one link. The number of links for
which the information is carried is specified in the field of the same name. The LinkID
and Link data fields identify the individual links. The metric and Num_TOS give the type
of metric being used to specify the cost (bandwidth, congestion etc.,), and the numeric
value of that metric. The link specific fields are repeated for each link at the advertising
router.
19.5.1 OSPF – additional features

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.

Support for TOS-based routing – It supports different parameters to be specified – for


providing different IP Type-of-Service. Multiple routes for multiple ToS are supported. A
separate shortest path tree will be constructed for each ToS.
Support for variable subnet length - Each route distributed has a destination and mask
to support advertising routing info for groups of subnets.

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.

Figure 19.8 A hierarchical AS

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.

Acknowledge ments & References :

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.

3. Computer Networks An Open Source Approach, Ying-Dar Lin, Ren-Hung Hwang,


Fred Baker, McGraw Hill, 2012.

You might also like