Cisco CCNA Routing and Switching
Lecture 05
Open Shortest Path First
(OSPF)
LINK- State
Link-state routing protocols are like your navigation system, they have a
complete map of the network.
If you have a full map of the network you can just calculate the shortest path to
all the different destinations out there.
•Link: the interface of on a router (a network connects two routers or a stub
network such as ethernet LAN).
•State: Description of the interface and how it’s connected to neighbor routers.
All link-state information includes the network prefix, prefix length, and cost.
Link-state routing protocols operate by sending link-state advertisements (LSA)
to all other link-state routers.
All the routers need to have these link-state advertisements so they can build their
link-state database or LSDB.
Link State: Distance Vector:
❑ Provides common view of entire ❑ Exchanges routing tables with
topology neighbors
❑ Calculates shortest path
❑ Utilizes event-triggered updates ❑ Utilizes frequent periodic updates
OSPF
•OSPF is an IGP, link state Protocol that overcomes the deficiencies of other
distance vector routing protocols and distributes routing information within a
single OSPF routing domain.
•OSPF supports VLSM (classless routing), summarization, and authentication.
•Faster convergence and much lager network than RIP.
Link-State Advertisements (LSAs)
• When a change occurs in the network topology, the router experiencing the change
creates a link-state advertisement (LSA) concerning that link.
◦ LSAs are also called link-state protocol data units (PDUs).
• The LSA is multicasted to all neighboring devices using either [Link] or [Link].
• Routers receiving the LSA immediately forward it to all neighboring routers.
Link-State Database (LSDB)
• Routers receiving add the LSA to their link-state database (LSDB).
• The LSDB is used to calculate the best paths through the network.
• OSPF best route calculation is based on Edsger Dijkstra's shortest
path first (SPF) algorithm.
SPF Routing Algorithm
• The SPF algorithm accumulates costs along each path, from source to destination.
◦ The accumulated costs is then used by the router to build a topology table.
SPF Tree and Routing Table
• The topology table is essentially an SPF tree which contains a listing of
all OSPF networks and the costs to reach them.
• The resulting best routes are then considered to be added to the routing
table.
OSPF - Link-State
• 8 OSPF routers connected on a switch.
• Each of those routers is going to become OSPF neighbors with all of the other
routers.
• Sending hello packets, flooding LSAs and building the LSDB.
• A full-mesh of OSPF neighbors.
• Each router will flood LSAs to all other routers so we will have a lot of OSPF
traffic.
• All our OSPF routers would just send their stuff to a single OSPF router
DR • OSPF router will then forward updates to all the other OSPF routers
• OSPF router uses something called a DR (Designated Router).
• Since a bad thing can happen to our networks
• We want to have backup for our DR
• This router is BDR (Backup Designated Router)
• All OSPF routers will only form full neighbor adjacencies with DR and BDR
DR and BDR election only occurs on multi-access networks such as Ethernet LANs.
BDR
Link State Database (LSDB)
• The LSDB is our full picture of the network called topology
• LSDB likes a full map of your country.
• Every router must have a complete map
• Router will start calculating the shortest path to all the different destinations
by using the shortest-path first (SPF) algorithm (navigation system).
• The BEST route information goes into the routing table.
OSPF Hierarchical Routing
▪ OSPF uses the concept of areas.
▪ OSPF Area is a group of routers that share the same link-state information in
their LSDBs.
Hierarchical routing using areas make OSPF:
▪ more efficient
▪ more scalable
Area ID is a 32-bit field and can be formated in simple decimal (0 through 4,294,967,295)
or dotted decimal ([Link] through [Link]).
OSPF can be implemented in one of two ways:
▪ Single-area OSPF: all routers are in one area (area 0).
▪ Multiarea OSPF: OSPF is implemented using multiple areas, in a hierarchical
fashion. All areas must connect to the backbone area (area 0).
Redistribution
• Routers in the backbone area (Area 0) are called backbone routers.
• Routers between 2 areas (like the one between area 0 and area 1) are called Area
Border Routers(ABR).
• Routers that run OSPF and are connected to another network that runs another
routing protocol (for example EIGRP) are called autonomous system border
routers or ASBR.
ASBR
ABR
ABR
ABR
OSPF Router Types
OSPF Router Types
All
ABR and Backbone ABR and
Backbone Routers Backbone
Router Router
Internal
Routers
Internal
Router
Internal
ASBR and
Router
Backbone
Router
OSPF Intra-Area and Interarea Routes
Network routes that are learned from other OSPF routers within the same area are known as
intra-area routes. In Figure 9-3, the network link between R2 and R4 ([Link]/29) is an intra-
area route to R1. The IP routing table displays OSPF intra-area routes with an O.
Network routes that are learned from
other OSPF routers from a different area
using an ABR are known as interarea
routes.
Example provides the routing table for
R1 from Figure. Notice that R1’s OSPF
routing table shows routes from within
Area 1234 as intra-area (O routes) and
routes from Area 0 and Area 56 as
interarea (O IA routes).
OSPF - Hello Packet
OSPF Type 1 packet = Hello packet
▪ Discover OSPF neighbors and establish neighbor adjacencies
▪ Advertise parameters on which two routers must agree to become neighbors
▪ Elect the Designated Router (DR) and Backup Designated Router (BDR) on multi
access networks like Ethernet and Frame Relay
OSPF-Hello Packet Intervals
▪ To [Link] in IPv4 and FF02::5 in IPv6 (all OSPF routers)
▪ Every 10 seconds (default on multi access and point-to-point networks)
▪ Every 30 seconds (default on non-broadcast multi access [NBMA] networks)
▪ Dead interval is the period that the router waits to receive a Hello packet before declaring the
neighbor down
▪ Router floods the LSDB with information about down neighbors out all OSPF enabled interfaces
▪ Cisco’s default is 4 times the Hello interval
Router–ID (RID), priority and loopback interface
▪ Each OSPF router needs to have a unique RID.
▪ If the interface priorities are not equal, the equal on all routers, the router with the highest priority will be
DR (priority is a value in the range of 0 to 255).
▪ Otherwise, router with the highest RID is elected the DR
▪ RID is a 32-bit value, represented as an IP4 address. It is used to uniquely identify an OSPF router.
▪ RID can be defined by the administrator (using router-id rid router configuration mode command) or
automatically assigned by the router (by choosing the highest IPv4 address of any of its interfaces).
▪ loopback interfaces which is a virtual interface, if exists on your OSPF router with an IP address,
then this IP address will be used as the RID (not the highest IPv4 address of a physical interface)
Router use RID to:
▪ Participate in the synchronization of OSPF database: during the exchange state, the router with the
highest router ID will send their database descriptor (DBD) packets first.
▪ Participate in the election of the DR: in a multiaccess LAN environment, the router with the highest
RID is elected the DR. The router with the second highest RID is elected the BDR.
OSPF DR and BDR Election
OSPF DR and BDR example
What options can you configure that will ensure that R2 will be the DR of
the LAN segment?
OSPF - load balancing
Paths must have an equal cost.
4 equal cost paths will be placed in routing table.
Maximum of 16 paths.
To make paths equal cost, change the “cost” of a link ?!!
Configuring OSPF:
• Using the global configuration command: router ospf process_id
Wildcard Address
The wildcard address is always one less than the block size
[Link]/30 = [Link]
[Link]/28 = [Link]
[Link]/27 = [Link]
[Link]/26 = [Link]
Lab 05
Open Shortest Path First
(OSPF)
Configure OSPF with Single Area
Task 01: Configure R1 – OSPF
1. R1#conf t
2. R1 (config)#interface f0/0
3. R1 (config -if)#ip address [Link]
[Link]
4. R1 (config -if)# no shutdown
5. R1 (config -if)# exit
6. R1 (config )# interface S0/0/0
7. R1 (config -if)# ip address [Link]
[Link]
8. R1 (config -if)# no shutdown
9. R1 (config -if)# end
10. R1#
Task 01: Configure R1 – OSPF
1. R1#conf t
2. R1 (config)#
3. R1(config)# router ospf 10
4. R1(config-router)# Router-ID [Link]
5. R1(config-router)# net [Link] [Link]
area 0
6. R1(config-router)# net [Link] [Link]
area 0
7. R1(config-router)#
8. R1(config-router)# end
9. R1# show ip route
10. R1# show ip protocol
11. R1# show ip ospf topology.
Task 02: Configure R2 – OSPF
1. R2#conf t
2. R2 (config)#interface f0/0
3. R2 (config -if)#ip address [Link]
[Link]
4. R2(config -if)# no shutdown
5. R2(config -if)# exit
6. R2(config )# interface S0/0/0
7. R2(config -if)# ip address [Link] [Link]
8. R2(config -if)# no shutdown
9. R2(config -if)# exit
10. R2(config )# interface S0/1/0
11. R2(config -if)# ip address [Link] [Link]
12. R2(config -if)# no shutdown
13. R2 (config -if)# end
14. R2#
Task 02: Configure R2 – OSPF
1. R2#conf t
2. R2 (config)#
3. R2(config)# router ospf 10
4. R2(config-router)# Router-ID [Link]
5. R2(config-router)# net [Link] [Link]
area 0
6. R2(config-router)# net [Link] [Link]
area 0
7. R2(config-router)# net [Link] [Link]
area 0
8. R2(config-router)# end
9. R2# show ip route
10. R2# show ip protocol
11. R2# show ip ospf topology
Task 03: Configure R3 – OSPF
1. R3#conf t
2. R3 (config)#interface f0/0
3. R3(config -if)#ip address [Link]
[Link]
4. R3(config -if)# no shutdown
5. R3(config -if)# exit
6. R3(config )# interface S0/1/0
7. R3(config -if)# ip address [Link]
[Link]
8. R3(config -if)# no shutdown
9. R3 (config -if)# end
10. R3#
Task 03: Configure R23 – OSPF
1. R3#conf t
2. R3 (config)#
3. R3(config)# router ospf 10
4. R3(config-router)# Router-ID [Link]
5. R3(config-router)# net [Link]
[Link] area 0
6. R3(config-router)# net [Link] [Link]
area 0
7. R3(config-router)# end
8. R3# show ip route
9. R3# show ip protocol
10. R3# show ip ospf topology
Task 04: Test OSPF Router
Verify the routes on Router R1:
R1# show ip route
Verify the routes on Router R2:
R2# show ip route
Verify the routes on Router R3:
R3# show ip route
Verifying the ping reply from Server1 to
PC01 and PC02:
• Server > ping [Link]
• Server > ping [Link]
Homework 04 :
Configure OSPF multi Areas with backbone Area
for the following:
Test the connection ping from Server1
to PCs (PC01 , PC02 and PC03)
Homework 05 :
Answer The following Questions:
1. What is the administrative distance of OSPF?
A. 90
B. 100
C. 120
D. 110
2. In OSPF, Hellos are sent to what IP address?
A. [Link]
B. [Link]
C. [Link]
D. [Link]
3. Which command will show all the LSAs known by a router?
A. show ip ospf
B. show ip ospf neighbor
C. show ip ospf interface
D. show ip ospf database