#! /bin/bash
# Estimates connection speed to your ISP

ISP="www.mindspring.com"
[ $ISP == "www.mindspring.com" ] && {
	echo "Be nice to MindSpring; put in your own ISP's name here."
	echo "For best effect, mention the gateway your ISP assigned to you,"
	echo "their nameserver, or their website."
}

# Check if 'traceroute' is installed on the system
[ -z `which traceroute` ] && {
    echo "\"${0:2}\" requires 'traceroute' to be installed."
    exit
}

# Check if 'bing' is installed on the system
[ -z `which bing` ] && {
    echo "\"${0:2}\" requires 'bing' to be installed"
    exit
}

remote=`time traceroute -m 1 $ISP 2>/dev/null|awk '{gsub("\(|\)","");print $3 " " $4}'`
echo -e "Ping time to ISP:" $(echo $remote|awk '{print $2}') "ms\nMeasuring speed...\n"
bing -c 1 -e 20 -S 1024 localhost $(echo $remote|awk '{print $1}') 2>&1|grep throughput
