Пытаюсь настроить приоритизацию трафика в Linux, чтобы не лагали FPS игры.
Хочу повысить приоритет всего UDP трафика, за исключением одного порта.
Есть такой скрипт:
Код:
#!/bin/bash
IPTABLES=/usr/sbin/iptables
TC=/usr/sbin/tc
# All traffic is given an iptables MARK depending on its type:
# * 10 for low latency traffic (all UDP traffic except the one
# originating from port 12222)
# * 20 anything else
# all traffic coming in on eth0 with the default 20
$IPTABLES -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 20
# udp except port 12222 - mark as 10
$IPTABLES -t mangle -A FORWARD -i eth0 -p udp ! --sport 12222 -j MARK --set-mark 10
# root qdisc
$TC qdisc add dev eth0 root handle 1: htb
# overall rate limits (1Mbps outgoing)
$TC class add dev eth0 parent 1: classid 1:1 htb rate 1024kbit
# interactive UDP
$TC class add dev eth0 parent 1:1 classid 1:10 htb rate 512kbit ceil 512kbit prio 0
# everything else
$TC class add dev eth0 parent 1:1 classid 1:20 htb rate 512kbit ceil 512kbit prio 1
# do fair shaping in each class
$TC qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
$TC qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
# divert traffic marked by iptables into each class
$TC filter add dev eth0 parent 1:0 protocol ip handle 10 fw flowid 1:10
$TC filter add dev eth0 parent 1:0 protocol ip handle 20 fw flowid 1:20
Хочу повысить приоритет всего UDP трафика, за исключением одного порта.
Есть такой скрипт:
Код:
#!/bin/bash
IPTABLES=/usr/sbin/iptables
TC=/usr/sbin/tc
# All traffic is given an iptables MARK depending on its type:
# * 10 for low latency traffic (all UDP traffic except the one
# originating from port 12222)
# * 20 anything else
# all traffic coming in on eth0 with the default 20
$IPTABLES -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 20
# udp except port 12222 - mark as 10
$IPTABLES -t mangle -A FORWARD -i eth0 -p udp ! --sport 12222 -j MARK --set-mark 10
# root qdisc
$TC qdisc add dev eth0 root handle 1: htb
# overall rate limits (1Mbps outgoing)
$TC class add dev eth0 parent 1: classid 1:1 htb rate 1024kbit
# interactive UDP
$TC class add dev eth0 parent 1:1 classid 1:10 htb rate 512kbit ceil 512kbit prio 0
# everything else
$TC class add dev eth0 parent 1:1 classid 1:20 htb rate 512kbit ceil 512kbit prio 1
# do fair shaping in each class
$TC qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
$TC qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
# divert traffic marked by iptables into each class
$TC filter add dev eth0 parent 1:0 protocol ip handle 10 fw flowid 1:10
$TC filter add dev eth0 parent 1:0 protocol ip handle 20 fw flowid 1:20