Yi Huang | 4a4566b | 2014-04-26 23:59:48 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | source ../multi-host.conf |
| 3 | if [[ $1 = "udp" ]] |
| 4 | then |
| 5 | a_ipaddr=$IP4_A1 |
| 6 | else |
| 7 | a_ipaddr=$(ip addr show to $IP4_A1 | head -1 | cut -d: -f2 | cut -d' ' -f2) |
| 8 | fi |
| 9 | mkdir -p logs |
| 10 | workdir=$(pwd) |
| 11 | |
| 12 | clean_up() { |
| 13 | r=$(ssh $CTRL_B "sudo killall nfd" 2>&1) |
| 14 | r=$(ssh $CTRL_C "sudo killall nfd" 2>&1) |
| 15 | r=$(sudo killall nfd 2>&1) |
| 16 | } |
| 17 | |
| 18 | # start nfd and ndn-traffic-server on B and C |
| 19 | ssh $CTRL_B "mkdir -p $workdir/logs;\ |
| 20 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 21 | sleep 3;\ |
| 22 | ndn-traffic-server $workdir/NDNTrafficServerB.conf &> $workdir/logs/server.log &" |
| 23 | ssh $CTRL_C "mkdir -p $workdir/logs;\ |
| 24 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 25 | sleep 3;\ |
| 26 | ndn-traffic-server $workdir/NDNTrafficServerC.conf &> $workdir/logs/server.log &" |
| 27 | |
| 28 | # start nfd and add nexthop of ndn:/test-mcast to UDP multicast face |
| 29 | sudo nfd &> $workdir/logs/nfd.log & |
| 30 | sleep 3 |
Yi Huang | 4a4566b | 2014-04-26 23:59:48 -0700 | [diff] [blame] | 31 | faceid=$(nfd-status -f | grep $a_ipaddr | grep -Po 'faceid=.*? ' | sed 's/faceid=//' | sed 's/ //') |
| 32 | nfdc add-nexthop ndn:/test-mcast $faceid |
| 33 | |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 34 | # use ndnpeek to test multicast feature |
| 35 | response=$(ndnpeek -p ndn:/test-mcast/B/1) |
Yi Huang | 4a4566b | 2014-04-26 23:59:48 -0700 | [diff] [blame] | 36 | if [[ $response != 'BBBBBBBB' ]] |
| 37 | then |
| 38 | echo "FAIL: Expected data for ndn:/test-mcast/B/1 is: 'BBBBBBBB', Actual: '$response'" |
| 39 | clean_up |
| 40 | exit 1 |
| 41 | fi |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 42 | response=$(ndnpeek -p ndn:/test-mcast/C/1) |
Yi Huang | 4a4566b | 2014-04-26 23:59:48 -0700 | [diff] [blame] | 43 | if [[ $response != 'CCCCCCCC' ]] |
| 44 | then |
| 45 | echo "FAIL: Expected data for ndn:/test-mcast/C/1 is: 'CCCCCCCC', Actual: '$response'" |
| 46 | clean_up |
| 47 | exit 2 |
| 48 | fi |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 49 | response=$(ndnpeek -p ndn:/test-mcast/Z/1) |
Yi Huang | 4a4566b | 2014-04-26 23:59:48 -0700 | [diff] [blame] | 50 | if [[ ( $response != 'ZZZZZZZB' ) && ( $response != 'ZZZZZZZC' ) ]] |
| 51 | then |
| 52 | echo "FAIL: Expected data for ndn:/test-mcast/Z/1 is: 'ZZZZZZZB' or 'ZZZZZZZC', Actual: '$response'" |
| 53 | clean_up |
| 54 | exit 3 |
| 55 | fi |
| 56 | |
| 57 | # kill ndn-traffic-server on host B |
| 58 | ssh $CTRL_B "sudo killall ndn-traffic-server" |
| 59 | |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 60 | # use ndnpeek to request ndn:/testmcast/Z/2 |
| 61 | response=$(ndnpeek -p ndn:/test-mcast/Z/2) |
Yi Huang | 4a4566b | 2014-04-26 23:59:48 -0700 | [diff] [blame] | 62 | if [[ $response != 'ZZZZZZZC' ]] |
| 63 | then |
| 64 | echo "FAIL: Expected data for ndn:/test-mcast/Z/2 is: 'ZZZZZZZC', Actual: '$response'" |
| 65 | clean_up |
| 66 | exit 4 |
| 67 | fi |
| 68 | |
| 69 | # clean up |
| 70 | clean_up |
| 71 | echo "Multicast Test PASSED" |