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