blob: 88419bf2f1433d700775c1fa0e48fb8e28d6992b [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
Eric Newberry6fc88222015-06-19 10:43:24 -070017mkdir -p logs/$1
Yi Huang9a118b32014-04-22 15:17:51 -070018
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
Eric Newberry6fc88222015-06-19 10:43:24 -070027sudo nfd &> logs/$1/nfd.log &
Yi Huang53fa8712014-06-10 20:14:26 -070028sleep 2
Yi Huang9a118b32014-04-22 15:17:51 -070029
30# start nfd and ndn-traffic-server on host D
31echo "starting nfd and ndn-traffic-server on host D..."
32workdir=$(pwd)
Eric Newberry6fc88222015-06-19 10:43:24 -070033ssh $CTRL_D "mkdir -p $workdir/logs/$1;\
34 sudo nfd &> $workdir/logs/$1/nfd.log &\
Yi Huang9a118b32014-04-22 15:17:51 -070035 sleep 3;\
Eric Newberry6fc88222015-06-19 10:43:24 -070036 ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/$1/server.log 2>&1 &"
Yi Huang9a118b32014-04-22 15:17:51 -070037sleep 5
38
39# open a tunnel from host A to host D and set nexthop of ndn:/tunnel-test to D
40echo "preparing tunnel..."
Eric Newberry7745c1a2017-04-20 00:23:05 -070041nfdc face create $1://$ipaddr
42nfdc route add ndn:/tunnel-test $1://$ipaddr
Yi Huang9a118b32014-04-22 15:17:51 -070043
44# run ndn-traffic client
45echo "running ndn-traffic client..."
Eric Newberry6fc88222015-06-19 10:43:24 -070046ndn-traffic -c 100 -i 100 NDNTrafficClient.conf > logs/$1/client.log 2>&1
Yi Huang9a118b32014-04-22 15:17:51 -070047
48# stop nfd on hostA
49echo "stopping nfd on host A..."
50sudo killall nfd
51
Yi Huang53fa8712014-06-10 20:14:26 -070052# stop ndn-traffic-server and nfd on hostD
53echo "stopping ndn-traffic-server and nfd on host D..."
Yi Huang9a118b32014-04-22 15:17:51 -070054clean_up
55
56# examine client log
57echo "analyzing results..."
Eric Newberry6fc88222015-06-19 10:43:24 -070058output=$(grep "Total Interest Loss" $workdir/logs/$1/client.log | head -1 | cut -d= -f2 | cut -d' ' -f2 | cut -d% -f1)
Eric Newberryafb5c5f2015-06-09 08:57:58 -070059if [[ $output != 0?(.+(0)) ]]
Yi Huang9a118b32014-04-22 15:17:51 -070060then
61 echo "Expected no Interest Loss. Actual: $output%"
Eric Newberry6fc88222015-06-19 10:43:24 -070062 echo "For more information, please examine the log at \"$(pwd)/logs/$1\""
Yi Huang9a118b32014-04-22 15:17:51 -070063 exit 2
64fi
65echo "Tunnel Test PASSED"