Link-state routing introduction
Link-state routing [LS] is a packet switching protocol for computer communications.
In LS every router constructs a map over which nodes they are directly connected to. Each router independently calculates the best path from it to all other possible nodes. A routing table is then built from the collection of best paths.
The large difference between LS and distance-vector routing is that distance-vector protocols shares its entire routing table while each node in LS only shares which neighbors it has. [WIKI]
In a LS network each router knows the entire network topology and independently calculates the best next hop to any other destination.
This combination of operations quickly gets each node a new version of the network.
When each node has a complete set of link-state advertisements (one per node in the network) all nodes create an individual version of the whole network.
The list of advertisements is iterated over and for each one new links are created (to the current advertisements sender to any of its neighbors not present in the map)
To avoid errors no link is trusted if only one advertisement reports it (each node shall have two reports as each end sends a report).
The calculation is done in several steps described below.
Each node independently use an algorithm to find the shortest path from itself to every other node, a modified version Dijkstra's algorithm is often used to build these tables. The paths are weighted by link costs which include bandwidth and additional variables.
Each node maintains two different data structures:
At the start both structures are empty and then starts with adding itself to the tree. Some variant of a greedy algorithm then repeatedly does the following:
The greedy algorithm continues until no candidates are left as all will be added to the tree.
For any given destination node, the best path for said destination is the first step (step on shortest path) from the root to the destination. To create the routing table one walks the tree and fills the routing table with each node - next hop - destination entry it finds. In the end each node holds the next hop for each node to any other node in the network.
In real world examples more optimized versions of link-state are used, some of the optimizations used are:
When a change in the network is detected a recomputation of the shortest path tree and then also the table is needed. To optimize this process a solution has been found to only recalculate the changed portion of the tree and the routing table is also built as the tree is built to improve efficiency.
Some systems only send one advertisement per edge where it is possible, a example is a node-(another node with only past node as neighbor). This slightly decreases the safety of the system but increases performance.