|Subject:||[lwip-users] ARP lookups and UDP servers|
|Date:||Thu, 23 Oct 2014 13:42:27 -0400|
|User-agent:||Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:22.214.171.124) Gecko/20091204 Thunderbird/3.0|
Hi all,I have an embedded application that is a NTP server (UDP based). Due to the timing sensitivity of the application I want to avoid doing an ARP lookup just to reply to a single query packet. I see there is an ETHARP_TRUST_IP_MAC option that will automatically save the MAC from incoming packets into the ARP table, however there are two things that keep it from helping much. Firstly it calls etharp_update_arp_entry with the ETHARP_FLAG_FIND_ONLY option which gives up if there isn't already a free entry. This means that if there are more clients than ARP table slots, the table fills up and it starts making ARP queries again. Secondly, even if I change that to ETHARP_FLAG_TRY_HARD which will displace the oldest entry, it only works for on-subnet clients. Distant clients will force a lookup of the gateway's IP each time. Of course a bigger ARP table will help, but I can only increase it so much and I want to be able to support subnets with arbitrarily many hosts on them, so relying on that is not practical.
Ideally I think I would simply like to take the original packet and flip it around so both layer 2 and layer 3 source and destination addresses are exchanged, and no lookup is needed. Is there any existing facility that can help with this? I can figure out how to manually munge the IP headers and send the reply as a raw layer 2 frame but it would be great if a function already existed to do this. Maybe a udp_reply() function that takes a pbuf as input.
Also this optimization needs to eventually happen for IPv6 as well. I haven't looked yet to see whether IPv6 has the same issue but I assume it has to, but in ND rather than ARP of course.
Misc details: using NO_SYS=1 (so raw API only), 32KB RAM total, hardware checksumming is on.
|[Prev in Thread]||Current Thread||[Next in Thread]|