Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a router organize its routing table?

How does a router organize its routing table in order to service the incomming packets fast? This is more of a programming question, and I am looking for:

  • algorithm and data structure to store the routing table entries for fast look up (hash? trie?)
  • optimization of the algorithm (e.g. using caches )
  • bonus: historical evolution of these algorithms (based on the fact that memory got cheaper etc.)

Note: the actual creation of the routing table (via routing protocols such as RIP, OSPF or manual entries) is irrelevant.

like image 672
Bogdan Gavril MSFT Avatar asked Nov 14 '22 23:11

Bogdan Gavril MSFT


1 Answers

You can have a trie and cache the lookups on a hash. See for example Linux's ip_route_input() (which tries to find the entry on a hash) and ip_route_input_slow() (which tries to find the entry in the Forwarding Information Base, a trie).

like image 171
ninjalj Avatar answered Dec 10 '22 05:12

ninjalj