blob: 4c39bf361bff147307a105e964c84622dd6d1809 [file] [log] [blame]
Yi Huang4a4566b2014-04-26 23:59:48 -07001#!/bin/bash
2source ../multi-host.conf
3if [[ $1 = "udp" ]]
4then
5 a_ipaddr=$IP4_A1
6else
7 a_ipaddr=$(ip addr show to $IP4_A1 | head -1 | cut -d: -f2 | cut -d' ' -f2)
8fi
9mkdir -p logs
10workdir=$(pwd)
11
12clean_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
19ssh $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 &"
23ssh $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
29sudo nfd &> $workdir/logs/nfd.log &
30sleep 3
Yi Huang4a4566b2014-04-26 23:59:48 -070031faceid=$(nfd-status -f | grep $a_ipaddr | grep -Po 'faceid=.*? ' | sed 's/faceid=//' | sed 's/ //')
32nfdc add-nexthop ndn:/test-mcast $faceid
33
Eric Newberryd4ed6222015-06-10 14:12:42 -070034# use ndnpeek to test multicast feature
35response=$(ndnpeek -p ndn:/test-mcast/B/1)
Yi Huang4a4566b2014-04-26 23:59:48 -070036if [[ $response != 'BBBBBBBB' ]]
37then
38 echo "FAIL: Expected data for ndn:/test-mcast/B/1 is: 'BBBBBBBB', Actual: '$response'"
39 clean_up
40 exit 1
41fi
Eric Newberryd4ed6222015-06-10 14:12:42 -070042response=$(ndnpeek -p ndn:/test-mcast/C/1)
Yi Huang4a4566b2014-04-26 23:59:48 -070043if [[ $response != 'CCCCCCCC' ]]
44then
45 echo "FAIL: Expected data for ndn:/test-mcast/C/1 is: 'CCCCCCCC', Actual: '$response'"
46 clean_up
47 exit 2
48fi
Eric Newberryd4ed6222015-06-10 14:12:42 -070049response=$(ndnpeek -p ndn:/test-mcast/Z/1)
Yi Huang4a4566b2014-04-26 23:59:48 -070050if [[ ( $response != 'ZZZZZZZB' ) && ( $response != 'ZZZZZZZC' ) ]]
51then
52 echo "FAIL: Expected data for ndn:/test-mcast/Z/1 is: 'ZZZZZZZB' or 'ZZZZZZZC', Actual: '$response'"
53 clean_up
54 exit 3
55fi
56
57# kill ndn-traffic-server on host B
58ssh $CTRL_B "sudo killall ndn-traffic-server"
59
Eric Newberryd4ed6222015-06-10 14:12:42 -070060# use ndnpeek to request ndn:/testmcast/Z/2
61response=$(ndnpeek -p ndn:/test-mcast/Z/2)
Yi Huang4a4566b2014-04-26 23:59:48 -070062if [[ $response != 'ZZZZZZZC' ]]
63then
64 echo "FAIL: Expected data for ndn:/test-mcast/Z/2 is: 'ZZZZZZZC', Actual: '$response'"
65 clean_up
66 exit 4
67fi
68
69# clean up
70clean_up
71echo "Multicast Test PASSED"