Yi Huang | a349b2c | 2014-04-27 16:46:03 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | mkdir -p logs |
| 4 | workdir=$(pwd) |
| 5 | |
| 6 | clean_up() { |
| 7 | echo "cleaning up..." |
| 8 | r=$(sudo killall nfd 2>&1) |
| 9 | r=$(ssh $CTRL_B "sudo killall ndn-traffic-server 2>&1; sudo killall nfd 2>&1" 2>&1) |
| 10 | r=$(ssh $CTRL_C "sudo killall ndn-traffic-server 2>&1; sudo killall nfd 2>&1" 2>&1) |
| 11 | r=$(ssh $CTRL_D "sudo killall nfd 2>&1" 2>&1) |
| 12 | } |
| 13 | |
| 14 | # start nfd on all hosts |
| 15 | echo "starting nfd on all hosts..." |
| 16 | ssh $CTRL_B "mkdir -p $workdir/logs;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 17 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 18 | sleep 3;\ |
| 19 | nrd &> $workdir/logs/nrd.log &\ |
| 20 | sleep 3" |
Yi Huang | a349b2c | 2014-04-27 16:46:03 -0700 | [diff] [blame] | 21 | ssh $CTRL_C "mkdir -p $workdir/logs;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 22 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 23 | sleep 3;\ |
| 24 | nrd &> $workdir/logs/nrd.log &\ |
| 25 | sleep 3" |
Yi Huang | a349b2c | 2014-04-27 16:46:03 -0700 | [diff] [blame] | 26 | ssh $CTRL_D "mkdir -p $workdir/logs;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 27 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 28 | sleep 3;\ |
| 29 | nrd &> $workdir/logs/nrd.log &\ |
| 30 | sleep 3" |
Yi Huang | a349b2c | 2014-04-27 16:46:03 -0700 | [diff] [blame] | 31 | sudo nfd &> $workdir/logs/nfd.log & |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame^] | 32 | sleep 3 |
| 33 | nrd &> $workdir/logs/nrd.log & |
Yi Huang | a349b2c | 2014-04-27 16:46:03 -0700 | [diff] [blame] | 34 | sleep 5 |
| 35 | |
| 36 | # start ndn-traffic-server on B and C |
| 37 | echo "starting ndn-traffic-server on B and C" |
| 38 | ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverB.log &" |
| 39 | ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverC.log &" |
| 40 | |
| 41 | # set up forwarding on A |
| 42 | echo "setting up forwarding on A..." |
| 43 | nfdc set-strategy ndn:/test-bcast ndn:/localhost/nfd/strategy/broadcast |
| 44 | faceid=$(nfdc create udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| 45 | nfdc add-nexthop -c 10 ndn:/test-bcast $faceid |
| 46 | faceid=$(nfdc create udp4://$IP4_C1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| 47 | nfdc add-nexthop -c 20 ndn:/test-bcast $faceid |
| 48 | |
| 49 | # set up forwarding on D |
| 50 | echo "setting up forwarding on D..." |
| 51 | faceid=$(ssh $CTRL_D "nfdc create udp4://$IP4_A2" | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| 52 | ssh $CTRL_D "nfdc add-nexthop ndn:/test-bcast $faceid" |
| 53 | |
| 54 | # run ndn-traffic client on D |
| 55 | echo "running ndn-traffic client on D..." |
| 56 | ssh $CTRL_D "ndn-traffic -c 100 -i 200 $workdir/NDNTrafficClient.conf > $workdir/logs/client.log 2>&1" |
| 57 | |
| 58 | # kill ndn-traffic-server on B and C |
| 59 | echo "killing ndn-traffic-server on B and C..." |
| 60 | ssh $CTRL_B "sudo killall ndn-traffic-server; sudo killall nfd" |
| 61 | ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd" |
| 62 | |
| 63 | # collect data from B, C and D |
| 64 | echo "collecting data from B, C and D..." |
| 65 | scp $CTRL_B:$workdir/logs/serverB.log $workdir/logs/serverB.log |
| 66 | scp $CTRL_C:$workdir/logs/serverC.log $workdir/logs/serverC.log |
| 67 | ssh $CTRL_D "nfd-status -f > $workdir/logs/nfd-status-D.log" |
| 68 | scp $CTRL_D:$workdir/logs/nfd-status-D.log $workdir/logs/nfd-status-D.log |
| 69 | scp $CTRL_D:$workdir/logs/client.log $workdir/logs/client.log |
| 70 | nfd-status > $workdir/logs/nfd-status-A.log |
| 71 | |
| 72 | # analyze result |
| 73 | echo "analyzing result" |
| 74 | b_received=$(grep "Total Interests Received" $workdir/logs/serverB.log | head -1 | cut -d= -f2 | cut -d' ' -f2) |
| 75 | if [[ $b_received -lt 80 ]] |
| 76 | then |
| 77 | echo "FAIL: B did not receive at least 80 interests." |
| 78 | clean_up |
| 79 | exit 1 |
| 80 | fi |
| 81 | c_received=$(grep "Total Interests Received" $workdir/logs/serverC.log | head -1 | cut -d= -f2 | cut -d' ' -f2) |
| 82 | if [[ $c_received -lt 80 ]] |
| 83 | then |
| 84 | echo "FAIL: C did not receive at least 80 interests." |
| 85 | clean_up |
| 86 | exit 2 |
| 87 | fi |
| 88 | cat $workdir/logs/nfd-status-D.log | grep udp4 | while read line |
| 89 | do |
| 90 | ind=$(echo $line | grep -Po "i .*?d} out" | sed 's/i //g' | sed 's/d} out//g') |
| 91 | if [[ $ind -gt 120 ]] |
| 92 | then |
| 93 | echo "FAIL: incoming data packet in D exceeded 120." |
| 94 | echo $line |
| 95 | clean_up |
| 96 | exit 3 |
| 97 | fi |
| 98 | done |
| 99 | |
| 100 | # clean up |
| 101 | clean_up |
| 102 | echo "Breadcast Test PASSED" |