sde1000 / NanodeUIP

Port of uIP library to Nanode
http://wiki.hackspace.org.uk/wiki/Project:Nanode/UIP
38 stars 22 forks source link

README: DHCP packet size issues #4

Open maniacbug opened 12 years ago

maniacbug commented 12 years ago

You might want to point out in the readme that DHCP can cause issues for a 450-byte packet size. The default DHCP Offer packet is 590 bytes. Some routers have a configuration to reduce it down to the ~300 necessary bytes, but others do not. (See http://www.linksysinfo.org/index.php?threads/dhcp-reduce-packet-size.20699/ for one example).

In fact, RFC2131 says, "A DHCP client must be prepared to receive DHCP messages with an 'options' field of at least length 312 octets. This requirement implies that a DHCP client must be prepared to receive a message of up to 576 octets, the minimum IP datagram size an IP host must be prepared to accept [3]. " No help to those of us on MCU's!

sde1000 commented 12 years ago

It might be better to up the default buffer size and make a note in the README anyway, on the grounds that if people are running out of memory and need to reduce it then it's better that they do so knowing that they should test against their DHCP server first...

maniacbug commented 12 years ago

Yeah... This leads to the bigger problem that with memory so scarce on 328, packet size is so application dependent. Arduino is badly missing a way to configure libraries in a sketch. If you don't ever use dhcp, you dont need the large size. I have Internet radio streaming going with 300 byte packets.

I am thinking an even better approach is to rewrite the truncated packed in the enc driver. By putting a new size and CRC on the packet, the upper layers can be none the wiser.

sde1000 commented 12 years ago

Yes, the way that Arduino goes for runtime configuration at the expense of RAM is really annoying. What's wrong with a per-sketch config file full of #defines?

That might be an interesting hack. Is the bit of the packet that doesn't make it through all padding?

maniacbug commented 12 years ago

Yes, the way that Arduino goes for runtime configuration at the expense of RAM is really annoying. What's wrong with a per-sketch config file full of #defines?

Indeed. Well I am having a conversation with David Mellis about this right now, trying to get it in. But it doesn't look likely. His view is that it's confusing for users. And by 'users', he means all the people who post on the forum asking, "How do I blink a light??"

What are your thoughts on moving to one-time dynamic allocation of buffers? That is, the values in uip-conf.f would be passed into the NanodeUIP constructor, and it allocates the required buffers, never to deallocate them.

That might be an interesting hack. Is the bit of the packet that doesn't make it through all padding?

Yup. And it's the only way this would work, because to validate the packet was not corrupted, you'd need to remake the checksum, and that requires knowing what the truncated values were.


From: Stephen Early reply@reply.github.com To: maniacbug maniacbug@ymail.com Sent: Wednesday, January 4, 2012 4:40 AM Subject: Re: [NanodeUIP] README: DHCP packet size issues (#4)

Yes, the way that Arduino goes for runtime configuration at the expense of RAM is really annoying. What's wrong with a per-sketch config file full of #defines?

That might be an interesting hack. Is the bit of the packet that doesn't make it through all padding?


Reply to this email directly or view it on GitHub: https://github.com/sde1000/NanodeUIP/issues/4#issuecomment-3354005

sde1000 commented 12 years ago

We could try a one-time dynamic allocation of buffers. The problems I foresee are:

So it's probably worth a shot, but I'm not sure I like it!

maniacbug commented 12 years ago

It's not ideal... Other alternatives:

As to the connection setup. One possibility is to keep a shared single size pool, like it is now, just make it dynamically allocated at runtime, so connections wouldn't have to pass in anything each time. Alternately, I would want to explore using dynamic allocation for ONLY the connection appdata. I hypothesize that in this case fragmentation is less likely due to its controlled nature. Needs experimentation. Alternately, connection app data could come from a fixed size allocator pool as implemented in memb.c. This would at least allow freeing of the DHCP state.

nolith commented 11 years ago

I would like to inform you that I had this problem in my home LAN. (I've got a fritzbox 7390 router)

I had to set #define UIP_CONF_BUFFER_SIZE 600 into libraries/NanodeUIP/uip-conf.h.

Maybe this issue, and the workaround, deserves to be more visible into the homepage.