cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2687
Views
0
Helpful
2
Replies

OSPF Cost calculation

rakeshvelagala
Level 3
Level 3

Hi All,

Please advise on the below. I am just understanding the cost calculations. Consider the link between R2 and R3.

R2 has loopback 2.2.2.2 in area 0

R4 has loopback 4.4.4.4 in area 0

I have changed the cost of R4 (Eth 1/1) as 200. 

From below

R2#sh ip ospf database router self-originate

Link connected to: a Stub Network
(Link ID) Network/subnet number: 2.2.2.2
(Link Data) Network Mask: 255.255.255.255
Number of MTID metrics: 0
TOS 0 Metrics: 1

Link connected to: a Virtual Link
(Link ID) Neighboring Router ID: 1.1.1.1
(Link Data) Router Interface address: 10.1.1.2
Number of MTID metrics: 0
TOS 0 Metrics: 10

Link connected to: a Transit Network
(Link ID) Designated Router address: 172.16.1.2
(Link Data) Router Interface address: 172.16.1.2
Number of MTID metrics: 0
TOS 0 Metrics: 10

So R2 is adjacent with DR( Considering as a Virtual Process) and the cost to reach the DR is 10.

Checking what is the DR adjacent with we have,

R2#sh ip ospf database network 172.16.1.2

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

Net Link States (Area 0)

Routing Bit Set on this LSA in topology Base with MTID 0
LS age: 776
Options: (No TOS-capability, DC)
LS Type: Network Links
Link State ID: 172.16.1.2 (address of Designated Router)
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0xCB8E
Length: 32
Network Mask: /24
Attached Router: 2.2.2.2
Attached Router: 4.4.4.4

So it has a router 4.4.4.4 attached to the link. So cost from 2.2.2.2 to reach the node with link identifier is cost 10 from above.

So from r2#sh ip route 4.4.4.4 (10 + 1(for r4 to loopback))=11

R2#sh ip route 4.4.4.4
Routing entry for 4.4.4.4/32
Known via "ospf 1", distance 110, metric 11, type intra area
Last update from 172.16.1.4 on Ethernet1/1, 00:19:44 ago
Routing Descriptor Blocks:
* 172.16.1.4, from 4.4.4.4, 00:19:44 ago, via Ethernet1/1
Route metric is 11, traffic share count is 1

Now Taking from R4#

Router Link States (Area 0)

LS age: 922
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 4.4.4.4
Advertising Router: 4.4.4.4
LS Seq Number: 80000005
Checksum: 0x8A25
Length: 60
Number of Links: 3

Link connected to: a Stub Network
(Link ID) Network/subnet number: 4.4.4.4
(Link Data) Network Mask: 255.255.255.255
Number of MTID metrics: 0
TOS 0 Metrics: 1

Link connected to: a Transit Network
(Link ID) Designated Router address: 192.168.1.3
(Link Data) Router Interface address: 192.168.1.4
Number of MTID metrics: 0
TOS 0 Metrics: 10

Link connected to: a Transit Network
(Link ID) Designated Router address: 172.16.1.2
(Link Data) Router Interface address: 172.16.1.4
Number of MTID metrics: 0
TOS 0 Metrics: 200


R4#sh ip ospf database network 172.16.1.2

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

Net Link States (Area 0)

Routing Bit Set on this LSA in topology Base with MTID 0
LS age: 1263
Options: (No TOS-capability, DC)
LS Type: Network Links
Link State ID: 172.16.1.2 (address of Designated Router)
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0xCB8E
Length: 32
Network Mask: /24
Attached Router: 2.2.2.2
Attached Router: 4.4.4.4

Now the metric is 201

R4#sh ip route 2.2.2.2
Routing entry for 2.2.2.2/32
Known via "ospf 1", distance 110, metric 201, type intra area
Last update from 172.16.1.2 on Ethernet1/1, 00:25:10 ago
Routing Descriptor Blocks:
* 172.16.1.2, from 2.2.2.2, 00:25:10 ago, via Ethernet1/1
Route metric is 201, traffic share count is 1

Not sure if I understand correctly, but if they are adjacent to  the DR, how can the cost differ? I mean if I have changed to cost on interface eth 1/1, should it not be reflected in R2#sh ip ospf database router self-originate?? Please kindly advise.

Thanks

1 Accepted Solution

Accepted Solutions

Peter Paluch
Cisco Employee
Cisco Employee

Hi,

Changing the cost of an OSPF interface only affects the metric of routes "going out" that interface. Specifically, when R2 was calculating the path to 4.4.4.4, it summed together

  • the cost of its interface to the network between R2 and R4 (10)
  • the cost of reaching R4 from this network (0 - all adjacencies referenced by an LSA2 have a cost of 0)
  • the cost of R4's Loopback interface  (1)

In the opposite direction, when R4 was calculating the path to 2.2.2.2, it summed together

  • the cost of its interface to the network between R4 and R2 (200)
  • the cost of reaching R2 from this network (0)
  • the cost of R2's Loopback interface (1)

Would this make sense?

Best regards,
Peter

View solution in original post

2 Replies 2

Peter Paluch
Cisco Employee
Cisco Employee

Hi,

Changing the cost of an OSPF interface only affects the metric of routes "going out" that interface. Specifically, when R2 was calculating the path to 4.4.4.4, it summed together

  • the cost of its interface to the network between R2 and R4 (10)
  • the cost of reaching R4 from this network (0 - all adjacencies referenced by an LSA2 have a cost of 0)
  • the cost of R4's Loopback interface  (1)

In the opposite direction, when R4 was calculating the path to 2.2.2.2, it summed together

  • the cost of its interface to the network between R4 and R2 (200)
  • the cost of reaching R2 from this network (0)
  • the cost of R2's Loopback interface (1)

Would this make sense?

Best regards,
Peter

rakeshvelagala
Level 3
Level 3

Many thanks Peter

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card