/[projects]/trafficcontrol/trafficcontrol.sh
ViewVC logotype

Contents of /trafficcontrol/trafficcontrol.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 112 - (show annotations) (download) (as text)
Thu Oct 9 11:24:43 2008 UTC (15 years, 7 months ago) by torben
File MIME type: application/x-sh
File size: 889 byte(s)
Netem is apparently designed for handling all options in one qdisc

1 #!/bin/bash
2
3 IF0=eth0
4 IF1=eth2
5
6 function clear_tc()
7 {
8 tc qdisc del dev $IF0 root 2>/dev/null >/dev/null
9 tc qdisc del dev $IF1 root 2>/dev/null >/dev/null
10 }
11
12 if [ "$1" == "clear" ] ; then
13 clear_tc
14 exit
15 fi
16
17
18 if [ $# -lt "3" ] ; then
19 echo "Usage: $0 <bandwidth> <delay> <delay-variation> [packet-loss]"
20 echo "eg.: $0 2mbit 50ms 0ms"
21 echo "eg.: $0 56kbit 100ms 10ms 0.8%"
22 echo ""
23 echo "or: $0 clear"
24 exit
25 fi
26
27 DIST="distribution normal"
28
29 if [ $3 == "0ms" ] ; then
30 DIST=""
31 fi
32
33 LOSS=""
34 if [ $# == "4" ] ; then
35 #packetloss fails if the simulated bandwidth is to small
36 #tc qdisc add dev $IF1 parent 1:1 netem loss $4
37 LOSS="loss $4"
38 fi
39
40 clear_tc
41
42 tc qdisc add dev $IF0 root handle 1: tbf rate $1 buffer 100000 limit 300000
43 tc qdisc add dev $IF0 parent 1:1 handle 2: netem delay $2 $3 $DIST $LOSS
44
45 tc qdisc add dev $IF1 root handle 1: tbf rate $1 buffer 100000 limit 300000
46
47
48 tc qdisc

  ViewVC Help
Powered by ViewVC 1.1.20