EtherCard Arduino library (oldie but goldie) ARP question

Added by ok1uhu 10 months ago

Hi phorum,

first of all, thanks to the author(s) for the EtherCard ENC28J60 library. Works pretty well and I am giving you a big respect for the work done. So far I used it for a TCP/IP without any problems.

My question:

When I try to use this library for a plain UDP communication, I have to initialize the IP stack with typical paramaters.

For the plain UDP/IP, the

port numbers
(eventually gw)

should be sufficient. Then, I issue an UDP packet send command with buffer and destination address. So far, I use the UDP comms this way in my other projects, based on embedded linux, without any problem.

But, in a case of EtherCard for Arduino, when there is no DNS server defined (why should I have it, when I issue the numeric IPs?), the output packet is malformed, see the picture attached. At the level of IP encapsulation, there's no destinaton MAC (zeroed). Thus, I think, no ARP negotiation has been performed. But, what the DNS server has with ARP in common?

When I configure the working DNS server, ARP is OK and the packets do have a correct destination MAC. But, at the technological networks, frequently no DNS and even no GW is present. And the linux IP stack discards the UDPs with wrong destination MAC - which is correct.

Is there any workaround or fix? Once more, I need a "plain, as plain it can be" UDP unicast communication between Arduino "slaves" and a linux "master". No external routing (no GW), no DNS needed, everything in one L2 network. Is there any possibility to perform just plain single ARP resolv for the destination IP?

Thank you for your help (before I start to reverse engineer the library :-) ).

Have a nice day


// ethernet interface ip address
static byte myip[] = { 192,168,168,33 };

// gateway ip address
static byte gwip[] = { 192,168,168,1 };

// DNS ip address
static byte dnsip[] = { 192,168,168,1 };

// network mask
static byte mask[] = { 255,255,255,0 };

// ethernet mac address
static byte mymac[] = { 0xDE,0xAD,0xBE,0xEF,0x00,0x01 };

// destination IP
static byte destip[]= {192,168,168,4};

// UDP port numbers
static int myport=1002,destport=1001;

ether.begin(sizeof Ethernet::buffer, mymac,10); // the pin number 10 is correct at my wiring

// ether.staticSetup(myip); // does send the malformed packets later, how, see the picture attached

ether.staticSetup(myip,gwip,dnsip,mask); // this way it works, but why do I need to have DNS for the ARP resolve?


ether.sendUdp (msg, msglen, myport, destip, destport);

Replies (2)

RE: EtherCard Arduino library (oldie but goldie) ARP question - Added by jcw 10 months ago

It's been a very long time since I used the EtherCard code.
I didn't write it, just adapted and extended it at the time.
DNS, DHCP, etc were all "hacked into" what there was, no meaningful design effort on my part.

You may get more responses on GitHub, some people do tend to track and reply to issues there.

RE: EtherCard Arduino library (oldie but goldie) ARP question - Added by ok1uhu 10 months ago

Well, thank you anyway, I understand the situation. Yes, I know there are some alternative libs for ENC28J60, but I am familiar with this one and wish to remain with it. Maybe some other user of this library can help?

I have to re-adapt those communication modules of my design (picture) from TCP/IP to UDP, thus, the hardware is given (about 50 modules).

I'll wait a while more and then ... start the hacking attempt to the library code. Not looking forward to that work :-)