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) |
| 10 | r=$(ssh $CTRL_C "sudo killall nfd" 2>&1) |
| 11 | r=$(sudo killall nfd 2>&1) |
| 12 | } |
| 13 | |
| 14 | mkdir -p logs |
| 15 | |
| 16 | # start nfd and ndn-traffic-server on host C |
| 17 | workdir=$(pwd) |
| 18 | echo "starting nfd and ndn-traffic-server on host C..." |
| 19 | ssh $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 |
| 25 | echo "starting nfd and adding nexthop of ndn:/localhop to C on host B..." |
| 26 | ssh $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 |
| 30 | echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..." |
| 31 | sudo nfd > logs/nfd.log 2>&1 & |
| 32 | sleep 3 |
Eric Newberry | 271f358 | 2015-06-18 20:00:26 -0700 | [diff] [blame] | 33 | nfdc add-nexthop ndn:/localhop udp4://$b_ipaddr |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 34 | if [[ $? -ne 0 ]] |
| 35 | then |
| 36 | echo "Fail to add nexthop of ndn:/localhop" |
| 37 | clean_up |
| 38 | exit 2 |
| 39 | fi |
| 40 | |
| 41 | # From A, send interest ndn:/localhop/test-localhop/A/1 |
| 42 | echo "From A, sending interest ndn:/localhop/test-localhop/A/1..." |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 43 | output=$(ndnpeek -p ndn:/localhop/test-localhop/A/1) |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 44 | if [[ ! -z $output ]] |
| 45 | then |
| 46 | echo "ndn:/localhop/test-localhop/A/1 is answered." |
| 47 | clean_up |
| 48 | exit 4 |
| 49 | fi |
| 50 | |
| 51 | # From B, send interest ndn:/localhop/test-localhop/B/1 |
| 52 | echo "From B, sending interest ndn:/localhop/test-localhop/B/1..." |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 53 | output=$(ssh $CTRL_B "ndnpeek -p ndn:/localhop/test-localhop/B/1") |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 54 | if [[ $output != BBBBBBBB ]] |
| 55 | then |
| 56 | echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output" |
| 57 | clean_up |
| 58 | exit 5 |
| 59 | fi |
| 60 | |
| 61 | # stop ndn-traffic-server and nfd on host C |
| 62 | echo "stopping ndn-traffic-server and nfd on host C..." |
| 63 | ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd" |
| 64 | |
| 65 | # stop nfd on host B |
| 66 | echo "stopping nfd on host B..." |
| 67 | ssh $CTRL_B "sudo killall nfd" |
| 68 | |
| 69 | # stop nfd on host A |
| 70 | echo "stopping nfd on host A..." |
| 71 | sudo killall nfd |
| 72 | |
| 73 | # copy back the server log |
| 74 | echo "copying back ndn-traffic-server log..." |
| 75 | scp $CTRL_C:$workdir/logs/server.log $workdir/logs/ |
| 76 | |
| 77 | # analyze server log |
| 78 | echo "analyzing server log..." |
| 79 | output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2) |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame^] | 80 | if [[ $output != 0?(.+(0)) ]] |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 81 | then |
| 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 |
| 86 | fi |
| 87 | clean_up |
| 88 | echo "Localhop Test PASSED" |