user1657666
user1657666

Reputation: 451

Source MAC address on Ethernet layer 2

My question is pretty basic and my apologized for that. In TCP/IP network, if you take a look on layer 2 (Ethernet), we have some fields like Source and Destination MAC address. If you think in your browser, it is totally understandable that you can type a IP, and then the layer 3 (IP) will know the destination IP, then the frame is sent to layer 2.. However, how the layer two know the destination MAC address ? The source MAC address is stored in the network card and it is understandable but on what part of communication the destination MAC address will be known ?

Upvotes: 0

Views: 973

Answers (3)

Sumit Trehan
Sumit Trehan

Reputation: 4045

I will give you the basic of how the routing works. This will clarify your doubts:

1) Assuming that we have a layer 3 IP packet which we want to send to some destination which have a DIP = y.

2) The route lookup in the routing table would give you the next hop and the outgoing interface through which the packet needs to go out.

3) Now we have the next hop. Still we dont have the layer 2 encap information which is the DMAC. Assuming this is the first packet we are sending and we dont have the DMAC vs next hop IP mapping yet.

4) The system will generate a ARP Query which will be broadcasted with a DMAC FF:FF:FF:FF:FF:FF within the subnet. This query asks who has the the next hop IP. (Remember we got this from the route lookup).

5) The router having the next hop IP would respond back to the src router (Unicast reply), thus we would know what is the DMAC that needs to be put on layer 2 header.

6) The L3 packet will now be encapsulated in layer 2 header with the dmac as already known now.

7) Remeber the dip won't change in the layer 3 header. This way the packet would traverse hop by hop. At each hop the layer 2 DMAC would change and not the DIP.

Remember that the MAC address identifies each router uniquely on a hop by hop basis.

Hope that clarifies your doubt.

Upvotes: 2

paulus
paulus

Reputation: 655

MAC address is resolved using layer-2 devices such as network switches. ARP tables is the tool to resolve IP to MAC.

# arp -an

Upvotes: 0

David Schwartz
David Schwartz

Reputation: 182779

Your computer determines the destination MAC address of the next hop is typically determined on an Ethernet network by using ARP, an Ethernet broadcast protocol that allows you to ask which device is assigned a particular IP address.

Upvotes: 0

Related Questions