blob: 19aa09932cf1c3f16000cebff169a48650c759a0 [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;\
Yi Huang53fa8712014-06-10 20:14:26 -070022 nrd > $workdir/logs/nrd.log 2>&1 &\
23 sleep 3;\
Yi Huang401f7962014-04-20 11:13:36 -070024 ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
25
26# start nfd and add nexthop of ndn:/localhop to C on host B
27echo "starting nfd and adding nexthop of ndn:/localhop to C on host B..."
28ssh $CTRL_B "mkdir -p $workdir/logs;\
29 $workdir/hostB.sh $workdir $c_ipaddr"
30
31# start nfd and add nexthop of ndn:/localhop to B on host A
32echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..."
33sudo nfd > logs/nfd.log 2>&1 &
34sleep 3
Yi Huang53fa8712014-06-10 20:14:26 -070035nrd > logs/nrd.log 2>&1 &
36sleep 3
Yi Huang401f7962014-04-20 11:13:36 -070037faceid=$(nfdc create udp4://$b_ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
38nfdc add-nexthop ndn:/localhop $faceid
39if [[ $? -ne 0 ]]
40then
41 echo "Fail to add nexthop of ndn:/localhop"
42 clean_up
43 exit 2
44fi
45
46# From A, send interest ndn:/localhop/test-localhop/A/1
47echo "From A, sending interest ndn:/localhop/test-localhop/A/1..."
48output=$(ndn-tlv-peek -p ndn:/localhop/test-localhop/A/1)
49if [[ ! -z $output ]]
50then
51 echo "ndn:/localhop/test-localhop/A/1 is answered."
52 clean_up
53 exit 4
54fi
55
56# From B, send interest ndn:/localhop/test-localhop/B/1
57echo "From B, sending interest ndn:/localhop/test-localhop/B/1..."
58output=$(ssh $CTRL_B "ndn-tlv-peek -p ndn:/localhop/test-localhop/B/1")
59if [[ $output != BBBBBBBB ]]
60then
61 echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output"
62 clean_up
63 exit 5
64fi
65
66# stop ndn-traffic-server and nfd on host C
67echo "stopping ndn-traffic-server and nfd on host C..."
68ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
69
70# stop nfd on host B
71echo "stopping nfd on host B..."
72ssh $CTRL_B "sudo killall nfd"
73
74# stop nfd on host A
75echo "stopping nfd on host A..."
76sudo killall nfd
77
78# copy back the server log
79echo "copying back ndn-traffic-server log..."
80scp $CTRL_C:$workdir/logs/server.log $workdir/logs/
81
82# analyze server log
83echo "analyzing server log..."
84output=$(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 -070085if [ $output != 0?(.+(0)) ]
Yi Huang401f7962014-04-20 11:13:36 -070086then
87 echo "Expected no interests with name ndn:/localhop/test-localhop/A/1 received on host C. Actual: $output"
88 echo "For more information, please examine the log at \"$(pwd)/logs\""
89 clean_up
90 exit 3
91fi
92clean_up
93echo "Localhop Test PASSED"