blob: ed96e3bdbf6469ecaa5b2ab69bc37d5c4ddc9948 [file] [log] [blame]
Hila Ben Abraham9f8c1182015-10-10 01:39:03 -05001#!/usr/bin/env bash
2source ../multi-host.conf
3workDir=$(pwd)
4logDir=$workDir/logs
5testLogA=$logDir/permanent-faceA.log
6testLogB=$logDir/permanent-faceB.log
7
8mkdir -p $workDir/logs
9
10echo "About to start nfd on host A" > $testLogA
11# start nfd on localhost (A)
12sudo nfd &> $logDir/nfdA.log &
13
14# start nfd on hostB
15ssh $CTRL_B "mkdir -p $logDir ; sudo nfd &> $logDir/nfdB.log &\
16 echo 'About to start nfd on host B' > $testLogB ; sleep 2"
17
18# on B, start ndnpingserver for prefix /B
19ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &"
20
21# on A, create a UDP permanent face toward B
Eric Newberry7745c1a2017-04-20 00:23:05 -070022nfdc face create udp://$IP4_B1 persistency permanent >> $testLogA
Hila Ben Abraham9f8c1182015-10-10 01:39:03 -050023
Eric Newberry7745c1a2017-04-20 00:23:05 -070024# on A, add route to ndn:/B on the face created in step 3
25nfdc route add ndn:/B udp4://$IP4_B1:6363 >> $testLogA
Hila Ben Abraham9f8c1182015-10-10 01:39:03 -050026
27# on A, execute ndnping for prefix ndn:/B with client specifier "a" for 10 probes
28pingOutput=$(ndnping ndn:/B -p a -c 10)
29echo $pingOutput >> $testLogA
30
31# fail the scenario if loss rate is more than 15%
Alexander Afanasyev1cbb9322017-01-25 14:14:43 -050032loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//')
Hila Ben Abraham9f8c1182015-10-10 01:39:03 -050033echo "LOSS rate of first ping is: $loss" >> $testLogA
34if [[ $loss -gt 15 ]]; then
35 echo "LOSS rate is greater than 15. FAILED!" >> $testLogA
36 sudo killall nfd 2>&1
37 ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
38 exit 1
39fi
40
41
42# stop NFD on B
43ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1 "
44
45# on A, execute ndnping for prefix ndn:/B with client specifier "b" for 10 probes
46pingOutput=$(ndnping ndn:/B -p b -c 10)
47echo $pingOutput >> $testLogA
48
49# fail the scenario if loss rate is less than 100%
Alexander Afanasyev1cbb9322017-01-25 14:14:43 -050050loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//')
Hila Ben Abraham9f8c1182015-10-10 01:39:03 -050051echo "LOSS rate of second ping is: $loss" >> $testLogA
52if [[ $loss -lt 100 ]]; then
53 echo "LOSS rate is less than 100. FAILED!" >> $testLogA
54 ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
55 exit 1
56fi
57
58
59# start nfd on hostB
60ssh $CTRL_B "mkdir -p $workDir/logs/ ; sudo nfd &> $workDir/logs/nfdB.log &\
61 sleep 2"
62sleep 2
63
64# on B, start ndnpingserver for prefix /B
65ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &"
66
67# on A, execute ndnping for prefix ndn:/B with client specifier "c" for 10 probes
68pingOutput=$(ndnping ndn:/B -p c -c 10)
69echo $pingOutput >> $testLogA
70
71# fail the scenario if loss rate is more than 15%
Alexander Afanasyev1cbb9322017-01-25 14:14:43 -050072loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//')
Hila Ben Abraham9f8c1182015-10-10 01:39:03 -050073echo "LOSS rate of third ping is: $loss" >> $testLogA
74if [[ $loss -gt 15 ]]; then
75 echo "LOSS rate is greater than 15. FAILED!" >> $testLogA
76 sudo killall nfd 2>&1
77 ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
78 exit 1
79fi
80
81# cleanup
82sudo killall nfd 2>&1
83ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1"
84
85exit 0