Skip to content

Non-blocking TCP connect; some edits for Arduino 1.5; a fix for duplicate packet spam #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

ZakKemble
Copy link

Added non-blocking TCP connect, with example code
Some edits for Arduino IDE 1.5

A fix for duplicate packet spam (needs a better fix, setting the timer
thing too low brings back the spam):
Changed uip_timer_reset() to uip_timer_restart(). When using uip_timer_reset() and if its been a while (say, 5 seconds) since the last call to UIPEthernet::tick() then uip_timer_expired() will return true for its next 20 calls since uip_timer_reset() only adds to the timer whatever the timer interval is set to. Setting the interval to 250 also seems a bit high, the minimum latency achievable with that setting is ~500ms. Ultimately we need to figure out why it's sending the same packet multiple times and fix that.

…cate packet spam

Added non-blocking TCP connect, with example code
Some edits for Arduino IDE 1.5
A fix for duplicate packet spam (needs a better fix, setting the timer
thing too low brings back the spam)
@ntruchsess
Copy link
Owner

Thank you for contributing!
I just added the path-changes and your fix setting the timer to master.
Regarding the nonblocking-connect, I have to give this a bit more thought and testing as this is breaking the stock Ethernet-libraries API. Maybe tracking different-branches (master for 100% compatibility to stock Ethernet and experimental for extensions?), or maybe using a Subclassing-sheme for that?

@ntruchsess
Copy link
Owner

regarding 'Ultimately we need to figure out why it's sending the same packet multiple times and fix that.':
By design It sends out the same packet when there's no ACK within the connections own retransmit-timer has expired (that is independend from the poll-timer that is used in UIPEthernet.cpp), which is not an error.
see https://github.com/ntruchsess/arduino_uip/blob/master/utility/uip.c#L740 for implementation details.

Did you see retransmitted packages after they were acknowledged?

@ZakKemble
Copy link
Author

To become non-blocking connect() requires a 3rd parameter set to true, without that 3rd parameter it defaults to blocking so it still maintains full compatibility with the stock Ethernet.
Duplicate packets stop as soon as they are acknowledged. Gah, seeing the packets retransmit so quickly made me forget that's what's meant to happen, just normally a bit slower >.<
Perhaps a new option to add a timestamp on transmitted packets so they are not retransmitted too soon, then the timer could be lowered to allow lower latencies at the cost of an extra 4 bytes (or maybe 2 bytes, since we're only going to be keeping track of a few seconds, or even 1 byte for 250ms resolution) of RAM per packet?

@ntruchsess
Copy link
Owner

I already check out the options. Either 1 additional timer per connection that expires maybe 50ms after packet and then calls uip_process(UIP_POLL_REQUEST) instead of uip_process(UIP_TIMER), or just 1 timer for all connetions (just that is triggers more often than the shared timer being used now). Then the retransmit-timer-interval can be set to 1 sec (defaulting to 3 Sec. initial retransmit time).

@ntruchsess
Copy link
Owner

While I'd like to have missing features in UIPEthernet I also want to stay compatible with the stock Ethernet-lib in both ways. Did you propose these API-changes to the Arduino-team too? They are here on github too: https://github.com/arduino/Arduino/tree/master/libraries/Ethernet

@ZakKemble
Copy link
Author

Hmm, it seems work has already been done to the Ethernet library for non-blocking connect and a few other things like DHCP and DNS. This pull request (arduino/Arduino#1240) took me to (https://github.com/arduino/Arduino/tree/2ac4e2f3bdf29e8e7bc4d4274ca03465b0b24d31/libraries/Ethernet).

@ntruchsess
Copy link
Owner

Yes, I've seen this, maybe you can try pushing it a bit since it's not yet merged?

@ntruchsess
Copy link
Owner

maybe you take the code from the pull-request and do some polishing...
e.g. make sure memory-footprint does not increase (both RAM and flash), so maybe it's better not to have the blocking method call the nonblocking version use a redundant implementation so the linker can remove what is not being used in the actuall sketch. (Or do some tests in this respect and post the results in the pull-request named above as this es a point the developers have brought up before the request stalled).

Do the same with your current pull-request and make sure this one and the one against Arduino implement the same API, then resubmit against my new branch https://github.com/ntruchsess/arduino_uip/tree/experimental

@ntruchsess
Copy link
Owner

I've added non-blocking TCP connect to class UIPClientExt ecbdc65
Until it's merged into master you find it in branch https://github.com/ntruchsess/arduino_uip/tree/ext

@ntruchsess ntruchsess closed this Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants