blob: f83d575a99d14303d64757080a633fce839dcca7 [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 Newberry7745c1a2017-04-20 00:23:05 -070034nfdc face create udp4://$b_ipaddr
35nfdc route add ndn:/localhop udp4://$b_ipaddr
Yi Huang401f7962014-04-20 11:13:36 -070036if [[ $? -ne 0 ]]
37then
Eric Newberryf3248ea2016-08-07 11:48:50 -070038 echo "Failed to add nexthop of ndn:/localhop"
Yi Huang401f7962014-04-20 11:13:36 -070039 clean_up
40 exit 2
41fi
42
Eric Newberryf3248ea2016-08-07 11:48:50 -070043# On B, add nexthop of `ndn:/localhop` to C
Eric Newberry7745c1a2017-04-20 00:23:05 -070044ssh $CTRL_B "nfdc face create udp4://$c_ipaddr"
45ssh $CTRL_B "nfdc route add ndn:/localhop udp4://$c_ipaddr"
Eric Newberryf3248ea2016-08-07 11:48:50 -070046
47# On C, start ndn-traffic-server
48echo "starting ndn-traffic-server on host C..."
49ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
50
51# From A, send interest ndn:/localhop/test-localhop/1
52echo "From A, sending interest ndn:/localhop/test-localhop/1..."
53output=$(ndnpeek -p ndn:/localhop/test-localhop/1)
54if [[ $? == "0" ]]
Yi Huang401f7962014-04-20 11:13:36 -070055then
Eric Newberryf3248ea2016-08-07 11:48:50 -070056 echo "Interest ndn:/localhop/test-localhop/1 answered with a Data."
Yi Huang401f7962014-04-20 11:13:36 -070057 clean_up
58 exit 4
59fi
60
Eric Newberryf3248ea2016-08-07 11:48:50 -070061echo "stopping nfd and ndn-traffic-server instances..."
62clean_up
Yi Huang401f7962014-04-20 11:13:36 -070063
64# copy back the server log
65echo "copying back ndn-traffic-server log..."
66scp $CTRL_C:$workdir/logs/server.log $workdir/logs/
67
68# analyze server log
69echo "analyzing server log..."
70output=$(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 -070071# output can be empty due to a receive error (End of file)
72if [[ -n $output ]] && [[ $output != 0?(.+(0)) ]]
Yi Huang401f7962014-04-20 11:13:36 -070073then
Eric Newberryf3248ea2016-08-07 11:48:50 -070074 echo "Expected no interests with name ndn:/localhop/test-localhop/1 to be received on host C. Actual: '$output'"
75 echo "For more information, please examine the logs at \"$(pwd)/logs\""
Yi Huang401f7962014-04-20 11:13:36 -070076 clean_up
77 exit 3
78fi
79clean_up
80echo "Localhop Test PASSED"