Assuming a router has a built in switch which passes data packets to machines on the LAN based on the MAC address of all locally connected devices I want to know when and how (readying the packet for the internet using IP addresses) its sent to the internet. I'm making an assumption that all local options are exhausted first but I thought it might be more intelligent than that.
NOTE: DNS resolution occurs before any of the below in order to determine destination IP address.
If the request IP Address is on your local LAN, your router doesn't even get involved (aside from the switch part which is a series of ethernet ports).
Your local routing table (command line
route print on win, plain
route on lin) shows you the routing table that the OS uses to figure out what interface to send the packet out of depending on addressing. The IP stack will then do an arp request to find the MAC for the machine on the local network and establish direct communications through the switch.
If the IP address is foreign to your local network, then the OS routing table sends it to the gateway address, which is your router and your router uses a similar routing table to forward the packet to its gateway, ad nauseum till it gets to destination.
At a very simple level, you are right.
Take Google. When you request Google.com, your router first checks its own local tables, if there is no matching table (Host / IP) then it passes it to your modem. The modem then does essentially the same thing, and sends the request to its DNS server, which might be the ISPs or a third party, this is repeated until it reaches either a router that has the correct entry or reaches the iana root servers.