Suppose a network stack receives an incoming message:
- Ethernet sees that EtherType is IPv4 so the payload is forwarded to the IPv4 handler
- IPv4 sees that the IP protocol number is ICMP so the message is passed to an ICMP handler
- ICMP type is Echo-Request so an Echo-Reply packet is created and send down to the IP handler
- IP sends it down to Ethernet
- However, at this point we need to know the destination MAC address.
How is the destination MAC determined?
- Is it found by inspecting the ethernet header of the original request?
- Or is it found using ARP? (Searched in ARP cache and ARP request sent if not in cache.)
I used ICMP request as just one example of an incoming request packet. The same question could be asked for handling i.e. a TCP-SYN packet.