cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
589
Views
4
Helpful
10
Replies

OSPF cost calculation for SVI

iores
Level 1
Level 1

Hi,

I have three switches: A <-> B <-> C.

B and C are connected over routed port, and OSPF is established via that port.

A and B are connected over trunk, and OSPF is established over SVI.

An SVI is advertised at switch C.

Switch A sees that prefix with a metric of 6.

The command show ip ospf interface shows that OSPF cost for SVI at se C is 1, cost for physical interface at sw B is 4, and cost for receiving SVI at switch A is 1.

How OSPF calculates cost when the path consists of physical, and virtual interfaces, knowing that cost being used is the one on the interface that receives advertisement for that route? So in my case, how is the cost 6?

10 Replies 10

Note

1- SVI's have a default BW of 1 Gbps. 

2- use show ip ospf interface breif 

To check cost of link

3-show ip ospf database router 

Note:- ospf cost is depend on bandwidth reference in device

MHM

Hello,

First make sure you understand cost is not really defined in the RFC. Cisco happens to use the Reference BW and divides that by the interface BW to get a cost. You can configure the cost (or reference BW) to whatever you want. Since youe switches are connected in a line and have no other path you can manipulate these with no routing changes to see how the different links affect the total cost.

But to answer your question the cost is 6 because:

SVI on SW C is 1

Link between SWB and SW C is 4

SVI on SW A is 1

So to get to the SVI on SW C from SW A it has to go through the SVI on A to get to B, Then through the link from B to C and then to the SVI on C for a total of 6.

Hope that helps

-David

"First make sure you understand cost is not really defined in the RFC."

Eh, are you sure?

My reading of the OSPF RFC is, cost is defined as a dimensionless metric.  I.e. it's defined, just not what it represents.

The OSPF RFC further defines equal cost permitting multi path usage, and host is an accumulating value as you transition network diagram vertexes.

I should have worded it better.

What I meant by that is a vendor can define the cost however it sees fit based on that. Cisco uses the Reference BW while other vendors may use a different metric calculation. So, an SVI in one vendor may have different affects (cost) than a Cisco SVI.

-David


@David Ruess wrote:

What I meant by that is a vendor can define the cost however it sees fit based on that. Cisco uses the Reference BW while other vendors may use a different metric calculation. So, an SVI in one vendor may have different affects (cost) than a Cisco SVI.


BTW, in my experience, years ago, most other vendors didn't automatically assign cost value, it was left to manual configuration.

As time pasted, some other vendors also adopted using bandwidth for auto costing, but their base bandwidth default, usually, was more than Cisco's 100 Mbps.

I also thought Juniper uses a default of 10 in the cost regardless of BW, but I could be mixing that with another protocol or mechanism.

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello @iores ,

OSPF is not able to discriminate L3 routed ports from logical SVI interfaces.

The cost associated to an SVI reflects some administrative parameters like the bandwidth.

in your case the total cost is 6 = 1 + 4 +1

the metric in the Router LSA originated by  Switch C for the destionation prefix  is added to the cost to reach switch C from switch A

so from switch A it is 1+4+1 = 6 it is not 5 because a metric is associated to the link in Switch C Router LSA.

In other words OSPF computes also the outgoing cost to exit on the connected interface.

each node places itself as the root of the SPF tree that is computed for each prefix .

the computation involves the use of each Router LSA and Network LSA to build a clear topology within the single OSPF area..

All possible paths are considered but only the shortest is used.

if Switch C advertises 10 prefixes from switch A the computation is the same for all of them and it will select the same best path to reach Switch C. The total cost for each prefix is the result of the sum of total cost to reach Switch C + link cost associated to the prefix on Switch C.

Hope to help

Giuseppe

Joseph W. Doherty
Hall of Fame
Hall of Fame

BTW, is the switch A SVI that's an OSPF neighbor of a switch B SVI or another SVI on switch A?  Is this, perhaps, what's making the SVI cost to switch C confusing?

Hello @Joseph W. Doherty ,

my understanding is that the OP @iores would expect a different total OSPF cost so I tried to explain that inside a Router LSA each link is listed with its own state and its own non zero cost, and that this link cost has to be added to the cost to reach the originating router SwitchC.

For me it is normal to count the cost to exit the connected interface associated to the prefix, but I am used to this.

Hope to help

Giuseppe

 

 


@Giuseppe Larosa wrote:

my understanding is that the OP @iores would expect a different total OSPF cost so I tried to explain that inside a Router LSA each link is listed with its own state and its own non zero cost, and that this link cost has to be added to the cost to reach the originating router SwitchC.

For me it is normal to count the cost to exit the connected interface associated to the prefix, but I am used to this.


Yup, most likely the situation.  I had thought to suggest taking note of every egress interface transited, but that was implicit in your earlier reply.

What I wondered, since OP didn't fully describe the switch A topology, its also possible cost to the switch C network would be 5 or 6.  6 if the source network was behind the switch A SVI (most likely situation) or 5 (or 6 [depends on gateway interface]) if the source network was on the subnet shared by the switches A and B SVIs (unlikely situation).

Review Cisco Networking for a $25 gift card