blob: 11295eee7704b94a8ed22afe079154a99b9d1327 [file] [log] [blame]
#!/bin/bash
source ../multi-host.conf
if [[ $1 = "udp" ]]
then
a_ipaddr=$IP4_A1
else
a_ipaddr=$(ip addr show to $IP4_A1 | head -1 | cut -d: -f2 | cut -d' ' -f2)
fi
mkdir -p logs/$1
workdir=$(pwd)
clean_up() {
r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
r=$(sudo killall nfd 2>&1)
}
# start nfd and ndn-traffic-server on B and C
ssh $CTRL_B "mkdir -p $workdir/logs/$1;\
sudo nfd &> $workdir/logs/$1/nfd.log &\
sleep 3;\
ndn-traffic-server $workdir/NDNTrafficServerB.conf &> $workdir/logs/$1/server.log &"
ssh $CTRL_C "mkdir -p $workdir/logs/$1;\
sudo nfd &> $workdir/logs/$1/nfd.log &\
sleep 3;\
ndn-traffic-server $workdir/NDNTrafficServerC.conf &> $workdir/logs/$1/server.log &"
# start nfd and add nexthop of ndn:/test-mcast to UDP multicast face
sudo nfd &> $workdir/logs/$1/nfd.log &
sleep 3
faceid=$(nfd-status -f | grep $a_ipaddr | grep -Po 'faceid=.*? ' | sed 's/faceid=//' | sed 's/ //')
nfdc add-nexthop ndn:/test-mcast $faceid
# use ndnpeek to test multicast feature
response=$(ndnpeek -p ndn:/test-mcast/B/1)
if [[ $response != 'BBBBBBBB' ]]
then
echo "FAIL: Expected data for ndn:/test-mcast/B/1 is: 'BBBBBBBB', Actual: '$response'"
clean_up
exit 1
fi
response=$(ndnpeek -p ndn:/test-mcast/C/1)
if [[ $response != 'CCCCCCCC' ]]
then
echo "FAIL: Expected data for ndn:/test-mcast/C/1 is: 'CCCCCCCC', Actual: '$response'"
clean_up
exit 2
fi
response=$(ndnpeek -p ndn:/test-mcast/Z/1)
if [[ ( $response != 'ZZZZZZZB' ) && ( $response != 'ZZZZZZZC' ) ]]
then
echo "FAIL: Expected data for ndn:/test-mcast/Z/1 is: 'ZZZZZZZB' or 'ZZZZZZZC', Actual: '$response'"
clean_up
exit 3
fi
# kill ndn-traffic-server on host B
ssh $CTRL_B "sudo killall ndn-traffic-server"
# use ndnpeek to request ndn:/testmcast/Z/2
response=$(ndnpeek -p ndn:/test-mcast/Z/2)
if [[ $response != 'ZZZZZZZC' ]]
then
echo "FAIL: Expected data for ndn:/test-mcast/Z/2 is: 'ZZZZZZZC', Actual: '$response'"
clean_up
exit 4
fi
# clean up
clean_up
echo "Multicast Test PASSED"