#!/bin/sh

defaultconfig=$(dirname $0)/hosts

if [ -z "$2" -a ! -f $defaultconfig ] ; then
	echo "Usage: $(basename $0) <hops> [<config>]"
	exit 1
fi
if [ -z "$1" ] ; then
	echo "Usage: $(basename $0) <hops> [<config>]"
	exit 1
fi

if [ -f "$2" ] ; then
	config=$1
else
	config=$defaultconfig
fi

hosts=$(grep -v -e prefix -e admin -e connection $config | perl -ne 's/=.*//; print')
connection=$(grep connection $config | sed -e 's/.*=//' -e 's/-/ /g')
host=$(echo $connection | cut -d ' ' -f $(($1+1)))

aodvrestart
sleep 1
echo
echo "Pinging from $host to 192.168.0.11..."
ssh msmeasure@$host "ping -c 1 192.168.0.11"
