blob: ffedeb8967139dd5c4eea1e14f61b16fd0adee34 [file] [log] [blame]
#!/usr/bin/env bash
source ../multi-host.conf
a_ipaddr=$IP4_A1
b_ipaddr=$IP4_B1
c_ipaddr=$IP4_C1
strategy=$1
logprefix=$2
echo "host A IP address $a_ipaddr"
echo "host B IP address $b_ipaddr"
echo "host C IP address $c_ipaddr"
echo "Strategy: $strategy"
mkdir -p logs
workdir=$(pwd)
clean_up() {
echo "cleaning up..."
sudo killall nfd 2>&1
ssh $b_ipaddr "sudo killall nfd 2>&1" 2>&1
ssh $c_ipaddr "sudo killall nfd 2>&1" 2>&1
}
trap clean_up EXIT
# generate nfd.conf: disable multicast faces
cp /usr/local/etc/ndn/nfd.conf $workdir/nfd.conf
ssh $CTRL_B "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
ssh $CTRL_C "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
# get keys
echo "getting keys..."
cp -r /usr/local/etc/ndn/keys $workdir/
ssh $CTRL_B "cp -r /usr/local/etc/ndn/keys $workdir/"
ssh $CTRL_C "cp -r /usr/local/etc/ndn/keys $workdir/"
# start NFD on three nodes and set nexthop to create loop
echo "start NFD on three nodes and set nexthop to create loop..."
ssh $CTRL_B "mkdir -p $workdir/logs;\
sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &\
sleep 2"
ssh $CTRL_C "mkdir -p $workdir/logs;\
sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &\
sleep 2"
sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &
sleep 5
ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy" || exit 3
ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy" || exit 3
$workdir/add-nexthop.sh $b_ipaddr $strategy || exit 3
# use ndn-traffic-client to send 100 interests
echo "using ndn-traffic-client to send 100 interests..."
ndn-traffic-client -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/${logprefix}_client.log 2>&1
# collect nfdc face list from B and C
echo "collecting nfdc face list from B and C..."
ssh $CTRL_B "nfdc face list > $workdir/logs/${logprefix}_nfdc-face-list-B.log 2>&1" || exit 4
scp $CTRL_B:$workdir/logs/${logprefix}_nfdc-face-list-B.log $workdir/logs/${logprefix}_nfdc-face-list-B.log
ssh $CTRL_C "nfdc face list > $workdir/logs/${logprefix}_nfdc-face-list-C.log 2>&1" || exit 4
scp $CTRL_C:$workdir/logs/${logprefix}_nfdc-face-list-C.log $workdir/logs/${logprefix}_nfdc-face-list-C.log
nfdc face list > $workdir/logs/${logprefix}_nfdc-face-list-A.log 2>&1 || exit 4
# analyze results
echo "analyzing results..."
for host in {A..C}
do
echo "Host $host:"
cat $workdir/logs/${logprefix}_nfdc-face-list-$host.log | grep udp4 | while read line
do
ini=$(echo "$line" | grep -Po "in={.*?i" | sed 's/in={//g' | sed 's/i//g')
outi=$(echo "$line" | grep -Po "out={.*?i" | sed 's/out={//g' | sed 's/i//g')
echo " $ini in, $outi out"
if [[ $ini -gt 200 ]]
then
echo "FAIL: counter for incoming interest on host $host is greater than 200"
echo "$line"
exit 1
fi
if [[ $outi -gt 200 ]]
then
echo "FAIL: counter for outgoing interest on host $host is greater than 200"
echo "$line"
exit 2
fi
done
done
# clean up
clean_up
echo "Interest Loop Test PASSED"