LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 05-16-2012, 11:58 AM   #1
Bringo
Member
 
Registered: Mar 2010
Posts: 31

Rep: Reputation: 16
Question Why IP (at Layer 3) needs MAC address (a Layer 2 information) ?


Hi there,
I am studying OSI and TCP/IP model. And I have a problem:
MAC addressing (physical addressing) is used at Layer 2.
IP addressing (logical addressing is used at Layer 3.
IP and ARP protocols both work at Layer 3. Then why does IP needs destination's MAC address that is only a Layer 2 information? IP uses the service of ARP protocol to find Physical address given a host's Logical Address. But why IP needs MAC address ?

Best Regards
 
Old 05-16-2012, 12:14 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
You can't send a frame to an IP address on an ethernet/802.3 or 802.11 network. Or really any layer 2 network, come to think of it. You can, however, send a frame from one MAC address to another.

In other words, to send an IP packet from one node to another on a layer 2 network, the IP stack first needs to locate the corresponding MAC address for the destination IP. It uses ARP to do this. The IP packet is then encapsulated in a header appropriate for the layer 2 network in question (say, ethernet), and sent as one or more frames across that network.
 
Old 05-17-2012, 08:20 AM   #3
Bringo
Member
 
Registered: Mar 2010
Posts: 31

Original Poster
Rep: Reputation: 16
Thanks Ser Olmy but MAC address, as you said yourself, is used with frames at layer 2. In TCP/IP or OSI model, I studied that layer 2 is responsible for framing and physical addressing. So finding or mapping fromIP to MAC address should also done by layer 2 and not by layer 3. This is the main confusion that is still not clear.

Best Regards
 
Old 05-17-2012, 09:00 AM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
The concept is that each layer provides services to the layer above. For instance, layer 2 is given a chunk of data by a layer 3 protocol, and is told "send this to layer 2 address X".

In order to do the above, the layer 3 protocol has to include protocols that perform layer 3 to layer 2 mapping. For IPv4, that protocol is ARP. It may sound like layer 3 needs to have at least a rudimentary understanding of the underlying layer 2 protocol in order to support it, and that's precicely how it works.

The opposite is not true. You may not tell layer 2 "send this chunk of data to layer 3 address X", as layer 2 cannot resolve the mapping between layer 3 and layer 2. If that was the responsibility of layer 2, it would need knowledge of every possible layer 3 protocol in existence.
 
Old 05-17-2012, 12:47 PM   #5
Bringo
Member
 
Registered: Mar 2010
Posts: 31

Original Poster
Rep: Reputation: 16
Thumbs up

Hats Off to you sir. Thanks a lot Ser Olmy.
Now I got it clear. Thanks again.
 
Old 05-17-2012, 02:08 PM   #6
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
IP only needs MAC addresses when being transmitted over a L2 technology that uses MAC addresses. If you Run IP over ATM there is not a MAC address to be seen. Send IP over PPP and again no MAC address. These technologies use their own addressing schemes and in each case IP needs to map the next-hop IP address to a L2 address to be able to transmit the IP packet (in a L2 frame suitable for the L2 technology. There is normally a variant of ARP which does this.
 
Old 05-19-2012, 11:44 PM   #7
Bringo
Member
 
Registered: Mar 2010
Posts: 31

Original Poster
Rep: Reputation: 16
Thanks. Does that mean that if an IP packet needs to pass through an L2 technology then MAC is required and not required otherwise?

Best Regards.

Last edited by Bringo; 05-19-2012 at 11:48 PM.
 
Old 05-20-2012, 09:58 AM   #8
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
Quote:
Originally Posted by Bringo View Post
Thanks. Does that mean that if an IP packet needs to pass through an L2 technology then MAC is required and not required otherwise?
If a packet doesn't have to pass through layer 2, then there's no need to perform a layer 3 to layer 2 mapping.

For instance, consider an application communicating with a server process, both running on the same physical system but bound to different IP addresses. The packets will go from the application down to layer 3, get routed directly to the other IP address, and then go up the chain to layer 7 and the server process.

As long as the packet has to traverse some form of physical network technology, layer 2 will be involved. This may or may not involve MAC addresses (as baldy3105 pointed out), depending on the network technology in question. (Nitpick: The virtual interfaces created by PPP actually do have MAC addresses.)
 
Old 05-21-2012, 02:13 PM   #9
baldy3105
Member
 
Registered: Jan 2003
Location: Cambridgeshire, UK
Distribution: Mint (Desktop), Debian (Server)
Posts: 891

Rep: Reputation: 184Reputation: 184
Quote:
Originally Posted by Bringo View Post
Thanks. Does that mean that if an IP packet needs to pass through an L2 technology then MAC is required and not required otherwise?

Best Regards.
Nearly, remember only Ethernet, Token Ring, and Arcnet (off the top of my head) use MAC addresses. Frame Relay can be considered a L2 technology, as can ATM, or PPP or X25. None of these understands MAC addresses. So its more correct to say that "if an IP packet needs to pass through an L2 technology then a L2 address is required". If said L2 is Ethernet then that L2 address is indeed a MAC.


Code:
L3    IP   <----------------------------------------IP----------------------------------------------------------> IP
L2  [host]<--ethernet-->[router]<--frame relay-->[router]<---ATM-->[router]<---PPP--->[router]<---token-ring--->[host]
In this quick illustration you can see how IP maps to the appropriate L2 as it hops along its path from source to destination. Only the ends , ethernet and token ring, require MAC addresses.

Its important to note that the MACs used at the Token Ring end are NOT the same as were used over the originating Ethernet, those got left behind at the first router.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Data communication between L4 (TCP) layer to application layer Mr.J Linux - Kernel 3 04-12-2009 02:50 PM
Passing info from MAC to network layer (cross layer) tassadaque Programming 1 12-31-2008 02:22 PM
Passing the message/packet from layer to layer in OSI Or Unix. dina3e Linux - Networking 8 08-12-2008 04:15 PM
information dynamic MAC address assignment data link layer ( patent holder qualcomm ) aux General 1 05-07-2008 02:22 AM
simple way to make k9copy shrink dual layer to single layer DVD replica9000 Linux - Software 2 12-06-2007 02:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration