blob: 503c0bdf137b1da26da81259699646eb022e1286 [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;\
Yi Huang53fa8712014-06-10 20:14:26 -070022 nrd &> $workdir/logs/nrd.log &\
23 sleep 3;\
Yi Huang4a4566b2014-04-26 23:59:48 -070024 ndn-traffic-server $workdir/NDNTrafficServerB.conf &> $workdir/logs/server.log &"
25ssh $CTRL_C "mkdir -p $workdir/logs;\
26 sudo nfd &> $workdir/logs/nfd.log &\
27 sleep 3;\
Yi Huang53fa8712014-06-10 20:14:26 -070028 nrd &> $workdir/logs/nrd.log &\
29 sleep 3;\
Yi Huang4a4566b2014-04-26 23:59:48 -070030 ndn-traffic-server $workdir/NDNTrafficServerC.conf &> $workdir/logs/server.log &"
31
32# start nfd and add nexthop of ndn:/test-mcast to UDP multicast face
33sudo nfd &> $workdir/logs/nfd.log &
34sleep 3
Yi Huang53fa8712014-06-10 20:14:26 -070035nrd &> $workdir/logs/nrd.log &
36sleep 3
Yi Huang4a4566b2014-04-26 23:59:48 -070037faceid=$(nfd-status -f | grep $a_ipaddr | grep -Po 'faceid=.*? ' | sed 's/faceid=//' | sed 's/ //')
38nfdc add-nexthop ndn:/test-mcast $faceid
39
Eric Newberryd4ed6222015-06-10 14:12:42 -070040# use ndnpeek to test multicast feature
41response=$(ndnpeek -p ndn:/test-mcast/B/1)
Yi Huang4a4566b2014-04-26 23:59:48 -070042if [[ $response != 'BBBBBBBB' ]]
43then
44 echo "FAIL: Expected data for ndn:/test-mcast/B/1 is: 'BBBBBBBB', Actual: '$response'"
45 clean_up
46 exit 1
47fi
Eric Newberryd4ed6222015-06-10 14:12:42 -070048response=$(ndnpeek -p ndn:/test-mcast/C/1)
Yi Huang4a4566b2014-04-26 23:59:48 -070049if [[ $response != 'CCCCCCCC' ]]
50then
51 echo "FAIL: Expected data for ndn:/test-mcast/C/1 is: 'CCCCCCCC', Actual: '$response'"
52 clean_up
53 exit 2
54fi
Eric Newberryd4ed6222015-06-10 14:12:42 -070055response=$(ndnpeek -p ndn:/test-mcast/Z/1)
Yi Huang4a4566b2014-04-26 23:59:48 -070056if [[ ( $response != 'ZZZZZZZB' ) && ( $response != 'ZZZZZZZC' ) ]]
57then
58 echo "FAIL: Expected data for ndn:/test-mcast/Z/1 is: 'ZZZZZZZB' or 'ZZZZZZZC', Actual: '$response'"
59 clean_up
60 exit 3
61fi
62
63# kill ndn-traffic-server on host B
64ssh $CTRL_B "sudo killall ndn-traffic-server"
65
Eric Newberryd4ed6222015-06-10 14:12:42 -070066# use ndnpeek to request ndn:/testmcast/Z/2
67response=$(ndnpeek -p ndn:/test-mcast/Z/2)
Yi Huang4a4566b2014-04-26 23:59:48 -070068if [[ $response != 'ZZZZZZZC' ]]
69then
70 echo "FAIL: Expected data for ndn:/test-mcast/Z/2 is: 'ZZZZZZZC', Actual: '$response'"
71 clean_up
72 exit 4
73fi
74
75# clean up
76clean_up
77echo "Multicast Test PASSED"