Implement token bucket duty cycle enforcement#1297
Implement token bucket duty cycle enforcement#1297ripplebiz merged 3 commits intomeshcore-dev:devfrom
Conversation
|
We had a discussion in the Dutch community today. Some people didn't care much, others wanted a proper implementation. I'm neutral either way (not even sure if I enabled it myself). Perhaps this could start a broader discussion to decide it once and for all. |
|
how does this work for USA where there is no duty cycle limit? |
The same as it is currently, airtime factor already limits it to the same amount, just less reliable. So both now and with this method, they would need to disable it. (set af 0) |
|
whatever the change is, it should not limit duty cycle at any percentage for regions that don't have duty cycle limit. |
Its probably higher than the current cap you guys have. But a valid point for another issue on if and what the default should be. Perhaps it should be set with the region or something. |
|
@ViezeVingertjes I welcome proper implemetation of hourly duty cycle for europe, but this needs to be set to 0 by default. we don't want US, AU, NZ and other countries be limited to 10% by default. |
Hmm, but default AF was 1.0 right? So i feel 10% would reflect the original 'duty cycle' more than 0%? In practice it should already transmit more than with the original AF, so if anything, it shouldn't be less after this change. |
yes, you are right. AF=0 can be dangerous.. AF=1 is optimal, sorry for that. |
Haha check! thought maybe my thought train was wrong, reverted it -> 1b959a9 |
you reverted it to 9 tho? we need it at 1 |
00de1a2 to
a43b0e5
Compare
|
@ViezeVingertjes You can simply drop the last two commits, right? First you change it from 1 to 9 and then back from 9 to 1. Except for the |
a43b0e5 to
eb4fa03
Compare
Done. |
|
how does a user know when they exceed the air time factor limit? just a failed send on the radio? any return error code to the clients so the clients can put up error messages to let the users know? |
Nothing changed on that behavior; the new calculation allows for bursts if there is budget, otherwise it will act like the 'old' AF waits, as its a sliding window. So its much more responsive while still utilizing the queue etc like it did before. I am not aware of any error code that is returned or feedback. Obviously you wont notice a difference when there is no duty cycle applicable in your country (or you have it disabled anyway like most people), but on the default it feels like it responds pretty much instantly most of the time, until the budget is depleted, then it feels like it did in the current release. |
|
thanks so much for implementing my request! |
|
@liamcottle @andymux this would be quiete important for countries with strict dutycycle limits. the current implementation with the waits throws away valuable tx time. |
|
@liamcottle this one would be very important for europe as well |
|
@ripplebiz are there any roadblocks preventing merging this request? |
|
Running this for a while now, I feel like it's a no-brainer. Better token bucket in practice and adhering to duty cycle more accurately. |
|
@liamcottle Let's merge this? Some arguments below:
tl;dr this replaces a fundamentally incorrect duty cycle model with the standard tocken bucket algorithm that actually enforces the regulatory requirements and actually improves throughput for bursty workloads while being more compliant, not less. The diff is tiny at +71, -14 LOC. Please let's merge this, it's time. |
This will also need review from @ripplebiz, as he's the core maintainer of the Dispatcher system. We are looking to do a v1.14.0 release later tonight, and I don't want to merge any new PRs that have a large footprint right now. Dev branch seems pretty stable right now. One thing I'd like to see, is a simpler command, such as The airtime factor calculations have always confused me, and when I initially added support for it in the app, I removed it because it didn't make sense in the user interface. Having a cleaner command make the user experience nicer. We can probably look at this properly after v1.14.0 is released. |
|
My 2 cents would be to merge it into v1.14.0😋. I'm really confident it's only going to improve the mesh as a whole. |
|
Let me chip in another 2 cents that I agree with @liamcottle that a dedicated Right now, often you need to resend messages. As people will think they are not heard they will use #bot and/or #test to see if they are heard, causing massive unnecessary chatter from several bots causing a lot of mesh overhead. If users see their messages get repeated, they are less likely to 'test', which in turn alleviates the mesh. |
|
Now that 1.14 is out, I would suggest to merge this rather sooner than later. This way we can get additional test coverage from people using dev until the next release is getting tagged. |
agree. @liamcottle @ripplebiz, can we make it happen please? |
|
If this one can't be resolved before merging;
Can someone please provide a map/list of airtime factor values and how they map to duty cycle values. Unless the user experience around this can be improved, it's unlikely I would add UI to the app. Users should be working with duty cycle numbers, since that's what's described in radio regulations etc. Regarding merging, I'd like for @ripplebiz to review the code first. I'll link this to him in a DM as well. |
I think it's good to replace af with dutycycle, but let's do it in a separate PR. This one has been open for 2 months and is good to go as it is, if we start changing things we need to test it all over.
|
af vs duty cycle examples: |
|
I can make a PR to add dutycycle command and deprecate af. |
|
I would merge this as it is. |
|
I'm also for merging this one, as it silently fixes all repeaters that have af=9 and get performance hit because how it's implemented |
|
See #1961 which builds on this PR and adds get/set dutycycle command. |
Thinking of the "Airtime Factor" as the amount of time-units to be "silent" I can grasp it intuitively: E.g. when I am only allowed to send 20% of the time, i.e. only 1/5th, 1 time unit I am allowed to send and the 4 remaining I am not allowed to send, to think of it. So, Regards! |

Replaces per-transmission delay with a rolling window token bucket for better regulatory compliance.
Resolves #817.