blob: f83d575a99d14303d64757080a633fce839dcca7 [file] [log] [blame]
#!/bin/bash
source ../multi-host.conf
b_ipaddr=$IP4_B1
c_ipaddr=$IP4_C1
echo "host B IP address $b_ipaddr"
echo "host C IP address $c_ipaddr"
clean_up() {
r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
r=$(ssh $CTRL_C "sudo killall nfd-traffic-server" 2>&1)
r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
r=$(sudo killall nfd 2>&1)
}
mkdir -p logs
# Start NFD on A, B, and C
workdir=$(pwd)
echo "starting nfd on host A..."
sudo nfd > $workdir/logs/nfd.log 2>&1 &
sleep 1
echo "starting nfd on host B..."
ssh $CTRL_B "mkdir -p $workdir/logs;\
sudo nfd &> $workdir/logs/nfd.log &"
sleep 1
echo "starting nfd on host C..."
ssh $CTRL_C "mkdir -p $workdir/logs;\
sudo nfd &> $workdir/logs/nfd.log &"
sleep 1
# On A, add nexthop of `ndn:/localhop` to B
nfdc face create udp4://$b_ipaddr
nfdc route add ndn:/localhop udp4://$b_ipaddr
if [[ $? -ne 0 ]]
then
echo "Failed to add nexthop of ndn:/localhop"
clean_up
exit 2
fi
# On B, add nexthop of `ndn:/localhop` to C
ssh $CTRL_B "nfdc face create udp4://$c_ipaddr"
ssh $CTRL_B "nfdc route add ndn:/localhop udp4://$c_ipaddr"
# On C, start ndn-traffic-server
echo "starting ndn-traffic-server on host C..."
ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
# From A, send interest ndn:/localhop/test-localhop/1
echo "From A, sending interest ndn:/localhop/test-localhop/1..."
output=$(ndnpeek -p ndn:/localhop/test-localhop/1)
if [[ $? == "0" ]]
then
echo "Interest ndn:/localhop/test-localhop/1 answered with a Data."
clean_up
exit 4
fi
echo "stopping nfd and ndn-traffic-server instances..."
clean_up
# copy back the server log
echo "copying back ndn-traffic-server log..."
scp $CTRL_C:$workdir/logs/server.log $workdir/logs/
# analyze server log
echo "analyzing server log..."
output=$(grep "Total Interests Received" $workdir/logs/server.log | head -2 | tail -1 | cut -d= -f2 | cut -d' ' -f2)
# output can be empty due to a receive error (End of file)
if [[ -n $output ]] && [[ $output != 0?(.+(0)) ]]
then
echo "Expected no interests with name ndn:/localhop/test-localhop/1 to be received on host C. Actual: '$output'"
echo "For more information, please examine the logs at \"$(pwd)/logs\""
clean_up
exit 3
fi
clean_up
echo "Localhop Test PASSED"