现在的位置: 首页 > 综合 > 正文

OSPF – Type 1 LSA vs Type 5 LSA (passive vs redistribute)

2012年02月21日 综合 ⁄ 共 7782字 ⁄ 字号 评论 8 条

In my OSPF database blog entry here: https://www.it598.net/demystifying-the-ospf-database/ – I mentioned that Type3, Type5 and Type7 LSAs are not very memory efficient. Each and every prefix needs a separate LSA, while with a Type1, multiple prefixes can be advertised.

So it stands to reason that perhaps Type1 are always better? Anything that reduces memory load in large topologies is good right? While not always…

Consider the following topology:

Granted, this is not a ‘large topology’, but the fundamentals are still the same. R1 and R2 are both OSPF speakers in Area 0 (yellow) – Both are linked to switches. Let’s pretend that each of these routers actually have 5 connections to each switch. Now there is 2 ways we can get these 5 subnets each into OSPF. If we put them in Area 0, but make them passive, they’ll also be part of the Type1 LSA that each router originates. We can also reditribute them into OSPF which will create a seperate Type5 for each subnet. What behaviour can we see for each?

Let’s start by creating 5 subinterfaces on each router, and then running OSPF passive on all of them.

This is the config on R1:

interface FastEthernet0/1
no ip address
interface FastEthernet0/1.10
encapsulation dot1Q 10
ip address 10.10.10.10 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.20
encapsulation dot1Q 20
ip address 20.20.20.20 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.30
encapsulation dot1Q 30
ip address 30.30.30.30 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.40
encapsulation dot1Q 40
ip address 40.40.40.40 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.50
encapsulation dot1Q 50
ip address 50.50.50.50 255.255.255.0
ip ospf 1 area 0
!
router ospf 1
log-adjacency-changes
passive-interface default
no passive-interface FastEthernet0/0R2:

interface FastEthernet0/1
no ip address
interface FastEthernet0/1.10
encapsulation dot1Q 10
ip address 11.11.11.11 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.20
encapsulation dot1Q 20
ip address 21.21.21.21 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.30
encapsulation dot1Q 30
ip address 31.31.31.31 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.40
encapsulation dot1Q 40
ip address 41.41.41.41 255.255.255.0
ip ospf 1 area 0
interface FastEthernet0/1.50
encapsulation dot1Q 50
ip address 51.51.51.51 255.255.255.0
ip ospf 1 area 0
!
router ospf 1
log-adjacency-changes
passive-interface default
no passive-interface FastEthernet0/0Let’s have a look at the database on R1:

R1#sh ip ospf database

OSPF Router with ID (10.12.12.1) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count
10.12.12.1 10.12.12.1 0 0x8000000B 0x0029E7 7
10.12.12.2 10.12.12.2 154 0x8000000B 0x00FE01 7
R1#Nice and neat. Only 2 Type1 LSAs as expected. If we dig into R2′s Type1 we can see:

R1#sh ip ospf database router 10.12.12.2

OSPF Router with ID (10.12.12.1) (Process ID 1)

Router Link States (Area 0)

LS age: 222
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 10.12.12.2
Advertising Router: 10.12.12.2
LS Seq Number: 8000000B
Checksum: 0xFE01
Length: 108
Number of Links: 7

Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 10.12.12.1
(Link Data) Router Interface address: 10.12.12.2
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 10.12.12.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 51.51.51.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 41.41.41.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 31.31.31.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 21.21.21.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 11.11.11.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10All of R2′s networks are advertised in this single LSA. Nice and simple.

Let’s remove the interface OSPF config and instead redistribute the fa0/1 subinterfaces into OSPF and see what we get. Let’s first look at the OSPF database:

R1#sh ip ospf database

OSPF Router with ID (10.12.12.1) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count
10.12.12.1 10.12.12.1 65 0x8000000E 0x00CE83 2
10.12.12.2 10.12.12.2 38 0x8000000E 0x00C28D 2

Type-5 AS External Link States

Link ID ADV Router Age Seq# Checksum Tag
10.10.10.0 10.12.12.1 64 0x80000001 0x0069F5 0
11.11.11.0 10.12.12.2 37 0x80000001 0x003F1C 0
20.20.20.0 10.12.12.1 64 0x80000001 0x00FF41 0
21.21.21.0 10.12.12.2 37 0x80000001 0x00D567 0
30.30.30.0 10.12.12.1 64 0x80000001 0x00968C 0
31.31.31.0 10.12.12.2 37 0x80000001 0x006CB2 0
40.40.40.0 10.12.12.1 64 0x80000001 0x002DD7 0
41.41.41.0 10.12.12.2 38 0x80000001 0x0003FD 0
50.50.50.0 10.12.12.1 66 0x80000001 0x00C323 0
51.51.51.0 10.12.12.2 38 0x80000001 0x009949 0A lot more than we had last time. Let’s have a look at the Router LSA and 1 External LSA:

R1#sh ip ospf database router 10.12.12.2

OSPF Router with ID (10.12.12.1) (Process ID 1)

Router Link States (Area 0)

Routing Bit Set on this LSA
LS age: 84
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 10.12.12.2
Advertising Router: 10.12.12.2
LS Seq Number: 8000000E
Checksum: 0xC28D
Length: 48
AS Boundary Router
Number of Links: 2

Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 10.12.12.1
(Link Data) Router Interface address: 10.12.12.2
Number of TOS metrics: 0
TOS 0 Metrics: 10

Link connected to: a Stub Network
(Link ID) Network/subnet number: 10.12.12.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 10

R1#sh ip ospf database external 51.51.51.0

OSPF Router with ID (10.12.12.1) (Process ID 1)

Type-5 AS External Link States

Routing Bit Set on this LSA
LS age: 107
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 51.51.51.0 (External Network Number )
Advertising Router: 10.12.12.2
LS Seq Number: 80000001
Checksum: 0x9949
Length: 36
Network Mask: /24
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 20
Forward Address: 0.0.0.0
External Route Tag: 0We are seeing exactly what we expected, but it’s just bloated everything a bit. So perhaps it’s better to put external interfaces into OSPF and run them as passive? Well, let’s take a closer look at something else. Let’s keep the Type5 LSA and check the SPF statistics on R2:

R2#sh ip ospf statistics

OSPF Router with ID (10.12.12.2) (Process ID 1)

Area 0: SPF algorithm executed 23 timesAt this very moment the SPF algorithm has excecuted 23 times. Let’s shut 2 of R1′s subinterfaces and see what happens in R2.

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int fa0/1.10
R1(config-subif)#shut
R1(config-subif)#int fa0/1.20
R1(config-subif)#shutR2#sh ip ospf statistics

OSPF Router with ID (10.12.12.2) (Process ID 1)

Area 0: SPF algorithm executed 23 timesNo change in the SPF calculation. Let’s now move everything back into Type1s again and do the same.

Everything has been changed back, so let’s take a before on R2:

R2#sh ip ospf statistics

OSPF Router with ID (10.12.12.2) (Process ID 1)

Area 0: SPF algorithm executed 31 timesR1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int fa0/1.10
R1(config-subif)#shut
R1(config-subif)#int fa0/1.20
R1(config-subif)#shutWhat do we now see on R2?

R2#sh ip ospf statistics

OSPF Router with ID (10.12.12.2) (Process ID 1)

Area 0: SPF algorithm executed 33 timesI removed the same 2 interfaces from OSPF, and this time SPF was run twice, once for each removal. What’s going on here?

If a router originates a Type1 LSA for all of it’s connected interfaces, each time 1 of those interfaces flap, it needs to originate the entire Type1 LSA again showing the removal of the prefix on that interface. Each time a Type1 LSA (and Type2 for that matter) is flooded into an area, all routers in the area need to run their SPF algorithm. A Type5 is inherently external to the OSPF domain, and so OSPF speakers in the area will believe whatever the ABRs and ASBRs tell them. The next-hop to these external routes will be to the ABR and ASBR in the area, of which the SPF algorithm has already been run to find a route to. This is part of OSPF’s DV behaviour when it gets outside the local area.

So now we see advantages and disadvantages to both methods. Type1′s keep the database small and clean, while Type5′s allow SPF to run far less when externally facing interfaces go up and down.

You can tweak OSPF with Incremental OSPF. This allows the OSPF process to only recalculate certain portions of the SPF tree when a Type1 or Type2 is flooded into the area. SPF still needs to be run, but at least in a much more optimised state.

目前有 8 条留言    访客:5 条, 博主:0 条 ,引用: 3 条

  1. urbaw 2012年02月23日 上午 7:08  @回复  Δ1楼 回复

    один

  2. Adriana 2012年02月25日 上午 12:12  @回复  Δ2楼 回复

    thanks for share!

  3. CCNA 2012年03月01日 下午 10:19  @回复  Δ3楼 回复

    Hello there! Would you mind if I share your blog with my facebook group? There’s a lot of people that I think would really appreciate your content. Please let me know;

  4. Nicolicoiu Damianic 2012年03月05日 下午 1:11  @回复  Δ4楼 回复

    Good day! You have done a wonderful job! I have added a link to your homepage on my website’s friends page. Hope this will help you to get more traffic.

  5. armagard 2012年03月27日 上午 8:23  @回复  Δ5楼 回复

    The information on this site is useful.

外部的引用: 3 条

  • Rollator Gehhilfe
  • allegra otc
  • cafelearn72

给我留言

留言无头像?