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

update qos token bucket size for flow like 1K #97

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/gtpu/trTCM.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "trTCM.h"
#include "log.h"

#define MTU 1500
#define MILLISECONDS_PER_SECOND 1000
#define NANOSECONDS_PER_SECOND 1000000000

TrafficPolicer* newTrafficPolicer(u64 bitRate) {
Expand All @@ -18,9 +20,13 @@ TrafficPolicer* newTrafficPolicer(u64 bitRate) {

p->byteRate = bitRate * 125 ; // Kbit/s to byte/s (*1000/8)

// 1ms as burst size
p->cbs = p->byteRate / 125; // bytes
p->ebs = p->cbs * 4; // bytes
// 8ms as burst size
p->cbs = p->byteRate * 8 * 1 / MILLISECONDS_PER_SECOND; // bytes
if (p->cbs < MTU) {
p->cbs = MTU;
}

p->ebs = p->cbs * 2; // bytes, 2 times of cbs size

// fill buckets at the begining
p->tc = p->cbs;
Expand Down