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

OSPF by Computernetworkingnotes

- OSPF (Open Shortest Path First) is a link-state routing protocol used within autonomous systems to determine the best paths between nodes. It uses areas and link state advertisements (LSAs) to share routing information. - Areas allow large networks to be divided into smaller logical areas and hide routing details between areas to reduce routing overhead and improve convergence time. The backbone area connects all other areas. - Routers flood LSAs containing their link states throughout their area. Each router stores LSAs in a link-state database (LSDB) and runs the shortest path first (SPF) algorithm to determine the best paths.

Uploaded by

aozcan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

OSPF by Computernetworkingnotes

- OSPF (Open Shortest Path First) is a link-state routing protocol used within autonomous systems to determine the best paths between nodes. It uses areas and link state advertisements (LSAs) to share routing information. - Areas allow large networks to be divided into smaller logical areas and hide routing details between areas to reduce routing overhead and improve convergence time. The backbone area connects all other areas. - Routers flood LSAs containing their link states throughout their area. Each router stores LSAs in a link-state database (LSDB) and runs the shortest path first (SPF) algorithm to determine the best paths.

Uploaded by

aozcan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

1.

OSPF Fundamental Terminology


Explained
This tutorial explains OSPF terminology (AS Number, Public AS Numbers, Private AS
Numbers, Area, Backbone, Area off Backbone, ABR, IR, Link, State, LSA and LSDB)
including basic concepts of OSPF routing protocol, advantage & disadvantage of OSPF and
difference between AS and Area in detail with examples.

OSPF stands for Open Shortest Path First. OSPF is a link state open standard based routing
protocol. It was created in mid-1980. Since it is based on open standard, we can use it with
any vendor’s router.

Features and advantage of OSPF

 It supports both IPv4 and IPv6 routed protocols.


 It supports load balancing with equal cost routes for same destination.
 Since it is based on open standards, it will run on most routers.
 It provides a loop free topology using SPF algorithm.
 It is a classless protocol.
 It supports VLSM and route summarization.
 It supports unlimited hop counts.
 It scales enterprise size network easily with area concept.
 It supports trigger updates for fast convergence.

Just like other routing protocols, OSPF also has its negatives.

Disadvantage of OSPF

 It requires extra CPU process to run SPF algorithm.


 It requires more RAM to store adjacency topology.
 It is more complex to setup and hard to troubleshoot.

This tutorial is the first part of our article “OSPF Routing Protocol Explained with examples".
You can read other parts of this article here.

Basically OPSF was created to fulfill the requirement of enterprise size network. To scale a
large size network it uses area concept. Area concept is similar to Subnetting. It allows us to
separate the large internetwork into smaller networks known as areas.

Along with Area concept OSPF also supports Autonomous System (AS). Just like area, AS
also divide a large network into smaller networks.
Difference between AS and Area concept

Area concept is a feature of OSPF. It is limited only with OSPF. We cannot use it with other
routing protocol.

AS is an independent concept originally defined in RFC 1771. We can use it with any routing
protocols which understand its concept.
AS

An AS is a group of networks running under a single administrative control. This could be our
company or a branch of company. Just like Subnetting AS is also used to break a large
network in smaller networks.

AS creates a boundary for routing protocol which allow us to control how far routing
information should be propagated. Beside this we can also filter the routing information
before sharing it with other AS system. These features enhance security and scalability of
overall network.

Basically AS concept was developed for large networks. Routing protocols which were
developed for small networks such as RIP do not understand the concept of AS systems.

There are two types of routing protocols IGP and EGP.

IGP (Interior Gateway Protocol) is a routing protocol that runs in a single AS such as RIP,
IGRP, EIGRP, OSPF and IS-IS.

EGP (Exterior Gateway Protocol) is a routing protocol that performs routing between
different AS systems. Nowadays only BGP (Border Gateway Protocol) is an active EGP
protocol.

To keep distinguish between different autonomous systems, AS numbers are used. An AS


number starts from 1 and goes up to 65535. Same as IP addresses, AS numbers are divided in
two types; Private and public.

Public AS Numbers: - We only need to use public numbers if we are going to connect our
AS with Internet backbone through the BGP routes from Internet. IANA (Numbers Authority)
controls the public AS numbers.

Private AS Numbers: - Private AS numbers are used to break our internal network into the
smaller networks. We can use any valid AS number in our network unless we connect it with
public network. In above example we used two AS numbers 10 and 20 to divide our company
network.

In OSPF implementation, routers which connect two different ASes are known as autonomous
system boundary router (ASBR). In an OSPF network any router can become ASBR.

Connecting multiple ASes is a complex process. Luckily Cisco understood this and pushed
this hard topic in CCNP exam. Till associate level exams we only need to focus on single AS
design.

Ok let’s remove extra burden (ASes) from example network.


Area

OSPF implements two levels hierarchy with areas: backbone and area off backbone.

Backbone

Backbone is the central point of this implementation. Routers running in this area required to
maintain a complete database of entire network. All areas need to connect with this area
through a physical link or via a virtual link if physical link is not possible.

Area off backbone

Area off backbone is the extension of backbone. Routes running in this area required to
maintain an area specific database instead of complete database. This is a cool feature. It will
speed-up the convergence time.

ABR

Area Border Router (ABR) is a bridge between Backbone and Area off backbone. With
correct IP addressing we can summarize routes information on this router.

IR

IR (Internal Router) is a router running in area off backbone. IR only needs to maintain an
area centric local database.

Let’s put all these together in a simple example. Assume that our company has 600 hosts. It
decided to use three class C subnets; 192.168.0.0/24, 192.168.1.0/24 and 192.168.2.0/24.
Each subnet has 200 hosts.
For easy administration these subnets are divided in smaller networks. With VLSM default
subnet /24 is subnetted in /29. When we break a default class C Subnet /24 in Subnet /29, it
produces 32 networks (8 hosts in each network).

In this situation if we use a classical flat network design, routers need to learn and advertise
96 (32 + 32 + 32) networks. With hierarchy design we can reduce this number to 34 (32 + 1 +
1). Well…. how could this be possible?

Create three areas (area 0, area 1 and area 2) one for each default subnet.

In a hierarchy design we always start from area 0. No matter how many areas you create, you
should always start counting from 0. Area 0 has special privilege in OSPF implementation.
OSPF treats area 0 as backbone area. Assign area 0 to our first subnet 192.168.0.0/24.

Create area 1 and assign it to subnet 192.168.1.0/24. Finally create area 2 and assign it to
subnet 192.168.2.0/24.

So how this implementation reduce network broadcasts?

There are two types of router in an area; ABR and IR.

ABR is a special router which connects two areas. In a proper implementation it should share
only summarized route information with remote area.

Through routes summarization on ABR, other areas would see only summarized networks for
respective areas instead of full subnets. By doing this we are reducing the amount of
information that ABR need to share.

Have a look on following figure. It illustrates our implementation. Area 0 has 32 sub networks
(/29) created from one default network 192.168.0.0/24. ABR of area 0 is sharing only one
route 192.168.0.0/24 with area 1 and area 2 instead of all internal routes connecting 32
networks.
Hierarchy design limits network instability in a single area. It also reduces routing overhead
and speed up the convergence time. If properly implemented with VLSM, it can scale an
enterprise size network. Vice versa a little mistake can make it a nightmare.

I have a good news for you, Cisco tests hierarchical design in CCNP. So you can fee relax
until you prepare for CCNP exam. Till associate level exam Cisco limits designing part to
single area. We will use area 0 to explain the remaining article. Of-course we can use any
other valid area number, but it is good practice to take correct learning path from beginning.
And we know that in a hierarchy design Area 0 stands on the top.

Okay let’s remove other areas from network and make it simple. Now we have only single
area to study. Let’s explore it step by step. You learned that OSPF is a link state protocol.
What does it mean? What is link? And what is state?

Link

Link is an interface running OSPF routing protocol. When we add an interface in OSPF
process, it will be considered as a link.

State

State is the information associated with a link (interface). A link (interface) contains several
information such as IP address, up/down status, subnet mask, type of interface, type of
network , bandwidth and delay. OSFP consider this information as state.

LSA

Link state advertisement (LSA) is data packet. It contains link-state and routing information.
OSPF uses it to share and learn network information.

LSDB

Every OSPF router maintains a Link state database (LSDB). LSDB is collection of all LSAs
received by a router. Every LSA has a unique sequence number. OSPF stores LSA in LADB
with this sequence number.

Upon initialization or due to any change in network information, an OSPF speaking router
generates a LSA. This LSA includes the collection of all link-states or link state updates. All
routers exchange LSA by flooding. Each router that receives a LSA will store a copy of it in
its LSDB then propagate the LSA to other routers.

For example figure display a basic flooding process where R1 is generating LSA and flooding
it to the other routers of network.
R2 and R5 are the first clients who receive this LSA. They will update their LSDB and then
forward it to R3 and R6 respectively. R3 and R6 will update their database with this LSA and
then forward it to R4. From here only one router either R3 or R6 will be able to forward this
LSA to R4. Why does this happen?

Because flooding process has a mechanism to prevent the loops. Before sending a LSA to
neighbors, it asks them “Do you have this LSA?” If neighbor reply with yes, it will avoid
flooding that LSA to this neighbor. If neighbor reply with no, it will flood that LSA to this
neighbor. Thus R4 will only receive this LSA only from one neighbor; either R3 or R6.

OSPF routers share LSA only with neighbors. To become an OSPF neighbor, certain
conditions need to be matched. In next part of this article we will explain those conditions in
detail with examples.

2.OSPF Neighborship Condition and


Requirement
This tutorial explains OSPF Neighborship requirements (Area ID, Network ID,
Authentication, Hello and Dead Intervals, Stub Flag and MTU Size) and conditions in detail
with examples. Two routers cannot become OSPF neighbor until these configuration values
match on both routers.

OSPF routers share routing information only with neighbors. OSPF uses hello packets to
discover neighbors in segments. A hello packet contains some essential configuration values
that must be same on both routers who want to build an OSPF neighborship. In this tutorial
we will explain these configuration values in detail with example.

OSPF Neighborship Requirement

In order to become OSPF neighbor following values must be match on both routers.
 Area ID
 Authentication
 Hello and Dead Intervals
 Stub Flag
 MTU Size

This tutorial is the second part of our article “OSPF Routing Protocol Explained with
examples". You can read other parts of this article here.

Area ID

OSPF uses area concept to scale an enterprise size network. I have explained OSPF Areas in
first part of this article. Just for reference, OSPF areas create a logical boundary for routing
information. By default routers do not share routing information beyond the area. So in order
to become neighbor, two routers must belong to same area. Here one confusing fact needs to
clear. Area is associated with specific interface, not with entire router. This allows us to
configure the router in multiple areas. For example a router that has two interfaces; Serial
interface and FastEthernet interface, can run Serial interface in one area and FastEthernet in
another area. It means link which connects two routers need be in same area including its both
ends interface. Beside this interfaces should have same network ID and subnet mask.

Following figure illustrate a simple OSPF network. In this network R1 is eligible to form
neighborship with R4 and R2 respectively on S0/0 and F0/0.

I have question for you. Why neighborship cannot be built between R1 and R3?

Let’s find out the answer step by step.

Both interfaces should be in same area.


Yes both interfaces ( R1’s Fo/1 and R3’s F0/1) are in same area.

Both interfaces should be in same segment.


Yes both interfaces ( R1’s Fo/1 and R3’s F0/1) are connected with direct link.

Both interfaces should have same subnet mask.


Yes both interfaces have same subnet mask /30.
Both interfaces should have same network ID.
No both interfaces have different network ID. R1’s F0/1 has network ID 192.168.0.4/30 while
R3’s F0/1 has network ID 192.168.0.8/30. This condition does not match. Thus these two
routers on these interfaces cannot build neighborship.

Authentication

To enhance the security of network, OSPF allows us to configure the password for specific
areas. Routers who have same password will be eligible for neighborship. If you want to use
this facility, you need to configure password on all routers which you want to include in
network. If you skip any router, that will not be able to form an OSPF neighborship.

Suppose that our network has two routers R1 and R2. Both routers are connected with direct
link and meet all criteria mentioned in first requirement. What if I configure password in R1
and leave R2 as it is? Will it form neighborship with R2?

Well in this situation neighborship will not take place. Because when both routers see each
other’s hello packet in segment, they try to match all configure values including password
field. One packet has a value in password filed while other has nothing in it. In this case
routers will simply ignore each other’s packet.

Hello packets and hello interval

Hello packets are the special type of LSAs (Link State Advertisements) which are used to
discover the neighbors in same segment. And once neighborship is built same hello packets
are used to maintain the neighborship. Hello packets contain all necessary information that is
required to form a neighborship. Hello packets are generated and distributed in hello interval
via multicast. Hello interval is the length of time in seconds between the hello packets.
Default hello interval is 10 seconds.

Dead Intervals

As we already know once neighborship is built, hello packets are used to maintain the
neighborship.

So a router must see hello packets from neighbor in particular time interval. This time interval
is known as dead interval. Dead interval is the number of seconds that a router waits for hello
packet from neighbor, before declaring it as dead.

Default dead interval is 40 seconds. If a router does not receive hello packet in 40 seconds
from neighbor it will declare that as dead. When this happens, router will propagate this
information to other OSPF neighboring router via LSA message.
Hello and dead interval must be same between two neighbors. If any of these intervals are
different, neighborship will not form.

Stub Area Flag

This value indicates that whether sending router belong to stub area or not. Routers who want
to build OPSF neighborship must have same stub area flag.

For example we have two routers R1 and R2:-

 Both routers belong to same stub area, neighborship can be built


 Both routers belong to different stub area, neighborship cannot be built
 Both routers do not belong to any stub area, neighborship can be built
 Only one router belongs to a stub area, neighborship cannot be built

Just like another areas, Stub area also has some specific meanings in OSPF hierarchal design.

A stub area has following requirements:-

 A stub area can have only single exit point from that area.
 Stub area cannot be used as a transit area for virtual links.
 Routing from stub area to outside of the area should not have to take an optimal path.
 Any external networks (redistributed from other protocols into OSPF) should not be
flooded in stub area.

Configuring a stub area reduces the size of topology table inside that area. Thus routers
running in this area require less memory.
MTU

Technically MTU (Maximum Transmission Unit) is not a part of compulsory matching


conditions. Still we should match this value. If this value does not match routers may stuck in
Exstart/Exchange exchange stage.

Consider a situation where MTU setting between two OSPF routers does not match. If the
router with the higher MTU sends a packet larger than the MTU set on the neighboring router,
the neighboring router will ignores this packet. This function creates serious problem for
database updates. Database updates are heavier in nature. Once an update becomes larger than
the configured MTU setting, it needs to be spilt. In a case of miss match MTU, database
update may lost few bytes. Due to this, OSPF will ignore that update and cannot sync with
database. It will be stuck in Exstart/Exchange stage.

It is always worth to spend a little extra time in matching optional values along with
compulsory values. Matching configuration values will make troubleshooting easier.

That’s all for this part. In next part we will learn how OSPF routers build neighborship in
detail with examples.

3.OSPF Neighbor States Explained with


Example
OSPF routers go through the seven states, called Down, Attempt/Init, Two ways, Exstart,
Exchange, Loading and full while building adjacency with other OSPF speaking routers. In
this tutorial I will explain these states in easy language with examples. Along with these states
I will also explain few other terminologies used in this process.

OSPF Neighborship states

OSPF routers go through the seven states while building neighborship with other routers.

1. Down state
2. Attempt/Init state
3. Two ways state
4. Exstart state
5. Exchange state
6. Loading state
7. Full state

If you are an intermediate or advance leaner, grab this tutorial from where you want. But if
you are a beginner or Cisco exam candidate, I suggest you to go through the entire article
without skipping any section. Believe me OSPF is the most complex routing protocol among
the routing protocols which you will study in CCNA.

Let’s understand these states with a simple example. Assume that our network has two routers
running OSPF routing protocol. Routers are connected with each other via serial link. We just
turned on both routers simultaneously.
Down state

At this point both routers have no information about each other. R1 does not know which
protocol is running on R2. Vice versa R2 have no clue about R1. In this stage OSPF learns
about the local interfaces which are configured to run the OSPF instance.

In down state routers prepares themselves for neighborship process. In this state routers
choose RID (Router ID). RID plays a big role in OSPF process. Before we move in next state
let’s understand what is RID.

RID

RID is a unique identifier of Router in OSPF network. It must be unique within the
autonomous system. Routers identify each other through the RID in AS.

How do routers choose RID?

An OSPF router looks in three places for RID:-

1. Manual configuration
2. Loopback interface IP configuration
3. Active interfaces IP configuration

Manual configuration

Because RID plays a significant role in network, OSPF allows us to configure it manually.
RID is 32 bit long. IP address is also 32 bit in length. We can use IP address as a RID. This
gives us more flexibility over RID. For example we can use a simple and sequential IP
scheme such as 1.1.1.1 for R1, 1.1.1.2 for R2, 1.1.1.3 for R3, 1.1.1.4 for R4, 1.1.1.5 for R5
and so on.

We can assign RID from OSPF sub command mode.

Router(config)#router ospf 1
Router(config-router)#router-id ip_address

If we have assigned RID manually, OSPF will not look in next two options. Suppose we did
not assign it through the command. In this situation OSPF will look in next option to find the
RID.
Loopback interface IP configuration

If loopback interface is configured, OSPF will choose its IP address as RID. If multiple
loopback interfaces are configured, highest IP address will be chosen from all loopback
interfaces configuration.

If loopback interface is not configured, OSPF will look in next and last possible place to
choose the RID.

Active interface IP configuration

OSPF will choose the highest IP address from all operational IP interfaces. We should not let
the OSPF to use this option. This option does not provide a fix RID which is very necessary
for network stability.

This option has several reasons which may force OSPF to recalculate the RID such as
Interface which IP address is chosen may go down or for troubleshooting we may enable /
disable the interfaces.

Key points

 OSPF will follow the sequence (Manual configuration => Loopback interface => Active
interface) of options while selecting RID. If RID is found, it will not look in next option.
 OSPF will choose IP address only from operational IP interface. Operational means interface
should be listed as line is up and line protocol is up in the output of show ip interface brief
command.
 When multiple IP addresses are available, OSPF will always pick highest IP address for RID.
 For network stability we should always set RID from either router-id command or by using
loopback interfaces.
 By default Router chooses OSPF RID when it initialized. Once RID is selected it will use that
RID until next reboot.
 OSPF will not consider any change in RID which we make after initialization. We have two
options to implement new RID. Either reboots the router or clear the OPSF process with clear
ip ospf process command.
 If OSPF fails to select the RID, it will halt the OSPF process. We cannot use OSPF process
without RID.
In down state router do following

 Choose RID and initialize the OSPF process


 Run OSPF instance on local interfaces which are configured through the network command
such as R1(config-router)#network 10.0.0.0 0.0.255.255 area 0.
 Collect necessary information for Hello packet such RID and configuration values which are
required to build the neighborship.

Attempt/Init state

Neighborship building process starts from this state. R1 multicasts first hello packet so other
routers in network can learn about the existence of R1 as an OSPF router. This hello packet
contains Router ID and some essential configuration values such as area ID, hello interval,
hold down timer, stub flag and MTU. Essential configuration values must be same on routers
who want to build an OSPF neighborship.

In previous part of this article I explained essential configuration values in detail with
example. For this tutorial I assume that these values match on both routers. If essential
configuration values match, R2 will add R1 in his neighbor Table.
In Init state routers do following

 R1 will generate a hello packet with RID and essential configuration values and send it out
from all active interfaces.
 The hello packets are sent to the multicast address 224.0.0.5.
 R2 will receive this packet.
 R2 will read RID from packet and look in neighbor table for existing entry.
 If match found, R2 would skip neighborship building process and reset the dead interval
timer for that entry.
 If OSPF does not find a match in neighbor table, it will consider R1 (sender router) as a
possible OSPF neighbor and start neighborship building process.
 R2 will match its essential configuration values with values listed in packet.
 If all necessary configuration values match, R2 will add R1 in its neighbor table.

At this moment R1 has no idea about R2. R1 will learn about R2 when it will respond.

Before we enter in third state, let’s have a quick look on attempt state.

Attempt

In Non-broadcast multi-access environment such as Frame Relay and X.25, OSPF uses
Attempt state instead of Init state. OSPF uses this state only if neighbors are statically
configured with neighbor command. In this situation, it does not have to discover them
dynamically. As it already knows the neighbors, it will use unicast instead of multicast in this
state.

Once neighborship is built, OSPF uses hello packets as keep alive. If a router does not receive
a hello packet from any particular neighbor in dead interval, it will change its state to down
from full. After changing the state it will make an effort to contact the neighbor by sending
Hello packets. This effort is made in Attempt state.

Basically Both Init and Attempt states describe similar situation where one router has sent a
hello packet and waiting for response.

Two ways state

If essential configuration values match, R2 will add R1 in neighbor table and reply with its
hello packet. As R2 knows the exact address of R1, it will use unicast for reply. Beside RID
and configuration values, this packet also contains the R2’s neighbor table data. As we know
R2 has already added R1 in its neighbor table. So when R1 will see R2’s neighbor table data,
R1 would also see its name in this data. This will assure R1 that R2 has accepted its
neighborship request.

At this point:-

 R2 has checked all essential configuration values listed in hello packet which it received from
R1.
 R2 is ready to build neighborship with these parameters.
 R2 has added R1 in its neighbor table.
 To continue the neighborship process, R2 has replied with its hello packet.
 R1 has received a reply from neighbor, with its own RID listed in R2’s neighbor table.

Now it is R1’s turn to take action on R2’s reply. This reply would be based on hello packet
which it received from R2. As we know that this hello packet contains one additional field;
Neighbor table data field which indicates that this is not a regular neighbor discovery hello
packet. This packet is a reply of its own request.

R1 will take following actions:-

 It will read RID from hello packet and look in its neighbor table for existing entry.
 If a match for RID found in neighbor table, it would reset the dead interval timer for that
entry.
 If a match is not found in neighbor table, it would read the essential configuration values
from packet.
 It will match configuration values with its own values. If values match, it will add R2’s RID in
neighbor table.
 If packet contains neighbor table data with its own RID, it will consider that as request to
enter in two way state.
 R1 will reply with a hello packet which contains its neighbor table data.
 This packet is a confirmation of two ways state.
Fine, our routers are neighbor now. They are ready to exchange the routing information.

Before we understand how routers will exchange routing information, we need to understand
the types of network. OSPF uses different types of exchange process for different types of
network.

Point to point network

It is a Cisco specific network type. It connects a single pair of routers. HDLC and PPP are
example of point to point network type. In this type of network:-

 All routers form full adjacencies with each other.


 Hello packets are sent using a multicast address 224.0.0.5
 No DR and BDR are required.
 All routers are considered as AllSPFRouters.

I will explain the terms adjacencies, DR, BDR and AllSPFRouters shortly.

Broadcast Networks

Broadcast networks are capable in connecting more than two devices. Ethernet and FDDI are
the example of broadcast type network. In this type of network:-

 A single transmitted packet can be received by all attached devices.


 DR and BDR are required.
 All routers form full adjacencies only with DR and BDR.
 Routers use a multicast address 224.0.0.6 to update the DR.
 DR uses a multicast address 224.0.0.5 to update the all routers.

NMBA

Non-broadcast Multi-access networks are also capable in connecting more than two devices.
But they do not have broadcast capability. X.25 and Frame Relay are the example of NMBA
type network. In this type of network:-
 As network does not have broadcast capability, dynamic network discovery will not be
possible.
 OSPF neighbors must have to define statically.
 All OSFP packets are unicast.
 DR and BDR are required.

Point to multipoint

Point to multipoint is a special implementation of NMBA network where networks are


configured as a collection of point to point links. In this type of network:-

 Network must be configured statically.


 No DR and BRD are selected in this type of network.
 OSPF packets are multicast.

We can divide these networks in two types;

1. Networks which need DR and BDR such as broadcast and NBMA


2. Networks which do not need DR and BDR such as point to point and point to multipoint

So what does DR and BDR actually do? Why do we need them in our network?

DR and BDR

OSPF routers in a network which need DR (Designated router) and BDR (Backup designated
router) do not share routing information directly with all each other’s. To minimize the
routing information exchange, they select one router as designated router (DR) and one other
router as backup designated router (BDR). Remaining routers are known as DROTHERs.

All DROTHERs share routing information with DR. DR will share this information back to
all DROTHERs. BDR is a backup router. In case DR is down, BDR will immediately take
place the DR and would elect new BDR for itself.
Main reason behind this mechanism is that routers have a central point for routing information
exchange. Thus they need not to update each other’s. A DROTHER only need to update the
central point (DR) and other DROTHERs will receive this update from DR.

Practically this will cut the numbers of routing information exchange from O(n*n) to O(n)
where n is the number of routers in a multi-access segment.

For example following figure illustrates a simple OSPF network. In this network R4 is
selected as DR and R5 is selected as BDR. DROTHERs (R1, R2 and R3) will share routing
information with R4 (DR) and R5 (BDR), but they will not share routing information with
each other. Later DR will share this information back to all DROTHERs.

DR and BDR Election process

OSPF uses priority value to select DR and BDR. OSPF router with the highest priority
becomes DR. Router with second highest priority becomes BDR. If there is a tie, router with
the highest RID will be chosen.

Priority value is 8 bit in length. Default priority value is 1. We can set any value from range 0
to 255. We can change it from Interface Sub-configuration mode with ip ospf priority
command.

We can force any router to become DR (Highest) or BDR (Second highest) by changing its
priority value. If we set priority value to 0, it will never become DR or BDR.

For example following figure illustrates a simple OPSF network. In this network we have five
routers. We do not want that R3 becomes DR or BDR. So we changed its default priority
value to 0. Now let’s see how these routers select DR and BDR.
Condition 1:- Use the highest priority value

This condition says “Arrange all routes in high to low order and pick the highest for DR and
second highest for BDR”. If we arrange our routers in high to lower order, R3 will stand at
last. Remaining routers have equal priority value. So at the end of this condition we have a tie
between four routers.

Condition 2:- If there is a tie use the highest RID

This condition says “If there is a tie, use RID value to choose”. In our network we have a tie
between four routers, so our routers will use RID to elect the DR and BDR. Arranging routers
in high to low order will give us the DR and BDR.

As we know that there are two types of network; networks which do not require DR and BDR
for exchange process and networks which require DR and BDR for exchange process.

In first type all routers will exchange routing information with each other’s. In second type
DROTHERs will exchange routing information with DR and BDR.

Routers which will exchange routing information are known as adjacent. Relationship
between two adjacent is known as adjacency. This terminology is associated with interfaces.

A router which has two interfaces can be adjacent in one interface and DROTHER in other
interface.

For example following figure illustrates an OSPF running NBMA network. In this network;

R3 will build adjacency with R1, so in this relationship they will be considered as Adjacent.
R3 will not build adjacency with R4, so in this relationship they will be considered only
DROTHER.

In a network which doesn’t require DR and BDR, all routers will be considered as Adjacent
and relationship between them will be considered as Adjacency.

Only adjacent routers will enter in next states to build the adjacency.

Exstart state

Routers who decided to build adjacency will form a master / slave relationship. In each
adjacency router who has higher RID will become master and other will become slave. Do not
mix Master /Slave relationship with DR/ BDR/ DROTHER relationship. Both terms look
similar but have different meaning. DR/ BDR/ DROTHER relationship is built in a segment
and have a wider meaning while Master / Slave relationship is built between two interfaces
which need to exchange routing information. Master / Slave relationship has limited purpose.
It is used to decide the Router who will start exchange process. Always Master starts
exchange process.
Once routers settle down on Master/Slave, they will establish the initial sequence numbers
which will be used in routing information exchange process. Sequence numbers insure that
routers get most accurate information.

Exchange state

In exchange state, Master and slave decide how much information needs to be exchange. A
router that has more than one interface may learn same network information from different
sources. An OSFP router is smart enough to filter the updates before receiving it. It will ask
only for the updates which it does not have. In this state, routers will filter the updates which
need be to exchange.

Before we learn how routes will filter this information, let’s understand few relative terms.

LSA and LSDB are explained in the first part of this tutorial. To maintain the flow of this
article I am including the summary of these terms here again.

LSA

Link state advertisement (LSA) is a data packet which contains link-state and routing
information. OSPF uses it share and learn network information.

LSDB

Every OSPF router maintains a Link state database (LSDB). LSDB is collection of all LSAs
received by a router. Every LSA has a sequence number. OSPF stores LSA in LADB with
this sequence number.

DBDs

Database description packets (also referred as DDPs) contain the list of LSA. This list
includes link state type, cost of link, ID of advertising router and sequence number of link.
Make sure you understand this term correctly. It is only a list of all LSAs from its respective
database. It does not include full LSAs.
In this state, routers exchanges DBDs. Through DBDs routers can learn which LSAs they
already have. For example in following network R1 has A1, A2 and B2 LSAs in its LADB.
So it will send a list of these LSAs to R2. This list is a DBDs. R2 will send an
acknowledgment of receiving the list with LSACK signal. Same as R2 will send its DBDs to
R1 and R1 would acknowledge that with its LSACK single.

LSR

Upon receiving DBDs, routers will compare it with their own LADB. Thus they will learn
what they need to order. For example R1 received a check list (DBDs) of A1 and B1. When it
will compare this list with its own LSA database (LADB), it will learn that it already has A1.
So it does not need to order this LSA again. But it does not have B1, so it needs to order for
this LSA. After a complete comparison, both routers will prepare a list of LSAs which they do
not have in their own LADB. This list is known as LSR (Link State Request).

What other have (DBDs) – What I have (LADB) = What I need to order (LSR)

At the end of this state both routers have a list of LSAs which need to be exchanged.

Loading state

In this state actual routing information is exchanged. Routers exchange LSAs from LSR list.

Routers will use LSU (Link state update) to exchange the LSAs. Each LSA contains routing
information about a particular link. Routers also maintain a retransmission list to make sure
that every sent LSA is acknowledged.

For example following figure illustrates loading state of above example. R1 sent a LSU which
contain two LSAs but it received acknowledgement of only one, so it had to resend lost LSA
again.
This exchange process will continue till router has any unsent LSA in LSR list.

Full state

Full state indicates that both routers has been exchanged all LSAs from LSR list. Now they
have identical LSDB.

Adjacent routers remain in this state for life time. This state also referred as adjacency. If any
change occurs in network, routers will go through this process again.

Maintaining adjacency

 Routers will send hello messages in hello interval.


 If a router does not receive hello message from neighbor in dead interval, it will declare that
neighbor as dead.
 Once a neighbor is dead, router will flood this change to other connected neighbors.
 Beside this if router detect any change in network or receive any update, it will flood that
change.
 A LSA has a default lifetime of 30 minutes. Any unchanged LSAs must be reflooded in every
30 minutes.

That’s all for this part. In next part, I will explain configuration part of OSPF.
To keep this tutorial simple, I used terms neighbor and adjacencies synonymously.
Technically both terms are related but have different meanings especially in OSPF.
Neighboring routers are defined in RFC 2328.

Neighboring routers are the routers that have interfaces in common network.

Adjacency is a relationship formed between neighboring routers for the purpose of


exchanging routing information. Not every pair of neighboring routers becomes adjacent.

4.OSPF Configuration Step by Step Guide


This tutorial explains how to configure OSPF Routing protocol step by step with practical
example in packet tracer. Learn OSPF configuration commands, OSPF show commands,
OSPF network configuration (Process ID, Network ID, Wild card mask and Area number)
and OSPF routing in detail.

For demonstration we will use packet tracer network simulator software. You can use real
Cisco devices or any other network simulator software for following this guide.

Create a topology as illustrate in following figure or download this pre-created topology.

Download OSPF Practice Topology

Initial IP Configuration

Device Interface IP Configuration Connected with

PC0 Fa0/0 10.0.0.2/8 Router0’s Fa0/0

Router0 Fa0/0 10.0.0.1/8 PC0’s Fa0/0


Device Interface IP Configuration Connected with

Router0 Fa0/1 192.168.1.1/30 Router5’s Fa0/1

Router5 Fa0/1 192.168.1.2/30 Router0’s Fa0/1

Router5 Fa0/0 192.168.1.5/30 Router6’s F0/0

Router6 Fa0/0 192.168.1.6/30 Router5’s Fa0/0

Router6 Fa0/1 20.0.0.1/8 Server0’s Fa0/0

Server0 Fa0/0 20.0.0.2/8 Router6’s Fa0/1

Router0 Serial 0/0/0 (DCE) 192.168.0.1/30 Router1’s Se0/0/0

Router1 Serial 0/0/0 192.168.0.2/30 Router0’s Se0/0/0

Router1 Serial 0/0/1 (DCE) 192.168.0.5/30 Router2’s Se0/0/1

Router2 Serial0/0/1 192.168.0.6/30 Router1’s Se0/0/1

Router2 Serial 0/0/0 (DCE) 192.168.0.9/30 Router6’s Se0/0/0

Router6 Serial 0/0/0 192.168.0.10/30 Router2’s Se0/0/0

Router0 Serial 0/0/1 192.168.2.1/30 Router3’s Se0/0/1

Router3 Serial 0/0/1 (DCE) 192.168.2.2/30 Router0’s Se0/0/1

Router3 Serial 0/0/0 192.168.2.5/30 Router4’s Se0/0/0

Router4 Serial 0/0/0 (DCE) 192.68.2.6/30 Router3’s Se0/0/0

Router4 Serial 0/0/1 192.168.2.9/30 Router6’s Se0/0/1

Router6 Serial0/0/1 (DCE) 192.168.2.10/30 Router4’s Se0/0/1

Assign IP address to PC

Double click PC0 and click Desktop menu item and click IP Configuration. Assign IP
address 10.0.0.2/8 to PC0.
Repeat same process for Server0 and assign IP address 20.0.0.2/8.

Assign IP address to interfaces of routers

Double click Router0 and click CLI and press Enter key to access the command prompt of
Router0.

Four interfaces FastEthernet0/0, FastEthernet0/1, Serial 0/0/0 and Serial0/0/1 of Router0 are
used in this topology. By default interfaces on router are remain administratively down during
the start up.

We need to configure IP address and other parameters on interfaces before we could actually
use them for routing. Interface mode is used to assign the IP address and other parameters.
Interface mode can be accessed from global configuration mode. Following commands are
used to access the global configuration mode.

Router>enable
Router# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#

From global configuration mode we can enter in interface mode. From there we can configure
the interface. Following commands will assign IP address on FastEthernet0/0 and
FastEthernet0/1.

Router(config)#interface fastEthernet 0/0


Router(config-if)#ip address 10.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address 192.168.1.1 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#

interface fastEthernet 0/0 command is used to enter in interface mode.

ip address 10.0.0.1 255.0.0.0 command would assign IP address to interface.

no shutdown command would bring the interface up.

exit command is used to return in global configuration mode.

Serial interface needs two additional parameters clock rate and bandwidth. Every serial
cable has two ends DTE and DCE. These parameters are always configured at DCE end.

We can use show controllers interface command from privilege mode to check the cable’s
end.

Router#show controllers serial 0/0/0


Interface Serial0/0/0
Hardware is PowerQUICC MPC860
DCE V.35, clock rate 2000000
[Output omitted]

Fourth line of output confirms that DCE end of serial cable is attached. If you see DTE here
instead of DCE skip these parameters.

Now we have necessary information let’s assign IP address to serial interfaces.

Router# configure terminal


Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface serial 0/0/0
Router(config-if)#ip address 192.168.0.1 255.255.255.252
Router(config-if)#clock rate 64000
Router(config-if)#bandwidth 64
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/1
Router(config-if)#ip address 192.168.2.1 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit

Router#configure terminal Command is used to enter in global configuration mode.

Router(config)#interface serial 0/0/0 Command is used to enter in interface mode.

Router(config-if)#ip address 192.168.0.1 255.255.255.252 Command assigns IP address to


interface. For serial link we usually use IP address from /30 subnet.

Router(config-if)#clock rate 64000 In real life environment this parameter controls the data
flow between serial links and need to be set at service provider’s end. In lab environment we
need not to worry about this value. We can use any valid clock rate here.
Router(config-if)#bandwidth 64 Bandwidth works as an influencer. It is used to influence
the metric calculation of OSPF or any other routing protocol which uses bandwidth parameter
in route selection process. Serial interface has default bandwidth of 1544Kbps. To explain,
how bandwidth influence route selection process we will configure (64Kbps) bandwidth on
three serial DCE interfaces of our network; R0’s Se0/0/0, R1’s Se0/0/1 and R2’s Se0/0/0.

Router(config-if)#no shutdown Command brings interface up.

Router(config-if)#exit Command is used to return in global configuration mode.

We will use same commands to assign IP addresses on interfaces of remaining routers.

Router1

Router2

As I mention earlier, serial interface has a default bandwidth of 1544Kbps. If we don’t assign
any custom bandwidth, router would use default bandwidth. To see this feature in action we
will not assign bandwidth on remaining routers.

Router6
Router5

Router3

Router4
Great job we have finished our half journey. Now routers have information about the
networks that they have on their own interfaces. Routers will not exchange this information
between them on their own. We need to implement OSPF routing protocol that will insist
them to share this information.

To be on same track I have uploaded my practice topology. Use this if you want to skip above
IP configuration part.

Download OSPF Practice Topology with IP configuration

Configure OSPF routing protocol

Enabling OSPF is a two steps process:-

 Enable OSPF routing protocol from global configuration mode.


 Tell OSPF which interfaces we want to include.

For these steps following commands are used respectively.

Router(config)# router ospf process_ID


Router(config-router)# network IP_network_# [wild card mask] Area Number
area number

Router(config)# router ospf process ID

This command will enable OSPF routing protocol in router. Process ID is a positive integer.
We can use any number from 1 to 65,535. Process ID is locally significant. We can run
multiple OSPF process on same router. Process ID is used to differentiate between them.
Process ID need not to match on all routers.

Router(config-router)# network IP_network_# [wildcard_mask] area [area number]

Network command allows us to specify the interfaces which we want to include in OSPF
process. This command accepts three arguments network number, wildcard mask and area
number.

Network number

Network number is network ID. We can use any particular host IP address or network IP
address. For example we can use 192.168.1.1 (host IP address) or we can use 192.168.1.0
(Network IP address). While targeting a specific interface usually we use host IP address
(configured on that interface).

While targeting multiple interfaces, we use network IP address. So any interface that belongs
to specified network ID will be selected.

Wildcard mask

Wildcard mask are used with network ID to filter the interfaces. Wildcard mask is different
from subnet mask. Subnet mask is used to separate the network portion and host portion in IP
address. While wildcard mask is used to match corresponding octet in network portion.
Wildcard mask tells OSPF the part of network address that must be matched. Wildcard masks
are explained with examples in access list tutorials of this category.

Key points

0 (Decimal – octet format) Wildcard mask indicates that corresponding octet in network
address must be matched exactly.

255 (Decimal – octet format) Wildcard mask indicates that we don’t care about
corresponding octet in network address.

For example

0 (Binary – bit format) Wildcard mask indicates that corresponding bit in network address
must be matched exactly.

255 (Binary – bit format) Wildcard mask indicates that we don’t care about corresponding bit
in network address.

OSPF is a classless protocol. With wildcard we can also filter Subnetted networks. In classes
implementation usually we use Subnetted networks. For example consider following figure

We have four networks 172.168.1.0/24, 172.168.2.0/24, 172.168.3.0/24 and 172.168.4.0/24


subnetted from single class B network 172.168.0.0/16. Classful configuration does not
understand the concept of subnetting. In classful configuration all these networks belong to a
single network. Classful configuration works only with in default boundary of mask. Default
boundary of this address is 16 bits. So a classful routing protocol will match only first 16 bits
(172.168.x.y) of network address. A classful routing protocol such as RIP cannot distinguish
between different Subnetted networks.

A classless routing protocol such as OSPF goes beyond the default boundary of mask and
work well with Subnetted networks. With wildcard mask we can easily filter Subnetted
networks.

With wildcard we are no longer limited with default boundaries. We can match Subnetted
networks as well as default networks.

For example we want to exclude serial interfaces in above configuration. We can use a
wildcard mask of 0.0.0.255 to match the subnet mask of /24.

Router(config-router)# network 172.168.1.0 0.0.0.255


Router(config-router)# network 172.168.2.0 0.0.0.255

Above commands will ask router to match /24 bits of address instead of default /16 bits. Now
router will look for 172.168.1.x and 172.168.2.x network. Our serial interfaces have
172.168.3.0/24 and 172.168.4.0/24 networks which do not fall in these search criteria.

Let’s take one more example, if we use following network command, which interfaces would
be selected.

Router(config-router)# network 192.168.0.0 0.0.0.3

In this case valid host IP addresses are 192.168.0.1 and 192.168.0.2. So any interface that has
these IP address would be selected. /30 network is usually used for serial link connection
which need only two valid host IP addresses; one for each end.

If you are unfamiliar with wildcard mask, I suggest you to check our tutorials on access lists
configuration in this category. In those tutorials wildcard masks are explained in detail with
examples.

For this tutorial let’s move on third argument. Third argument which network command
accept is area number. This parameter say router to put matched interface in specified area.
OSPF areas are explained in second part this article.

Now we know the essential commands for configuration. Let’s implement them in our
network.
OSPF configuration

Router0

Router1

Router2

Router6
Router5

Router4

Router3

That’s it. Our network is ready to take the advantage of OSPF routing. To verify the setup we
will use ping command. ping command is used to test the connectivity between two devices.

We have two routes between source and destination. tracert command is used to know the
route which is used to get the destination.

Access the command prompt of PC1 and use ping command to test the connectivity from
Server0. After that use tracert command to print the taken path.
Great! We have successfully implemented OSFP routing in our network.

If you did not get the same out as explained in this tutorial, use this configured topology to
cross check your topology and find out the reason.
Download OSPF Practice Topology with OSPF configuration

Summary

Command Description

Router(config)#router opsf 10 Enable OSPF routing protocol under process ID 10.

Router(config-router)#network
Enable OSPF with area 0 on matching interface.
10.10.0.0 0.0.255.255 area 0

Router(config)#interface Create a Loopback interface and move in sub interface


loopback 0 configuration mode

Router(config-if)#ip address
Assign IP address to loopback interface.
192.168.250.250 255.255.255.0

Router(config-router)#router-id
Set 1.1.1.1 as router ID
1.1.1.1

Router(config)#interface serial
Inter in sub interface configuration mode
0/0

Router(config-if)#ip ospf priority Used to influence DR/BDR selection process. Valid range is 0 to
100 255. 0 makes router ineligible for DR/BDR while 255 makes router
guaranteed DR/BDR. Higher priority value means higher chance of
Command Description

becoming DR/BDR.

Used to influence route metric cost. Cost is the inverse of


Router(config-if)#bandwidth 256 bandwidth. Higher bandwidth has lower cost. Bandwidth is
defined in Kbps. 256 means 256 Kbps.

Router(config-if)#ip ospf hello- Set hello interval timer to 15 seconds. Hello timer must be match
interval timer 15 on both routers in order become neighbors.

Router(config-if)#ip ospf dead- Set dead interval timer to 60 seconds. Dead interval timer must be
interval 60 match on both routers in order to become neighbor

Router#show ip route Display all routes from routing table

Router#show ip route ospf Display all routers learned through OSPF from routing table

Router#show ip ospf Display basic information about OSPF

Router#show ip ospf interface Display information about all OSPF active interfaces

Router#show ip ospf interface


Display OSPF information about serial 0/0/0 interface
serial 0/0/0

Router#show ip ospf neighbor


OSPF neighbors with basic info
List all

Router#show ip ospf neighbor


List OSPF neighbors with detail info
detail

Router#show ip ospf database Display data for OSPF database

Router#clear ip route * Clear all routes from routing table.

Router#clear ip route 10.0.0.0/8 Clear particular route from routing table

Router#clear ip ospf counters Clear OSPF counters

Router#debug ip ospf events Display all ospf events

Router#debug ip ospf packets Display exchanged OSPF packets

Router#debug ip ospf adjacency Display DR/BDR election process state


That’s all for this part. In next part of this article I will explain how OSPF calculate the
shortest path for destination.

5.OSPF Metric cost Calculation Formula


Explained
This tutorial explains OSPF Metric calculation formula and SPF algorithm step by step in
detail with examples. Learn how SPF (Shortest Path First) algorithm calculates cumulative
cost of route to build the Shortest Path Tree (SPT) and how OSPF Metric Formula can be
manipulated by changing reference bandwidth value.

Shortest Path First (SPF) Algorithm

As we know upon initialization or due to any change in routing information an OSPF router
generates a LSA. This LSA (Link State Advertisement) contains the collection of all link-
states on that router. Router propagates this LSA in network. Each router that receives this
LSA would store a copy of it in its LSA database then flood this LSA to other routers.

After database is updated, router selects a single best route for each destination from all
available routes. Router uses SPF algorithm to select the best route.

Just like other routing algorithm SPF also uses a metric component called cost to select the
best route for routing table.

This tutorial is the last part of our article “OSPF Routing Protocol Explained with
examples". You can read other parts of this article here.

OSPF Metric cost

Logically a packet will face more overhead in crossing a 56Kbps serial link than crossing a
100Mbps Ethernet link. Respectively it will take less time in crossing a higher bandwidth link
than a lower bandwidth link. OSPF uses this logic to calculate the cost. Cost is the inverse
proportional of bandwidth. Higher bandwidth has a lower cost. Lower bandwidth has a higher
cost.

OSPF uses following formula to calculate the cost

Cost = Reference bandwidth / Interface bandwidth in bps.

Reference bandwidth was defined as arbitrary value in OSPF documentation (RFC 2338).
Vendors need to use their own reference bandwidth. Cisco uses 100Mbps (108) bandwidth as
reference bandwidth. With this bandwidth, our equation would be

Cost = 108/interface bandwidth in bps


Key points

 Cost is a positive integer value.


 Any decimal value would be rounded back in nearest positive integer.
 Any value below 1 would be considered as 1.

Now we know the equation, let’s do some math and figure out the default cost of some
essential interfaces.

Default cost of essential interfaces.

Interface Type bandwidth Metric Calculation Cost

Ethernet Link 10Mbps 100000000/10000000 = 10 10

FastEthernet Link 100Mbps 100000000/100000000 = 1 1

Serial Link 1544Kbps(default) 100000000/1544000 = 64.76 64

Cost of common lines

Line Bandwidth Metric calculation Cost

56 Kbps line 56Kbps 100000000/56000 = 1785.71 1785

64 Kbps line 64Kbps 100000000/64000 = 1562.5 1562

128 Kbps line 128Kbps 100000000/128000 = 781.25 781

512 Kbps line 512 Kbps 100000000/512000 = 195.31 195

1 Mbps line 1Mbps 100000000/1000000 = 100 100

10 Mbps line 10Mbps 100000000/10000000 = 10 10

100 Mbps line 100Mbps 100000000/100000000 = 1 1

1 Gbps line 1Gbps 100000000/100000000 0= 0.1 1

10 Gbps line 10Gbps 100000000/10000000000 = 0.01 1

SPT (Shortest Path Tree)

OSPF router builds a Shortest Path Tree. SPT is just like a family tree where router is the root
and destination networks are the leaves. SPF algorithm calculates the branch cost between
leaves and root. Branch with lowest cost will be used to reach at leaf. In technical language
route that has lowest cumulative cost value between source and destination will be selected
for routing table.

Cumulative cost = Sum of all outgoing interfaces cost in route

Best route for routing table = Route which has the lowest cumulative cost

Summary

 OSPF uses SPT tree to calculate the best route for routing table.
 A SPT tree cannot grow beyond the area. So if a router has interfaces in multiple areas, it
needs to build separate tree for each area.
 SPF algorithm calculates all possible routes from source router to destination network.
 Cumulative cost is the sum of the all costs of the outgoing OSPF interfaces in the path.
 While calculating cumulative cost, OSPF consider only outgoing interfaces in path. It does not
add the cost of incoming interfaces in cumulative cost.
 If multiple routes exist, SPF compares the cumulative costs. Route which has the lowest
cumulative cost will be chosen for routing table.

Now we have a basic understanding of SPF algorithm. In remaining part this tutorial we will
learn how SPF algorithm selects the best route from available routes.

Create a practice lab as illustrated in following figure or download this pre-created practice
lab and load in practice tracer.

Download OSPF Practice Topology with OSPF configuration

Access CLI prompt of Router0.

Run show ip route ospf command from privilege mode to view all learned routes through the
OSPF protocol.
As output shows, Router0 has six routes from OSPF in routing table. We will go through the
each route and find out why it was chosen as the best route for routing table by OSPF.

Route 20.0.0.0

We have three routes to get 20.0.0.0/8 network. Let’s calculate the cumulative cost of each
route.

Via Route R0-R1-R2-R6

Router Exit Interface Bandwidth Metric Calculation Cost

R0 Se0/0/0 64Kbps ( Manually Assigned) 100000000/64000 = 1562.5 1562

R1 Se0/0/1 64Kbps ( Manually Assigned) 100000000/64000 = 1562.5 1562

R2 Se0/0/0 64Kbps ( Manually Assigned) 100000000/64000 = 1562.5 1562

R6 Fa0/1 100Mbps 100000000/100000000 = 1 1

Cumulative cost of route (1562 + 1562 + 1562 + 1) = 4687

Via route R0 – R3 – R4 – R6

Router Exit Interface Bandwidth Metric Calculation Cost

R0 Se0/0/1 1544Kbps (Default ) 100000000/1544000 = 64.76 64

R3 Se0/0/0 1544Kbps (Default ) 100000000/1544000 = 64.76 64

R2 Se0/0/1 1544Kbps (Default ) 100000000/1544000 = 64.76 64

R6 Fa0/1 100Mbps 100000000/100000000 = 1 1


Router Exit Interface Bandwidth Metric Calculation Cost

Cumulative cost of route (64 + 64 + 64 + 1) = 193

Via route R0 – R5 – R6

Router Exit Interface Bandwidth Metric Calculation Cost

R0 Fa0/1 100Mbps 100000000/100000000 = 1 1

R5 Fa0/0 100Mbps 100000000/100000000 = 1 1

R0 Fa0/1 100Mbps 100000000/100000000 = 1 1

Cumulative cost of route (1+ 1 + 1) = 3

Among these routes, route R0-R5-R6 has the lowest cumulative cost. So it was selected as the
best route for routing table.

Route 192.168.0.4

Via Route R0 – R1

R0’s Serial 0/0/0 cost (1562) + R1’s Serial 0/0/1 cost (1562) = 3124 (Cumulative cost)

Via Route R0 – R3 – R4 – R6 – R2

R0’s Serial 0/0/1 cost (64) + R3’s Serial 0/0/0 cost (64) + R4’s Serial 0/0/1 cost (64) + R6’s
Serial 0/0/0 cost (64) + R2’s Serial 0/0/1 cost (64) = 320 (Cumulative cost)

Via Route R0 – R5 – R6 – R2
Ro’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) + R6’s Serial 0/0/0 cost (64)
+R2’s Serial 0/0/1 cost (64) = 130 (Cumulative cost)

Among these routes, Route R0 – R5 – R6 – R2 has the lowest cost so it was picked for
routing table.

Route 192.168.0.8

Via Route R0 – R1

R0’s Serial 0/0/0 cost (1562) + R1’s Serial 0/0/1 cost (1562) + R2’s Serial 0/0/0 (1562) =
4686 (Cumulative cost)

Via Route R0 – R3 – R4 – R6

R0’s Serial 0/0/1 cost (64) + R3’s Serial 0/0/0 cost (64) + R4’s Serial 0/0/1 cost (64) + R6’s
Serial 0/0/0 cost (64) = 256 (Cumulative cost)

Via Route R0 – R5 – R6

Ro’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) + R6’s Serial 0/0/0 cost (64) =
66 (Cumulative cost)
Among these routes, Route R0 – R5 – R6 has the lowest cost so it was picked for routing
table.

Route 192.168.1.4

Via Route R0 – R1 – R2 – R6

R0’s Serial 0/0/0 cost (1562) + R1’s Serial 0/0/1 (1562) + R2’s Serial 0/0/0 (1562) + R6’s
FastEthernet 0/0 (1) = 4687 (Cumulative cost)

Via R0 – R3 – R4 – R6

R0’s Serial 0/0/1 cost (64) + R3’s Serial 0/0/0 cost (64) + R4’s Serial 0/0/1 cost (64) + R6’s
FastEthernet 0/0 (1) = 193

Via R0 – R5

R0’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) = 2
Among these routes, Route R0 – R5 has the lowest cost so it was selected as the best route.

Route 192.168.2.4

Via Route R0 – R1 – R2 – R6 – R4

R0’s Serial 0/0/0 cost (1562) + R1’s Serial 0/0/1 cost (1562) + R2’s Serial 0/0/0 cost (1562) +
R6’s Serial 0/0/1 cost (64) + R4’s Serial 0/0/0 cost (64) = 4814

Via Route R0 – R5 – R6 – R4

R0’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) + R6’s Serial 0/0/1 (64) + R4’s
Serial 0/0/0 cost (64) = 130

Via Route R0 – R3

R0’s Serial 0/0/1 cost (64) + R3’s serial 0/0/0 cost (64) = 128
Among these routes, Route R0 - R3 has the lowest cost for destination 192.168.2.4.

Route 192.168.2.8

Via Route R0 – R3 – R4

R0’s Serial 0/0/1 cost (64) + R3’s Serial 0/0/0 cost (64) + R4’s Serial 0/0/1 cost (64) = 192

Via Route R0 – R1 – R2 – R6

Ro’s Serial 0/0/0 cost (1562) + R1’s Serial 0/0/1 cost (1562) + R2’s Serial 0/0/0 cost (1562) +
R6’s Serial 0/0/1 cost (64) = 4750

Via Route R0 – R5 – R6

R0’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) + R6’s Serial 0/0/1 cost (64) =
66

Route R0 – R5 – R6 has the lowest cost value.

After selecting best route for each destination OSPF network look likes following figure.
OSPF Route cost Manipulation

We can manipulate OSPF route cost in two ways.

1. By changing bandwidth of interface


2. By changing reference bandwidth value

By changing bandwidth of interface

Sub interface mode command Bandwidth is used to set the bandwidth of supported interface.

If bandwidth is set through this command, OSPF will use it. If bandwidth is not set, it will use
interface’s default bandwidth.

When we enable an interface, router automatically assign a bandwidth value to it based on its
type. For example serial interface has a default bandwidth value of 1544k. Until we change
this value with bandwidth command, it will be used where it is required.

Let me clear one more thing about bandwidth. Changing default bandwidth with bandwidth
command does not change actual bandwidth of interface. Neither default bandwidth nor
bandwidth set by bandwidth command has anything to do with actual layer one link
bandwidth.

Then what purpose does this command solve?

This command is only used to influence the routing protocol which uses bandwidth in route
selection process such as OSPF and EIGRP.

We have already seen an example of this method in our example. We changed default
bandwidth (1544Kbps) to custom (64kbps) bandwidth on R0’s serial 0/0/0, R1’s serial 0/0/1
and R2’s serial 0/0/0. Due to this change R0 took another router for 192.168.0.4 network.

Let’s understand this in more detail.


Current cost for destination 192.168.0.4 from R0

Via Route R0 – R1

R0’s Serial 0/0/0 cost (1562) + R1’s Serial 0/0/1 cost (1562) = 3124 (Cumulative cost)

Via Route R0 – R5 – R6 – R2

Ro’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) + R6’s Serial 0/0/0 cost (64)
+R2’s Serial 0/0/1 cost (64) = 130 (Cumulative cost)

Via Route R0 – R3 – R4 – R6 – R2

R0’s Serial 0/0/1 cost (64) + R3’s Serial 0/0/0 cost (64) + R4’s Serial 0/0/1 cost (64) + R6’s
Serial 0/0/0 cost (64) + R2’s Serial 0/0/1 cost (64) = 320 (Cumulative cost)

Among these routes, Route R0 – R5 – R6 – R2 has the lowest cost so it was picked for
routing table.

Well … Which route would have selected, if we had used default bandwidth?

Cost for destination 192.168.0.4 from R0 with default bandwidth.

Via Route R0 – R1

R0’s Serial 0/0/0 cost (64) + R1’s Serial 0/0/1 cost (64) = 128 (Cumulative cost)

Via Route R0 – R5 – R6 – R2

Ro’s FastEthernet 0/1 cost (1) + R5’s FastEthernet 0/0 cost (1) + R6’s Serial 0/0/0 cost (64)
+R2’s Serial 0/0/1 cost (64) = 130 (Cumulative cost)

Via Route R0 – R3 – R4 – R6 – R2

R0’s Serial 0/0/1 cost (64) + R3’s Serial 0/0/0 cost (64) + R4’s Serial 0/0/1 cost (64) + R6’s
Serial 0/0/0 cost (64) + R2’s Serial 0/0/1 cost (64) = 320 (Cumulative cost)

Among these routes, Route R0 – R1 has the lowest cost value so it would be selected for
routing table. Thus by changing interface bandwidth we actually influenced route selection
process.

By changing reference bandwidth value

As I mention earlier, by default OSPF uses 100Mbps bandwidth as a reference bandwidth.


Changing this value would also change the cost of route. If we use 1000Mbps as a reference
bandwidth, cost of 100Mbps link would become 10. This sounds great, especially if we have
higher bandwidth links in our network. For example have a look on following figure.
Which route will R2 take to get the network of 10.0.0.0/8?

Route R2 – R3

In this route we have two exit points. Both points have default 1oo Mbps speed.

R2’s FastEthernet cost (100000000/100000000) = 1

R3’s FastEthernet cost (100000000/100000000) = 1

Cost of this route 1 + 1 = 2

Route R2 – R1 – R3

In this route we have three exit points. Two exit points (R2 and R1) have 1 Gbps link.

R2’s FastEthernet cost (100000000/1000000000) = .1 (Anything below 1 would be


considered as 1)

R3’s FastEthernet (100000000/1000000000) = .1 (Anything below 1 would be considered as


1)

R3’s FastEthernet cost (100000000/100000000) = 1

Cost of this route 1 + 1 + 1 = 3

With default reference bandwidth R2 will choose Route R2 – R3, which is not good.

We can adjust reference bandwidth with auto-cost reference-bandwidth ref-band command.

We need to adjust reference bandwidth on all routers of network. Mismatched reference


bandwidth can cause routers to run the SPF algorithm continually, which could create a
serious performance issue.

Reference bandwidth is assigned in Mbps. Valid range is 1 to 4294967. Default reference


bandwidth is 100Mbps.

Sadly packet tracer does not include this command. For the practice of this command please
use other simulator software which support this command or use real router.
Let’s change reference bandwidth to 1000Mbps on all three routers using following
commands

Router# configure terminal


Enter configuration commands, one per line. End with CNTL/Z.
Router (config)#router ospf 1
Router (config-router)#auto-cost reference-bandwidth 1000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
Router (config-router)#exit
Router #

Route cost with new reference bandwidth

{module in_art_slot_10}

Route R2 – R3

R2’s FastEthernet cost (1000000000/100000000) = 10

R3’s FastEthernet cost (1000000000/100000000) = 10

Cost of this route 10 + 10 = 20

Route R2 – R1 – R3

R2’s FastEthernet cost (1000000000/1000000000) = 1

R3’s FastEthernet (1000000000/1000000000) = 1

R3’s FastEthernet cost (1000000000/100000000) = 10

Cost of this route 1 + 1 + 10 = 12

In this case Route R2-R1-R3 will be selected, which is the shortest route for destination.

That’s all for this article. I hope now you have better understanding of OSPF Routing
protocol. In next article I will explain Access List in detail with examples.

6.OSPF Stub Areas


Think of Stub area’s in OSPF a way to simplify an area so that a particular area does not need
the full routing table; in which case this conserves router resources. Show below is a list of
the different type of stub area’s and their properties;

Stub Area – An area that has a single exit point and blocks type 5/7 LSA types and receives
type 3/4 LSA’s with a default route (0.0.0.0/0) This type of stub area is an IETF standard. To
configure an Area as a stub you’d execute the area # stub in OSPF router configuration mode
on the ABR.
Not-So-Stubby-Area (NSSA) – This area allows a stub area to have characteristics of a stub
and non stub. External routes advertised into the OSPF autonomous system by am NSSA
advertising an LSA type 7 which is translated at the ABR to type 5 and forwarded into the
OSPF backbone. This type of stub area is an IETF standard. To configure an area as a NSSA
you’d execute the area # nssa in OSPF router configuration mode on the ABR.

Totally Stubby Area – Permits type 1 and 2 LSA’s while blocking types 3*/4/5/7 LSA’s.
*TSA’s receive a single type 3 LSA containing a default route to the ABR. This type of stub
area is an extension to OSPF created by Cisco. To configure an area as a totally stubby area
you’d execute the area # stub no-summary in OSPF router configuration mode on the ABR.

Totally NSSA – Is an area that permits LSA’s 1, 2 and 7 while blocking 3 4 and 5. This stub
area receives a default route from the ABR using a type 3 LSA. This type of stub area is an
extension to OSPF created by Cisco. To configure an area as a not so totally stubby area area
you’d execute the area # nssa no-summary in OSPF router configuration mode on the ABR.

When configuring an area stub type the command is executed on the ABR, however when
you specify an area as a stub on the ABR, all routers in that area must have be configured as a
stub by using the area # stub

In this lab you will configure and verify area 3 as a stub area and totally stubby area.

Familiarize yourself with the following new command(s);

Command Description
This command is executed in OSPF configuration mode to configure
a specific area in OSPF as a stub. All routers in a stub area must have
area # stub the stub area flag set. This means that all routers in the area must be
configure with this command if the ABR has the area configured as a
stub.
This command is executed in OSPF configuration mode on the ABR
to specify an area as a not so stubby area. This type of area allows for
area # nssa redistributed routes as a type 7 lsa which is translated to a type 5 at
the ABR before being propagated through out the autonomous
system.
This command is executed in OSPF configuration mode on the ABR
area # stub no- to specify an area as a totally stubby area which only allows type 1
summary and 2 LSA’s and a single type 3 LSA (default route) from the ABR.
all other LSA’s are blocked.
This command is executed in OSPF configuration mode on the ABR
in OSPF configuration mode to specify a specific area as a not so
area # nssa no-
totally stubby area which blocks types 3 4 and 5 LSA’s but allows a
summary
single type 3 LSA as the default route and type 7 LSA’s internal to
the area.

You might also like