aboutsummaryrefslogtreecommitdiffstats
path: root/tests/channel.sh
blob: 28a187e72565e11be1254e4d1d40c92932901d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

set -e

DEV=$2
RATE=$3mbit
DELAY=$4ms
JITTER=$5ms
LOSS=$6

if [[ $1 -eq "set" ]]; then
    tc qdisc add dev "$DEV" root handle 1:0 htb default 1
    tc class add dev "$DEV" parent 1:0 classid 1:1 htb rate "$RATE"
    tc qdisc add dev "$DEV" parent 1:1 handle 2:0 netem delay "$DELAY"
    "$JITTER" loss random "$LOSS"
    echo "Dev: $DEV, rate: $RATE, delay: $DELAY, jitter: $JITTER, loss: $LOSS%"
elif [[ $1 -eq "change" ]]; then
    tc qdisc change dev "$DEV" parent 1:1 handle 2:0 netem delay "$DELAY" "$JITTER" loss random "$LOSS"
    echo "Dev: $DEV, rate: $RATE, delay: $DELAY, jitter: $JITTER, loss: $LOSS%"
else
    echo "set or change"
fi