1

Sorry in advance for such a noob set of questions.

I understand that when set with the task of sending a packet to its destination, a computer first checks that the IP address of the destination is on the same network by its mask and IP address. I know that when a computer needs the MAC address, it broadcasts an ARP requests to all nodes on that broadcast domain.

How does this work for external networks? For example, let's say that I want to navigate to https://google.com, and my browser goes through with all the DNS queries and fetches the IP Address. I am guessing because of Ethernet, my computer sends an IP packet with the source as myself and the destination as Google's IP address, then wraps that in a layer 2 frame with the default gateway as the destination MAC. Does the router/default gateway strip the layer 2 frame and send that up to its default gateway over PPPoA (this is my situation), or does it then replace that frame with its own source MAC and the destination MAC as its default gateway?

Having trouble finding answers and would really love some help.

0

Your understanding is pretty close.

When a router receives a frame, it does strip off the frame to get to the packet. The router then looks in its routing table to see if it has a route to the destination address. If not, it drops the packet. If so (and a default route works as a last resort), the router switches the packet to its interface of the next hop.

That hop may, or may not, have a protocol which uses MAC addresses (not all do, PPP doesn't use MAC addresses). In any case, the router builds a new frame, encapsulating the packet for the next hop, and it forwards the new frame out the next hop interface.

  • Okay, so Ethernet inherently needs a source and destination MAC address as well as the IP addresses but there are protocols that do not use MAC addresses but only IP Addresses depending on that hop? Does the router/default gateway decide when to do that automatically? – user4191887 Aug 12 '16 at 1:19
  • networkengineering.stackexchange.com/questions/26163/… I notice here that you mention, "strip off a layer-2 frame before forwarding the layer-3 packet encapsulated in the layer-2 frame." Is this a different situation? – user4191887 Aug 12 '16 at 1:23
  • Ethernet doesn't need IP addresses. It is happy to transport any number of layer-3 protocols (IPv4, IPX, IPv6, AppleTalk, CLNP, etc.). IPv4 also doesn't care which layer-2 protocol carries it (ethernet, token ring, FDDI, Wi-Fi, PPP HDLC, frame relay, ATM, etc.). The network protocol layers are separate, and you should not confuse them. A router knows what sort of interfaces it has, and it must have software built into the routing software to handle those interfaces. Apparently, your router uses PPP over ATM for the WAN. – Ron Maupin Aug 12 '16 at 1:23
  • Application data are encapsulated in layer-4 segments, which are encapsulated in layer-3 packets, which are encapsulated in layer-2 frames, which are serialized and sent out over the wire. You can have multiple combinations of different protocols in the various layers. Routers are only concerned with layer-3 packets, and they strip off incoming frames to get to the encapsulated packets, and build outgoing frames to encapsulate the outgoing packets. – Ron Maupin Aug 12 '16 at 1:28
  • I understand, so even though in this answer networkengineering.stackexchange.com/questions/26163/… you say the router re-encapsulates the layer-3 packets into layer-2 frames, you say it is dependent on the protocols like PPP and Ethernet? – user4191887 Aug 12 '16 at 1:31
2

There are a number of steps

  • The router performs any nessacery L2 filtering to prevent inadvertant packet duplication. For Ethernet this means comparing the packet's destination MAC address with the MAC address of the incoming Ethernet port on the router.
  • The router strips off the L2 framing and passes the packet into IP routing.
  • The router looks up the destination IP address in it's routing table. Based on this table it determines what interface it should send the packet out of and what the "next hop IP address" is.
  • If the outgoing interface is Ethernet or similar the router uses the ARP table for the interface to resolve the next hop IP address to a MAC address. If there is no entry in the ARP table then the packet will be queued while one is created.
  • The packet is wrapped up in a new L2 frame and sent to the next hop.

The default gateway is just an entry in the routing table that matches as a last resort if no more explicit route is known. Some routers don't have a default gateway set and instead rely on knowing the entire internet routing table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.