Routing
The process of routing is getting a packet the network associated to its IP address. To do this all routers store a routing table which maps the tuple of an IP address and a network mask to either a interface or a IP address.
There are two types of routing Intradomain routing, how routers exchange information within the same Autonomous system (AS), and interdomain routing how routes get shared between Autonomous system (AS).
There are 3 ways a router can populate its routing table
- Directly connected: This is for networks directly connected to the router. It adds an entry for that networks and the interface of the router it is connected to.
- Static route: This is a route that has been manually configured on a router. Instead of an interface it will have an IP address to forward that packet on to.
- Dynamic routing: This is the same in structure to the static rout but instead of being manually added this gets populated by routers sharing known addresses with one another.
This table might grow very large but routers use route summarization to keep the tables shorter.
Once a router has been configured when it receives a packet it looks at its layer 3 header containing the destination IP address. It compares that again the known address, using the network mask and finds the most precise match (matching on the longest network mask) then forwards it to that interface or IP address.