blob: 61374d9e494e88132ec8fc976e1293f18e03e0e8 [file] [log] [blame]
Yi Huang401f7962014-04-20 11:13:36 -07001#!/bin/bash
2source ../multi-host.conf
3b_ipaddr=$IP4_B1
4c_ipaddr=$IP4_C1
5echo "host B IP address $b_ipaddr"
6echo "host C IP address $c_ipaddr"
7
8clean_up() {
9 r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
10 r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
11 r=$(sudo killall nfd 2>&1)
12}
13
14mkdir -p logs
15
16# start nfd and ndn-traffic-server on host C
17workdir=$(pwd)
18echo "starting nfd and ndn-traffic-server on host C..."
19ssh $CTRL_C "mkdir -p $workdir/logs;\
20 sudo nfd > $workdir/logs/nfd.log 2>&1 &\
21 sleep 3;\
22 ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
23
24# start nfd and add nexthop of ndn:/localhop to C on host B
25echo "starting nfd and adding nexthop of ndn:/localhop to C on host B..."
26ssh $CTRL_B "mkdir -p $workdir/logs;\
27 $workdir/hostB.sh $workdir $c_ipaddr"
28
29# start nfd and add nexthop of ndn:/localhop to B on host A
30echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..."
31sudo nfd > logs/nfd.log 2>&1 &
32sleep 3
Yi Huang401f7962014-04-20 11:13:36 -070033faceid=$(nfdc create udp4://$b_ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
34nfdc add-nexthop ndn:/localhop $faceid
35if [[ $? -ne 0 ]]
36then
37 echo "Fail to add nexthop of ndn:/localhop"
38 clean_up
39 exit 2
40fi
41
42# From A, send interest ndn:/localhop/test-localhop/A/1
43echo "From A, sending interest ndn:/localhop/test-localhop/A/1..."
Eric Newberryd4ed6222015-06-10 14:12:42 -070044output=$(ndnpeek -p ndn:/localhop/test-localhop/A/1)
Yi Huang401f7962014-04-20 11:13:36 -070045if [[ ! -z $output ]]
46then
47 echo "ndn:/localhop/test-localhop/A/1 is answered."
48 clean_up
49 exit 4
50fi
51
52# From B, send interest ndn:/localhop/test-localhop/B/1
53echo "From B, sending interest ndn:/localhop/test-localhop/B/1..."
Eric Newberryd4ed6222015-06-10 14:12:42 -070054output=$(ssh $CTRL_B "ndnpeek -p ndn:/localhop/test-localhop/B/1")
Yi Huang401f7962014-04-20 11:13:36 -070055if [[ $output != BBBBBBBB ]]
56then
57 echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output"
58 clean_up
59 exit 5
60fi
61
62# stop ndn-traffic-server and nfd on host C
63echo "stopping ndn-traffic-server and nfd on host C..."
64ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
65
66# stop nfd on host B
67echo "stopping nfd on host B..."
68ssh $CTRL_B "sudo killall nfd"
69
70# stop nfd on host A
71echo "stopping nfd on host A..."
72sudo killall nfd
73
74# copy back the server log
75echo "copying back ndn-traffic-server log..."
76scp $CTRL_C:$workdir/logs/server.log $workdir/logs/
77
78# analyze server log
79echo "analyzing server log..."
80output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2)
Eric Newberryafb5c5f2015-06-09 08:57:58 -070081if [ $output != 0?(.+(0)) ]
Yi Huang401f7962014-04-20 11:13:36 -070082then
83 echo "Expected no interests with name ndn:/localhop/test-localhop/A/1 received on host C. Actual: $output"
84 echo "For more information, please examine the log at \"$(pwd)/logs\""
85 clean_up
86 exit 3
87fi
88clean_up
89echo "Localhop Test PASSED"