Description

In this section we will discuss how OSPF calculate best path using path cost / metric , OSPF always run SPF (shortest path first) algorithm in a certain time interval to calculate best path . OSPF calculate best path using cost of the path . The formula OSPF use to calculate best path is cost = ref-bandwidth/bandwidth .

  • reference-bandwidth—Reference bandwidth, in bits per second. Range: 9600 through 4,000,000,000,000 bits , Default: 100 Mbps (100,000,000 bits)

NOTE: The default behavior is to use the reference-bandwidth value to calculate the cost of OSPF interfaces. You can override this behavior for any OSPF interface by configuring a specific cost with the metric statement.

 

Metric :: Specify the cost of an OSPF interface. The cost is a routing metric that is used in the link-state calculation. / Cost of the route. Range: 1 through 65,535 ,

 

Default: By default, the cost of an OSPF route is calculated by dividing the reference-bandwidth value by the bandwidth of the physical interface. Any specific value you configure for the metric overrides the default behavior of using the reference-bandwidth value to calculate the cost of the route for that interface.

 

Please refer below topology as an example ::

Capture.PNG

We have configured OSPF between all three MX device and only MX1 is in stub area . In this scenario we are sending traffic from MX1 to MX2 . IP 172.31.31.5 assigned to MX2 . MX1 having xe-3/0/0 interface which connected to MX2 with xe-3/0/1 interface using 172.31.195.95 IP address .

 

 

Symptoms

When we sending traffic from MX1 to MX2 its always taking the upper path (MX1 ----- MX2) .

 

MX1> show ospf interface

Interface          State  Area           DR ID          BDR ID         Nbrs

ge-0/1/1          PtToPt 0.0.3.234      0.0.0.0        0.0.0.0           0 ----------------------> upper path

xe-0/3/0         PtToPt 0.0.3.234      0.0.0.0        0.0.0.0           1 ----------------------> lower path

 

    

MX1> traceroute 172.31.31.5

traceroute to 172.31.31.5 (172.31.31.5), 30 hops max, 40 byte packets

 1 172.31.31.5 (172.31.31.5) 1.924 ms 1.873 ms 1.782 ms  ----------------------> its taking the direct path between MX1 and MX2 (upper path)

 

The above is default behavior of OSPF . (taking the shortest path)

 

In our case customer having some requirement and now they want to send large amount of traffic from MX1 to MX2 . But now the 1g link not able to handle this huge amount is traffic . Traffic limit is exceeding above 1g and interface is over utilized and customer is facing connectivity issue because of this issue .

Solution

The simple solution is path manipulation using OSPF metric / path cost . Here in our scenario we can add metric / extra cost on the 1g link (upper link) . As below :://

 

MX1> show configuration protocols ospf

traffic-engineering;

external-preference 180;

reference-bandwidth 800g;

area 0.0.3.234 {

   stub;

   interface lo0.0;

   interface ge-0/1/2.0 {

       interface-type p2p;

       authentication {

           md5 60 key /* SECRET-DATA */; ## SECRET-DATA

       }

       bfd-liveness-detection {

           minimum-interval 300;

           multiplier 4;

           full-neighbors-only;

       }

   }

   interface ge-0/1/1 {

       interface-type p2p;

       metric 10000;   ------------------------------- > metric increased to manipulate the path (forcing the traffic to take the lower path)

        authentication {

           md5 60 key /* SECRET-DATA */; ## SECRET-DATA

       }

   }

   interface xe-0/3/0 {

       interface-type p2p;

       authentication {

           md5 60 key /* SECRET-DATA */; ## SECRET-DATA

       }

 

Post the above configuration change we can verify that the traffic is taking the lower path now (MX1 ---> MX3 ---> MX2)

 

    

MX1> traceroute 172.31.31.5

traceroute to 172.31.31.5 (172.31.31.5), 30 hops max, 40 byte packets

1 172.31.195.95 (172.31.195.95) 1.823 ms 1.497 ms 1.228 ms --------------> Traffic taking the lower path correctly 

 2 172.31.31.5 (172.31.31.5) 1.924 ms 1.873 ms 1.782 ms ------------------> MX480 (destination)

 

MX1> show route 172.31.31.5

 

inet.0: 151 destinations, 161 routes (151 active, 0 holddown, 0 hidden)

+ = Active Route, - = Last Active, * = Both

 

172.31.31.5/32    *[OSPF/10] 00:25:47, metric 161 ---------------------------- > lower metric / cost as compared to upper path

                   > to 172.31.195.95 via xe-0/3/0 ------------> taking lower path because we have applied 10000 metric on upper path(ge-0/1/1)

 

Now we achieve our goal by manipulating the traffic from upper path to lower path .

 

For referance bandwidth and metric please follow below document .

 

Referance Bandwidth :: https://www.juniper.net/documentation/us/en/software/junos/ospf/topics/ref/statement/reference-bandwidth-edit-protocols-ospf.html

Metric :: https://www.juniper.net/documentation/en_US/junos/topics/reference/configuration-statement/metric-edit-protocols-ospf.html

 

 

Modification History

2023-12-19 : Article Created