kuchin://Linux/Network/Shaping

Root
Boards
Cars
Company
Development
Fish
Hardware
House
Internet
Israel
Linux
     Cron
     mySQL
     Network
     ADSL
     Shaping
     Programs
     Time
     SSH
Multimedia
Network
PDA
Photo
Travel
Unsorted
Windows



Rambler's Top100

Скрипт для траффик-шейпинга (приоретизация траффика)

#!⁄bin⁄bash
# Config for an ADSL link with 750Kbit downstream and 96Kbit upstream
##############################################################################################


##############################################################################################
# A packet of size 0-500 will be considered interactive traffic and marked with fwmark value 3
# Next packets of size 500-1500 will be marked as data traffic with value 4
##############################################################################################

iptables -t mangle -A OUTPUT -m length --length 0:500 -j MARK --set-mark 3
iptables -t mangle -A OUTPUT -m length --length 500:1500 -j MARK --set-mark 4

##############################################################################################
# Masqueraded machine should also have its upload tuned
##############################################################################################

iptables -t mangle -A PREROUTING -i eth1 -m length --length 0:500 -j MARK --set-mark 3
iptables -t mangle -A PREROUTING -i eth1 -m length --length 500:1500 -j MARK --set-mark 4

##############################################################################################
# This creates a root queuing discipline with handle 10: for the device
# ppp0 of type cbq, with maximum bandwidth of 10Mbits (pppoe), average
# packet size will be of 1000 bytes and minimum packet size of 64
# (ethernet)
##############################################################################################

tc qdisc add dev ppp0 root handle 10: cbq bandwidth 10Mbit avpkt 1000 mpu 64

##############################################################################################
# Perhaps you'll need to fine tune to suit your needs, just make sure to have enough
# bandwidth in the interactive class to acknowledge all incoming tcp data.
# Interactive class rate = Download bandwidth ⁄ 20 = 750 ⁄ 20 = 38
# Data class rate = Upload bandwidth - Interactive class rate = 96 - 38 = 58
##############################################################################################

tc class add dev ppp0 parent 10:0 classid 10:1 cbq bandwidth 10Mbit \
rate 38Kbit allot 1514 prio 1 maxburst 10 avpkt 100 isolated
tc class add dev ppp0 parent 10:0 classid 10:2 cbq bandwidth 10Mbit \
rate 58Kbit allot 1514 prio 8 maxburst 2 avpkt 1500 bounded

##############################################################################################
# At least we need to tell the kernel which class we want to send packets to:
##############################################################################################

tc filter add dev ppp0 parent 10:0 protocol ip handle 3 fw flowid 10:1
tc filter add dev ppp0 parent 10:0 protocol ip handle 4 fw flowid 10:2