Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | source ../multi-host.conf |
| 3 | b_ipaddr=$IP4_B1 |
| 4 | c_ipaddr=$IP4_C1 |
| 5 | echo "host B IP address $b_ipaddr" |
| 6 | echo "host C IP address $c_ipaddr" |
| 7 | |
| 8 | clean_up() { |
| 9 | r=$(ssh $CTRL_B "sudo killall nfd" 2>&1) |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 10 | r=$(ssh $CTRL_C "sudo killall nfd-traffic-server" 2>&1) |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 11 | r=$(ssh $CTRL_C "sudo killall nfd" 2>&1) |
| 12 | r=$(sudo killall nfd 2>&1) |
| 13 | } |
| 14 | |
| 15 | mkdir -p logs |
| 16 | |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 17 | # Start NFD on A, B, and C |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 18 | workdir=$(pwd) |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 19 | echo "starting nfd on host A..." |
| 20 | sudo nfd > $workdir/logs/nfd.log 2>&1 & |
| 21 | sleep 1 |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 22 | |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 23 | echo "starting nfd on host B..." |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 24 | ssh $CTRL_B "mkdir -p $workdir/logs;\ |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 25 | sudo nfd &> $workdir/logs/nfd.log &" |
| 26 | sleep 1 |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 27 | |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 28 | echo "starting nfd on host C..." |
| 29 | ssh $CTRL_C "mkdir -p $workdir/logs;\ |
| 30 | sudo nfd &> $workdir/logs/nfd.log &" |
| 31 | sleep 1 |
| 32 | |
| 33 | # On A, add nexthop of `ndn:/localhop` to B |
Eric Newberry | 7745c1a | 2017-04-20 00:23:05 -0700 | [diff] [blame] | 34 | nfdc face create udp4://$b_ipaddr |
| 35 | nfdc route add ndn:/localhop udp4://$b_ipaddr |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 36 | if [[ $? -ne 0 ]] |
| 37 | then |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 38 | echo "Failed to add nexthop of ndn:/localhop" |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 39 | clean_up |
| 40 | exit 2 |
| 41 | fi |
| 42 | |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 43 | # On B, add nexthop of `ndn:/localhop` to C |
Eric Newberry | 7745c1a | 2017-04-20 00:23:05 -0700 | [diff] [blame] | 44 | ssh $CTRL_B "nfdc face create udp4://$c_ipaddr" |
| 45 | ssh $CTRL_B "nfdc route add ndn:/localhop udp4://$c_ipaddr" |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 46 | |
| 47 | # On C, start ndn-traffic-server |
| 48 | echo "starting ndn-traffic-server on host C..." |
| 49 | ssh $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 |
| 52 | echo "From A, sending interest ndn:/localhop/test-localhop/1..." |
| 53 | output=$(ndnpeek -p ndn:/localhop/test-localhop/1) |
| 54 | if [[ $? == "0" ]] |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 55 | then |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 56 | echo "Interest ndn:/localhop/test-localhop/1 answered with a Data." |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 57 | clean_up |
| 58 | exit 4 |
| 59 | fi |
| 60 | |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 61 | echo "stopping nfd and ndn-traffic-server instances..." |
| 62 | clean_up |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 63 | |
| 64 | # copy back the server log |
| 65 | echo "copying back ndn-traffic-server log..." |
| 66 | scp $CTRL_C:$workdir/logs/server.log $workdir/logs/ |
| 67 | |
| 68 | # analyze server log |
| 69 | echo "analyzing server log..." |
| 70 | output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2) |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 71 | # output can be empty due to a receive error (End of file) |
| 72 | if [[ -n $output ]] && [[ $output != 0?(.+(0)) ]] |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 73 | then |
Eric Newberry | f3248ea | 2016-08-07 11:48:50 -0700 | [diff] [blame] | 74 | 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 Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 76 | clean_up |
| 77 | exit 3 |
| 78 | fi |
| 79 | clean_up |
| 80 | echo "Localhop Test PASSED" |