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

04 OSPF Route Calculation

Uploaded by

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

04 OSPF Route Calculation

Uploaded by

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

OSPF Route Calculation

Page 1 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Foreword
• Open Shortest Path First (OSPF) routers in the same area have the same link state database
(LSDB). In an area, OSPF uses the shortest path first (SPF) algorithm to calculate routes.
• As the network scale expands, routers consume more memory and CPU resources to calculate
routes. Area partitioning can relieve the pressure on routers to some extent.
• On a large-scale network, there may be other routing protocols besides OSPF. OSPF can import
external routes so that OSPF routers can know the routes to other areas.
• This course describes the principles of OSPF route calculation, including the calculation of
intra-area routes, inter-area routes, and external routes.

Page 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Objectives
• Upon completion of this course, you will be able to:
▫ Explain functions of key fields in link-state advertisements (LSAs).

▫ Describe common LSA types and functions.

▫ Illustrate the SPF algorithm.

▫ Describe the principles for calculating intra-area and inter-area OSPF routes.

▫ Describe the loop prevention mechanism of OSPF inter-area routes.

▫ Describe the principles for calculating OSPF external routes.

Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
▪ Introduction to LSAs
▫ Router-LSA

▫ Network-LSA

▫ SPF Calculation Process

2. Inter-Area Route Calculation


3. External Route Calculation

Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Review
All routers in the same area have the same LSDB. According to the command output of R2, multiple LSAs
exist on the network. <R2>display ospf lsdb
R1 R2
OSPF Process 1 with Router ID 10.0.2.2
Link State Database

Area: 0.0.0.0

Type LinkState ID AdvRouter Age Len Sequence Metric


Router 10.0.4.4 10.0.4.4 662 72 80000006 48
SW1 Router 10.0.2.2 10.0.2.2 625 72 8000000C 1
R4 Router 10.0.1.1 10.0.1.1 638 60 80000007 1
Router 10.0.5.5 10.0.5.5 634 60 8000000B 1
Router 10.0.3.3 10.0.3.3 639 60 80000009 1
Network 10.0.235.5 10.0.5.5 634 36 80000005 0
Network 10.0.12.2 10.0.2.2 629 32 80000003 0

R3 R5
What information does each LSA contain? Based on the preceding
Ethernet link Serial link information, how does a router calculate routes?

Page 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic Concepts of LSAs
Key Fields
• LSAs are the basis for OSPF to calculate routes.
• LS Age: indicates the lifetime of an LSA, in seconds.
• An OSPF Link State Update (LSU) packet can carry
• Options: Each bit corresponds to a feature supported by OSPF.
multiple types of LSAs.
• LS Type: indicates the type of the local LSA.
• LSAs of different types have the same packet header. • Link State ID: indicates the link state ID in the LSA header. This field varies with LSAs.

• Advertising Router: indicates the router ID of the device that generates the LSA.
IP Header OSPF Header LSU Payload
• LS Sequence Number: indicates the sequence number in the LSA header. The value

LSA Header Payload increases each time a new instance is generated.

• LS Checksum: is used to ensure data integrity and accuracy.


… …
• Length: indicates the length of an LSA, including the length of the LSA header.

LS Age Options LS Type


Link State ID • LS Type, Link State ID, and Advertising Router uniquely identify an
Advertising Router LSA.
LS Sequence Number • LS Age, LS Sequence Number, and LS Checksum are used to
LS Checksum Length determine whether an LSA is old or new.

Page 6 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Common LSA Types

Type Name Description

Every router on an OSPF network generates Router-LSAs. A Router-LSA describes a router's link state and cost and can be
1 Router-LSA
flooded only in the area to which the interface belongs.

A designated router (DR) generates Network-LSAs. A Network-LSA describes all the routers that establish adjacencies
2 Network-LSA with the DR on the MA network to which the DR is connected and the DR itself. The LSA can be flooded only in the area
to which the interface belongs.

An area border router (ABR) generates Network-summary-LSAs. A Network-summary-LSA describes the route to the
3 Network-summary-LSA
destination network segment of an area. It is used to transmit inter-area routes.

An ABR generates ASBR-summary-LSAs. An ASBR-summary-LSA describes routes to an ASBR, and is equivalent to a


4 ASBR-summary-LSA
host route to an autonomous system border router (ASBR).

5 AS-external-LSA An ASBR generates AS-external-LSAs. An AS-external-LSA describes routes to destinations outside an AS.

An ASBR generates NSSA LSAs. An NSSA LSA describes routes to destinations outside an AS. NSSA LSAs have similar
7 NSSA LSA functions as AS-external-LSAs, but are flooded in different areas. NSSA LSAs can be flooded only in the NSSA and
cannot enter area 0. The ABR in the NSSA converts Type 7 LSAs into Type 5 LSAs and injects them into area 0.

Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
▫ Introduction to LSAs

▪ Router-LSA
▫ Network-LSA

▫ SPF Calculation Process

2. Inter-Area Route Calculation


3. External Route Calculation

Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Description of a Router-LSA (1)
• Router-LSA (Type 1 LSA): Every router on an OSPF network generates Router-LSAs. A Router-LSA describes a
router's link state and cost.

• Router-LSAs can be flooded only in the area that the interface belongs to.

LS Age Options LS Type


• V (virtual link): If the router that generates the LSA is the
Link State ID
endpoint of a virtual link, this field is set to 1.
Advertising Router
• E (external): If the router that generates the LSA is an ASBR, this
LS Sequence Number
field is set to 1.
LS Checksum Length
0 V E B 0 #Links • B (border): If the router that generates the LSA is an ABR, this
Link ID field is set to 1.
Link Data • Links: indicates the number of links in the LSA. Router-LSAs
Link Type #TOS Metric use links to carry information about directly connected interfaces
… on routers.

Page 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Description of a Router-LSA (2)
• Router-LSAs use links to carry information about directly connected interfaces on routers.

• Each link contains the link type, link ID, link data, and metric.

• A router may use one or more links to describe an interface.


LS Age Options LS Type Link Type Link ID Link Data
Link State ID Point-to-point (P2P): describes a P2P link IP address of the router
ID of the
between the local router and a neighboring interface that
Advertising Router neighboring
router, which is included in the topology advertises the Router-
router.
information. LSA.
LS sequence number
TransNet: describes a connection from the
IP address of the router
LS checksum length local router to a transit network segment Interface IP
interface that
such as an MA or NBMA network address of the
advertises the Router-
0 V E B 0 #links segment, which is included in the topology DR
LSA.
information.
Link ID
StubNet: describes a connection from the Network IP
local router to a stub network segment, for address of the
Link Data Subnet mask of the
example, a loopback interface, which is router interface
stub network.
included in the network segment that advertises
link type #TOS metric information. the Router-LSA

Page 10 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Router-LSAs: P2P Networks

<R1>display ospf lsdb router self-originate


Type : Router
LSA header
Ls id : 10.0.1.1
Router ID 10.0.1.1 Router ID 10.0.3.3 Adv rtr : 10.0.1.1
Serial
* Link ID: 10.0.3.3 First link in the
10.0.13.1/24 10.0.13.3/24 Data : 10.0.13.1 Router-LSA:
R1 R3 Describe the
Link Type: P-2-P topology
Router-LSA Metric : 48 information.

R1 sends a Router-LSA to R3. The Router-LSA carries * Link ID: 10.0.13.0

topology and network segment information. Data : 255.255.255.0 Second link in the
Link Type: StubNet Router-LSA:
Describe the network
Metric : 48 segment information.
Priority : Low

Page 11 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Router-LSAs: TransNet Networks

<R2>display ospf lsdb router self-originate


Router ID 10.0.3.3
Type : Router
LSA header
Ls id : 10.0.2.2
R3 Adv rtr : 10.0.2.2
Router ID 10.0.2.2 Router ID 10.0.5.5
DR
* Link ID: 10.0.235.2 Link contained in a
10.0.235.2
Data : 10.0.235.2 Router-LSA:
R2 R5 Describe topology
Router-LSA Link Type: TransNet information.
Metric : 1
R2 sends Router-LSAs carrying topology
information to R3 and R5.
How is complete network segment information described
on the TransNet network if there is no network mask
information?

Page 12 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
▫ Introduction to LSAs

▫ Router-LSA

▪ Network-LSA
▫ SPF Calculation Process

2. Inter-Area Route Calculation


3. External Route Calculation

Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Description of a Network-LSA
• Network-LSA (Type 2 LSA): is originated by a DR, describes the link state of the local network segment, and is
advertised in an area to which the DR belongs.

• A Network-LSA records all OSPF routers that have established adjacencies with the DR on the network segment and
carries the network mask of the network segment.

LS Age Options LS Type


Link State ID • Link State ID: indicates the IP address of an interface on the DR.

Advertising Router • Network Mask: indicates the subnet mask of the MA network.
LS Sequence Number
• Attached Router: indicates the router ID of the device connected to the
LS Checksum Length
MA network.
Network Mask
Attached Router
...

Page 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Network-LSAs Describe the MA Network

<R2>display ospf lsdb network self-originate


Router ID 10.0.3.3
OSPF Process 1 with Router ID 10.0.2.2
Area: 0.0.0.0
R3 Link State Database

Type : Network LSA header


Router ID 10.0.2.2 Router ID 10.0.5.5
Ls id : 10.0.235.2
Adv rtr : 10.0.2.2
DR
R2 10.0.235.2 R5 10.0.235.0/24

Network-LSA Net mask : 255.255.255.0


Priority : Low Topology
R2 sends Network-LSAs to R3 and R5, carrying topology and Attached Router 10.0.2.2 information
network segment information. Attached Router 10.0.3.3
Attached Router 10.0.5.5

Page 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
▫ Introduction to LSAs

▫ Router-LSA

▫ Network-LSA

▪ SPF Calculation Process

2. Inter-Area Route Calculation


3. External Route Calculation

Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
SPF Algorithm (1)

Phase 1: Construct an SPF tree. Root


10.0.1.1
▫ A router takes itself as the root of the SPF tree. Each time a Cost 1
new node is added, the router with the smallest cost is DR
added to the SPF tree based on the topology information in 10.0.12.2
Cost 0
the Router-LSA and Network-LSA. A router is identified
by a router ID or DR ID. 10.0.2.2

▫ On a broadcast network, the cost between the DR and the t 48


C os Cost 1
router connected to it is 0.
t 0 Co
os st
▫ The SPF tree has only the unidirectional shortest path, C 0
10.0.4.4 DR
which prevents routing loops in the OSPF area. 10.0.235.2

10.0.3.3 10.0.5.5

Page 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
SPF Algorithm (2)

Phase 2: Calculate the optimal route. Root Cost 48


10.0.13.0/24
10.0.1.1
▫ The routing information in the Router-LSA and Network-
Cost 1
LSA is attached to the corresponding OSPF router to
Cost 0
DR
calculate the optimal route. 10.0.12.0/24
10.0.12.2
Cost 0
▫ The existing routing information is not added to the SPF
Cost 48
tree. 10.0.2.2 10.0.24.0/24
48
st Cost 1
Co

Cost 0
10.0.235.0/24
s t0 Co
Co st
0
10.0.4.4 DR
10.0.235.2
Cost
10.145.0/24
48

10.0.3.3 10.0.5.5

Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
SPF Algorithm Example
R1 R2

The following uses R1 as an example to describe the


OSPF topology and route calculation process.

SW1
R4

Neighbor to be ignored

R3 R5
Neighbor to be added

Route prefix

Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (1)


1. R1 takes itself as the root and checks the Router-LSA. For a non-StubNet link, R1
<R1>display ospf lsdb router self-originate
adds the link ID to the candidate list and records the path cost.
Type : Router
Ls id : 10.0.1.1
Total Candidate
Candidate List Root/Parent Node Adv rtr : 10.0.1.1
Cost
10.0.12.2 1 10.0.1.1
* Link ID : 10.0.12.2
10.0.3.3 48 10.0.1.1 Data : 10.0.12.1
Link Type : TransNet
Metric : 1
2. R1 moves the candidate with the lowest total path cost from the candidate list to the
SPF tree, and deletes the candidate from the candidate list. * Link ID : 10.0.3.3
Data : 10.0.13.1
Cost 1 Link Type : P-2-P
Metric : 48
R1 DR
10.0.1.1 10.0.12.2 * Link ID : 10.0.13.0
Total Candidate Data : 255.255.255.0 1
Candidate List Root/Parent Node First route prefix
Cost Link Type : StubNet
10.0.13.0/24
10.0.12.2 1 10.0.1.1 Metric : 48
Priority : Low
10.0.3.3 48 10.0.1.1

Page 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (2)


3. R1 continues to query the Network-LSAs generated by the DR and adds the
topology information described in the Network-LSAs to the candidate list. If the <R1>display ospf lsdb network 10.0.12.2
node described in the LSAs already exists in the SPF tree, the node does not need to
be added to the topology. Type : Network
Total Candidate Root/Parent
Ls id : 10.0.12.2 2
Candidate List
Cost Node Adv rtr : 10.0.2.2 Second route prefix
10.0.12.0/24
10.0.3.3 48 10.0.1.1
Net mask : 255.255.255.0
10.0.2.2 1+0 10.0.12.2 Priority : Low
Attached Router 10.0.2.2
4. R1 moves the candidate with the lowest total path cost from the candidate list to the The node does not
SPF tree, and deletes the candidate from the candidate list. Attached Router 10.0.1.1 need to be added to the
topology because the
node already exists in
Cost 1 Cost 0 the SPF tree.
R1 DR R2
10.0.1.1 10.0.12.2 10.0.2.2
Total Candidate Root/Parent
Candidate List
Cost Node
10.0.3.3 48 10.0.1.1
10.0.2.2 1+0 10.0.12.2

Page 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (3)


5. Based on Router-LSAs generated by R2, R1 records neighbor information <R1>display ospf lsdb router 10.0.2.2
in the candidate list.
Type : Router
Total Candidate
Candidate List Root/Parent Node Ls id : 10.0.2.2
Cost
Adv rtr : 10.0.2.2
10.0.3.3 48 10.0.1.1
10.0.235.2 1+0+1 10.0.2.2 * Link ID: 10.0.235.2
Data : 10.0.235.2
10.0.4.4 1+0+48 10.0.2.2 Link Type: TransNet
Metric : 1
6. R1 moves the candidate with the lowest total path cost from the candidate list to the
SPF tree, and deletes the candidate from the candidate list.
* Link ID: 10.0.4.4
R2 Data : 10.0.24.2
Cost 1 Cost 0 10.0.2.2 Link Type: P-2-P
Metric : 48
Cost 1
R1 DR
10.0.1.1 10.0.12.2 * Link ID: 10.0.12.2
Data : 10.0.12.2
DR Link Type: TransNet
10.0.235.2 Metric : 1

Total Candidate * Link ID: 10.0.24.0


Candidate List Root/Parent Node
Cost Data : 255.255.255.0 3
10.0.3.3 48 10.0.1.1 Link Type: StubNet Third route prefix
Metric : 48 10.0.24.0/24
10.0.235.2 1+0+1 10.0.2.2 Priority : Low
10.0.4.4 1+0+48 10.0.2.2

Page 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (4)


7. R1 continues to query Type 2 LSAs generated by the DR and adds the topology <R1>display ospf lsdb network 10.0.235.2
information described in Type 2 LSAs to the candidate list.
Total Candidate Type : Network
Candidate List Root/Parent Node
Cost Ls id : 10.0.235.2 4
10.0.3.3 48 10.0.1.1 Adv rtr : 10.0.2.2 Fourth route prefix
10.0.4.4 1+0+48 10.0.2.2 10.0.235.0/24
Net mask : 255.255.255.0
10.0.3.3 1+0+1+0 10.0.235.2 Priority : Low
10.0.5.5 1+0+1+0 10.0.235.2 Attached Router 10.0.2.2

8. R1 moves the candidate with the lowest total path cost from the candidate list to the Attached Router 10.0.3.3
SPF tree, and deletes the candidate from the candidate list. Attached Router 10.0.5.5

R2
Cost 1 Cost 0 10.0.2.2
R1 DR Cost 1
10.0.1.1 10.0.12.2 Total Candidate
Candidate List Root/Parent Node
Cost
10.0.3.3 48 10.0.1.1
Cost 0 Cost 0
DR 10.0.4.4 1+0+48 10.0.2.2
10.0.235.2
10.0.3.3 1+0+1+0 10.0.235.2
10.0.5.5 1+0+1+0 10.0.235.2
R3 R5
10.0.3.3 10.0.5.5
Page 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (5)


9. R1 queries Type 1 LSAs of R3. All neighbors of R3 are in the SPF tree, and the
topology does not change.
<R1>display ospf lsdb router 10.0.3.3
Total Candidate
Candidate List Root/Parent Node Type : Router
Cost
Ls id : 10.0.3.3
10.0.4.4 1+0+48 10.0.2.2 Adv rtr : 10.0.3.3

* Link ID: 10.0.235.2


R2 Data : 10.0.235.3
10.0.2.2 The two nodes do not
Cost 1 Cost 0 Link Type: TransNet
Metric : 1 need to be added to the
R1 DR Cost 1
topology because the
10.0.1.1 10.0.12.2 * Link ID: 10.0.1.1 two nodes already exist
Data : 10.0.13.3 in the SPF tree.
Link Type: P-2-P
Cost 0 Cost 0 Metric : 48
DR
10.0.235.2 * Link ID: 10.0.13.0
Data : 255.255.255.0 1
Link Type: StubNet Same as the first route
Metric : 48 prefix 10.0.13.0/24
R3 R5 Priority : Low
10.0.3.3 10.0.5.5

Page 24 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (6)


10. R1 queries Type 1 LSAs of R5, adds R4 to the SPF tree, and deletes R4 from the
candidate list.

Cost 1 Cost 0 R2
<R1>display ospf lsdb router 10.0.5.5
10.0.2.2
Cost 1 Type : Router
R1 DR Ls id : 10.0.5.5
10.0.1.1 10.0.12.2 Cost 48
Adv rtr : 10.0.5.5

* Link ID: 10.0.235.2


Data : 10.0.235.5
Cost 0 Cost 0 Link Type: TransNet
R4 DR Metric : 1
10.0.4.4 10.0.235.2
* Link ID: 10.0.4.4
Data : 10.0.45.5
Link Type: P-2-P
Metric : 48
R3 R5
10.0.3.3 10.0.5.5 * Link ID: 10.0.45.0
Data : 255.255.255.0
5
Total Candidate Link Type: StubNet Fifth route prefix
Candidate List Root/Parent Node Metric : 48
Cost 10.0.45.0/24
Priority : Low
10.0.4.4 1+0+48 10.0.2.2
10.0.4.4 1+0+1+0+48 10.0.5.5

Page 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Setting Up an SPF Tree (7)


11. R1 queries Type 1 LSAs of R4. All neighbors are in the SPF tree. In addition, all LSAs <R1>display ospf lsdb router 10.0.4.4
have been calculated, and the SPF tree has been established.
Type : Router
Ls id : 10.0.4.4
Adv rtr : 10.0.4.4

Cost 1 Cost 0 * Link ID: 10.0.2.2


R2
Data : 10.0.24.4
10.0.2.2 Link Type: P-2-P
R1 DR Cost 1 Metric : 48
* Link ID: 10.0.5.5
10.0.1.1 10.0.12.2 Cost 48
Data : 10.0.45.4
Link Type: P-2-P
Metric : 48

Cost 0 Cost 0 * Link ID: 10.0.24.0 2


R4 DR Data : 255.255.255.0 Same as the second
10.0.4.4 10.0.235.2 Link Type: StubNet
route prefix
Metric : 48
Priority : Low 10.0.24.0/24
5
* Link ID: 10.0.45.0 Same as the second
R3 R5 Data : 255.255.255.0 route prefix
10.0.3.3 10.0.5.5 Link Type: StubNet
10.0.45.0/24
Metric : 48
Priority : Low

Page 26 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Phase 1 Phase 2

Calculating the Optimal Route


Starting from the root node, routing information in the LSA of each node is added according to the sequence
in which nodes are added to the SPF tree. The routes that have been added to the SPF tree are not added.

* Link ID: 10.0.24.0 3


Cost 1 Cost 0 Data : 255.255.255.0
Link Type: StubNet
Metric : 48
R1 DR Cost 1 R2 Priority : Low
10.0.1.1 10.0.12.2 Cost 48 10.0.2.2
* Link ID: 10.0.13.0 1 Type : Network 4
Data : 255.255.255.0 Ls id : 10.0.235.2
Link Type: StubNet Adv rtr : 10.0.2.2
Metric : 48 Cost 0 Cost 0 Net mask : 255.255.255.0
Priority : Low R4 DR
10.0.4.4 10.0.235.2
* Link ID: 10.0.45.0 5
Type : Network 2 Data : 255.255.255.0
Ls id : 10.0.12.2 Link Type: StubNet
Adv rtr : 10.0.2.2 Metric : 48
Net mask : 255.255.255.0 R3 R5 Priority : Low
10.0.3.3 10.0.5.5

Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Verifying the Configuration

<R1>display ospf routing

OSPF Process 1 with Router ID 10.0.1.1 <R1>display ip routing-table


Routing Tables
Destination/Mask Proto Pre Cost NextHop
Routing for Network 10.0.12.0/24 Direct 0 0 10.0.12.1
Destination Cost Type NextHop AdvRouter Area 10.0.13.0/24 Direct 0 0 10.0.13.1
10.0.12.0/24 1 Transit 10.0.12.1 10.0.1.1 0.0.0.0 10.0.24.0/24 OSPF 10 49 10.0.12.2
10.0.13.0/24 48 Stub 10.0.13.1 10.0.1.1 0.0.0.0 10.0.45.0/24 OSPF 10 50 10.0.12.2
10.0.24.0/24 49 Stub 10.0.12.2 10.0.2.2 0.0.0.0 10.0.235.0/24 OSPF 10 2 10.0.12.2
10.0.45.0/24 50 Stub 10.0.12.2 10.0.5.5 0.0.0.0
10.0.235.0/24 2 Transit 10.0.12.2 10.0.5.5 0.0.0.0

OSPF routing table of R1 Global routing table of R1

Question: Why are not all routes in the OSPF routing table of R1 displayed in the global routing table?

Page 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. (Multiple) Which of the following link types are included in a Router-LSA?( )
A. P2P

B. TransNet

C. StubNet

D. Vlink

2. (TorF) After the SPF algorithm is used to calculate routes, the OSPF routes that are considered as the
optimal routes are added to the routing table of the router.

Page 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Section Summary
• OSPF calculates the routing table based on the LSDB. The LSDB may contain multiple types of
LSAs, and all LSAs have the same packet header format.
• OSPF routers in the same area have the same LSDB. When there is only one area, there are two
types of LSAs in the area: Router-LSA and Network-LSA.
• Each router generates a Router-LSA that describes the information about the directly connected
interface of the router.
• On an MA network, a DR generates a Network-LSA to describe the router IDs (including the
DR itself) of all the routers that access the MA network and the mask of the network.

Page 30 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
2. Inter-Area Route Calculation
▪ Inter-Area Route Calculation Process
▫ Inter-Area Routing Loop Prevention Mechanism

▫ Functions and Configurations of Virtual Links

3. External Route Calculation

Page 31 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Problems in a Single OSPF Area on a Large-Scale
Network
• A network consisting of a series of consecutive OSPF routers is called an
OSPF domain.

• OSPF requires that routers on the network synchronize their LSDBs to keep
consistent network information.

… • When the network scale increases continuously, the LSDB becomes


oversized. A device calculates routes based on the LSDB, which increases
Area 0
the burden. In addition, the size of the routing table of the router increases,
deteriorating the performance of the router.
… • When the network topology changes, the changes need to be spread to the
entire network and may trigger route recalculation on the entire network.

• The single-area design makes it impossible to deploy route summarization.

Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Area Partitioning
• Router-LSAs and Network-LSAs are flooded only within an area, so area
Area 0 partitioning reduces the memory and CPU usage of network devices.

R1 Internal router
ABR

R2
… R3
Area 1 R1 Area 2

Area 0

R4
… R5
R4 R2 R3 R5

Area 1 Area N
• After areas are partitioned, routers can be classified into the following types:
▫ Internal router: An internal router has all its interfaces belonging to the same OSPF area, for
example, R1, R4, and R5.

▫ Area border router (ABR): An ABR connects to two or more areas, for example, R2 and R3.

Page 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Area Routing Information Transmission
• OSPF inter-area routing information is transmitted through Type 3 Network-Summary-LSAs generated by ABRs.

• Transmission of the route to 192.168.1.0/24 is used as an example.


▫ R2 calculates a route (intra-area route) to 192.168.1.0/24 based on the Router-LSA and Network-LSA flooded in area 1, and advertises the route
to area 0 through a Network-Summary-LSA. R3 can calculate the inter-area route to 192.168.1.0/24 based on the Network-Summary-LSA.

▫ R3 generates a Network-Summary-LSA and advertises it to area 2. Then, routers in all OSPF areas can learn the route to 192.168.1.0/24.

R1

192.168.1.0/24 192.168.2.0/24

R4 R2 Area 0 R3 R5

Area 1 Area 2

192.168.1.0/24 192.168.1.0/24 Type 1 LSA


R2 generates a Type 3 LSA. R3 regenerates a Type 3 LSA. Type 3 LSA

Page 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Description of a Network-Summary-LSA
An ABR generates Network-summary-LSAs (Type 3 LSAs) and advertises them within its area to notify
destination addresses of routes from this area to other areas.

LS Age Options LS Type


Link State ID • Main Fields

Advertising Router ▫ LS Type: The value 3 indicates a Network-summary-LSA.

LS Sequence Number ▫ Link State ID: indicates the destination network address of a route.

LS Checksum Length ▫ Advertising Router: indicates the router ID of the device that generates the LSA.

Network Mask ▫ Network Mask: indicates the network mask of a route.


0 Metric
▫ Metric: indicates the cost of the route to the destination address.
...

Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of a Network-Summary-LSA
Network-Summary-LSA
192.168.1.0/24
<R2>display ospf lsdb summary 192.168.1.0
OSPF Process 1 with Router ID 10.0.2.2
Area: 0.0.0.0
192.168.1.0/24 R1 Link State Database
Area 1 Area 2
Area 0 Type : Sum-Net
1
=

R4 R2 R3 R5 Ls id : 192.168.1.0
st
Co

10.0.2.2
Adv rtr : 10.0.2.2
Ls age : 86
Routing
Len : 28
information
Options :E
This LSA is generated by R2 and is used to advertise inter-area 192.168.1.0/24
seq# : 80000001
routes destined for 192.168.1.0/24 to area 0. chksum : 0x7c6d
Net mask : 255.255.255.0
Tos0 metric: 1
Priority : Low

Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Calculation on R1 and R3

192.168.1.0/24 192.168.1.0/24 1. Through SPF calculation, the cost of the route from R1 to R2 is
Cost = 1+1 Cost = 1+1+1
1, and that of the route from R3 to R2 is 2.

Cost = 1
2. R1 and R3 calculate routes based on the received Network-

1
R1 Summary-LSAs.

=
st
Area 1 Area 2

Co
Area 0 ▫ R1 adds the cost of the route to R2 and the cost carried in the
1

Network-summary-LSA. Therefore, the cost of the route from R1 to


=

R4 R2 R3 R5
st
Co

192.168.1.0/24 is 2.
Cost 1
192.168.1.0/24 ▫ R3 adds the cost of the route to R2 and the cost carried in the
Network-summary-LSA. Therefore, the cost of the route from R3 to
192.168.1.0/24 is 3.
The cost of the route from R2 to 192.168.1.0/24 is 1, so the cost of the
route to 192.168.1.0/24 advertised by R2 to area 0 is 1.

Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Calculation on R5

192.168.1.0/24
Cost =1+3 1. R3 functions as an ABR. It calculates the route to
192.168.1.0/24 based on the Network-Summary-LSA flooded
in area 0, and reinjects the Network-Summary-LSA to area 2.
R1 Area 2

1
The Network-Summary-LSA contains the cost (value 3) of the

=
st
Co
Area 1
Area 0 route to the network segment.
R4 R2 R3 R5
2. Through SPF calculation, the cost of the route from R5 to R3 is

Network-Summary-LSA
1, so the cost of the route from R5 to 192.168.1.0/24 is 4.
192.168.1.0/24 Cost = 3

The cost of the route from R3 to 192.168.1.0/24 is 3, so the cost of the


route to 192.168.1.0/24 advertised by R3 to area 2 is 3.

Page 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Area Route Calculation Result Verification

<R1>display ip routing-table
Destination/Mask Proto Pre Cost
192.168.1.0/24 OSPF 10 2

R1 <R3>display ip routing-table
Destination/Mask Proto Pre Cost
Area 0 192.168.1.0/24 OSPF 10 3
Area 1 Area 2
R4 R2 R3 R5
<R5>display ip routing-table
Destination/Mask Proto Pre Cost
192.168.1.0/24 OSPF 10 4

Check the routing tables on R1, R3, and R5.

Page 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
2. Inter-Area Route Calculation
▫ Inter-Area Route Calculation Process

▪ Inter-Area Routing Loop Prevention Mechanism


▫ Functions and Configurations of Virtual Links

3. External Route Calculation

Page 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Area Routing Loops
R1

R2 advertises the inter-


area route to
192.168.1.0/24 to area 0.
• The process of advertising OSPF inter-area
1
R2 R3
routes is similar to that of advertising routes of
Area 0
2
R3 advertises the
distance-vector routing protocols.
inter-area route to
4 192.168.1.0/24 to • OSPF also requires a loop prevention
area 2.
Potential
routing
mechanism for inter-area route advertisement.
Area 1 loop Area 2

192.168.1.0/24 Area 3

R4 3 R5
R5 advertises the inter-area route to
192.168.1.0/24 to area 3.

Page 41 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Area Routing Loop Prevention Mechanism
(1)

Area 1

• OSPF requires that all non-backbone areas be directly


Area 2 connected to area 0 and inter-area routes be advertised
through area 0.
Area 0
• Inter-area routes cannot be advertised between two non-
backbone areas. As such, a star topology is logically
formed in the OSPF area architecture.
Area 3 Inter-area route

Page 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Area Routing Loop Prevention Mechanism
(2)

Type 1 and Type 2 LSAs Type 3 LSA

R1 R2 R3

Area 1 Area 0

An ABR does not reinject Type 3 LSAs that describe routes to a


network segment in an area to the area.

Page 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Inter-Area Routing Loop Prevention Mechanism
(3)
Type 3 LSAs received by an ABR from a non-backbone area cannot be used to calculate inter-area routes.

The link between R1 and R2 and the link between R3 and R4 are
R1 R2 disconnected, forming the non-contiguous backbone area.

Loopback 0
• R4 advertises the route to 10.0.2.2/32 to area 1 in the form of Type
Area 0 10.0.2.2/32
3 LSA.

• R5 and R6 can calculate the route to 10.0.2.2/32 based on the Type


R3 R4 3 LSA.

• After receiving Type 3 LSAs from a non-backbone area, R3 does


Area 1 not calculate routes or advertise them to other areas.

• In this case, R1 and R3 cannot communicate with the device at


R5 R6
10.0.2.2/32.

How to solve the problem of the non-contiguous backbone area?

Page 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
2. Inter-Area Route Calculation
▫ Intra-Area Route Calculation Process

▫ Inter-Area Routing Loop Prevention Mechanism

▪ Functions and Configurations of Virtual Links

3. External Route Calculation

Page 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Functions and Configurations of Virtual Links
• OSPF requires that the backbone area should be contiguous physically or logically using virtual links.

• A virtual link can be established between any two ABRs, but the two ABRs must have interfaces connected to the
same non-backbone area.
R1

Router ID 10.0.2.2 Router ID 10.0.3.3


Virtual link

R4 R2 Area 1 R3 R5

Area 0 Area 2

[R2-ospf-1]ospf 1 [R3-ospf-1]ospf 1
[R2-ospf-1]area 1 [R3-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]vlink-peer 10.0.3.3 [R3-ospf-1-area-0.0.0.1]vlink-peer 10.0.2.2

Page 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. (TorF) A Network-summary-LSA can describe only one route.
2. (Essay) How does OSPF prevent inter-area routing loops?

Page 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Section Summary
• OSPF introduces the concept of multi-area to support larger-scale networking.

• OSPF uses Type 3 LSAs to describe inter-area routing information.

• To prevent inter-area routing loops, OSPF defines multiple rules.

• An OSPF virtual link is a virtual and logical link deployed between two OSPF routers. It
traverses a non-backbone area to connect another non-backbone area to the backbone area (area
0). The virtual link is only used in the scenario where a non-backbone area is not directly
connected to area 0.

Page 48 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Intra-Area Route Calculation
2. Inter-Area Route Calculation
3. External Route Calculation

Page 49 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Importing External Routes

Common server

The OSPF protocol is not enabled for some links on the


1 2
network.
Area 0
▫ Routers connect to external networks using static routes or
BGP routes.
… ▫ The OSPF protocol is not enabled for the link directly
connected to the server.

Area 1 Area N

Page 50 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic Concepts for External Route Import

[R1]ospf 1
[R1-ospf-1]import-route …
External route • Autonomous system boundary router (ASBR): An
192.168.1.0/24
ASBR OSPF device that imports external routes will
become an ASBR, for example, R1 in the figure.

R1 • An ASBR floods external routes in AS-external-


Area 1 Area 0 Area 2
LSAs (Type 5 LSAs) on an OSPF network.
R4 R2 R3 R5

Type 5 LSA

Page 51 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Description of AS-external LSAs
AS-external-LSA (Type 5 LSA): Originated by an ASBR, an AS-External-LSA describes routes to
destinations outside an AS, and is flooded to all areas except stub areas and NSSAs.
LS Age Options LS Type Main fields
▫ LS Type: The value 5 indicates an AS-external-LSA.
Link State ID
▫ Link State ID: indicates the destination network address of an external route.
Advertising Router ▫ Advertising Router: indicates the router ID of the device that originates the LSA.
LS Sequence Number ▫ Network Mask: indicates the network mask of a route.

LS Checksum length ▫ E: indicates the metric type used by the external route.
▪ 0: The metric type is Metric-Type-1.
Network Mask
▪ 1: The metric type is Metric-Type-2.
E 0 Metric ▫ Metric: indicates the cost of the route to the destination network.
Forwarding Address ▫ Forwarding Address (FA): Packets destined for the advertised destination address
are forwarded to the address specified by this field.
External Route Tag
...

Page 52 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of an AS-external-LSA

[R1]ospf 1 <R1>display ospf lsdb ase self-originate


[R1-ospf-1] import-route direct
OSPF Process 1 with Router ID 10.0.1.1
Server Link State Database
192.168.1.0/24 Router ID 10.0.1.1 Type : External
Ls id : 192.168.1.0
R1
Adv rtr : 10.0.1.1
Ls age : 1340
Area 0 Routing
Area 1 Area 2 Len : 36
R4 R2 R3 R5 information
Options : E
192.168.1.0/24
seq# : 80000004
R1 is directly connected to the server on the network segment chksum : 0xb5cc

192.168.1.0/24. After the direct route is imported to OSPF on R1, R1 Net mask : 255.255.255.0
TOS 0 Metric: 1
injects an AS-external-LSA that describes the route to 192.168.1.0/24
E type :2
to OSPF. The AS-external-LSA is flooded in the entire OSPF area. Forwarding Address : 0.0.0.0
Tag :1
Priority : Low

Page 53 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Calculation on R3
1. External routes are attached to R1.
192.168.1.0/24
2. According to the Advertising Router field in the Type 5 LSA,
Cost 1
R3 determines that the packet needs to pass through R1 before
reaching the external network.

10.0.12.1 3. R3 performs intra-area SPF calculation and adds R1 to the SPF


R1 tree. R3 sets the next-hop router of the route to the external
Area 0 network to R1.
Area 1 Area 2
R4 R2 R3 R5
4. The calculation method of R2 is similar to that of R3.

• R3 and R1 (ASBR) are in the same area, so R3 can calculate the route
[R3]display ospf routing to the ASBR based on the flooded Router-LSAs and Network-LSAs.
Destination Cost Type NextHop AdvRouter
• If R5 and R1 are not in the same area, how does R5 calculate external
192.168.1.0/24 1 Type2 10.0.12.1 10.0.1.1
routes?

Page 54 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Description of an ASBR-Summary-LSA
ASBR-Summary-LSA (Type 4 LSA): Originated by an ABR, an ASBR-summary-LSA describes the routes to an ASBR,
and is flooded to related areas. LS Age Options LS Type

[R1]ospf 1 Link State ID


[R1-ospf-1] import-route direct Advertising Router
LS Sequence Number
LS Checksum Length
Network Mask
0 Metric
R1
...
Area 0 • Main fields

R4 Area 1 R2 R3 Area 2 R5 ▫ LS Type: The value 4 indicates an ASBR-summary LSA.

▫ Link State ID: indicates the router ID of an ASBR.


R2 and R3 generate Type 4 LSAs and advertise them to ▫ Advertising Router: indicates the router ID of the device that originates the
area 1 and area 2 respectively.
LSA.

Type 5 LSA ▫ Network Mask: This parameter is reserved.

Type 4 LSA ▫ Metric: indicates the cost of the route to the destination address.

Page 55 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Example of an ASBR-Summary LSA

<R3>display ospf lsdb asbr self-originate


[R1]ospf 1
[R1-ospf-1] import-route direct Area: 0.0.0.2
Link State Database Router ID of the
Type : Sum-Asbr ASBR
Router ID 10.0.1.1
Ls id : 10.0.1.1

R1 = 1 Adv rtr : 10.0.3.3


st
Co Ls age : 15
Area 0
Len : 28
R4 Area 1 R2 R3 Area 2 R5
Options : E
seq# : 80000005
The following uses the ASBR-summary LSA advertised Cost of the route from
by R3 to area 2 as an example. chksum : 0xf456 R3 to the ASBR
Tos 0 metric: 1

Page 56 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Route Calculation on R5

192.168.1.0/24 1. External routes are attached to R1.

2. R5 determines that the Type 5 LSA is generated by R1


according to the Advertising Router field in the Type 5 LSA.
R1
However, R1 does not exist in the SPF tree of R5.
Area 0
3. Based on the Type 4 LSAs generated by R3, R5 sets the next
R4 Area 1 R2 R3 Area 2 R5
hop of the route to the external network to R3.

[R3]display ospf routing 4. Route calculation on R4 is similar to that on R5.


Destination Cost Type NextHop AdvRouter
192.168.1.0/24 1 Type2 10.0.12.1 10.0.1.1
On the physical network, the costs of the routes from R3 and R5 to the
[R5]display ospf routing external network are different, but cannot be represented in the routing
Destination Cost Type NextHop AdvRouter
192.168.1.0/24 1 Type2 10.0.34.3 10.0.1.1 table.

Note: The cost of all device interfaces is 1.

Page 57 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Distinguishing Two Types of OSPF External
Routes (1)
• Metric-Type-1
▫ When the cost of an external route equals that of an AS internal route and can be compared with the cost of an OSPF route, the external route has
high reliability and can be configured as a Metric-Type-1 external route.

▫ The cost of a Metric-Type-1 external route equals that of a link between a router and its ASBR plus the cost of the link between the ASBR and the
destination.

• Metric-Type-2
▫ When the cost of the route from an ASBR to the destination outside an AS is much greater than the cost of the internal route to the ASBR, the
external route has low reliability and can be configured as a Metric-Type-2 external route.

▫ Metric-Type-2 external routes have the same cost as AS external routes. Type 5 LSA
Route to 192.168.1.0/24
Cost of the link between the ASBR
and the destination
Cost of a link
between a router and
192.168.1.0/24 its ASBR

Outside the OSPF area ASBR OSPF

Page 58 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Distinguishing Two Types of OSPF External
Routes (2)
Type Description Cost
Cost of the AS internal route
Metric-Type-1 High reliability.
+ Cost of the AS external route
Low reliability. The cost of the AS external route is much
Metric-Type-2 (default) Cost of the AS external route
greater than the cost of the AS internal route.

The cost of the


external route is 1.
[R3]display ospf routing
[R1]ospf 1 Destination Cost Type Tag NextHop AdvRouter
[R1-ospf-1]import-route direct type 1 cost 1 192.168.1.0/24 2 Type1 1 10.0.12.1 10.0.1.1

The external route type is Metric-Type-1. In the routing table of R3, the cost of
Imported Metric-Type-1 the route to 192.168.1.0/24 is the cost of the external route plus the cost of the
external route internal route from R3 to R1 (ASBR).
Server
192.168.1.0/24
[R5]display ospf routing
Destination Cost Type Tag NextHop AdvRouter
R1 =1
Area 1 st Area 2 192.168.1.0/24 3 Type1 1 10.0.34.3 10.0.1.1
Co
Area 0 The cost of the route to 192.168.1.0/24 in the routing table of R5 is equal to the
cost of the external route plus the cost of the internal route from R5 to R1
R4 R2 R3 =1 R5
st (ASBR).
Co

Page 59 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. (Multiple) Which of the following types of LSAs may be originated by an ABR?( )
A. ASBR-summary-LSA

B. AS-external-LSA

C. Router-LSA

D. Network-summary-LSA

2. (Single) Which of the following routes has the highest priority for the same route prefix?( )
A. Intra-area route

B. Inter-area route

C. Type 1 external route

D. Type 2 external route

Page 60 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Section Summary
• On a large-scale network, there may be multiple routing protocols. OSPF can import AS external routes to
the local AS so that routers in the AS can learn the routes to other ASs.

• After an ASBR imports external routes into OSPF, the ASBR uses Type 5 LSAs to describe these routes.
Routers in the same area as the ASBR can calculate external routes based on Type 5 LSAs as well as Type
1 and Type 2 LSAs in the area. Routers that are not in the same area as the ASBR need to use Type 4
LSAs to calculate external routes.

• After OSPF imports external routes, you can set the metric type of the routes to Metric-Type-1 or Metric-
Type-2. The cost calculation methods and priorities of external routes with different metric types are
different, Metric-Type-1 routes have a higher priority than Metric-Type-2 routes.

Page 61 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary
• This course describes calculation of OSPF intra-area routes, inter-area routes, and external routes.

• Intra-area routes, inter-area routes, Metric-Type-1 external routes, and Metric-Type-2 external routes are
in descending order of priority.

• LSAs carry OSPF link state information. As the network scale expands, network services become
complex. As OSPF areas are partitioned and a large number of external routes are imported, the LSDB of
a router may contain a large number of Type 1, Type 2, Type 3, Type 4, and Type 5 LSAs, which may
cause the device performance to deteriorate.

• What technical means does OSPF use to prevent the device performance from deteriorating while
ensuring network reachability?

Page 62 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
谢谢
Thank You
www.huawei.com

Page 63 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.

You might also like