blob: c9e7710177f456c803fefe117fb99bdc53043307 [file] [log] [blame]
Yi Huang9a118b32014-04-22 15:17:51 -07001#!/usr/bin/env bash
2usage=$'Usage: tcp-udp-tunnel-test.sh [tcp|udp][4|6]'
3if [ $# != 1 ]
4then
5 echo "$usage"
6 exit
7fi
8source ../multi-host.conf
9if [[ ($1 = "tcp4") || ($1 = "udp4") ]]
10then
11 ipaddr="$IP4_D1"
12else
13 ipaddr="[$IP6_D1]"
14fi
15echo "host D IP address $ipaddr"
16
17mkdir -p logs
18
19clean_up() {
20 r=$(ssh $CTRL_D "sudo killall ndn-traffic-server;\
21 sleep 1;\
22 sudo killall nfd" 2>&1)
23 r=$(sudo killall nfd 2>&1)
24}
25
26# start nfd on host A
27sudo nfd > logs/nfd.log 2>&1 &
28
29# start nfd and ndn-traffic-server on host D
30echo "starting nfd and ndn-traffic-server on host D..."
31workdir=$(pwd)
32ssh $CTRL_D "mkdir -p $workdir/logs;\
33 sudo nfd &> $workdir/logs/nfd.log &\
34 sleep 3;\
35 ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
36sleep 5
37
38# open a tunnel from host A to host D and set nexthop of ndn:/tunnel-test to D
39echo "preparing tunnel..."
40faceid=$(nfdc create $1://$ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
41if [[ -z $faceid ]]
42then
43 echo "Fail to create face"
44 clean_up
45 exit 1
46fi
47nfdc add-nexthop ndn:/tunnel-test $faceid
48
49# run ndn-traffic client
50echo "running ndn-traffic client..."
51ndn-traffic -c 100 -i 100 NDNTrafficClient.conf > logs/client.log 2>&1
52
53# stop nfd on hostA
54echo "stopping nfd on host A..."
55sudo killall nfd
56
57# stop ndn-traffic-server and nfd on hostB
58echo "stopping ndn-traffic-server and nfd on host B..."
59clean_up
60
61# examine client log
62echo "analyzing results..."
63output=$(grep "Total Interest Loss" $workdir/logs/client.log | head -1 | cut -d= -f2 | cut -d' ' -f2 | cut -d% -f1)
64if [ $output != '0' ]
65then
66 echo "Expected no Interest Loss. Actual: $output%"
67 echo "For more information, please examine the log at \"$(pwd)/logs\""
68 exit 2
69fi
70echo "Tunnel Test PASSED"