What is OSPF (Open Shortest Path First)?

A link-state routing protocol used inside an organization. Each router floods the state of its own links so that all routers share the network topology, and computes the path with the lowest total cost using Dijkstra's algorithm. Costs are generally derived from link bandwidth, and splitting the network into several areas lets it scale to large networks.

Japanese name: OSPF

OSPF (Open Shortest Path First) appears in 6 practice questions across 2 topics, including Network Design and Operations, Computer Networking Basics.

Field: Network Design and Operations

How link-state routing works

OSPF routers form adjacencies with their neighbors using Hello packets and flood information describing the state of their links (LSAs) to every router in the same area. From the collected LSAs, each router builds the same map of the topology (the link-state database), computes a shortest-path tree rooted at itself with Dijkstra's algorithm, and installs the results in its routing table. When a link fails, the change is flooded at once and every router recalculates, so OSPF settles on new routes faster than the distance-vector protocol RIP.

Cost and reference bandwidth

The cost of each interface is generally set as "reference bandwidth ÷ interface bandwidth," and the cost of a route is the sum of the costs of the interfaces it passes through. If the reference bandwidth is left at 100 Mbps, long the default on much equipment, every link of 100 Mbps or faster costs 1, and 1 Gbps cannot be told apart from 10 Gbps. Networks with fast links therefore set the reference bandwidth to a larger value, the same on every router. Costs can also be set by hand on each interface.

Hierarchy with areas

As the number of routers grows, so do the volume of LSAs and the burden of Dijkstra calculations. OSPF divides the network into several areas, sharing detailed link states only within an area and passing only route information between areas. Every area must connect to the central backbone area (area 0), and routers at area borders (ABRs) can also pass on routes in summarized form (route summarization).

Try it: questions about OSPF (Open Shortest Path First)

A router has learned routes to the same destination, 192.168.50.0/24, from both OSPF and RIP. On this router, the administrative distance, which expresses the preference for each route source (lower is preferred), is 110 for OSPF and 120 for RIP. Which route goes into the routing table?

  1. ABoth routes are installed and used alternately for each packet
  2. BOnly the RIP route is installed
  3. COnly the OSPF route is installed
Show answer and explanation

Answer: C. Only the OSPF route is installed

Routing protocols express route quality (the metric) in different ways, such as OSPF cost and RIP hop count, so their metrics cannot be compared directly. When routes to the same destination with the same prefix length are learned from several sources, the router therefore installs the one with the lower administrative distance, a measure of how much each source is trusted. Here OSPF's 110 is lower than RIP's 120, so the OSPF route goes into the routing table. Directly connected networks commonly get 0 and static routes 1, giving lower values to what people configure, but the name and default values differ between equipment vendors.

A router's routing table holds three routes: a static route 10.0.0.0/8 (next hop router A, administrative distance 1), 10.1.0.0/16 learned by OSPF (router B, 110) and 10.1.1.0/24 learned by RIP (router C, 120). To which router is a packet for 10.1.1.5 sent?

  1. ARouter A (the static route)
  2. BRouter B (the OSPF route)
  3. CRouter C (the RIP route)
Show answer and explanation

Answer: C. Router C (the RIP route)

The three routes have different prefix lengths, so each is installed in the routing table as a separate route. When forwarding a packet, the router chooses the matching route with the longest prefix and does not compare administrative distances. 10.1.1.5 matches all three, but the longest, the /24 RIP route, is chosen and the packet goes to router C. Administrative distance is used only to decide which of several routes to the same destination with the same prefix length goes into the routing table.

FAQ

What is the difference between OSPF and RIP?

RIP is a distance-vector protocol that chooses routes only by the number of routers passed (the hop count, at most 15), so it ignores link speed. OSPF is a link-state protocol that chooses routes by total cost derived from bandwidth, reacts to changes faster, and can scale to large networks by dividing them into areas.

When is OSPF used and when BGP?

OSPF is a protocol (an IGP) for quickly finding the shortest paths inside one organization (AS). BGP is a protocol for exchanging routes between organizations based on route attributes and policies. Large organizations commonly combine the two, using OSPF inside and BGP toward their ISPs.

OSPF (Open Shortest Path First) in the explanations

Questions that mention OSPF (Open Shortest Path First) (6)

  1. A router has learned routes to the same destination, 192.168.50.0/24, from both OSPF and RIP. On this router, the administrative distance, which expresses the preference for each route source (lower is preferred), is 110 for OSPF and 120 for RIP. Which route goes into the routing table?
  2. A router's routing table holds three routes: a static route 10.0.0.0/8 (next hop router A, administrative distance 1), 10.1.0.0/16 learned by OSPF (router B, 110) and 10.1.1.0/24 learned by RIP (router C, 120). To which router is a packet for 10.1.1.5 sent?
  3. In OSPF, router R1 has three paths to a network beyond R4. Path A uses a 10 Gbps link R1–R5 and a 1 Gbps link R5–R4; path B is a direct 100 Mbps link R1–R4; and path C uses 1 Gbps links R1–R2, R2–R3 and R3–R4. The cost of each link is "reference bandwidth 10 Gbps ÷ link bandwidth", and the cost beyond R4 is the same for all paths. Which path does R1 choose?
  4. Which correctly describes dynamic routing?
  5. Which statement correctly describes a link-state routing protocol?
  6. On the internet, which protocol exchanges routing information between the networks run by organizations such as ISPs (ASes, autonomous systems) and chooses routes based on attributes such as the sequence of ASes a route has passed through (AS_PATH) and on each organization's policy?

Books on Network Design and Operations Ad

As an Amazon Associate I earn from qualifying purchases.

Comparisons that include this term

Semiconductor, Electronics and Computing Calculators

Related terms

Router IP routing Administrative distance BGP (Border Gateway Protocol) Packet Dijkstra's algorithm ACL (access control list) Broadcast domain Link aggregation Longest prefix match

Back to the glossary