blob: ace5b0aa7d4a32bac4646e2714ace406bbb51cbe [file] [log] [blame]
#!/usr/bin/env bash
usage=$'Usage: tcp-udp-tunnel-test.sh [tcp|udp][4|6]'
if [ $# != 1 ]
then
echo "$usage"
exit
fi
source ../multi-host.conf
if [[ ($1 = "tcp4") || ($1 = "udp4") ]]
then
ipaddr="$IP4_D1"
else
ipaddr="[$IP6_D1]"
fi
echo "host D IP address $ipaddr"
mkdir -p logs/$1
clean_up() {
r=$(ssh $CTRL_D "sudo killall ndn-traffic-server;\
sleep 1;\
sudo killall nfd" 2>&1)
r=$(sudo killall nfd 2>&1)
}
# start nfd on host A
sudo nfd &> logs/$1/nfd.log &
sleep 2
# start nfd and ndn-traffic-server on host D
echo "starting nfd and ndn-traffic-server on host D..."
workdir=$(pwd)
ssh $CTRL_D "mkdir -p $workdir/logs/$1;\
sudo nfd &> $workdir/logs/$1/nfd.log &\
sleep 3;\
ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/$1/server.log 2>&1 &"
sleep 5
# open a tunnel from host A to host D and set nexthop of ndn:/tunnel-test to D
echo "preparing tunnel..."
nfdc face create $1://$ipaddr
nfdc route add ndn:/tunnel-test $1://$ipaddr
# run ndn-traffic-client
echo "running ndn-traffic-client..."
ndn-traffic-client -c 100 -i 100 NDNTrafficClient.conf > logs/$1/client.log 2>&1
# stop nfd on hostA
echo "stopping nfd on host A..."
sudo killall nfd
# stop ndn-traffic-server and nfd on hostD
echo "stopping ndn-traffic-server and nfd on host D..."
clean_up
# examine client log
echo "analyzing results..."
output=$(grep "Total Interest Loss" $workdir/logs/$1/client.log | head -1 | cut -d= -f2 | cut -d' ' -f2 | cut -d% -f1)
if [[ $output != 0?(.+(0)) ]]
then
echo "Expected no Interest Loss. Actual: $output%"
echo "For more information, please examine the log at \"$(pwd)/logs/$1\""
exit 2
fi
echo "Tunnel Test PASSED"