Lost packets and strange "behaviour" of my TC rules

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.

I'm going on my 3rd week trying to get a simple traffic shapping to work the right way :( !!

My goal it to shape the traffic coming from one machine (pc1) to another machine (pc2) throught the "eth0" interface. My test configuration is as follows:

PC1

  IP: 192.168.105.237
  Mask: 255.255.255.0
  OS: Red Hat Linux Kernel 2.4.20-8
  Rules:
=========================================================================
  interface="eth0"

  #Delete previous stored configuration
  tc qdisc del dev $interface root

  #Creating the root Qdisc (Queueing Disk)
  tc qdisc add dev $interface root handle 1: htb default 12

  #Definition of classes
  tc class add dev $interface parent 1: classid 1:1 htb rate 100kbit ceil 100kbit
  tc class add dev $interface parent 1:1 classid 1:10 htb rate 30kbit ceil 100kbit
  tc class add dev $interface parent 1:1 classid 1:11 htb rate 10kbit ceil 100kbit
  tc class add dev $interface parent 1:1 classid 1:12 htb rate 60kbit ceil 100kbit

  tc qdisc add dev $interface parent 1:10 handle 20: sfq perturb 10
  tc qdisc add dev $interface parent 1:11 handle 30: sfq perturb 10
  tc qdisc add dev $interface parent 1:12 handle 40: sfq perturb 10

  #Definition of the filters
  tc filter add dev $interface protocol ip parent 1:0 prio 1 u32 match ip src 192.168.105.237
  match ip dport 20000 0xffff flowid 1:10
  tc filter add dev $interface protocol ip parent 1:0 prio 1 u32 match ip src 192.168.105.237
  match ip dport 20001 0xffff flowid 1:11
=========================================================================


PC2:

  IP: 192.168.105.211
  Mask: 255.255.255.0
  OS: Red Hat Linux Kernel 2.4.20-8


I'm using the TG (www.postel.org/tg) as a TCP traffic generator, to establish three 90kbits/s TCP flows from PC1(any port) to PC2(port 20000, 20001 and 20002), with different durations and pause times, which as can be shown in the next files:

=========================================================================
  on 0:2 tcp 192.168.105.211.20000
  at 3 setup
  at 5 arrival constant 0.0888889 length constant 1000
  time 3
  wait 3
  at 11 arrival constant 0.0888889 length constant 1000
  time 15
=========================================================================

=========================================================================
  on 0:2 tcp 192.168.105.211.20001
  at 3 setup
  at 5 arrival constant 0.0888889 length constant 1000
  time 9
  wait 3
  at 17 arrival constant 0.0888889 length constant 1000
  time 6
  wait 2
=========================================================================

=========================================================================
  on 0:2 tcp 192.168.105.211.20002
  at 3 setup
  at 5 arrival constant 0.0888889 length constant 1000
  time 15
  wait 10
=========================================================================

I'm also using the TCPTRACE program, so that I can get some statistics from a captured file made with the help of ETHEREAL (capture filter="ip src 192.168.105.237 && port 20000 || port 20001 || port 20002"), installed on PC2.

Before adding the TC rules to the system, I've runned my test system and got the following output from the ethereal captured file using the command: "tcptrace -l <ethereal.file>":

=========================================================================
=========================================================================
  886 packets seen, 886 TCP packets traced
  elapsed wallclock time: 0:00:00.024537, 36108 pkts/sec analyzed
  trace file elapsed time: 0:00:23.034820
  TCP connection info:
  3 TCP connections traced:
  TCP connection 1:
 host a:        192.168.105.237:36069
 host b:        192.168.105.211:20000
 complete conn: no (SYNs: 1)  (FINs: 1)
 first packet:  Sun Oct 16 16:21:21.332143 2005
 last packet:   Sun Oct 16 16:21:44.366963 2005
 elapsed time:  0:00:23.034820
 total packets: 205
 filename:      linksharing.ethereal
   a->b:         b->a:
     total packets:           205           total packets:             0     
     ack pkts sent:           204           ack pkts sent:             0     
     pure acks sent:            2           pure acks sent:            0     
     sack pkts sent:            0           sack pkts sent:            0     
     dsack pkts sent:           0           dsack pkts sent:           0     
     max sack blks/ack:         0           max sack blks/ack:         0     
     unique bytes sent:    201000           unique bytes sent:         0     
     actual data pkts:        201           actual data pkts:          0     
     actual data bytes:    201000           actual data bytes:         0     
     rexmt data pkts:           0           rexmt data pkts:           0     
     rexmt data bytes:          0           rexmt data bytes:          0     
     zwnd probe pkts:           0           zwnd probe pkts:           0     
     zwnd probe bytes:          0           zwnd probe bytes:          0     
     outoforder pkts:           0           outoforder pkts:           0     
     pushed data pkts:        200           pushed data pkts:          0     
     SYN/FIN pkts sent:       1/1           SYN/FIN pkts sent:       0/0     
     req 1323 ws/ts:          Y/Y           req 1323 ws/ts:          N/N     
     adv wind scale:            0           adv wind scale:            0     
     req sack:                  Y           req sack:                  N     
     sacks sent:                0           sacks sent:                0     
     urgent data pkts:          0 pkts      urgent data pkts:          0 pkts
     urgent data bytes:         0 bytes     urgent data bytes:         0 bytes
     mss requested:          1460 bytes     mss requested:             0 bytes
     max segm size:          1448 bytes     max segm size:             0 bytes
     min segm size:           552 bytes     min segm size:             0 bytes
     avg segm size:           999 bytes     avg segm size:             0 bytes
     max win adv:            5840 bytes     max win adv:               0 bytes
     min win adv:            5840 bytes     min win adv:               0 bytes
     zero win adv:              0 times     zero win adv:              0 times
     avg win adv:            5840 bytes     avg win adv:               0 bytes
     initial window:       201000 bytes     initial window:            0 bytes
     initial window:          201 pkts      initial window:            0 pkts
     ttl stream length:    201000 bytes     ttl stream length:        NA     
     missed data:               0 bytes     missed data:              NA     
     truncated data:            0 bytes     truncated data:            0 bytes
     truncated packets:         0 pkts      truncated packets:         0 pkts
     data xmit time:       20.909 secs      data xmit time:        0.000 secs
     idletime max:         3109.6 ms        idletime max:             NA ms  
     throughput:             8726 Bps       throughput:                0 Bps 
  ================================
  TCP connection 2:
 host c:        192.168.105.237:36070
 host d:        192.168.105.211:20001
 complete conn: yes
 first packet:  Sun Oct 16 16:21:21.332520 2005
 last packet:   Sun Oct 16 16:21:41.332416 2005
 elapsed time:  0:00:19.999896
 total packets: 340
 filename:      linksharing.ethereal
   c->d:         d->c:
     total packets:           172           total packets:           168     
     ack pkts sent:           171           ack pkts sent:           168     
     pure acks sent:            2           pure acks sent:          166     
     sack pkts sent:            0           sack pkts sent:            0     
     dsack pkts sent:           0           dsack pkts sent:           0     
     max sack blks/ack:         0           max sack blks/ack:         0     
     unique bytes sent:    168000           unique bytes sent:         0     
     actual data pkts:        168           actual data pkts:          0     
     actual data bytes:    168000           actual data bytes:         0     
     rexmt data pkts:           0           rexmt data pkts:           0     
     rexmt data bytes:          0           rexmt data bytes:          0     
     zwnd probe pkts:           0           zwnd probe pkts:           0     
     zwnd probe bytes:          0           zwnd probe bytes:          0     
     outoforder pkts:           0           outoforder pkts:           0     
     pushed data pkts:        166           pushed data pkts:          0     
     SYN/FIN pkts sent:       1/1           SYN/FIN pkts sent:       1/1     
     req 1323 ws/ts:          Y/Y           req 1323 ws/ts:          Y/Y     
     adv wind scale:            0           adv wind scale:            0     
     req sack:                  Y           req sack:                  Y     
     sacks sent:                0           sacks sent:                0     
     urgent data pkts:          0 pkts      urgent data pkts:          0 pkts
     urgent data bytes:         0 bytes     urgent data bytes:         0 bytes
     mss requested:          1460 bytes     mss requested:          1460 bytes
     max segm size:          1448 bytes     max segm size:             0 bytes
     min segm size:           552 bytes     min segm size:             0 bytes
     avg segm size:           999 bytes     avg segm size:             0 bytes
     max win adv:            5840 bytes     max win adv:           64000 bytes
     min win adv:            5840 bytes     min win adv:            8000 bytes
     zero win adv:              0 times     zero win adv:              0 times
     avg win adv:            5840 bytes     avg win adv:           60610 bytes
     initial window:         1000 bytes     initial window:            0 bytes
     initial window:            1 pkts      initial window:            0 pkts
     ttl stream length:    168000 bytes     ttl stream length:         0 bytes
     missed data:               0 bytes     missed data:               0 bytes
     truncated data:            0 bytes     truncated data:            0 bytes
     truncated packets:         0 pkts      truncated packets:         0 pkts
     data xmit time:       17.847 secs      data xmit time:        0.000 secs
     idletime max:         3104.7 ms        idletime max:         3019.2 ms  
     throughput:             8400 Bps       throughput:                0 Bps 
  ================================
  TCP connection 3:
 host e:        192.168.105.237:36071
 host f:        192.168.105.211:20002
 complete conn: yes
 first packet:  Sun Oct 16 16:21:21.332771 2005
 last packet:   Sun Oct 16 16:21:38.378520 2005
 elapsed time:  0:00:17.045748
 total packets: 341
 filename:      linksharing.ethereal
   e->f:         f->e:
     total packets:           172           total packets:           169     
     ack pkts sent:           171           ack pkts sent:           169     
     pure acks sent:            2           pure acks sent:          167     
     sack pkts sent:            0           sack pkts sent:            0     
     dsack pkts sent:           0           dsack pkts sent:           0     
     max sack blks/ack:         0           max sack blks/ack:         0     
     unique bytes sent:    168000           unique bytes sent:         0     
     actual data pkts:        168           actual data pkts:          0     
     actual data bytes:    168000           actual data bytes:         0     
     rexmt data pkts:           0           rexmt data pkts:           0     
     rexmt data bytes:          0           rexmt data bytes:          0     
     zwnd probe pkts:           0           zwnd probe pkts:           0     
     zwnd probe bytes:          0           zwnd probe bytes:          0     
     outoforder pkts:           0           outoforder pkts:           0     
     pushed data pkts:        167           pushed data pkts:          0     
     SYN/FIN pkts sent:       1/1           SYN/FIN pkts sent:       1/1     
     req 1323 ws/ts:          Y/Y           req 1323 ws/ts:          Y/Y     
     adv wind scale:            0           adv wind scale:            0     
     req sack:                  Y           req sack:                  Y     
     sacks sent:                0           sacks sent:                0     
     urgent data pkts:          0 pkts      urgent data pkts:          0 pkts
     urgent data bytes:         0 bytes     urgent data bytes:         0 bytes
     mss requested:          1460 bytes     mss requested:          1460 bytes
     max segm size:          1448 bytes     max segm size:             0 bytes
     min segm size:           552 bytes     min segm size:             0 bytes
     avg segm size:           999 bytes     avg segm size:             0 bytes
     max win adv:            5840 bytes     max win adv:           64000 bytes
     min win adv:            5840 bytes     min win adv:            8000 bytes
     zero win adv:              0 times     zero win adv:              0 times
     avg win adv:            5840 bytes     avg win adv:           60630 bytes
     initial window:         1000 bytes     initial window:            0 bytes
     initial window:            1 pkts      initial window:            0 pkts
     ttl stream length:    168000 bytes     ttl stream length:         0 bytes
     missed data:               0 bytes     missed data:               0 bytes
     truncated data:            0 bytes     truncated data:            0 bytes
     truncated packets:         0 pkts      truncated packets:         0 pkts
     data xmit time:       14.919 secs      data xmit time:        0.000 secs
     idletime max:         2112.8 ms        idletime max:         2113.0 ms  
     throughput:             9856 Bps       throughput:                0 Bps 

=========================================================================
=========================================================================


 After adding the refered TC rules I've runned the configuration again, I can see that the number of captured packets has decreased a lot (almost half) !! So I've type the following TC command to find out what was effectively sent from PC1 to PC2, "tc -d -s class show dev eth0" and got the following output:

=========================================================================
  class htb 1:11 parent 1:1 leaf 30: prio 0 quantum 1000 rate 10Kbit ceil 100Kbit burst 1611b/8 mpu 0b cburst 1727b/8 mpu 0b level 0
   Sent 42108 bytes 34 pkts (dropped 0, overlimits 0)
   lended: 30 borrowed: 4 giants: 0
   tokens: -758272 ctokens: 106496

  class htb 1:1 root rate 100Kbit ceil 100Kbit burst 1727b/8 mpu 0b cburst 1727b/8 mpu 0b level 7
   Sent 370941 bytes 295 pkts (dropped 0, overlimits 0)
   lended: 12 borrowed: 0 giants: 0
   tokens: 108032 ctokens: 108032

  class htb 1:10 parent 1:1 leaf 20: prio 0 quantum 1000 rate 30Kbit ceil 100Kbit burst 1637b/8 mpu 0b cburst 1727b/8 mpu 0b level 0
   Sent 122770 bytes 89 pkts (dropped 0, overlimits 0)
   lended: 81 borrowed: 8 giants: 0
   tokens: -415481 ctokens: 100352

  class htb 1:12 parent 1:1 leaf 40: prio 0 quantum 1000 rate 60Kbit ceil 100Kbit burst 1675b/8 mpu 0b cburst 1727b/8 mpu 0b level 0
   Sent 206063 bytes 172 pkts (dropped 0, overlimits 0)
   lended: 172 borrowed: 0 giants: 0
   tokens: 174507 ctokens: 108032
=========================================================================

So we can see that before the TC rules, I Had about 537kbytes transfered (201k+168k+168k), after having applied the TC rules I've only got a total of 370.941 bytes !!!!!!!! Where have they gone ?

I've also plotted a graph with gnuplot, showing me that (somehow) my rules were "correct", I've got an average value of 30kbits/s, a 10kbits/s and a 60kbits/s.

Is it normal that some packets get dropped by the rules or not (taking into account my test configuration) ?

This is my last researched subject in my master thesis (www.fe.up.pt/si/teses_posgrad.tese?p_sigla=MEEC&P_ALU_NUMERO=030553029), and this is the only thing that has kept me from finishing it !!!

Thanks lot for your answers !!

Best regards.


Paulo Augusto

 

_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux