Skip to content

Commit a4ac994

Browse files
committed
Update tcp_pacing_ratio based on interface and frequency bandwidth
1 parent d446eb3 commit a4ac994

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

module/service.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,41 @@ set_congestion() {
8080
fi
8181
}
8282

83+
set_tcp_pacing() {
84+
local ca="$1"
85+
local ss="$2"
86+
echo "$ca" > /proc/sys/net/ipv4/tcp_pacing_ca_ratio 2>/dev/null
87+
echo "$ss" > /proc/sys/net/ipv4/tcp_pacing_ss_ratio 2>/dev/null
88+
}
89+
8390
get_active_iface() {
8491
iface=$(ip route get 192.0.2.1 2>/dev/null | awk '/dev/ {for(i=1;i<=NF;i++) if($i=="dev") print $(i+1)}')
8592
echo "$iface"
8693
}
8794

95+
get_wifi_freq() {
96+
local iface="$1"
97+
iw dev "$iface" link 2>/dev/null | grep "freq:" | awk '{print $2}'
98+
}
99+
88100
apply_wifi_settings() {
89101
local iface="$1"
90102
local applied=0
103+
freq=$(get_wifi_freq "$iface")
104+
log_print "Wi-Fi band detected: ${freq} MHz"
105+
if [ -n "$freq" ]; then
106+
if [ "$freq" -lt 3000 ]; then
107+
# 2.4 GHz
108+
set_tcp_pacing 150 200
109+
elif [ "$freq" -lt 6000 ]; then
110+
# 5 GHz or higher
111+
set_tcp_pacing 200 300
112+
else
113+
# 6 GHz or higher
114+
set_tcp_pacing 250 350
115+
fi
116+
fi
117+
91118
for algo in $congestion_algorithms; do
92119
if [ -f "$MODPATH/wlan_$algo" ]; then
93120
set_congestion "$algo" "Wi-Fi"
@@ -106,6 +133,9 @@ apply_wifi_settings() {
106133
apply_cellular_settings() {
107134
local iface="$1"
108135
local applied=0
136+
137+
set_tcp_pacing 120 200
138+
109139
for algo in $congestion_algorithms; do
110140
if [ -f "$MODPATH/rmnet_data_$algo" ]; then
111141
set_congestion "$algo" "Cellular"

0 commit comments

Comments
 (0)