How does a router choose the route to send a packet?

in CCNA & CCENT
The routes ip addresses in question are:
172.16.1.1
172.16.1.2
172.16.2.2
172.16.4.3
show ip route rip:
R 172.16.1.1/32 .....
R 172.16.1.0/24 .....
R 172.16.0.0/22 .....
R 172.16.0.0/16 .....
The book says that the router would choose the route with the longest prefix, but that 172.16.4.3 would go out 172.16.0.0/16.
Wouldn't 172.16.0.0/22 have the longer prefix?
172.16.1.1
172.16.1.2
172.16.2.2
172.16.4.3
show ip route rip:
R 172.16.1.1/32 .....
R 172.16.1.0/24 .....
R 172.16.0.0/22 .....
R 172.16.0.0/16 .....
The book says that the router would choose the route with the longest prefix, but that 172.16.4.3 would go out 172.16.0.0/16.
Wouldn't 172.16.0.0/22 have the longer prefix?
Comments
-
Forsaken_GA Member Posts: 4,024 ■■■■■■■■■■
Greenmet29 wrote: »The routes ip addresses in question are:
172.16.1.1
172.16.1.2
172.16.2.2
172.16.4.3
show ip route rip:
R 172.16.1.1/32 .....
R 172.16.1.0/24 .....
R 172.16.0.0/22 .....
R 172.16.0.0/16 .....
The book says that the router would choose the route with the longest prefix, but that 172.16.4.3 would go out 172.16.0.0/16.
Wouldn't 172.16.0.0/22 have the longer prefix?
No. 172.16.0.0/22 is equivalent to 172.16.0.0 to 172.16.3.255, so 4.3 doesn't fit.
You've gotta remember that 0 is a discrete, valid number, it does not indicate null