Você está na página 1de 8

NETMANIAS

TECH-BLOG

Please visit www.netmanias.com to view more posts

Quick Guide to OSPF: Part 1. Building Shortest


Path Tree Topology
May 6, 2015 | By Chris Yoo (tech@netmanias.com)

This time, we will discuss how routers discover IP network topologies and build shortest path trees by using
OSPF protocols.
Certainly, routing protocols like OSPF are based on operating principles that are hard to understand if you are
not a routing expert. Many people are quite good at routing configuration using Command Line Interface (CLI),
but only a few fully understand the operating principles of the protocols. To help you, routing novices,
understand OSPF better, below we have provided lots of easy-to-understand illustrations.

OSPF network topology


OSPF Topology
10.1.0.4/32

R4

1.1.3.0/30, (10)

.2
.2

10.1.0.2/32
.1
.1

OSPF enabled Interface

.2
R2

1.1.1.0/30, (10)
1.1.1.0/30, (10)

1.1.5.0/30, (10)

Link IP Network
.1
.1

10.1.0.5/32
1.1.4.0/30, (20)

.2
.2

10.1.0.3/32
1.1.6.0/30, (20)

R5

Link Cost

10.1.0.1/32

.1
.1

.2
R3

1.1.2.0/30, (10)

R1

.2

1.1.1.0/30, (10)

R2
1.1.1.2/30

.1
R1

1.1.1.1/30

In the figure, there are five OSPF routers (R1 ~ R5), along with their respective interface IP address, OSPF cost
and loopback address (e.g. 10.1.0.1 for R1).

Here OSPF cost means cost needed to deliver a packet to each link. From OSPF's perspective, a least
cost path is the shortest path. In general, the cost of a link is determined based on its bandwidth. For
example, the cost of 100Mbps link is greater than that of 1GE link, and the cost of 1GE of greater
than that of 10GE (The system operator of a network configures link costs for each interface in a
router, by using CLI)

In order for routers to exchange OSPF messages with each other, IP addresses for identifying routers
(OSPF RID (Router ID)) are required. For the purpose, loopback addresses are usually used. IP
addresses of physical links can also be used, but loopback addresses are preferred for the following
reasons:

If a physical link IP address is used: The IP address disappears when the physical link is
down. That is, an OSPF router that uses this address as OSPF RID can no longer

Netmanias Tech-Blog: Quick Guide to OSPF: Part 1. Building Shortest Path Tree Topology

communicate with its connected neighbor OSPFs.

If a loopback IP address is used: The IP address remains valid even when the physical link is
down because loopback addresses are logical addresses that are not bound to a certain
physical link.

Routers flooding their link IP addresses to other routers


1. R1 floods its link information to neighbor OSPF routers
1 R1 floods Router-LSA
10.1.0.4/32

R4

t=2

.2
.2

LSA Message

10.1.0.2/32
.1
.1

LS Type Link State ID Advertising Router

Link Type Link ID


Link Type Link ID

.2
R2

...

t=1
10.1.0.3/32

t=2

.1
.1

R5

.1
.1
R1

.2

R3
Each OSPF router builds LSDB after receiving Router-LSA originated from R1

R1~R5: OSPF LSDB

...

Router-LSA (originated from R1)


1 10.1.0.1 10.1.0.1
1 10.1.0.2 1.1.1.1 10
1 10.1.0.3 1.1.2.1 10
3 10.1.0.1
/32
0

10.1.0.1/32
t=2

.2
.2

...

LSA
Identifier

t=1

t=2

10.1.0.5/32

...

Link Data Metric


Link Data Metric

Router-LSA (originated from R1)


Router-LSA (originated from R1), which is
discarded due to duplicated LSA

R1~R5: OSPF Network Topology

Originator Neighbor, Cost


R1(1.1.1.1) R2, 10
R1(1.1.2.1) R3, 10

R2
1.1.1.1, (10)

R1
1.1.2.1, (10)

R3

R1 floods its link (interface) address and loopback address to R2 and R3, through Router-LSA message [t=1].
Upon receiving the message, R2 and R3 flood it through all the links except the one that the message was sent
through, having both R4 and R5 receive the same Router-LSA message twice [t=2]. At this time, if the two
messages have the same LSA identifiers, {LS Type, Link State ID, Advertising Router}, the one that arrived later
is discarded.

LS Type: Identifies Router-LSA (1), Network-LSA (2), External-LSA (5), etc.

Link State ID: Same as Advertising Router value (10.1.0.1) in case of Router-LSA

Advertising Router: ID of the router that originated generated Router-LSA (OSPF RID, i.e. loopback
address = 10.1.0.1)

The Router-LSA message sent by R1 includes (see the table in the upper right corner of the figure above):

Link Type: Identifies link types. Values for Link ID and Link Data are determined according to this
value.

Link Type = 1: Point-to-point connection (all the routers in the figure have this type of
connection)

Link Type = 3: Stub network (loopback address of router)

Netmanias Tech-Blog: Quick Guide to OSPF: Part 1. Building Shortest Path Tree Topology

Link ID

In case of Link Type = 1, Link ID is the Router ID of the OSPF Neighbor connected to R1
(Neighbor RIDs are known to each other while OSPF Neighbors exchange Hello message)

In case of Link Type = 3, Link ID is the loopback address of R1

Link Data

In case of Link Type = 1, Link Data is the link IP address of R1

In case of Link Type = 3, Link Data is the subnet mask of R1's loopback address (/32 =
255.255.255.255)

Upon arrival of the Router-LSA message sent by R1, the receiving routers (i.e. R2 ~R5 here) store the
information in their respective OSPF Link State DataBase (LSDB), and build an OSPF topology based on the
information. With the information available so far, the routers now know:

R1's loopback address (10.1.0.1/32)

R1's link address 1.1.1.1 is connected to R2 (10.1.0.2)

R1's link address 1.1.2.1 is connected to R3 (10.1.0.3)

2. R2 floods its link information to neighbor OSPF routers


2 R2 floods Router-LSA
10.1.0.4/32

R4

t=1

.2
.2

LSA Message

10.1.0.2/32
.1
.1

LS Type Link State ID Advertising Router

Link Type Link ID


Link Type Link ID

.2

...

R2

10.1.0.1/32
.1
.1

t=2

.2
.2

t=2

10.1.0.3/32
.1
.1

R5

t=2

R1

.2

R3
Each OSPF router builds LSDB after receiving Router-LSA originated from R2

R1~R5: OSPF LSDB

...

LSA
Identifier

...

t=1

t=1

10.1.0.5/32

...

Link Data Metric


Link Data Metric

Router-LSA (originated from R2)


1 10.1.0.2 10.1.0.2
1 10.1.0.1 1.1.1.2 10
1 10.1.0.4 1.1.3.1 10
1 10.1.0.5 1.1.5.1 10
3 10.1.0.2
/32
0
Router-LSA (originated from R2)
Router-LSA (originated from R2), which is
discarded due to duplicated LSA

R1~R5: OSPF Network Topology

Originator Neighbor, Cost


R2(1.1.1.2) R1, 10
R2(1.1.3.1) R4, 10
R2(1.1.5.1) R5, 10

1.1.3.1, (10)
1.1.5.1, (10)
1.1.1.2, (10)
R2

R4
R1
R5

R2 floods its link (interface) address and loopback address to R1, R4 and R5, through Router-LSA message [t=1].
Upon receiving the message, R1, R4 and R5 flood it through all the links except the one that the message was
sent through [t=2].
R1, R3, R4 and R5 store the information (Router-LSA) in their respective LSDB. Now another "OSPF network
topology" is obtained as seen in the figure above.

3. R3 floods its link information to neighbor OSPF routers

Netmanias Tech-Blog: Quick Guide to OSPF: Part 1. Building Shortest Path Tree Topology

3 R3 floods Router-LSA
10.1.0.4/32

R4

.2
.2

.1
.1

t=2

LSA Message

10.1.0.2/32

LS Type Link State ID Advertising Router

Link Type Link ID


Link Type Link ID

.2

...

R2

t=1

.1
.1
10.1.0.3/32
.1
.1

R5

t=1

R1

.2

Router-LSA (originated from R3)


Router-LSA (originated from R3), which is
discarded due to duplicated LSA

R3
Each OSPF router builds LSDB after receiving Router-LSA originated from R3

R1~R5: OSPF LSDB


Originator Neighbor, Cost
R3(1.1.2.2) R1, 10
R3(1.1.4.1) R4, 20
R3(1.1.6.1) R5, 20

...

Router-LSA (originated from R3)


1 10.1.0.3 10.1.0.3
1 10.1.0.1 1.1.2.2 10
1 10.1.0.4 1.1.4.1 20
1 10.1.0.5 1.1.6.1 20
3 10.1.0.3
/32
0

10.1.0.1/32
t=1

.2
.2

...

LSA
Identifier

t=2

t=2

10.1.0.5/32

...

Link Data Metric


Link Data Metric

R1~R5: OSPF Network Topology


R4
R1
R5
R3

1.1.2.2, (10)
1.1.4.1, (20)
1.1.6.1, (20)

Again, R3 floods its link (interface) address and loopback address to R1, R4 and R5, through Router-LSA
message [t=1]. Upon receiving the message, R1, R4 and R5 flood it through all the links except the one that the
message was sent through [t=2].
R1, R2, R4 and R5 store the information (Router-LSA) in their respective LSDB. Now again another "OSPF
network topology" is obtained as seen in the figure above.

4. R4 floods its link information to neighbor OSPF routers


4 R4 floods Router-LSA
10.1.0.4/32

R4

.2
.2

t=1

.1
.1

LS Type Link State ID Advertising Router

Link Type Link ID


Link Type Link ID

.2

...

t=2

R2

t=2

10.1.0.5/32
.2
.2

LSA Message

10.1.0.2/32

10.1.0.1/32
.1
.1

t=1
t=2

10.1.0.3/32
.1
.1

R5

t=2

R1

.2

R3
Each OSPF router builds LSDB after receiving Router-LSA originated from R4

R1~R5: OSPF LSDB


Originator Neighbor, Cost
R4(1.1.3.2) R2, 10
R4(1.1.4.2) R3, 20

...

Link Data Metric


Link Data Metric

...

LSA
Identifier

...

Router-LSA (originated from R4)


1 10.1.0.4 10.1.0.4
1 10.1.0.2 1.1.3.2 10
1 10.1.0.3 1.1.4.2 20
3 10.1.0.4
/32
0
Router-LSA (originated from R4)
Router-LSA (originated from R4), which is
discarded due to duplicated LSA

R1~R5: OSPF Network Topology


1.1.3.2, (10)
1.1.4.2, (20)

R2
R4

R3

R4 floods its link (interface) address and loopback address to R2 and R3, through Router-LSA message [t=1].

Netmanias Tech-Blog: Quick Guide to OSPF: Part 1. Building Shortest Path Tree Topology

Upon receiving the message, R2 and R3 flood it through all the links except the one that the message was sent
through [t=2].
R1, R2, R3 and R5 store the information (Router-LSA) in their respective LSDB. Now again, another "OSPF
network topology" is obtained as seen in the figure above.

5. R5 floods its link information to neighbor OSPF routers


5 R5 floods Router-LSA
10.1.0.4/32

R4

.2
.2

t=2

.1
.1

LS Type Link State ID Advertising Router

Link Type Link ID


Link Type Link ID

.2

...

t=2

R2

t=1

10.1.0.5/32
.2
.2

LSA Message

10.1.0.2/32

...

t=1

10.1.0.3/32

.1
.1

.1
.1

R5

t=2

R1

.2

R3
Each OSPF router builds LSDB after receiving Router-LSA originated from R5

R1~R5: OSPF LSDB

...

LSA
Identifier

...

Router-LSA (originated from R5)


1 10.1.0.5 10.1.0.5
1 10.1.0.2 1.1.5.2 10
1 10.1.0.3 1.1.6.2 20
3 10.1.0.5
/32
0

10.1.0.1/32
t=2

Link Data Metric


Link Data Metric

Router-LSA (originated from R5)


Router-LSA (originated from R5), which is
discarded due to duplicated LSA

R1~R5: OSPF Network Topology

Originator Neighbor, Cost


R5(1.1.5.2) R2, 10
R5(1.1.6.2) R3, 20

R2

R5
1.1.5.2, (10)

R3
1.1.6.2, (20)

Same thing again. R5 floods its link (interface) address and loopback address to R2, and R3, through RouterLSA message [t=1]. Upon receiving the message, R2 and R3 flood it through all the links except the one that
the message was sent through [t=2].
R1 ~ R4 store the information (Router-LSA) in their respective LSDB. Now another "OSPF network topology" is
obtained as seen in the figure above.
Note 1: In real networks, all routers flood their Router-LSA to their neighbor OSPFs all at the same time. In this
post, however, we assumed all the flooding are sequential, for easier understanding.
Note 2: In order for routers to send Router-LSA, their link types should be configured as point-to-point. If
configured otherwise (e.g. broadcast), Network-LSA is sent instead. Most of link connections among routers
are of point-to-point type. So, we will not further discuss other types of link connections than point-to-point as
this particular post is for routing novices like you.

Netmanias Tech-Blog: Quick Guide to OSPF: Part 1. Building Shortest Path Tree Topology

Routers building OSPF Topologies


1 Topology by R1's Router-LSA

2 Topology by R2's Router-LSA

R2
1.1.1.1, (10)

R1
1.1.2.1, (10)

R3

3 Topology by R3's Router-LSA

1.1.3.1, (10)
1.1.5.1, (10)
1.1.1.2, (10)
R2

R4
R1

R4

R1
R5

R5

4 Topology by R4's Router-LSA

R4

R3
1.1.6.2, (20)

1.1.3.1, (10)
1.1.5.1, (10)
1.1.1.2, (10)
R2

OSPF LSDB

1.1.3.2, (10)

1.1.1.1, (10)

R4
R1

1.1.2.1, (10)

R5
1.1.5.2, (10)

R5
1.1.5.2, (10)

R3

1.1.4.2, (20)

R2

R2

OSPF Topology Map

1.1.2.2, (10)
1.1.4.1, (20)
1.1.6.1, (20)

5 Topology by R5's Router-LSA

1.1.3.2, (10)
1.1.4.2, (20)

R3

R3

1.1.2.2, (10)
1.1.4.1, (20)
1.1.6.1, (20)

1.1.6.2, (20)

Originator Neighbor, Cost


R1(1.1.1.1) R2, 10
R1(1.1.2.1) R3, 10
R2(1.1.1.2) R1, 10
R2(1.1.3.1) R4, 10
R2(1.1.5.1) R5, 10
R3(1.1.2.2) R1, 10
R3(1.1.4.1) R4, 20
R3(1.1.6.1) R5, 20
R4(1.1.3.2) R2, 10
R4(1.1.4.2) R3, 20
R5(1.1.5.2) R2, 10
R5(1.1.6.2) R3, 20

As a result of exchanging Router-LSA messages with each other, all the five OSPF routers end up having the
same LSDB, and thus the same OSPF topology map built based on the LSDB as seen above.

Netmanias Tech-Blog: Quick Guide to OSPF: Part 1. Building Shortest Path Tree Topology

Calculating shortest path tree


R1: Shortest Path Tree

R4
R5

10

R2
10

10

R1

20
20

R1: Traffic Path to R2, R3, R4, R5

10

R3

R2: Shortest Path Tree

R4
R5

10

10

R1

20
20

10

R3

R3: Shortest Path Tree

R4
R5

10

10

R1

20
20

10

R3

R4: Shortest Path Tree

R4
R5

10

10

R1

20
20

10

R3

R5: Shortest Path Tree

R4
R5

10

10

R1

20
20

10

R3

R3

R1

10

R2

10

R4

R1

10

R2

10

R5

R2

10

R1

R2

10

R1

R2

10

R4

R2

10

R5

10

R3

10

R1

R3

10

R1

R3

20

R4

R3

20

R5

10

Destination Network
10.1.0.1/32 (R1)
10.1.0.3/32 (R3)
10.1.0.4/32 (R4)
10.1.0.5/32 (R5)

10

R2

R4

10

R2

10

R1

R4

10

R2

10

R5

R4

20

R3

R5

10

R2

R5

10

R2

10

R1

R5

10

R2

10

R4

R5

20

R3

Next Hop
1.1.1.1 (R1)
1.1.1.1 (R1)
1.1.3.2 (R4)
1.1.5.2 (R5)

R3 RIB/FIB
Destination Network
10.1.0.1/32 (R1)
10.1.0.2/32 (R2)
10.1.0.4/32 (R4)
10.1.0.5/32 (R5)

R2

R4

Next Hop
1.1.1.2 (R2)
1.1.2.2 (R3)
1.1.1.2 (R2)
1.1.1.2 (R2)

R2 RIB/FIB

R3

R5: Traffic Path to R1, R2, R3, R4

R2

10

10

R4: Traffic Path to R1, R2, R3, R5

R2

10

R1

R1 RIB/FIB
Destination Network
10.1.0.2/32 (R2)
10.1.0.3/32 (R3)
10.1.0.4/32 (R4)
10.1.0.5/32 (R5)

R3: Traffic Path to R1, R2, R4, R5

R2

10

R2

R2: Traffic Path to R1, R3, R4, R5

R2

10

R1

10

Next Hop
1.1.2.1 (R1)
1.1.2.1 (R1)
1.1.4.2 (R4)
1.1.6.2 (R5)

R4 RIB/FIB
Destination Network
10.1.0.2/32 (R2)
10.1.0.1/32 (R1)
10.1.0.5/32 (R5)
10.1.0.3/32 (R3)

Next Hop
1.1.3.1 (R2)
1.1.3.1 (R2)
1.1.3.1 (R2)
1.1.4.1 (R3)

R5 RIB/FIB
Destination Network
10.1.0.2/32 (R2)
10.1.0.1/32 (R1)
10.1.0.4/32 (R4)
10.1.0.3/32 (R3)

Next Hop
1.1.5.1 (R2)
1.1.5.1 (R2)
1.1.5.1 (R2)
1.1.6.1 (R3)

Using the OSPF topology generated above, each router calculates the shortest path tree, i.e. the shortest path
to their respective destinations. The shortest path information is installed at the Routing Information Base
(RIB) and Forwarding Information Base (FIB) of each router (Note: RIB is a routing table managed in the
control plane where routing protocols like OSPF are used while FIB is a routing table located in the data plane
where wire-speed packet forwarding by packet processors takes place).
can have more than one SSIDs, and each SSID may provide different authentication/encryption methods (e.g.
In SK Telecom networks, an AP has 2 SSIDs - T wifi zone_secure and T wifi zone).

Netmanias Research and Consulting Scope


99

00

01

02

03

04

05

06

07

08

09

10

11

12

13

eMBMS/Mobile IPTV
CDN/Mobile CDN
Transparent Caching
BSS/OSS

Services

Cable TPS
Voice/Video Quality
IMS
Policy Control/PCRF
IPTV/TPS
LTE

Mobile
Network

Mobile WiMAX
Carrier WiFi
LTE Backaul
Data Center Migration
Carrier Ethernet
FTTH

Wireline
Network

Data Center
Metro Ethernet
MPLS
IP Routing

CDN
Transparent
Caching

Analysis

Networks

eMBMS

LTE
IMS
Infrastructure Services

Analyze trends, technologies and market


Report
Technical documents
Blog
One-Shot gallery

Concept Design
DRM

POC

Training

Wi-Fi

We design the future

protocols

IP/MPLS

We design the future

Carrier Ethernet

We design the future

Consulting

Visit http://www.netmanias.com to view and download more technical documents.

Future

About NMC Consulting Group (www.netmanias.com)


NMC Consulting Group is an advanced and professional network consulting company, specializing in IP network areas (e.g., FTTH, Metro Ethernet and IP/MPLS), service
areas (e.g., IPTV, IMS and CDN), and wireless network areas (e.g., Mobile WiMAX, LTE and Wi-Fi) since 2002.
Copyright 2002-2015 NMC Consulting Group. All rights reserved.

Você também pode gostar