For one of my courses I am writing a Java Applet that simulates network activity. I have a host machine which keeps an ARP table of MAC to IP address, and then I have the switch keeps track of what MAC is attached to what physical port. (interface)
My question is, how should I simulate the router. From my understanding, the host will perform a computation on the outgoing IP to determine if that IP is on the network, assuming it is not, the host sends the packet to the default gateway (by looking up the MAC address of the IP address of the default gateway), in this case the router. Now the router will have at least two interfaces on two different networks.
So, my theory is that the router will look at the destination IP address and pipe the packet down the right interface that has that network on it. But then, do routers have "default gateways" where if none of those interfaces are on the destination network, can the router just pass it off to some other router?