Integrated use of netem with testnet scripts (#6746)

automerge
This commit is contained in:
Pankaj Garg
2019-11-05 15:04:06 -08:00
committed by Grimes
parent 8f91b5aab3
commit 8993b15248
3 changed files with 38 additions and 0 deletions

20
scripts/netem.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Start/Stop network emulation
#
set -e
[[ $(uname) == Linux ]] || exit 0
cd "$(dirname "$0")"
sudo=
if sudo true; then
sudo="sudo -n"
fi
set -x
iface="$(ifconfig | grep mtu | grep -iv loopback | grep -i running | awk 'BEGIN { FS = ":" } ; {print $1}')"
# shellcheck disable=SC2086 # Do not want to quote $2. It has space separated arguments for netem
$sudo tc qdisc "$1" dev "$iface" root netem $2