parallaxinc / PropLoader

Parallax Propeller loader supporting both serial and wifi downloads
MIT License
27 stars 13 forks source link

Enhance Discovery Protocol #5

Open PropGit opened 8 years ago

PropGit commented 8 years ago

Please enhance the loader's module discovery protocol according to what is decided in the Parallax Wi-Fi Module's firmware repo issue#1.

PropGit commented 8 years ago

UPDATE: In a test with 4 Parallax Wi-Fi Modules (all within a 10 foot radius of the central access point), the current Discovery process successfully identified all modules 65% of the time (13 out of 20 tries).

In a second test (with same modules, moments later), the Discovery process successfully identified all modules 73% of the time (22 out of 30 tries); two of the tries failed to identify two of the modules while all other attempts identified 3 or 4 (not always the same modules appear in, or disappear from, the results).

Note this was just a simple test; results are expected to vary based on network traffic, separation distance, signal strength, wireless noise, and pseudo-random chance.

PropGit commented 8 years ago

UPDATE: This is much improved! Using esp-link-2016-03-28.zip and proploader.exe from 03/28, I performed the same tests as above.

The Discovery process identified all 4 modules 86% of the time (26 out of 30 tries); one of the tries reported only 2 of the 4 modules, and three tries reported 3 out of 4. Different modules disappeared from the results at different times.

In a second series of 30 discovery request, all four modules were found 100% of the time.

It appears that the changes made to the discovery process greatly improved the reliability of the results.

dbetz commented 8 years ago

Thanks for testing. Maybe I should change the timeout to something longer than 250ms to see if that helps. How about three attempts separated by 500ms? That means the entire discovery process would complete in 1.5 seconds? Or maybe four at 500ms. Will 2 seconds be acceptable?

PropGit commented 8 years ago

To answer that, here's the same related response I just sent in email (copied here for history):

Lets try keeping it at 250 ms timeout, the duplicate responses are already filtered out by proploader and they don't seem to happen too often in my tests (that I can tell).

Also, please make it attempt not a static 4 tries, but rather have it keep trying until 3 contiguous tries don't result in any responses from previously unknown modules. There are some important implications in this:

The above means the discovery process will take a minimum of 750 ms (for a network with no active modules), and somewhere around 3.25 seconds when there are a lot of them (assuming there are 200 modules and the host only hears from about 20 new modules upon each transmitted discovery request).

In my tests, on occasion I see three module addresses appear right away... then a brief (maybe 1/4 second) delay, followed by the fourth module address. That's the kind of thing I'd expect to see if the fourth module's response collided the first time, then was received the next time. However; there are still cases where only two or, more often, three modules that are "found" in the entire process... it's curious why the fourth was never found despite a sizable delay following the discovery of the first three (where I'm assuming it's sending out more discovery requests).

PropGit commented 8 years ago

Questions:

dbetz commented 8 years ago

The 0x00000000 at the start of each request marks it as a request and not a response. The response is a JSON string that starts with "{" and hence will never be zero.

PropGit commented 8 years ago

[Using 2016-03-28 firmware and proploader.exe from 2016-03-28 03:09 pm PST]

I've been studying the packet traffic during discovery, looking for any oddities during cases where only three of my four active modules are discovered. Here's what I found: