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;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 22 | nrd > $workdir/logs/nrd.log 2>&1 &\ |
| 23 | sleep 3;\ |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 24 | ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &" |
| 25 | |
| 26 | # start nfd and add nexthop of ndn:/localhop to C on host B |
| 27 | echo "starting nfd and adding nexthop of ndn:/localhop to C on host B..." |
| 28 | ssh $CTRL_B "mkdir -p $workdir/logs;\ |
| 29 | $workdir/hostB.sh $workdir $c_ipaddr" |
| 30 | |
| 31 | # start nfd and add nexthop of ndn:/localhop to B on host A |
| 32 | echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..." |
| 33 | sudo nfd > logs/nfd.log 2>&1 & |
| 34 | sleep 3 |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 35 | nrd > logs/nrd.log 2>&1 & |
| 36 | sleep 3 |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 37 | faceid=$(nfdc create udp4://$b_ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| 38 | nfdc add-nexthop ndn:/localhop $faceid |
| 39 | if [[ $? -ne 0 ]] |
| 40 | then |
| 41 | echo "Fail to add nexthop of ndn:/localhop" |
| 42 | clean_up |
| 43 | exit 2 |
| 44 | fi |
| 45 | |
| 46 | # From A, send interest ndn:/localhop/test-localhop/A/1 |
| 47 | echo "From A, sending interest ndn:/localhop/test-localhop/A/1..." |
| 48 | output=$(ndn-tlv-peek -p ndn:/localhop/test-localhop/A/1) |
| 49 | if [[ ! -z $output ]] |
| 50 | then |
| 51 | echo "ndn:/localhop/test-localhop/A/1 is answered." |
| 52 | clean_up |
| 53 | exit 4 |
| 54 | fi |
| 55 | |
| 56 | # From B, send interest ndn:/localhop/test-localhop/B/1 |
| 57 | echo "From B, sending interest ndn:/localhop/test-localhop/B/1..." |
| 58 | output=$(ssh $CTRL_B "ndn-tlv-peek -p ndn:/localhop/test-localhop/B/1") |
| 59 | if [[ $output != BBBBBBBB ]] |
| 60 | then |
| 61 | echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output" |
| 62 | clean_up |
| 63 | exit 5 |
| 64 | fi |
| 65 | |
| 66 | # stop ndn-traffic-server and nfd on host C |
| 67 | echo "stopping ndn-traffic-server and nfd on host C..." |
| 68 | ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd" |
| 69 | |
| 70 | # stop nfd on host B |
| 71 | echo "stopping nfd on host B..." |
| 72 | ssh $CTRL_B "sudo killall nfd" |
| 73 | |
| 74 | # stop nfd on host A |
| 75 | echo "stopping nfd on host A..." |
| 76 | sudo killall nfd |
| 77 | |
| 78 | # copy back the server log |
| 79 | echo "copying back ndn-traffic-server log..." |
| 80 | scp $CTRL_C:$workdir/logs/server.log $workdir/logs/ |
| 81 | |
| 82 | # analyze server log |
| 83 | echo "analyzing server log..." |
| 84 | output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2) |
Eric Newberry | afb5c5f | 2015-06-09 08:57:58 -0700 | [diff] [blame^] | 85 | if [ $output != 0?(.+(0)) ] |
Yi Huang | 401f796 | 2014-04-20 11:13:36 -0700 | [diff] [blame] | 86 | then |
| 87 | echo "Expected no interests with name ndn:/localhop/test-localhop/A/1 received on host C. Actual: $output" |
| 88 | echo "For more information, please examine the log at \"$(pwd)/logs\"" |
| 89 | clean_up |
| 90 | exit 3 |
| 91 | fi |
| 92 | clean_up |
| 93 | echo "Localhop Test PASSED" |