entrypoint.sh 735 Bytes
Newer Older
1 2 3 4 5 6 7
#!/bin/bash

dev=eth0

command=$1
shift

8
if [[ "$command" == "sender" || "$command" == "receiver" ]]; then
9 10 11
    :
else
    echo "Command should be either sender or receiver."
12
    exit 0;
13 14
fi

15 16 17 18 19
NETEM=()
PRRT=()
while [[ $# -gt 0 ]]
do
key="$1"
20

21 22 23 24 25 26 27 28 29 30 31 32
case $key in
    -t|--target|-p|--port|-r|--rounds)
    PRRT+=("$1 $2")
    shift
    shift
    ;;
    *)    # unknown option
    NETEM+=("$1") # save it in an array for later
    shift # past argument
    ;;
esac
done
33

34 35
PRRT_PARAMS="${PRRT[@]}"
NETEM_PARAMS="${NETEM[@]}"
36

37 38 39
echo "Running PRRT with command: \"$command $PRRT_PARAMS\" and link parameters: \"$NETEM_PARAMS\""

tc qdisc add dev $dev root netem $NETEM_PARAMS
40
/prrt/$command $PRRT_PARAMS -o /output/log.csv
41
tc qdisc del dev $dev root