keepcalculator

06 Numbers and Powers

Link State Routing: What Routers Learn From Updates

Card No. 06·30296 · Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered
You enter
Finish time, Distance
You get
Average pace, Average speed
Rounding
2 dp

Link state routing is a network algorithm where every router learns the complete topology of the network—every router, every link, and the cost of each link—by exchanging “link state advertisements” (LSAs) with all other routers. From these updates, a router builds a full map of the network and then runs a shortest-path calculation (typically Dijkstra’s algorithm) to determine the best route to every destination. This article explains exactly what information is contained in those updates, how it is used, and why it matters for network performance.

Formula

The core of link state routing is not a single formula but an algorithm. The most common is Dijkstra’s shortest-path algorithm, which computes the least-cost path from the source router to all other routers. In mathematical terms, given a graph G = (V, E) where V is the set of routers and E is the set of links with associated costs c(u,v) for each link between routers u and v, Dijkstra’s algorithm finds the path with the minimum total cost from a source node s to every other node. The algorithm maintains a set of nodes whose shortest distance from s is known, and iteratively relaxes edges to find the next closest node.

Variables:

  • V – set of all routers (vertices) in the network
  • E – set of all links (edges) between routers
  • c(u,v) – cost of the link between router u and router v (e.g., in milliseconds delay, or a unitless metric)
  • d(v) – the current known shortest distance from source s to router v

The algorithm works as follows: initialize d(s)=0 and d(v)=� for all other v. Then repeatedly select the unvisited node with the smallest d(v), mark it as visited, and for each neighbor w of v, update d(w) = min(d(w), d(v) + c(v,w)). Continue until all nodes are visited.

Worked Example

Consider a small network of four routers: A, B, C, and D. The link costs are: A-B = 1, A-C = 4, B-C = 2, B-D = 5, C-D = 1. We want to find the shortest path from A to D.

  1. Start with A: d(A)=0, d(B)=�, d(C)=�, d(D)=�.
  2. Visit A. Update neighbors: d(B)=1, d(C)=4.
  3. Select B (smallest d). Update neighbors: d(C)=min(4, 1+2)=3, d(D)=min(�, 1+5)=6.
  4. Select C (d=3). Update neighbor D: d(D)=min(6, 3+1)=4.
  5. Select D (d=4). Done.

The shortest path from A to D has cost 4, via A-B-C-D. The path is A→B→C→D.

Background: Distance Vector vs. Link State

Before link state, routing protocols like RIP (Routing Information Protocol) used a distance vector approach. In distance vector, each router only knows the distance to each destination as reported by its neighbors, and it shares its entire routing table with those neighbors. This is often described as “routing by rumor” because a router’s knowledge is indirect. Link state was developed to overcome the slow convergence and routing loops that plagued distance vector. The key idea, first described in the 1970s, is that every router should have a complete and consistent view of the network. This is achieved by flooding link state advertisements to all routers, each of which then runs the same shortest-path algorithm independently.

What Exactly Is in a Link State Update?

A link state advertisement (LSA) is a small data packet that describes the state of a single router’s links. The typical contents are:

  • Router ID – a unique identifier for the router that originated the LSA (often an IP address).
  • Sequence number – a number that increases with each new LSA from the same router, used to distinguish newer from older information.
  • Age – how long the LSA has been in the network, used to expire stale entries.
  • Neighbor ID and link cost – for each directly connected neighbor, the router includes the neighbor’s ID and the cost of the link to that neighbor. Cost can be based on bandwidth, delay, or an administratively assigned metric.
  • Link type – whether the link is a point-to-point connection, a broadcast link (like Ethernet), or a stub network.

When a router receives an LSA, it stores it in its link state database. If the LSA is newer than what it already has, it forwards (floods) the LSA to all its other neighbors. This flooding ensures that every router eventually receives every LSA, building a synchronized database.

How the Router Uses the Learned Information

Once a router has received LSAs from all routers in the network (or at least enough to build a complete graph), it runs Dijkstra’s algorithm on the resulting graph. The output is a shortest-path tree rooted at the router itself. From this tree, the router constructs its forwarding table (also called routing table), which maps destination IP prefixes to the next-hop interface and next-hop router. This table is then used to forward packets. Because every router has the same link state database and runs the same algorithm, they all agree on the topology and produce consistent, loop-free routes.

One important nuance: the link state database contains the state of all links, but the router only cares about the shortest path to each destination. The algorithm computes the best path, but if multiple equal-cost paths exist, some protocols (like OSPF) can load-balance across them.

Common Problems and Misconceptions

One common misconception is that link state routing requires more bandwidth than distance vector because of flooding. In reality, LSAs are small and only sent when a change occurs, whereas distance vector protocols periodically send entire routing tables. However, flooding can be problematic in very large networks, which is why link state protocols are usually used in hierarchical designs (e.g., OSPF areas) to limit the scope of flooding.

Another issue is the risk of stale information. If a router fails, its LSAs age out, but until that happens, other routers may still route through the dead router. To mitigate this, link state protocols use hello messages to detect neighbor failures quickly and trigger new LSAs. Also, sequence number wrap-around and database overflow are handled by protocol-specific mechanisms.

Finally, a frequent question: “Does link state routing use hop count as cost?” Not necessarily. While RIP uses hop count, OSPF, a common link state protocol, uses a cost metric that is typically inversely proportional to bandwidth (e.g., 10^8 / bandwidth in bps). This allows it to prefer higher-bandwidth links even if they have more hops.

Comparison: OSPF, IS-IS, and Others

The two most widely used link state protocols are OSPF (Open Shortest Path First) and IS-IS (Intermediate System to Intermediate System). Both use the same fundamental principles, but differ in details:

  • OSPF – runs on top of IP, uses IP addresses for router IDs, and is commonly used in enterprise and service provider networks. It supports areas to reduce flooding scope.
  • IS-IS – runs directly over the data link layer, uses ISO addresses, and is often used in large ISP backbones. It is also link state and supports areas, but its addressing is different.

Both protocols are more scalable and converge faster than distance vector protocols. However, they are more complex to configure and require more CPU and memory resources on routers.

Choosing the Right Routing Protocol

When deciding between link state and distance vector, consider the network size and the need for fast convergence. For small networks (fewer than 15 routers), distance vector like RIP may be sufficient and simpler. For larger networks, link state protocols are the standard because they converge quickly and avoid routing loops. However, link state protocols require careful planning of areas (in OSPF) to prevent excessive flooding. Also, the administrative overhead of maintaining a link state database is higher, so routers need adequate memory and CPU.

In practice, most modern enterprise networks use OSPF or EIGRP (a hybrid protocol that is not pure link state but has some link state features). IS-IS is common in ISP backbones. The choice often depends on existing equipment, vendor support, and administrative familiarity.

Safety and Operational Considerations

From a network operations perspective, link state routing is generally safe because it is deterministic and loop-free. However, misconfiguration can cause problems. For example, if a router advertises an incorrect cost, it can attract traffic to a congested link. Also, if all routers in an area do not have the same link state database, routing loops can occur. To prevent this, protocols use checksums and sequence numbers to ensure database synchronization. Additionally, authentication can be used to prevent unauthorized routers from injecting false LSAs, which is a security concern in untrusted environments.

When implementing link state routing, always ensure that all routers in an area are running the same protocol version and have consistent area definitions. Use authentication if the network is exposed to untrusted parties. Monitor the link state database for anomalies, such as LSAs that never age out or sequence numbers that jump unexpectedly.

Frequently Asked Questions

What is the main difference between link state and distance vector?

Link state routers have a complete map of the network and compute the best path independently, while distance vector routers only know the distance to each destination as reported by neighbors and share their entire routing table. This makes link state converge faster and avoid loops, but it requires more memory and CPU.

Why does OSPF use cost instead of hop count?

Cost in OSPF is typically based on bandwidth, so a high-speed link has a lower cost than a slow one. This allows OSPF to choose the fastest path, not just the fewest hops. For example, a 1 Gbps link has a cost of 1 (10^8/10^9), while a 100 Mbps link has a cost of 10, so OSPF prefers the 1 Gbps link even if it adds a hop.

Can link state routing work over the internet?

The internet uses a hierarchical routing system with many autonomous systems. Link state protocols like OSPF are used within an autonomous system (interior gateway protocol), but between autonomous systems, path vector protocols like BGP are used. BGP does not use link state flooding because the internet is too large and no single router can hold the full topology.

What happens if a link fails in a link state network?

When a link fails, the routers on either side detect the failure (via hello messages or physical layer signals) and immediately flood a new LSA that omits the failed link. All routers update their link state database and recompute their shortest-path trees. This process typically takes a few seconds, which is much faster than distance vector convergence.

Is EIGRP a link state protocol?

EIGRP is often called a hybrid protocol. It uses distance vector logic but also maintains neighbor tables and sends only changes (like link state). However, it does not flood the full topology; it only sends the metric information to neighbors. So it is not a pure link state protocol, but it shares some characteristics.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0 | 100000
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →