Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are MAC addresses used in routing packets?

Tags:

tcp

ip

I recently found that packets are encapsulated within ethernet frames. Packets use IP addresses, frames use MAC addresses.

Why aren't IP addresses used in ethernet frames for routing? I understand that when trying to access a basic website, the computer goes to a DNS to find the IP address relevant to the user-entered domain name. How do computers find the correct MAC address?

Really, how are MAC addresses used in routing internet traffic?

Thanks

like image 778
BenAdamson Avatar asked May 29 '14 13:05

BenAdamson


People also ask

Are MAC addresses sent in packets?

A MAC address, also known as “hardware address” or “physical address”, is a binary number used to uniquely identify computer network adapters. Packets that are sent on the Ethernet are always coming from a MAC address and sent to a MAC address.

Why don't we use MAC addresses for routing?

If MAC were to be used for routing, your routing table would contain routes to each node on network because MAC addresses are different for every manufacturer. IP is like a standard platform for network devices from different manufacturers to communicate.

Why MAC addresses are not used to route packets over the Internet?

With MAC addresses, there is no hierarchy, and thus packet forwarding would not be possible. So, MAC addresses are not used for packet transfer.

What MAC addresses are used for and how it is obtained?

The MAC address (short for media access control address) is the worldwide unique hardware address of a single network adapter. The physical address is used to identify a device in computer networks. Since MAC addresses are assigned directly by the hardware manufacturer, they are also referred to as hardware addresses.


3 Answers

IP packets aren't always encapsulated in Ethernet frames. There are other physical media such as ISDN, etc. When packets are routed, IP addresses are used to determine the next hop and the physical address is used to physically identify the interface serving as the next hop. Only the former (determining next-hop) is usually called routing.

To answer your second part, MAC addresses are discovered through ARP (Address Resolution Protocol) in IPv4 & ND6 (Neighbor Discovery) in IPv6.

Update: The destination IP address in the IP header is the final destination. In the process of routing (at each hop), you get the next hop's IP address to (eventually) reach the final destination from the routing table (this could be a default gateway's IP address). To send the packet to the next hop, you need its MAC address. While hopping through intermediate links, the IP address in the IP header don't change - only the MAC addresses change.

like image 52
jman Avatar answered Oct 27 '22 06:10

jman


Bit late but still here is my answer :) ... To send data you need two address, the MAC address and the IP address. Basically the sending host will ARP for a MAC address, this occurs when the local host doesn't know the MAC address of the host it has an IP address for or it will ARP for the default gateway MAC address (if it doesn't already know it) if the IP address in on a different subnet/ network. Once it obtains a MAC address the IP packet is encapsulated in a L2 frame and sent across the media. If the IP packet is meant for a host on a different subnet/ network, it will be sent to the default gateway, this router will de-encapsulate the L2 frame (remove and discard it) check the IP address and will forward it. For the router to do this it needs a MAC address to send it over the media, It will look up the next hop in it's routing table, encapsulate the IP packet with the same source and destination IP address that was sent from the original host into a new L2 frame. This time the MAC address for the source address will be that of the forwarding interface of the router, and the receiving interface of the next hop will be the destination MAC address. This will continue from hop to hop until it reaches the final host, each time the MAC addresses will change, but the original IP address will remain the same.

like image 24
caspe_ghost Avatar answered Oct 27 '22 06:10

caspe_ghost


Here's the key point -- there can be more types of packets than INTERNET traffic. You could be using IPX, which is non-routable. How do clients identify each other? By the MAC address.

Routing != Addressing, which is really where the MAC comes into play.

In order to be routed, the OSI model adds a layer to allow for path discovery to the next gateway. This layer is responsible for routing, but knows nothing about the MAC address.

As a side note, at the hardware level, MAC addresses ARE used by switches, but not for routing. From How Stuff Works:

The switch gets the first packet of data from Node A. It reads the MAC address and saves it to the lookup table for Segment A. The switch now knows where to find Node A anytime a packet is addressed to it. This process is called learning.

In this way, a switch can make sure that traffic is only outputted to the correct port. This isn't accomplishing routing so much as reducing network congestion. Only broadcasts and traffic destined specifically for that MAC address should be sent out the port.

like image 41
Lynn Crumbling Avatar answered Oct 27 '22 07:10

Lynn Crumbling