blob: ed96e3bdbf6469ecaa5b2ab69bc37d5c4ddc9948 [file] [log] [blame]
#!/usr/bin/env bash
source ../multi-host.conf
workDir=$(pwd)
logDir=$workDir/logs
testLogA=$logDir/permanent-faceA.log
testLogB=$logDir/permanent-faceB.log
mkdir -p $workDir/logs
echo "About to start nfd on host A" > $testLogA
# start nfd on localhost (A)
sudo nfd &> $logDir/nfdA.log &
# start nfd on hostB
ssh $CTRL_B "mkdir -p $logDir ; sudo nfd &> $logDir/nfdB.log &\
echo 'About to start nfd on host B' > $testLogB ; sleep 2"
# on B, start ndnpingserver for prefix /B
ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &"
# on A, create a UDP permanent face toward B
nfdc face create udp://$IP4_B1 persistency permanent >> $testLogA
# on A, add route to ndn:/B on the face created in step 3
nfdc route add ndn:/B udp4://$IP4_B1:6363 >> $testLogA
# on A, execute ndnping for prefix ndn:/B with client specifier "a" for 10 probes
pingOutput=$(ndnping ndn:/B -p a -c 10)
echo $pingOutput >> $testLogA
# fail the scenario if loss rate is more than 15%
loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//')
echo "LOSS rate of first ping is: $loss" >> $testLogA
if [[ $loss -gt 15 ]]; then
echo "LOSS rate is greater than 15. FAILED!" >> $testLogA
sudo killall nfd 2>&1
ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
exit 1
fi
# stop NFD on B
ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1 "
# on A, execute ndnping for prefix ndn:/B with client specifier "b" for 10 probes
pingOutput=$(ndnping ndn:/B -p b -c 10)
echo $pingOutput >> $testLogA
# fail the scenario if loss rate is less than 100%
loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//')
echo "LOSS rate of second ping is: $loss" >> $testLogA
if [[ $loss -lt 100 ]]; then
echo "LOSS rate is less than 100. FAILED!" >> $testLogA
ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
exit 1
fi
# start nfd on hostB
ssh $CTRL_B "mkdir -p $workDir/logs/ ; sudo nfd &> $workDir/logs/nfdB.log &\
sleep 2"
sleep 2
# on B, start ndnpingserver for prefix /B
ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &"
# on A, execute ndnping for prefix ndn:/B with client specifier "c" for 10 probes
pingOutput=$(ndnping ndn:/B -p c -c 10)
echo $pingOutput >> $testLogA
# fail the scenario if loss rate is more than 15%
loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//')
echo "LOSS rate of third ping is: $loss" >> $testLogA
if [[ $loss -gt 15 ]]; then
echo "LOSS rate is greater than 15. FAILED!" >> $testLogA
sudo killall nfd 2>&1
ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
exit 1
fi
# cleanup
sudo killall nfd 2>&1
ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
exit 0