blob: 549b8d1b63ea8d4218974a716b5c8362ff840d4c [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)
Eric Newberryf3248ea2016-08-07 11:48:50 -070010 r=$(ssh $CTRL_C "sudo killall nfd-traffic-server" 2>&1)
Yi Huang401f7962014-04-20 11:13:36 -070011 r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
12 r=$(sudo killall nfd 2>&1)
13}
14
15mkdir -p logs
16
Eric Newberryf3248ea2016-08-07 11:48:50 -070017# Start NFD on A, B, and C
Yi Huang401f7962014-04-20 11:13:36 -070018workdir=$(pwd)
Eric Newberryf3248ea2016-08-07 11:48:50 -070019echo "starting nfd on host A..."
20sudo nfd > $workdir/logs/nfd.log 2>&1 &
21sleep 1
Yi Huang401f7962014-04-20 11:13:36 -070022
Eric Newberryf3248ea2016-08-07 11:48:50 -070023echo "starting nfd on host B..."
Yi Huang401f7962014-04-20 11:13:36 -070024ssh $CTRL_B "mkdir -p $workdir/logs;\
Eric Newberryf3248ea2016-08-07 11:48:50 -070025 sudo nfd &> $workdir/logs/nfd.log &"
26sleep 1
Yi Huang401f7962014-04-20 11:13:36 -070027
Eric Newberryf3248ea2016-08-07 11:48:50 -070028echo "starting nfd on host C..."
29ssh $CTRL_C "mkdir -p $workdir/logs;\
30 sudo nfd &> $workdir/logs/nfd.log &"
31sleep 1
32
33# On A, add nexthop of `ndn:/localhop` to B
Eric Newberry271f3582015-06-18 20:00:26 -070034nfdc add-nexthop ndn:/localhop udp4://$b_ipaddr
Yi Huang401f7962014-04-20 11:13:36 -070035if [[ $? -ne 0 ]]
36then
Eric Newberryf3248ea2016-08-07 11:48:50 -070037 echo "Failed to add nexthop of ndn:/localhop"
Yi Huang401f7962014-04-20 11:13:36 -070038 clean_up
39 exit 2
40fi
41
Eric Newberryf3248ea2016-08-07 11:48:50 -070042# On B, add nexthop of `ndn:/localhop` to C
43ssh $CTRL_B "nfdc add-nexthop ndn:/localhop udp4://$c_ipaddr"
44
45# On C, start ndn-traffic-server
46echo "starting ndn-traffic-server on host C..."
47ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
48
49# From A, send interest ndn:/localhop/test-localhop/1
50echo "From A, sending interest ndn:/localhop/test-localhop/1..."
51output=$(ndnpeek -p ndn:/localhop/test-localhop/1)
52if [[ $? == "0" ]]
Yi Huang401f7962014-04-20 11:13:36 -070053then
Eric Newberryf3248ea2016-08-07 11:48:50 -070054 echo "Interest ndn:/localhop/test-localhop/1 answered with a Data."
Yi Huang401f7962014-04-20 11:13:36 -070055 clean_up
56 exit 4
57fi
58
Eric Newberryf3248ea2016-08-07 11:48:50 -070059echo "stopping nfd and ndn-traffic-server instances..."
60clean_up
Yi Huang401f7962014-04-20 11:13:36 -070061
62# copy back the server log
63echo "copying back ndn-traffic-server log..."
64scp $CTRL_C:$workdir/logs/server.log $workdir/logs/
65
66# analyze server log
67echo "analyzing server log..."
68output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2)
Eric Newberryf3248ea2016-08-07 11:48:50 -070069# output can be empty due to a receive error (End of file)
70if [[ -n $output ]] && [[ $output != 0?(.+(0)) ]]
Yi Huang401f7962014-04-20 11:13:36 -070071then
Eric Newberryf3248ea2016-08-07 11:48:50 -070072 echo "Expected no interests with name ndn:/localhop/test-localhop/1 to be received on host C. Actual: '$output'"
73 echo "For more information, please examine the logs at \"$(pwd)/logs\""
Yi Huang401f7962014-04-20 11:13:36 -070074 clean_up
75 exit 3
76fi
77clean_up
78echo "Localhop Test PASSED"