The shaper on the tc, how?

0 like 0 dislike
28 views
Wrote a script for traffic shaping for one machine on the local network, eth0-looks in the LAN, eth1 to the ISP. Tell me why it is not working shaper?

The script code shaper.sh:
# show
if [ "$1" = "show" ]; then
/sbin/tc -s qdisc show dev eth0
/sbin/tc-s class show dev eth0
/sbin/tc-s filter show dev eth0
/sbin/tc-s filter show dev eth0 parent 12:
exit;
fi

if [ "$1" = "stop" ]; then
echo "Stopped."
# clean
/sbin/tc qdisc del dev eth0 root 2>/dev/null
/sbin/tc qdisc del dev eth1 root 2>/dev/null
/sbin/tc qdisc del dev eth0 ingress 2> /dev/null

exit
fi

if [ "$1" = "start" ]; then

echo "Started."

/sbin/tc qdisc add dev eth0 root handle 1: prio bands 3
/sbin/tc qdisc add dev eth0 parent 1:1 handle 10: pfifo
/sbin/tc qdisc add dev eth0 parent 1:2 handle 11: pfifo
/sbin/tc qdisc add dev eth0 parent 1:3 handle 12: htb default 0

/sbin/tc filter add dev eth0 parent 12: prio 3 handle 1: protocol ip u32 divisor 256
/sbin/tc filter add dev eth0 protocol ip parent 12: prio 3 u32 match ip dst 172.16.0.0/24 hashkey mask 0x000000ff at 16 link 1:

/sbin/tc class add dev eth0 parent 12: classid 12:101 htb rate 1024Kbit ceil 1024Kbit quantum 1514 mtu 16500
/sbin/tc qdisc add dev eth0 parent 12:101 handle 101: sfq perturb 5
/sbin/tc filter add dev eth0 protocol ip parent 12: prio 7 u32 ht 1:65: match ip dst 172.16.0.2 flowid 12:101
/sbin/tc filter add dev eth0 parent 1:0 protocol ip prio 4 u32 match ip dst 172.16.0.0/24 flowid 1:3

exit
fi

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
list)
list
;;
stats)
list-s
;;
*)
echo "Usage: $0 {start|stop|restart|list|stats}"
exit 1
esac


The output of tc-s class show dev eth0:
root@promeline://# tc-s class show dev eth0
class prio 1:1 parent 1: leaf 10:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class prio 1:2 parent 1: leaf 11:
Sent 84 bytes 2 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class prio 1:3 parent 1: leaf 12:
1287381 Sent 1545 bytes pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class htb 12:101 root leaf 101: prio 0 rate 1024Kbit ceil 1024Kbit burst cburst 16499b 16499b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: ctokens 2014156: 2014156

class htb 12:102 root leaf 102: prio 0 rate 1024Kbit ceil 1024Kbit burst cburst 16499b 16499b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: ctokens 2014156: 2014156
by | 28 views

5 Answers

0 like 0 dislike
This is because the queue is not PRIO sapit, but just looking at the TOS field of package builds traffic in a queue according to priorities
You need to use HTB
tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:10 htb rate 1024Kbit burst 10k
tc filter add dev eth0 parent 1: protocol ip u32 match ip dst 172.16.0.0/24 flowid 1:10
The manual for the HTB luxik.cdi.cz/~devik/qos/htb/manual/userg.htm it was necessary to begin with it
by
0 like 0 dislike
All traffic on 172.16.0.0/24 is wrapped in a class prio 1:3 what's not to love?
by
0 like 0 dislike
Your shaper can head to a break, sauzaie htb.init it is simpler and easy to understand.
by
0 like 0 dislike
on the computer with the ip address at full speed, ie traffic from this address is not sypitsya
by
0 like 0 dislike
all understood, parameter ht must comply with the table where the hash is the last octet of the destination address (in hexadecimal notation). The shaper worked need:
/sbin/tc qdisc add dev eth0 root handle 1: prio bands 3
/sbin/tc qdisc add dev eth0 parent 1:1 handle 10: pfifo
/sbin/tc qdisc add dev eth0 parent 1:2 handle 11: pfifo
/sbin/tc qdisc add dev eth0 parent 1:3 handle 12: htb default 0
\r
/sbin/tc filter add dev eth0 parent 12: prio 3 handle 1: protocol ip u32 divisor 256
/sbin/tc filter add dev eth0 protocol ip parent 12: prio 3 u32 match ip dst 172.16.0.0/24 hashkey mask 0x000000ff at 16 link 1:
\r
/sbin/tc class add dev eth0 parent 12: classid 12:101 htb rate 1024Kbit ceil 1024Kbit quantum 1514 mtu 16500
/sbin/tc qdisc add dev eth0 parent 12:101 handle 101: sfq perturb 5
/sbin/tc filter add dev eth0 protocol ip parent 12: prio 7 u32 ht 1:2: match ip dst 172.16.0.2 flowid 12:101
/sbin/tc filter add dev eth0 parent 1:0 protocol ip prio 4 u32 match ip dst 172.16.0.0/24 flowid 1:3
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Mar 22, 2019 by paramobilus
0 like 0 dislike
4 answers
0 like 0 dislike
3 answers
110,608 questions
257,186 answers
0 comments
32,865 users