A router compares a packet destination against its route table, picks the longest matching prefix and forwards to that route next hop.
100%
Legend
Current step
Packet arrives at R1
The router reads the destination address and looks it up in the route table.
Source address
192.0.2.10
Destination address
203.0.113.130
Longest-prefix match always wins: a /25 beats a /24 for the same destination regardless of metric. The default route 0.0.0.0/0 is used only when nothing more specific matches.
Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.