The interactions and differences between Layer 2 and Layer 3 are very important to understand how data flows between two computers. For example, if we already have a unique L2 addressing scheme on each NIC (like a MAC address), why us need another addressing scheme on L3 (like an IP address)? Or vice versa?
The answer is that the two addressing schemes have different functions :
- Layer 2 uses MAC addresses and is responsible for delivery hop-to-hop packets.
- Layer 3 uses IP addresses and is responsible for delivery package from end to end .
When the computer has data to send, it encapsulates it in an IP header will include information such as the Source and Destination IP addresses of the two "ends" communication.
The IP header and data are then further encapsulated in a MAC address header, which will include information such as the Source and Destination MAC address of the "hop" currently on the path to the final destination.
Here is an illustration to drive this point home :
Notice between each Router the MAC address header is stripped and regenerated for get it to the next hop. The IP header generated by the first computer is only stripped by the last computer, then the IP header takes care of sending the "end to edge", and each of the four different MAC headers involved in the animation it takes care of "hop to hop" delivery.