Hila Ben Abraham | 9f8c118 | 2015-10-10 01:39:03 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | workDir=$(pwd) |
| 4 | logDir=$workDir/logs |
| 5 | testLogA=$logDir/permanent-faceA.log |
| 6 | testLogB=$logDir/permanent-faceB.log |
| 7 | |
| 8 | mkdir -p $workDir/logs |
| 9 | |
| 10 | echo "About to start nfd on host A" > $testLogA |
| 11 | # start nfd on localhost (A) |
| 12 | sudo nfd &> $logDir/nfdA.log & |
| 13 | |
| 14 | # start nfd on hostB |
| 15 | ssh $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 |
| 19 | ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &" |
| 20 | |
| 21 | # on A, create a UDP permanent face toward B |
Eric Newberry | 7745c1a | 2017-04-20 00:23:05 -0700 | [diff] [blame] | 22 | nfdc face create udp://$IP4_B1 persistency permanent >> $testLogA |
Hila Ben Abraham | 9f8c118 | 2015-10-10 01:39:03 -0500 | [diff] [blame] | 23 | |
Eric Newberry | 7745c1a | 2017-04-20 00:23:05 -0700 | [diff] [blame] | 24 | # on A, add route to ndn:/B on the face created in step 3 |
| 25 | nfdc route add ndn:/B udp4://$IP4_B1:6363 >> $testLogA |
Hila Ben Abraham | 9f8c118 | 2015-10-10 01:39:03 -0500 | [diff] [blame] | 26 | |
| 27 | # on A, execute ndnping for prefix ndn:/B with client specifier "a" for 10 probes |
| 28 | pingOutput=$(ndnping ndn:/B -p a -c 10) |
| 29 | echo $pingOutput >> $testLogA |
| 30 | |
| 31 | # fail the scenario if loss rate is more than 15% |
Alexander Afanasyev | 1cbb932 | 2017-01-25 14:14:43 -0500 | [diff] [blame] | 32 | loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//') |
Hila Ben Abraham | 9f8c118 | 2015-10-10 01:39:03 -0500 | [diff] [blame] | 33 | echo "LOSS rate of first ping is: $loss" >> $testLogA |
| 34 | if [[ $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 |
| 39 | fi |
| 40 | |
| 41 | |
| 42 | # stop NFD on B |
| 43 | ssh $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 |
| 46 | pingOutput=$(ndnping ndn:/B -p b -c 10) |
| 47 | echo $pingOutput >> $testLogA |
| 48 | |
| 49 | # fail the scenario if loss rate is less than 100% |
Alexander Afanasyev | 1cbb932 | 2017-01-25 14:14:43 -0500 | [diff] [blame] | 50 | loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//') |
Hila Ben Abraham | 9f8c118 | 2015-10-10 01:39:03 -0500 | [diff] [blame] | 51 | echo "LOSS rate of second ping is: $loss" >> $testLogA |
| 52 | if [[ $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 |
| 56 | fi |
| 57 | |
| 58 | |
| 59 | # start nfd on hostB |
| 60 | ssh $CTRL_B "mkdir -p $workDir/logs/ ; sudo nfd &> $workDir/logs/nfdB.log &\ |
| 61 | sleep 2" |
| 62 | sleep 2 |
| 63 | |
| 64 | # on B, start ndnpingserver for prefix /B |
| 65 | ssh $CTRL_B "ndnpingserver /B >> $testLogB 2>&1 &" |
| 66 | |
| 67 | # on A, execute ndnping for prefix ndn:/B with client specifier "c" for 10 probes |
| 68 | pingOutput=$(ndnping ndn:/B -p c -c 10) |
| 69 | echo $pingOutput >> $testLogA |
| 70 | |
| 71 | # fail the scenario if loss rate is more than 15% |
Alexander Afanasyev | 1cbb932 | 2017-01-25 14:14:43 -0500 | [diff] [blame] | 72 | loss=$(echo $pingOutput | grep -i 'lost' | grep -Po '\d*%' | sed 's/%//') |
Hila Ben Abraham | 9f8c118 | 2015-10-10 01:39:03 -0500 | [diff] [blame] | 73 | echo "LOSS rate of third ping is: $loss" >> $testLogA |
| 74 | if [[ $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 |
| 79 | fi |
| 80 | |
| 81 | # cleanup |
| 82 | sudo killall nfd 2>&1 |
| 83 | ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1" |
| 84 | |
| 85 | exit 0 |