Publicada por tutasme em 29/04/2007 - 20:06h:
* tutasme usa Suse

CBQ, Pessoal até hoje eu não consigo configurar meu CBQ de forma alguma. O que acontece.
Eu instalo o CBQ e configuro as regras todas estudadas com a maior calma e com os minimos detalhes tudo verificado corretamente.
O desempenho
Cai drasticamente quando jogo o RATE=64Kbit pra um ip qualquer da rede o CBQ solta apenas 64Kbit na interface, não passar de 64 de jeito algum até os clientes que não tão configurado no /etc/sysconfig/cbq só saem até 64Kbit se dois clientes acessarem a rede, cada cliente tem 32Kbit e só pronto
A DISTRO
ja utilizei, suse 8.2.
Mandrake 9
Agora vou testar o opensuse 10.2 que não tem o cbq na distro padrão tambem o mandrake 9 não tem nem o suse 8.2.
*Detalhes nenhuma dessas distrubuções tem o shapercfg, o suse tem o wondershaper que é um utilitário QOS que eu instalo e não faz diferença alguma.
Quem pode realmente me ajudar, Por favor faça-o
Agradeço de coração!!!
*Tô usando delay_pools que é bom, mas não é 100% principalmente nos uploads e nos "P2P" da vida ele não segura

  
 
Resposta de neonx em 29/04/2007 - 20:41h:
* neonx usa Slackware
* neonx tem conceito: 7.6
 


em qual interface vc está jogando o cbq?? lembrando que dever jogar na placa interna do servidor e não na placa de internet, passe tbm as regras que está jogando no cbq para que possamos entender melhor...

 
Resposta de tutasme em 30/04/2007 - 16:19h:
* tutasme usa Suse
* tutasme tem conceito: 8.5
 


Prezado Amigo, estou jogando na interface eth1, que é a interface da minha rede interna, estas são as regras e quando eu dou um cbq start a interface não passa de 64Kbit nem a pau
DEVICE=eth1,100Mbit,10Mbit
RATE=64Kbit
WEIGHT=6Kbit
PRIO=8
BOUNDED=yes
ISOLATED=no
RULE=192.168.30.35
me ajude por favor

 
Resposta de neonx em 30/04/2007 - 17:49h:
* neonx usa Slackware
* neonx tem conceito: 7.6
 


As regras estão OK... vc não incluiu a placa do servidor no cbq nao né... pois aí estaria limitando também o servidor a 64kbits, eu uso um script que cria os arquivos cbq deixo de fora os servidores..

 
Resposta de tutasme em 30/04/2007 - 19:12h:
* tutasme usa Suse
* tutasme tem conceito: 8.5
 


Não entedi o quer vc quer dizer quando fala "VC NÃO INCLUI A PLACA DO SERVIDOR NO CBQ NÃO NÉ ", mas até onde eu saiba não. Usei a regra acima e o problema continua. Pode me ajudar

 
Resposta de neonx em 30/04/2007 - 19:52h:
* neonx usa Slackware
* neonx tem conceito: 7.6
 


lhe perguntei pois esse tipo de problema é caracteristico quando o cbq está agindo em cima da eth1 do servidor tbm... mas enfim faca o teste tirando o BOUNDED e o ISOLATED da sua regra.. eu nao utilizao nenhum deles....

 
Resposta de tutasme em 01/05/2007 - 08:41h:
* tutasme usa Suse
* tutasme tem conceito: 8.5
 


amigok, tentei usar isso tirei de todas as regras o bonded e o isolated mandei um cbq restart e tambem não funcionou, tentei usar com a tabela mangle do iptables com mark ( pra marcar os pacotes e tambem não funcionou ) ainda há o que fazer ? praver se funciona

 
Resposta de neonx em 01/05/2007 - 10:22h:
* neonx usa Slackware
* neonx tem conceito: 7.6
 


amigo me envie por e-mail o seu cbq (script de inicialização) para que eu possa dar uma analisada e conferir com o meu para ver se está OK.

 
Resposta de tutasme em 03/05/2007 - 17:20h:
* tutasme usa Suse
* tutasme tem conceito: 8.5
 


KARO AMIGO SEGUE AQUI O SCRIPT DE INICIALIZAÇÃO DO CBQ
PRECISO MUITO DE AJUDA ( TIREI OS COMENTARIOS PRA NÃO AUMENTAR DE TAMANHO )

PATH="/sbin:/usr/sbin:/bin:/usr/bin"

### Default filter priorities (must be different)
PRIO_RULE=${PRIO_RULE:-100}
PRIO_MARK=${PRIO_MARK:-200}
PRIO_REALM=${PRIO_REALM:-300}

### Default CBQ_PATH & CBQ_CACHE settings
CBQ_PATH=${CBQ_PATH:-/etc/sysconfig/cbq}
CBQ_CACHE=${CBQ_CACHE:-/var/cache/cbq.init}

### Uncomment to enable logfile for debugging
#CBQ_DEBUG="/var/run/cbq-$1"

### Modules to probe for. Uncomment the last CBQ_PROBE
### line if you have QoS support compiled into kernel
CBQ_PROBE="sch_cbq sch_tbf sch_sfq sch_prio"
CBQ_PROBE="$CBQ_PROBE cls_fw cls_u32 cls_route"
#CBQ_PROBE=""

### Keywords required for qdisc & class configuration
CBQ_WORDS="DEVICE|RATE|WEIGHT|PRIO|PARENT|LEAF|BOUNDED|ISOLATED"
CBQ_WORDS="$CBQ_WORDS|BUFFER|LIMIT|PEAK|MTU|QUANTUM|PERTURB"


#############################################################################
############################# SUPPORT FUNCTIONS #############################
#############################################################################

### Get list of network devices
cbq_device_list () {
   ip link show| sed -n "/^[0-9]/ \
      { s/^[0-9]\+: \([a-z0-9]\+\)[:@].*/\1/; p; }"
} # cbq_device_list


### Remove root class from device $1
cbq_device_off () {
   tc qdisc del dev $1 root 2> /dev/null
} # cbq_device_off


### Remove CBQ from all devices
cbq_off () {
   for dev in `cbq_device_list`; do
      cbq_device_off $dev
   done
} # cbq_off


### Prefixed message
cbq_message () {
   echo -e "**CBQ: $@"
} # cbq_message

### Failure message
cbq_failure () {
   cbq_message "$@"
   exit 1
} # cbq_failure

### Failure w/ cbq-off
cbq_fail_off () {
   cbq_message "$@"
   cbq_off
   exit 1
} # cbq_fail_off



### Convert time to absolute value
cbq_time2abs () {
   _min=${1##*:}
   _min=${_min##0}
   echo $[${1%%:*}*60 + _min]
} # cbq_time2abs


### Display CBQ setup
cbq_show () {
   for dev in `cbq_device_list`; do
      [ `tc qdisc show dev $dev| wc -l` -eq 0 ] && continue
      echo -e "### $dev: queueing disciplines\n"
      tc $1 qdisc show dev $dev; echo

      [ `tc class show dev $dev| wc -l` -eq 0 ] && continue
      echo -e "### $dev: traffic classes\n"
      tc $1 class show dev $dev; echo

      [ `tc filter show dev $dev| wc -l` -eq 0 ] && continue
      echo -e "### $dev: filtering rules\n"
      tc $1 filter show dev $dev; echo
   done
} # cbq_show


### Check configuration and load DEVICES, DEVFIELDS and CLASSLIST from $1
cbq_init () {
   ### Get a list of configured classes
   CLASSLIST=`find $1 -name 'cbq-*' -maxdepth 1 -printf "%f\n"| sort`
   [ -z "$CLASSLIST" ] &&
      cbq_failure "no configuration files found in $1!"

   ### Gather all DEVICE fields from $1/cbq-*
   DEVFIELDS=`find $1 -name 'cbq-*' -maxdepth 1 -exec sed -ne \
       's/#.*//; s/ //g; /^DEVICE=[^,]*,[^,]*\(,[^,]*\)\?/ \
       { s/.*=//; p; q; }; /^DEVICE=/ q' {} \;| sort -u`
   [ -z "$DEVFIELDS" ] &&
      cbq_failure "no DEVICE field found in $1/cbq-*!"

   ### Check for different DEVICE fields for the same device
   DEVICES=`echo "$DEVFIELDS"| sed 's/,.*//'| sort -u`
   [ `echo "$DEVICES"| wc -l` -ne `echo "$DEVFIELDS"| wc -l` ] &&
      cbq_failure "different DEVICE fields for single device!\n$DEVFIELDS"
} # cbq_init


### Load class configuration from $1/$2
cbq_load_class () {
   CLASS=`echo $2| sed 's/^cbq-0*//; s/^\([0-9a-fA-F]\+\).*/\1/'`
   CFILE=`sed -n 's/#.*//; s/ //g; /^[[:alpha:]]\+=[[:alnum:].,:;/*-]\+$/ p' $1/$2`

   ### Check class number
   IDVAL=`/usr/bin/printf "%d" 0x$CLASS 2> /dev/null`
   [ $? -ne 0 -o $IDVAL -lt 2 -o $IDVAL -gt 65535 ] &&
      cbq_fail_off "class ID of $2 must be in range <0002-FFFF>!"

   ### Set defaults & load class
   RATE=""; WEIGHT=""; PARENT=""; PRIO=5
   LEAF=tbf; BOUNDED=yes; ISOLATED=no
   BUFFER=10Kb/8; LIMIT=15Kb; MTU=1500
   PEAK=""; PERTURB=""; QUANTUM=""

   eval `echo "$CFILE"| grep -E "^($CBQ_WORDS)="`

   ### Require RATE/WEIGHT
   [ -z "$RATE" -o -z "$WEIGHT" ] &&
      cbq_fail_off "missing RATE or WEIGHT in $2!"

   ### Class device
   DEVICE=${DEVICE%%,*}
   [ -z "$DEVICE" ] && cbq_fail_off "missing DEVICE field in $2!"

   BANDWIDTH=`echo "$DEVFIELDS"| sed -n "/^$DEVICE,/ \
       { s/[^,]*,\([^,]*\).*/\1/; p; q; }"`

   ### Convert to "tc" options
   PEAK=${PEAK:+peakrate $PEAK}
   PERTURB=${PERTURB:+perturb $PERTURB}
   QUANTUM=${QUANTUM:+quantum $QUANTUM}

   [ "$BOUNDED" = "no" ] && BOUNDED="" || BOUNDED="bounded"
   [ "$ISOLATED" = "yes" ] && ISOLATED="isolated" || ISOLATED=""
} # cbq_load_class


#############################################################################
#################################### INIT ###################################
#############################################################################

### Check for presence of ip-route2 in usual place
[ -x /sbin/tc -a -x /sbin/ip ] ||
   cbq_failure "ip-route2 utilities not installed or executable!"


### Various tweaks
if [ "$1" = "compile" ]; then
   ### no module probing
   CBQ_PROBE=""

   ### echo-only version of "tc" command
   tc () {
      echo "tc $@"
   } # tc

elif [ -n "$CBQ_DEBUG" ]; then
   echo -e "# `date`" > $CBQ_DEBUG

   ### Logging version of "ip" command
   ip () {
      echo -e "\n# ip $@" >> $CBQ_DEBUG
      /sbin/ip "$@" 2>&1 | tee -a $CBQ_DEBUG
   } # ip

   ### Logging version of "tc" command
   tc () {
      echo -e "\n# tc $@" >> $CBQ_DEBUG
      /sbin/tc "$@" 2>&1 | tee -a $CBQ_DEBUG
   } # tc
fi # command logging


case "$1" in

#############################################################################
############################### START/COMPILE ###############################
#############################################################################

start|compile)

### Probe QoS modules (start only)
for module in $CBQ_PROBE; do
   modprobe $module || cbq_failure "failed to load module $module"
done

### If we are in compile/nocache/logging mode, don't bother with cache
if [ "$1" != "compile" -a "$2" != "nocache" -a -z "$CBQ_DEBUG" ]; then
   VALID=1

   ### validate the cache
   [ "$2" = "invalidate" -o ! -f $CBQ_CACHE ] && VALID=0
   if [ $VALID -eq 1 ]; then
      [ `find $CBQ_PATH -maxdepth 1 -newer $CBQ_CACHE| \
       wc -l` -gt 0 ] && VALID=0
   fi

   ### compile the config if the cache is invalid
   if [ $VALID -ne 1 ]; then
      $0 compile > $CBQ_CACHE ||
         cbq_fail_off "failed to compile CBQ configuration!"
   fi

   ### run the cached commands
   exec /bin/sh $CBQ_CACHE 2> /dev/null
fi

### Load DEVICES, DEVFIELDS and CLASSLIST
cbq_init $CBQ_PATH


### Setup root qdisc on all configured devices
for dev in $DEVICES; do
   ### Retrieve device bandwidth and, optionally, weight
   DEVTEMP=`echo "$DEVFIELDS"| sed -n "/^$dev,/ { s/$dev,//; p; q; }"`
   DEVBWDT=${DEVTEMP%%,*};   DEVWGHT=${DEVTEMP##*,}
   [ "$DEVBWDT" = "$DEVWGHT" ] && DEVWGHT=""

   ### Device bandwidth is required
   if [ -z "$DEVBWDT" ]; then
      cbq_message "could not determine bandwidth for device $dev!"
      cbq_failure "please set up the DEVICE fields properly!"
   fi

   ### Check if the device is there
   ip link show $dev &> /dev/null ||
      cbq_fail_off "device $dev not found!"

   ### Remove old root qdisc from device
   cbq_device_off $dev


   ### Setup root qdisc + class for device
   tc qdisc add dev $dev root handle 1 cbq \
   bandwidth $DEVBWDT avpkt 1000 cell 8

   ### Set weight of the root class if set
   [ -n "$DEVWGHT" ] &&
      tc class change dev $dev root cbq weight $DEVWGHT allot 1514

   [ "$1" = "compile" ] && echo
done # dev


### Setup traffic classes
for classfile in $CLASSLIST; do
   cbq_load_class $CBQ_PATH $classfile

   ### Create the class
   tc class add dev $DEVICE parent 1:$PARENT classid 1:$CLASS cbq \
   bandwidth $BANDWIDTH rate $RATE weight $WEIGHT prio $PRIO \
   allot 1514 cell 8 maxburst 20 avpkt 1000 $BOUNDED $ISOLATED ||
      cbq_fail_off "failed to add class $CLASS with parent $PARENT on $DEVICE!"

   ### Create leaf qdisc if set
   if [ "$LEAF" = "tbf" ]; then
      tc qdisc add dev $DEVICE parent 1:$CLASS handle $CLASS tbf \
      rate $RATE buffer $BUFFER limit $LIMIT mtu $MTU $PEAK
   elif [ "$LEAF" = "sfq" ]; then
      tc qdisc add dev $DEVICE parent 1:$CLASS handle $CLASS sfq \
      $PERTURB $QUANTUM
   fi


   ### Create fw filter for MARK fields
   for mark in `echo "$CFILE"| sed -n '/^MARK/ { s/.*=//; p; }'`; do
      ### Attach fw filter to root class
      tc filter add dev $DEVICE parent 1:0 protocol ip \
      prio $PRIO_MARK handle $mark fw classid 1:$CLASS
   done ### mark

   ### Create route filter for REALM fields
   for realm in `echo "$CFILE"| sed -n '/^REALM/ { s/.*=//; p; }'`; do
      ### Split realm into source & destination realms
      SREALM=${realm%%,*}; DREALM=${realm##*,}
      [ "$SREALM" = "$DREALM" ] && SREALM=""

      ### Convert asterisks to empty strings
      SREALM=${SREALM#\*}; DREALM=${DREALM#\*}

      ### Attach route filter to the root class
      tc filter add dev $DEVICE parent 1:0 protocol ip \
      prio $PRIO_REALM route ${SREALM:+from $SREALM} \
      ${DREALM:+to $DREALM} classid 1:$CLASS
   done ### realm

   ### Create u32 filter for RULE fields
   for rule in `echo "$CFILE"| sed -n '/^RULE/ { s/.*=//; p; }'`; do
      ### Split rule into source & destination
      SRC=${rule%%,*}; DST=${rule##*,}
      [ "$SRC" = "$DST" ] && SRC=""


      ### Split destination into address, port & mask fields
      DADDR=${DST%%:*}; DTEMP=${DST##*:}
      [ "$DADDR" = "$DST" ] && DTEMP=""

      DPORT=${DTEMP%%/*}; DMASK=${DTEMP##*/}
      [ "$DPORT" = "$DTEMP" ] && DMASK="0xffff"


      ### Split up source (if specified)
      SADDR=""; SPORT=""
      if [ -n "$SRC" ]; then
         SADDR=${SRC%%:*}; STEMP=${SRC##*:}
         [ "$SADDR" = "$SRC" ] && STEMP=""

         SPORT=${STEMP%%/*}; SMASK=${STEMP##*/}
         [ "$SPORT" = "$STEMP" ] && SMASK="0xffff"
      fi


      ### Convert asterisks to empty strings
      SADDR=${SADDR#\*}; DADDR=${DADDR#\*}

      ### Compose u32 filter rules
      u32_s="${SPORT:+match ip sport $SPORT $SMASK}"
      u32_s="${SADDR:+match ip src $SADDR} $u32_s"
      u32_d="${DPORT:+match ip dport $DPORT $DMASK}"
      u32_d="${DADDR:+match ip dst $DADDR} $u32_d"

      ### Uncomment the following if you want to see parsed rules
      #echo "$rule: $u32_s $u32_d"

      ### Attach u32 filter to the appropriate class
      tc filter add dev $DEVICE parent 1:0 protocol ip \
      prio $PRIO_RULE u32 $u32_s $u32_d classid 1:$CLASS
   done ### rule

   [ "$1" = "compile" ] && echo
done ### classfile
;;


#############################################################################
################################# TIME CHECK ################################
#############################################################################

timecheck)

### Get time + weekday
TIME_TMP=`date +%w/%k:%M`
TIME_DOW=${TIME_TMP%%/*}
TIME_NOW=${TIME_TMP##*/}
TIME_ABS=`cbq_time2abs $TIME_NOW`

### Load DEVICES, DEVFIELDS and CLASSLIST
cbq_init $CBQ_PATH

### Run through all classes
for classfile in $CLASSLIST; do
   ### Gather all TIME rules from class config
   TIMESET=`sed -ne 's/#.*//; s/ //g; /^TIME/ { s/.*=//; p; }' \
      $CBQ_PATH/$classfile`
   [ -z "$TIMESET" ] && continue

   MATCH=0; CHANGE=0
   for timerule in $TIMESET; do
      ### Split TIME rule to pieces
      TIMESPEC=${timerule%%;*}; PARAMS=${timerule##*;}
      WEEKDAYS=${TIMESPEC%%/*}; INTERVAL=${TIMESPEC##*/}
      BEG_TIME=${INTERVAL%%-*}; END_TIME=${INTERVAL##*-}

      ### Check the day-of-week (if present)
      [ "$WEEKDAYS" != "$INTERVAL" -a \
       -n "${WEEKDAYS##*$TIME_DOW*}" ] && continue

      ### Compute interval boundaries
      BEG_ABS=`cbq_time2abs $BEG_TIME`
      END_ABS=`cbq_time2abs $END_TIME`

      ### Midnight wrap fixup
      if [ $BEG_ABS -gt $END_ABS ]; then
         [ $TIME_ABS -le $END_ABS ] &&
            TIME_ABS=$[TIME_ABS + 24*60]

         END_ABS=$[END_ABS + 24*60]
      fi

      ### If the time matches, remember params and set MATCH flag
      if [ $TIME_ABS -ge $BEG_ABS -a $TIME_ABS -lt $END_ABS ]; then
         TMP_RATE=${PARAMS%%/*}; PARAMS=${PARAMS#*/}
         TMP_WGHT=${PARAMS%%/*}; TMP_PEAK=${PARAMS##*/}

         [ "$TMP_PEAK" = "$TMP_WGHT" ] && TMP_PEAK=""
         TMP_PEAK=${TMP_PEAK:+peakrate $TMP_PEAK}

         MATCH=1
      fi
   done ### timerule


   cbq_load_class $CBQ_PATH $classfile

   ### Get current RATE of CBQ class
   RATE_NOW=`tc class show dev $DEVICE| sed -n \
       "/cbq 1:$CLASS / { s/.*rate //; s/ .*//; p; q; }"`
   [ -z "$RATE_NOW" ] && continue

   ### Time interval matched
   if [ $MATCH -ne 0 ]; then

      ### Check if there is any change in class RATE
      if [ "$RATE_NOW" != "$TMP_RATE" ]; then
         NEW_RATE="$TMP_RATE"
         NEW_WGHT="$TMP_WGHT"
         NEW_PEAK="$TMP_PEAK"
         CHANGE=1
      fi

   ### Match not found, reset to default RATE if necessary
   elif [ "$RATE_NOW" != "$RATE" ]; then
      NEW_WGHT="$WEIGHT"
      NEW_RATE="$RATE"
      NEW_PEAK="$PEAK"
      CHANGE=1
   fi

   ### If there are no changes, go for next class
   [ $CHANGE -eq 0 ] && continue

   ### Replace CBQ class
   tc class replace dev $DEVICE classid 1:$CLASS cbq \
   bandwidth $BANDWIDTH rate $NEW_RATE weight $NEW_WGHT prio $PRIO \
   allot 1514 cell 8 maxburst 20 avpkt 1000 $BOUNDED $ISOLATED

   ### Replace leaf qdisc (if any)
   if [ "$LEAF" = "tbf" ]; then
      tc qdisc replace dev $DEVICE handle $CLASS tbf \
      rate $NEW_RATE buffer $BUFFER limit $LIMIT mtu $MTU $NEW_PEAK
   fi

   cbq_message "$TIME_NOW: class $CLASS on $DEVICE changed rate ($RATE_NOW -> $NEW_RATE)"
done ### class file
;;


#############################################################################
################################## THE REST #################################
#############################################################################

stop)
   cbq_off
   ;;

list)
   cbq_show
   ;;

stats)
   cbq_show -s
   ;;

restart)
   $0 stop
   $0 start
   ;;

*)
   echo "Usage: `basename $0` {start|compile|stop|restart|timecheck|list|stats}"
esac



  


ATENÇÃO: Antes de contribuir com uma resposta, leia o artigo Qualidade de respostas e certifique-se de que esteja realmente contribuindo com a comunidade. Muitas vezes o ímpeto de contribuir nos leva a atrapalhar ao invés de ajudar.

Contribuir com resposta



CAPTCHA
[ Recarregar imagem ]

Digite o código acima:

  
* Nota: só é possível enviar respostas usuário que possui conta e esteja logado com ela, caso contrário sua mensagem será perdida.



Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts