Bookmarks

OSPF — Open Shortest Path First

A dynamic routing protocol for use inside a single autonomous system: routers exchange link-state information and build a map of the network themselves.

Also: OSPFv2, open shortest path first

checked 9 Nov

All terms

OSPF works inside one organisation (a campus, a data centre network or an operator’s network) and lays routes itself, using a map of the network that each router assembles from its neighbours’ messages. When a subnet is added or a link fails, the change spreads across the network in seconds and traffic is rerouted without any help from an administrator.

How it works

  • Adjacency: routers on a shared segment find each other with Hello packets (on broadcast networks, sent to the multicast address 224.0.0.5) and agree on the connection parameters.
  • Topology database: each router sends its neighbours advertisements about its links (LSAs), and a reliable flooding mechanism synchronises the databases so that all routers in an area see the same topology.
  • Calculation: from the database, each router runs Dijkstra’s algorithm (SPF), places itself at the root of the shortest-path tree and obtains a routing table.
  • Convergence: when a link changes, a new LSA is flooded across the area and the routers recalculate SPF; the protocol quickly finds new paths without loops.

Areas and router roles

To keep the topology database and recalculations from growing without limit, the network is divided into areas. An area’s topology is hidden from the others: only routes go out, so the database and the control traffic shrink considerably. All areas connect to the backbone area, whose identifier is 0.0.0.0; between areas, routes are exchanged essentially with distance-vector logic. If an area does not border the backbone directly, it is attached by a virtual link through a neighbouring area.

Router typeRole
internalall interfaces are in one area
backbonehas an interface in area 0.0.0.0
area border router (ABR)connects an area to the backbone: keeps a separate database for each area and summarises data before passing it on
autonomous system boundary router (ASBR)injects routes from outside the autonomous system, from BGP or static

Cost and an example

Each link is assigned a cost, and the cost of a route is the sum of the costs of the links along the path. Vendors calculate it differently: on Cisco, an interface’s cost is inversely proportional to its bandwidth, 100,000,000 divided by the speed in bit/s. If several paths of equal cost lead to a network, OSPF installs them all in the table and spreads traffic between them (equal-cost multipath, ECMP).

textCisco IOS: OSPF in area 0 for the local network 10.1.0.0/16 and the link to R2
R1(config)# router ospf 1R1(config-router)# network 10.1.0.0 0.0.255.255 area 0R1(config-router)# network 10.0.12.0 0.0.0.255 area 0
textThe neighbour is in the FULL state, and the route to the network behind R2 is marked with the letter O
R1# show ip ospf neighbor 2.2.2.2   1   FULL/DR   00:00:33   10.0.12.2   GigabitEthernet0/0 R1# show ip route ospfO  10.2.0.0/16 [110/1] via 10.0.12.2, 00:05:01, GigabitEthernet0/0

The protocol was developed by an IETF working group: the first specification appeared in 1989 (RFC 1131), the current version 2 is described in RFC 2328 and has Internet Standard status, and IPv6 has its own version, OSPFv3.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • BGPBorder Gateway Protocol

    BGP exchanges routes between autonomous systems, that is, between providers and large networks; OSPF works inside a single AS.

  • NATnetwork address translation

    NAT rewrites addresses at the network edge and builds no routes; OSPF distributes routes inside the network.

In depth in the references

where the topic is covered in detail