Skip to content
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

airbase: fix beacon interval timing #2177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beansrus
Copy link

Hello. This pull request tries to fix up some of the beacon timing in airbase that I came across. Please let me know if there is anything I need to fixup to be accepted.


The current implementation had a few problems.

  • the beacons timing would not scale correctly for multiple ssids. If
    the time was 100 ms, and 5 ssids were beaconing, each ssid would beacon
    every 500ms instead of every 100ms.
  • The beacon timing would drift after some time.
  • The gettimeofday() is affected by discontinuous jumps in the system
    time (NTP adjustments and such).
  • the rtc code seemed to over complicate the timing code. Beacon
    frames are usually 100ms. A timer that takes into account small
    amounts of jitter should be sufficient for beacon timing.

Tested with 50 ssids, on a ARMv7 @ 400mhz and didn't have any problem
keeping up. I saw jitter somewhere between 400us-1.5ms

@jbenden
Copy link
Collaborator

jbenden commented Nov 8, 2020

Hi,

Would you mind rebasing on top of the lastest master branch?

Thanks!
-Joe

@beansrus
Copy link
Author

Hello! rebased on master. Quickly gave it a test run and it still seems to work.

@jbenden
Copy link
Collaborator

jbenden commented Nov 25, 2022

I am concerned that big-endian machines will fail. An example is the timestamp; this value is internally CPU native but has been encoded in fixed form dependent on native CPU endianess.

@beansrus
Copy link
Author

Do you mean the part like (beacon[24 +i] = (uint8_t)((timestamp >> (i *8)) & 0xFF)) ? This is existing code. You can see the same usage pattern a couple of times in the file.

Also, it seems to be ok, as its updating the beacon 1 byte at a time so byte ordering shouldn't come into play.

@jbenden
Copy link
Collaborator

jbenden commented Dec 7, 2022

@Mister-X- Is this PR ready for merge?

@Mister-X-
Copy link
Collaborator

By the way, monotonic clock is still affected by jumps of time, like gettimeofday().

If I'm understanding correctly we'd have to use the TAI clock to be unaffected, however, that's Linux only.

@Mister-X-
Copy link
Collaborator

Could you also check and fix codestyle? We have a .clang-format file at the root that can be used with clang-format 3.8.

@beansrus beansrus force-pushed the master branch 2 times, most recently from 5552912 to b3028d1 Compare December 27, 2022 23:15
The current implementation had a few problems.

* the beacons timing would not scale correctly for multiple ssids.  If
  the time was 100 ms, and 5 ssids were beaconing, each ssid would beacon
  every 500ms instead of every 100ms.
* The beacon timing would drift after some time.
* The gettimeofday() is affected by discontinuous jumps in the system
  time.
* the rtc code seemed to over complicate the timing code.  Beacon
  frames are usually 100ms.  A timer that takes into account small
  amounts of jitter should be sufficient for beacon timing.

Tested with 50 ssids, on a ARMv7 @ 400mhz and didn't have any problem
keeping up.  I saw jitter somewhere between 400us-1.5ms
@beansrus
Copy link
Author

Hmm, I updated the comment about the NTP, perhaps I must have been thinking about monotonic_raw. Also, I don't see any changes with clang 3.8, although I do with clang-format 14 (was already installed in my system). Perhaps I missed something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#airbase-ng bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants