Related Documentation
- ACX, J, M, MX, QFX, SRX, T Series
- OSPF Overview
- ACX, J, M, MX, PTX, QFX, SRX, T Series
- Example: Controlling the Cost of Individual OSPF Network Segments
- Example: Controlling OSPF Route Preferences
- J, M, MX, QFX, SRX, T Series
- Example: Configuring ECMP Flow-Based Forwarding
- Additional Information
- Junos OS Routing Protocols Configuration Guide
Understanding OSPF Traffic Control
Once a topology is shared across the network, OSPF uses the topology to route packets between network nodes. Each path between neighbors is assigned a cost based on the throughput, round-trip time, and reliability of the link. The sum of the costs across a particular path between hosts determines the overall cost of the path. Packets are then routed along the shortest path using the shortest-path-first (SPF) algorithm. Routes with lower total path metrics are preferred over those with higher path metrics.
You can use the following methods to control OSPF traffic:
- Control the cost of individual OSPF network segments
- Dynamically adjust OSPF interface metrics based on bandwidth
- Control OSPF route selection
Controlling the Cost of Individual OSPF Network Segments
OSPF uses the following formula to determine the cost of a route:
You can modify the reference-bandwidth value, which is used to calculate the default interface cost. The interface bandwidth value is not user-configurable and refers to the actual bandwidth of the physical interface.
By default, OSPF assigns a default cost metric of 1 to any link faster than 100 Mbps, and a default cost metric of 0 to the loopback interface (lo0). No bandwidth is associated with the loopback interface.
To control the flow of packets across the network, OSPF allows you to manually assign a cost (or metric) to a particular path segment. When you specify a metric for a specific OSPF interface, that value is used to determine the cost of routes advertised from that interface. For example, if all routers in the OSPF network use default metric values, and you increase the metric on one interface to 5, all paths through that interface have a calculated metric higher than the default and are not preferred.
![]() | Note: Any value you configure for the metric overrides the default behavior of using the reference-bandwidth value to calculate the route cost for that interface. |
When there are multiple equal-cost routes to the same destination in a routing table, an equal-cost multipath (ECMP) set is formed. If there is an ECMP set for the active route, the Junos OS software uses a hash algorithm to choose one of the next-hop addresses in the ECMP set to install in the forwarding table.
You can configure Junos OS so that multiple next-hop entries in an ECMP set are installed in the forwarding table. Define a load-balancing routing policy by including one or more policy-statement configuration statements at the [edit policy-options] hierarchy level, with the action load-balance per-packet. Then apply the routing policy to routes exported from the routing table to the forwarding table.
Dynamically Adjusting OSPF Interface Metrics Based on Bandwidth
You can specify a set of bandwidth threshold values and associated metric values for an OSPF interface or for a topology on an OSPF interface. When the bandwidth of an interface changes, the Junos OS automatically sets the interface metric to the value associated with the appropriate bandwidth threshold value. Junos OS uses the smallest configured bandwidth threshold value that is equal to or greater than the actual interface bandwidth to determine the metric value. If the interface bandwidth is greater than any of the configured bandwidth threshold values, the metric value configured for the interface is used instead of any of the bandwidth-based metric values configured. The ability to recalculate the metric for an interface when its bandwidth changes is especially useful for aggregate interfaces.
![]() | Note: You must also configure a metric for the interface when you enable bandwidth-based metrics. |
Controlling OSPF Route Preferences
You can control the flow of packets through the network using route preferences. Route preferences are used to select which route is installed in the forwarding table when several protocols calculate routes to the same destination. The route with the lowest preference value is selected.
By default, internal OSPF routes have a preference value of 10, and external OSPF routes have a preference value of 150. Although the default settings are appropriate for most environments, you might want to modify the default settings if all of the routing devices in your OSPF network use the default preference values, or if you are planning to migrate from OSPF to a different interior gateway protocol (IGP). If all of the devices use the default route preference values, you can change the route preferences to ensure that the path through a particular device is selected for the forwarding table any time multiple equal-cost paths to a destination exist. When migrating from OSPF to a different IGP, modifying the route preferences allows you to perform the migration in a controlled manner.
Related Documentation
- ACX, J, M, MX, QFX, SRX, T Series
- OSPF Overview
- ACX, J, M, MX, PTX, QFX, SRX, T Series
- Example: Controlling the Cost of Individual OSPF Network Segments
- Example: Controlling OSPF Route Preferences
- J, M, MX, QFX, SRX, T Series
- Example: Configuring ECMP Flow-Based Forwarding
- Additional Information
- Junos OS Routing Protocols Configuration Guide
Published: 2012-12-08
Related Documentation
- ACX, J, M, MX, QFX, SRX, T Series
- OSPF Overview
- ACX, J, M, MX, PTX, QFX, SRX, T Series
- Example: Controlling the Cost of Individual OSPF Network Segments
- Example: Controlling OSPF Route Preferences
- J, M, MX, QFX, SRX, T Series
- Example: Configuring ECMP Flow-Based Forwarding
- Additional Information
- Junos OS Routing Protocols Configuration Guide