blob: 19aa09932cf1c3f16000cebff169a48650c759a0 [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" 2>&1)
r=$(sudo killall nfd 2>&1)
}
mkdir -p logs
# start nfd and ndn-traffic-server on host C
workdir=$(pwd)
echo "starting nfd and ndn-traffic-server on host C..."
ssh $CTRL_C "mkdir -p $workdir/logs;\
sudo nfd > $workdir/logs/nfd.log 2>&1 &\
sleep 3;\
nrd > $workdir/logs/nrd.log 2>&1 &\
sleep 3;\
ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
# start nfd and add nexthop of ndn:/localhop to C on host B
echo "starting nfd and adding nexthop of ndn:/localhop to C on host B..."
ssh $CTRL_B "mkdir -p $workdir/logs;\
$workdir/hostB.sh $workdir $c_ipaddr"
# start nfd and add nexthop of ndn:/localhop to B on host A
echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..."
sudo nfd > logs/nfd.log 2>&1 &
sleep 3
nrd > logs/nrd.log 2>&1 &
sleep 3
faceid=$(nfdc create udp4://$b_ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
nfdc add-nexthop ndn:/localhop $faceid
if [[ $? -ne 0 ]]
then
echo "Fail to add nexthop of ndn:/localhop"
clean_up
exit 2
fi
# From A, send interest ndn:/localhop/test-localhop/A/1
echo "From A, sending interest ndn:/localhop/test-localhop/A/1..."
output=$(ndn-tlv-peek -p ndn:/localhop/test-localhop/A/1)
if [[ ! -z $output ]]
then
echo "ndn:/localhop/test-localhop/A/1 is answered."
clean_up
exit 4
fi
# From B, send interest ndn:/localhop/test-localhop/B/1
echo "From B, sending interest ndn:/localhop/test-localhop/B/1..."
output=$(ssh $CTRL_B "ndn-tlv-peek -p ndn:/localhop/test-localhop/B/1")
if [[ $output != BBBBBBBB ]]
then
echo "ndn:/localhop/test-localhop/B/1 is not correctly answered. Content: $output"
clean_up
exit 5
fi
# stop ndn-traffic-server and nfd on host C
echo "stopping ndn-traffic-server and nfd on host C..."
ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
# stop nfd on host B
echo "stopping nfd on host B..."
ssh $CTRL_B "sudo killall nfd"
# stop nfd on host A
echo "stopping nfd on host A..."
sudo killall nfd
# 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)
if [ $output != 0?(.+(0)) ]
then
echo "Expected no interests with name ndn:/localhop/test-localhop/A/1 received on host C. Actual: $output"
echo "For more information, please examine the log at \"$(pwd)/logs\""
clean_up
exit 3
fi
clean_up
echo "Localhop Test PASSED"