What are the differences between LAN and WAN, and how do routing protocols determine the best path for packet delivery?