File: tbf

package info (click to toggle)
tcng 10b-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,632 kB
  • ctags: 2,515
  • sloc: ansic: 19,038; pascal: 4,640; yacc: 2,619; sh: 1,908; perl: 1,546; lex: 772; makefile: 755
file content (27 lines) | stat: -rw-r--r-- 623 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * tbf - Single TBF shaper
 *
 */

#define RATE 1Mbit	/* be very sure not to use Mbps here ... */
#define BURST  3kB
#define LIMIT 20kB

#define NOTHING
#define PACKET		/* 100-sizeof(iphdr) = 80 bytes. */ \
  IP_PCK(NOTHING) \
  0 x 80

dev eth0 10000 /* 10 Mbps */

tc qdisc add dev eth0 root handle 1:0 tbf limit LIMIT rate RATE burst BURST

every 0.0005s send PACKET		/* 1.6 Mbps */

; Excess: 600 kbps, so we will fill the burst after 24ms, and start
; losing packets 267ms later. We should lose about 532 packets (of
; 2001) or 53200 bytes. Actual numbers vary slightly due to 1024 vs.
; 1000 issues.

time 1s
end