Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

What is Routing Algorithm?

Explain Link state routing algorithm and


Distance vector routing algorithm.
Routing algorithm:
In order to transfer the packets from source to the destination, the network layer must
determine the best route through which packets can be transmitted.Whether the network layer
provides datagram service or virtual circuit service, the main job of the network layer is to
provide the best route. The routing protocol provides this job.The routing protocol is a routing
algorithm that provides the best path from the source to the destination. The best path is the
path that has the "least-cost path" from source to the destination.Routing is the process of
forwarding the packets from source to the destination but the best route to send the packets is
determined by the routing algorithm.

Routing Techniques Elements Routing Techniques Elements:

 Performance criterion: Hops, Distance, Speed, Delay, Cost


 Decision time: Packet, session
 Decision place: Distributed, centralized, Source
 Network information source: None, local, adjacent nodes, nodes along route, all nodes
 Routing strategy: Fixed, adaptive, random, flooding
 Adaptive routing update time: Continuous, periodic, topology change, major load
change

Explain Link state routing algorithm and Distance vector routing algorithm.

Link State Routing:

 It is a dynamic routing algorithm in which each router shares knowledge of its neighbors
with every other router in the network.
 A router sends its information about its neighbors only to all the routers through
flooding.
 Information sharing takes place only whenever there is a change.
 It makes use of Dijkastra’s Algorithm for making routing tables.
 Problems – Heavy traffic due to flooding of packets.
– Flooding can result in infinite looping which can be solved by using Time to leave (TTL)
field.
Features of link state routing protocols:
 Link state packet – A small packet that contains routing information.
 Link state database – A collection information gathered from link state packet.
 Shortest path first algorithm (Dijkstra algorithm) – A calculation performed on the
database results into shortest path
 Routing table – A list of known paths and interfaces.
Calculation of shortest path:
To find shortest path, each node need to run the famous Dijkstra algorithm. This famous
algorithm uses the following steps:
 Step-1: The node is taken and chosen as a root node of the tree, this creates the tree
with a single node, and now set the total cost of each node to some value based on the
information in Link State Database
 Step-2: Now the node selects one node, among all the nodes not in the tree like
structure, which is nearest to the root, and adds this to the tree.The shape of the tree gets
changed .
 Step-3: After this node is added to the tree, the cost of all the nodes not in the tree
needs to be updated because the paths may have been changed.
 Step-4: The node repeats the Step 2. and Step 3. until all the nodes are added in the tree
Link State protocols in comparison to Distance Vector protocols have:

1. It requires large amount of memory.


2. Shortest path computations require many CPU circles.
3. If network use the little bandwidth ; it quickly reacts to topology changes
4. All items in the database must be sent to neighbors to form link state packets.
5. All neighbors must be trusted in the topology.
6. Authentication mechanisms can be used to avoid undesired adjacency and problems.
7. No split horizon techniques are possible in the link state routing.
Open shortest path first (OSPF) routing protocol:
 Open Shortest Path First (OSPF) is a unicast routing protocol developed
by working group of the Internet Engineering Task Force (IETF).
 It is a intradomain routing protocol.
 It is an open source protocol.
 It is similar to Routing Information Protocol (RIP)
 OSPF is a classless routing protocol, which means that in its updates, it includes
the subnet of each route it knows about, thus, enabling variable-length subnet masks.
With variable-length subnet masks, an IP network can be broken into many subnets of
various sizes. This provides network administrators with extra network-configuration
flexibility.These updates are multicasts at specific addresses (224.0.0.5 and 224.0.0.6).
 OSPF is implemented as a program in the network layer using the services
provided by the Internet Protocol
 IP datagram that carries the messages from OSPF sets the value of protocol field
to 89
 OSPF is based on the SPF algorithm, which sometimes is referred to as the
Dijkstra algorithm
 OSPF has two versions – version 1 and version 2. Version 2 is used mostly
OSPF Messages – OSPF is a very complex protocol. It uses five different types of messages.
These are as follows:
1. Hello message (Type 1) – It is used by the routers to introduce itself to the other
routers.
2. Database description message (Type 2) – It is normally send in response to the Hello
message.
3. Link-state request message (Type 3) – It is used by the routers that need information
about specific Link-State packet.
4. Link-state update message (Type 4) – It is the main OSPF message for building Link-
State Database.
5. Link-state acknowledgement message (Type 5) – It is used to create reliability in the
OSPF protocol.
Distance Vector Routing:
 It is a dynamic routing algorithm in which each router computes distance between itself
and each possible destination i.e. its immediate neighbors.
 The router share its knowledge about the whole network to its neighbors and
accordingly updates table based on its neighbors.
 The sharing of information with the neighbors takes place at regular intervals.
 It makes use of Bellman Ford Algorithm for making routing tables.
 Problems – Count to infinity problem which can be solved by splitting horizon.
– Good news spread fast and bad news spread slowly.
– Persistent looping problem i.e. loop will be there forever.
Bellman Ford Basics – Each router maintains a Distance Vector table containing the distance
between itself and ALL possible destination nodes. Distances,based on a chosen metric, are
computed using information from the neighbors’ distance vectors.
Information kept by DV router -
 Each router has an ID
 Associated with each link connected to a router,
 there is a link cost (static or dynamic).
 Intermediate hops

Distance Vector Table Initialization -


 Distance to itself = 0
 Distance to ALL other routers = infinity number.
Distance Vector Algorithm:
1. A router transmits its distance vector to each of its neighbors in a routing packet.
2. Each router receives and saves the most recently received distance vector from each of
its neighbors.
3. A router recalculates its distance vector when:
 It receives a distance vector from a neighbor containing different information
than before.
 It discovers that a link to a neighbor has gone down.
The DV calculation is based on minimizing the cost to each destination

Dx(y) = Estimate of least cost from x to y

C(x,v) = Node x knows cost to each neighbor v

Dx = [Dx(y): y ∈ N ] = Node x maintains distance vector

Node x also maintains its neighbors' distance vectors


– For each neighbor v, x maintains Dv = [Dv(y): y ∈ N ]

Note:
 From time-to-time, each node sends its own distance vector estimate to neighbors.
 When a node x receives new DV estimate from any neighbor v, it saves v’s distance
vector and it updates its own DV using B-F equation:
 Dx(y) = min { C(x,v) + Dv(y), Dx(y) } for each node y ∈ N

Example – Consider 3-routers X, Y and Z as shown in figure. Each router have their routing
table. Every routing table will contain distance to the destination nodes.

Consider router X , X will share it routing table to neighbors and neighbors will share it routing
table to it to X and distance from node X to destination will be calculated using bellmen- ford
equation.

Dx(y) = min { C(x,v) + Dv(y)} for each node y ∈ N

As we can see that distance will be less going from X to Z when Y is intermediate node(hop) so it
will be update in routing table X.

Similarly for Z also –


Finally the routing table for all –

Explain working of Intra-ASRouting in the internet:RIP and OSPF.


Routing in the Internet:
The Internet consists of interconnected autonomous systems (ASs). An AS typically consists of
many networks, where a network (also called an IP network) was defined in the previous
section.That each autonomous system is administered independently. The administrator of an
autonomous system chooses the intra-AS routing algorithm for that AS, and is responsible for
administering that AS and no others. Datagrams must also be routed among the ASs, and this is
the job of inter-AS routing protocols. As discussed in Section 4.3, this hierarchical organization
of the Internet has permitted the Internet to scale. In this section we examine the intra-AS and
inter-AS routing protocols for that are commonly used in the Internet.

Intra-Autonomous System Routing in the Internet:

An intra-AS routing protocol is used to configure and maintain the routing tables within an
autonomous system (AS).  Once the routing tables are configured, datagrams are routed within
the AS as described in the previous section. Inter-AS routing protocols are also known as
interior gateway protocols. Historically, three routing protocols have been used extensively for
routing within an autonomous system in the Internet: RIP (the Routing Information Protocol),
and OSPF (Open Shortest Path First), and IGRP (Cisco's propriety Interior Gateway Routing
Protocol).

RIP: Routing Information Protocol:

The Routing Information Protocol (RIP) was one of the earliest intra-AS Internet routing
protocols and is still in widespread use today.  It traces its origins and its name to the  Xerox
Network Systems (XNS) architecture.  The widespread deployment of RIP was due in great part
to its inclusion in 1982 of the Berkeley Software Distribution (BSD) version of UNIX supporting
TCP/IP.

RIP is a distance vector protocol that operates in a manner very close  to the idealized protocol.
The version of RIP specified in RFC 1058 uses hop count as a cost metric, i.e., each link has a
cost of 1, and limits the maximum cost of a path to 15.  This limits the use of RIP to autonomous
systems that are less than 15 hops in diameter.Recall that in distance vector protocols,
neighboring routers exchange routing information with each other. In RIP, the routing tables
are exchanged between neighbors every 30 seconds using RIP's. This is done with RIP's so-
called response message, with each response message containing that host's routing table
entries for up to 25 destination networks. These response messages containing routing tables
are also called advertisements.

Let us take a look at a simple example of how RIP advertisements work. Consider the portion of
an AS the rectangles denote routers and the lines connecting the rectangles denote networks.
Note that the routers are labeled A, B, etc. and the networks are labeled 1, 10, 20, 30, etc. For
visual convenience, some of the routers and networks are not labeled. Dotted lines in the figure
indicate that the autonomous system continues on and perhaps loops back.

Now suppose that the routing table for router D.Note that the routing table has three columns.
The first column is for the destination network, the second column indicates the next router
along the shortest path to the destination network, and the third column indicates the number
of hops (i.e., the number of networks that have to be traversed, including the destination
network,  to get to the destination network along the shortest path). For this example, the table
indicates that to send a datagram from router D to destination network 1, the datagram should
be first sent to neighboring router A; moreover, the table indicates that destination network 1
is two hops away along the shortest path. Also note that the table indicates that network 30 is
seven hops away via router B. In principle, the routing table should have one row for each
network in the AS. (Although aggregation, a topic beyond the scope of this book, can be used to
aggregate entries.) It should also have at least one row for networks that are outside of the AS.

number
destination next 
of hops to
network router
destination
1 A 2
20 B 2
30 B 7
10 -- 1
.... .... ....

Now suppose that 30 seconds later, router D receives from router A the advertisement.Note
that this advertisement is nothing other but the routing table in router A! This routing table
says, in particular, that network 30 is only 4 hops away from router A.

number
destination next
of hops to
network router
destination
30 C 4
1 -- 1
10 -- 1
.... .... ....

Router D, upon receiving this advertisement, merges the advertisement with the "old" routing
table.In particular, router D learns that there is now a path through router A to network 30 that
is shorter than the path through router B. Thus, router D updates its routing table to account
for the "shorter" shortest path. How is it, you might ask, that the shortest path to network 30
became shorter. This is because either this decentralized distance vector algorithm was still in
the process of converging, or new links and/or routers were added to the AS, which changed
the actual shortest paths in the network.

number
destination next
of hops to
network router
destination
1 A 2
20 B 2
30 A 5
.... .... ....

Finally, let us take a quick look at a RIP routing table.  The RIP routing is taken from a UNIX
router giroflee.eurecom.fr. If you give a netstat -rn  command on a UNIX system, you can view
the routing table for that host or router. Performing a netstat on  giroflee.eurecom.fr yields the
following routing table:

  Destination           Gateway           Flags  Ref   Use   Interface


-------------------- -------------------- ----- ----- ------ ---------
127.0.0.1            127.0.0.1             UH       0  26492  lo0
192.168.2.           192.168.2.5           U        2     13  fa0
193.55.114.          193.55.114.6          U        3  58503  le0
192.168.3.           192.168.3.5           U        2     25  qaa0
224.0.0.0            193.55.114.6          U        3      0  le0
default              193.55.114.129        UG       0 143454

OSPF: Open Shortest Path First


Like RIP, the Open Shortest Path First (OSPF) routing is used for intra-AS routing. The "Open" in
OSPF indicates that the routing protocol specification is publicly available (e.g., as opposed to
Cisco's IGRP protocol).

OSPF was conceived as the successor to RIP and as such has a number of advanced features.  At
its heart, however, OSPF is a link-state protocol that uses flooding of link state information and
a Dijkstra least cost path algorithm. With OSPF, a router constructs a complete topological map
(i.e., a directed graph) of the entire autonomous system. The router then locally runs Dijkstra's
shortest path algorithm to determine a shortest path tree to all networks with itself as the root
node. The router's routing table is then obtained from this shortest path tree. Individual link
costs are configured by the network administrator.
Let us now contrast and compare the advertisements sent by RIP and OSPF. With OSPF, a
router periodically sends routing information to all other routers in the autonomous system,
not just to its neighboring routers. This routing information sent by a router has one entry for
each of the router's neighbors; the entry gives the distance (i.e., link state) from the router to
the neighbor. On the otherhand, a  RIP advertisement sent by a router contains information
about all the networks in the autonomous system, although this information is only sent to its
neighboring routers. In a sense, the advertising techniques of RIP and OSPF are duals of each
other.

Some of the advances embodied in OSPF include the following:

 Security.  All exchanges between OSPF routers (e.g., link state updates) are
authenticated. This means that only trusted routers can participate in the OSPF protocol
within a domain, thus preventing malicious intruders (or networking students taking
their newfound knowledge out for a joyride) from injecting incorrect information into
router tables.
 Multiple same-cost paths.  When multiple paths to a destination have the same cost,
OSPF allows multiple paths to be used (i.e., a single path need not be not chosen for
carrying all traffic when multiple equal cost paths exist).
 Different cost metrics for different TOS traffic.  OSPF allows each link to have different
costs for different TOS (type of service) IP packets.  For example, a high bandwidth
satellite link might be configured to have a low cost (and hence be attractive) for non-
time critical traffic, but a very high cost metric for delay-sensitive traffic. In essence,
OSPF sees different network topologies for different classes of traffic, and hence can
compute different routes for each type of traffic.
 Integrated support for unicast and multicast routing.   Multicast OSPF (RFC 1584) 
provides simple extensions to OSPF to provide for multicast routing (a topic we cover in
more depth in Section 4.8).  MOSPF uses the existing OSPF link database and adds a new
type of  link state advertisement to the existing OSPF link state broadcast mechanism.
 Support for hierarchy within a single routing domain. Perhaps the most significant
advance in OSPF is the ability to hierarchically structure an autonomous system.  Section
4.3 has already looked at the many advantages of hierarchical routing structures.  We
cover the implementation of OSPF hierarchical routing in the remainder of this section.

As OSPF autonomous system can be configured into "areas."  Each area runs its own OSPF link
state routing algorithm, with each router in an area broadcasting its link state to all other
routers in that area.  The internal details of an area thus remain invisible to all routers outside
the area.  Intra-area routing involves only those routers within the same area.

Within each area, one of more area border routers are responsible for routing packets outside
the area.  Exactly one OSPF area in the AS is configured to be the backbone area.  The primary
role of the backbone area is to route traffic between the other areas in the AS.  The backbone
always contains all area border routers in the AS and may contain non border routers as well. 
Inter-area routing within the AS requires that the packet be first routed to an area border
router (ntradomain routing), then routed though the backbone to the area border router that is
in the destination area, and then routed to the final destination.

 internal routers.  These routers, shown in black, are in a non-backbone areas and only
perform intra-AS routing.
 area border routers.  These routers, shown in blue, belong to both an area and the
backbone.
 backbone routers (non border routers).  These routers, shown in gray, perform routing
within the backbone but themselves are not area border routers.  Within a non-
backbone area, internal routers learn of the existence of routes to other areas from
information (essentially a link state advertisement, but advertising the cost of a route to
another area, rather than a link cost) broadcast within the area by its backbone routers.
 boundary routers.  A boundary router, shown in blue, exchanges routing information
with routers belonging to other autonomous systems. This router might, for example,
use BGP to perform inter-AS routing.  It is through such a boundary router that other
routers learn about paths to external networks.

Refrences:

 https://www.javatpoint.com/
 https://www.geeksforgeeks.org/
 https://www.javatpoint.com/
 http://www2.ic.uff.br/~michael/kr1999/4-network/4_05-routinet.htm

You might also like