I have read that if we are using NAT, router knows where to send the incoming packets in the local network based on TCP/UDP port information. If this information can be used to uniquely identify each machine on a local network, then why is MAC address needed?
-
What you have read is incorrect. The router knows where to send incoming packets using MAC information, NOT the TCP/UDP port information. TCP/UDP port information is for identifying flows. It cannot identify machines. – qasdfdsaq Jul 31 '15 at 13:44
3 Answers
You need to be able to identify a connection at all levels of the network stack.
The mac address ONLY identifies the LAN adapter in the ethernet layer (Layer 2 Simplified OSI model).
The IP address (TCP and/or UDP) ONLY works in the IP layer (Layer 3).
Not all communication using IP goes via ethernet.
IP can be send over other Layer2 layers where there are no MAC-addresses.
And Ethernet can carry other Layer3 traffic, besides IP, which don't use IP-addresses at all.
In case of IP over ethernet you need BOTH identifiers, simply because both the layers involved require each their own ID system.
- 29,601
- 7
- 52
- 84
-
This explaination does not satisfy me. Why do we need layer 2 identification and addressing? Why not just identify and route at level 3. This is not covered in the answer. You do not need to identify at all levels of the stack - use OSI for example, and especially not need to identify device at all levels. – croraf Nov 01 '17 at 19:22
-
1@croraf I think because Separation of concerns, different layers are supposed to do different things, and can be replaced without affection other layers. – Lyubomir May 15 '23 at 21:12
-
MAC is required for a couple of reasons, the biggest of which is that IP addresses are not (necessarily) unique.
Before a computer has an IP address, it typically requests one on the network by using a service called DHCP. At this point, the computer sends a broadcast message to the entire network saying “Hey, I don't have an IP address. My unique identifier is <MAC>. Can a DHCP server assign me one so that I can communicate on the network?”
In addition to that, routers and switches use MAC address tables to figure out what devices lie on what ports. This is used to intelligently move packets to the right port. It’s easier to use MAC address than IP address because a network card can have more then one IP address assigned to it at once, so it’s more efficient to store the MAC instead.
There are other uses too. It’s often used as a unique identifier for licensing purposes, and as part of a random seed for entropy purposes.
A MAC Address is a physical signature that exists on every hardware that can connect to a network. It is also always unique. It's basically a low level unique id for your network device.
Now, you cannot communicate knowing only the port information because multiple devices could listen/send to the same port.
It it the base of communication in a network! Since MAC addresses are unique, there are often used to limit access in wireless network for example.
You can read this if you want to understand a bit more : http://www.howtogeek.com/169540/what-exactly-is-a-mac-address-used-for/