Last active
August 18, 2016 04:23
-
-
Save ffund/2515f9cb5f735fadde7237ca29df0722 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script accepts three arguments: the destination (to ping, and from which to retrieve files), | |
# the total duration for which to generate traffic (in seconds), and the time to wait before starting | |
# to generate traffic (in seconds). | |
addr=$1 | |
time=$2 | |
wait=$3 | |
lastwait=$(expr 260 - $wait - $time) | |
# Make sure the delay is set on the link | |
sudo tc qdisc replace dev eth1 root netem delay 100ms | |
# Start pinging the destination | |
sudo ping -i 0.1 -c 2600 $addr > originalping.csv & | |
sleep $wait | |
starttime=$(date '+%H:%M:%S'); | |
echo "start getting files from" $addr "at" "$starttime" | |
shift 2 | |
i=1 | |
while [ $i -lt 21 ] | |
do | |
wget -q -O/dev/null ftp://$addr/test"$i".dat & | |
i=$(($i+1)) | |
done | |
sleep $time | |
#PID=`ps -ef | grep ftp | grep -v "grep" | awk '{print $2}'` | |
#kill -9 $PID | |
sudo kill -9 `ps -ef | grep ftp | grep -v grep | awk '{print $2}'` | |
endtime=$(date '+%H:%M:%S'); | |
echo "stop getting files from" $addr "at" "$endtime" | |
sleep $lastwait | |
tail -n+2 originalping.csv | head -n-4 > middleping.csv | |
awk -F "[: ]" '{print $7","$9}' middleping.csv | sed -e "s/icmp_seq=//" | sed -e "s/time=//" | awk -F',' '{$2 = $2 - 100; print $1","$2}' > ping_delay.csv | |
gnuplot /usr/local/bin/plot-ping-delay.gp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment