#!/bin/bash

# ensure args were passed
if [ $# -eq 0 ]
  then
   myLatency="10ms"
   myLoss="6%"
   echo "setup.sh:  latency (ms)  loss (percentage)"
   exit -1
else
  myLatency="$1ms"
  myLoss="$2%"
fi

myIF="enp0s17"

# Google netem packet loss
#An optional correlation may also be added. This causes the random number generator to be less random and can be used to emulate packet burst losses.
# tc qdisc change dev eth0 root netem loss 0.3% 25%
# This will cause 0.3% of packets to be lost, and each successive probability depends by a quarter on the last one.
# Probn = .25 * Probn-1 + .75 * Random
#tc qdisc add dev eth0 root netem limit 100 delay 40ms loss 5% 25%
#tc qdisc add dev enp0s8 root netem limit 1000 delay $2ms loss $1%
#tc qdisc add dev enp0s8 root netem limit 1000 delay 30ms loss 10% 

echo "Setting loss rate of $myLoss latency of $myLatency over interface $myIF "
#tc qdisc add dev enp0s17 root netem limit 1000 delay $myLatency loss $myLoss
tc qdisc add dev $myIF root netem limit 1000 delay $myLatency loss $myLoss


