blob: a4bae83f0636ae8a1c0085e6eb2dbef82e640719 [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
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..."
r=$(sudo killall nfd 2>&1)
r=$(ssh $b_ipaddr "sudo killall nfd 2>&1" 2>&1)
r=$(ssh $c_ipaddr "sudo killall nfd 2>&1" 2>&1)
}
# 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/nfd.log &\
sleep 2"
ssh $CTRL_C "mkdir -p $workdir/logs;\
sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\
sleep 2"
sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &
sleep 5
ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy"
ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy"
$workdir/add-nexthop.sh $b_ipaddr $strategy
# use ndn-traffic client to send 100 interests
echo "using ndn-traffic client to send 100 interests..."
ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/client.log 2>&1
# collect nfd-status from B and C
echo "collecting nfd-status from B and C..."
ssh $CTRL_B "nfd-status -f > $workdir/logs/nfd-status-B.log 2>&1"
scp $CTRL_B:$workdir/logs/nfd-status-B.log $workdir/logs/nfd-status-B.log
ssh $CTRL_C "nfd-status -f > $workdir/logs/nfd-status-C.log 2>&1"
scp $CTRL_C:$workdir/logs/nfd-status-C.log $workdir/logs/nfd-status-C.log
nfd-status -f > $workdir/logs/nfd-status-A.log 2>&1
# analyze results
echo "analyzing results..."
for host in {A..C}
do
echo "Host $host:"
cat $workdir/logs/nfd-status-$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"
clean_up
exit 1
fi
if [[ $outi -gt 200 ]]
then
echo "FAIL: counter for outgoing interest on host $host is greater than 200"
echo "$line"
clean_up
exit 2
fi
done
done
# clean up
clean_up
echo "Interest Loop Test PASSED"