blob: 796fb95d056efc90ef7aa1fa75c8eb543af45414 [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
Eric Newberry271f3582015-06-18 20:00:26 -070033nfdc add-nexthop ndn:/localhop udp4://$b_ipaddr
Yi Huang401f7962014-04-20 11:13:36 -070034if [[ $? -ne 0 ]]
35then
36 echo "Fail to add nexthop of ndn:/localhop"
37 clean_up
38 exit 2
39fi
40
41# From A, send interest ndn:/localhop/test-localhop/A/1
42echo "From A, sending interest ndn:/localhop/test-localhop/A/1..."
Eric Newberryd4ed6222015-06-10 14:12:42 -070043output=$(ndnpeek -p ndn:/localhop/test-localhop/A/1)
Yi Huang401f7962014-04-20 11:13:36 -070044if [[ ! -z $output ]]
45then
46 echo "ndn:/localhop/test-localhop/A/1 is answered."
47 clean_up
48 exit 4
49fi
50
51# From B, send interest ndn:/localhop/test-localhop/B/1
52echo "From B, sending interest ndn:/localhop/test-localhop/B/1..."
Eric Newberryd4ed6222015-06-10 14:12:42 -070053output=$(ssh $CTRL_B "ndnpeek -p ndn:/localhop/test-localhop/B/1")
Yi Huang401f7962014-04-20 11:13:36 -070054if [[ $output != BBBBBBBB ]]
55then
56 echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output"
57 clean_up
58 exit 5
59fi
60
61# stop ndn-traffic-server and nfd on host C
62echo "stopping ndn-traffic-server and nfd on host C..."
63ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
64
65# stop nfd on host B
66echo "stopping nfd on host B..."
67ssh $CTRL_B "sudo killall nfd"
68
69# stop nfd on host A
70echo "stopping nfd on host A..."
71sudo killall nfd
72
73# copy back the server log
74echo "copying back ndn-traffic-server log..."
75scp $CTRL_C:$workdir/logs/server.log $workdir/logs/
76
77# analyze server log
78echo "analyzing server log..."
79output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2)
Eric Newberry6fc88222015-06-19 10:43:24 -070080if [[ $output != 0?(.+(0)) ]]
Yi Huang401f7962014-04-20 11:13:36 -070081then
82 echo "Expected no interests with name ndn:/localhop/test-localhop/A/1 received on host C. Actual: $output"
83 echo "For more information, please examine the log at \"$(pwd)/logs\""
84 clean_up
85 exit 3
86fi
87clean_up
88echo "Localhop Test PASSED"