Routing
To determine the optimal path for data transfer, a router references its routing table, which contains a list of destination routes. When the destination address of an incoming packet matches an entry in the routing table, the router forwards the packet to the appropriate route. This process is carried out by multiple routers in a "relay-like" fashion, ensuring that packets reach hosts on different network segments.
If a packet's destination address does not match any routes in the routing table, the router discards the packet and sends a destination unreachable notification to the sender via an ICMP packet. If multiple matching routes exist, the router selects the most optimal one for forwarding the packet.
Destination routes are added to the routing table through two methods:
- Static Routing: Routes are manually configured by administrators.
- Dynamic Routing: The router automatically gathers routing information from neighboring routers and updates the table accordingly. Dynamic routing relies on routing protocols to exchange information between routers.
The internet itself is a collection of multiple Autonomous Systems (AS). Routing between ASes is managed using an Exterior Gateway Protocol (EGP), while routing within an AS is handled using an Interior Gateway Protocol (IGP). Currently, BGP-4 (Border Gateway Protocol version 4) is widely used as an EGP, and OSPF (Open Shortest Path First) is commonly used as an IGP.
