2

I'm writing a TCP/IP stack on an extremely resource limited embedded device. I would like to know if it is safe to use the source mac address of an ethernet frame to reply to an IPV4 packet.

The normal procedure when you want to reply to the source ip address of an IPV4 packet is to check your ARP cache, and if it's not already populated, do an ARP request to get the MAC address.

I would instead like to use the source mac address of the ethernet frame that the IPV4 packet came in on. (as I will always already have this and thus be able to respond to a packet without waiting for more incoming packets)

Will this strategy ever cause problems?

For example, in a local network where the device is only connected to one router/switch, the reply mac address has to be the one the request came from, so there should never be an issue. However, I've heard packets don't always follow the same route upon reply. Would an end device ever have to reply to a different mac address than a request came from?

I believe routers are required by the standards to emit an ARP request themselves before declaring a destination unreachable, so my thought was that even in a set-up where the end device was connected to two routers (one for incoming packets and one for outgoing) that even if my device replied to the incoming packet router, that it would just forward it to the outgoing router, correcting for my device's deficiency.

Of course, I realize relying on other devices' conformance to the standards to allow my device to not follow the standards is rather hypocritical...

Rick
  • 1,240
  • 14
  • 21
  • So, your device is only going to reply to incoming frames and never originate frames to a device that has not first contacted it? – Ron Maupin May 18 '17 at 20:48
  • @RonMaupin That correct. (with the slight exception of broadcasts to do DHCP and SSDP, but those won't need address resolution.) – Rick May 19 '17 at 02:19

1 Answers1

0

Short answer:

will it work? Yes, Is it safe? No.

Long answer

Problems that you may run into:

  • You are required to reply to ARP requests, even if you are the one originating the TCP connection, the TCP server will still make an ARP request to populate its own cache.

  • Your device will behave strangely when network is not configured properly (example: duplicate IP addresses)

  • Your device won't handle network changes well (for example an IP address was moved from one device to another)

Ayoub Kaanich
  • 992
  • 8
  • 20
  • As it wouldn't use a cache, I think it would actually handle the duplicate IPs and network changes better than a standards compliant device. And yes, every device needs to be respond to ARP requests that wasn't in question. – Rick Oct 13 '20 at 15:15