Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | workDir=$(pwd) |
| 4 | logDir=$workDir/logs |
| 5 | testLogA=$logDir/nack-scenario-A.log |
| 6 | testLogB=$logDir/nack-scenario-B.log |
| 7 | testLogC=$logDir/nack-scenario-C.log |
| 8 | testLogD=$logDir/nack-scenario-D.log |
| 9 | mkdir -p $workDir/logs |
| 10 | |
| 11 | clean_up() { |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 12 | echo "killing nfd on B, C and D..." |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 13 | ssh $CTRL_B "sudo killall nfd >> $testLogB 2>&1" |
| 14 | if [[ $# -ge 1 ]]; then |
| 15 | local dataB=$1 |
| 16 | ssh $CTRL_B "sudo tc qdisc del dev $dataB root" |
| 17 | fi |
| 18 | ssh $CTRL_C "sudo killall nfd >> $testLogC 2>&1" |
| 19 | if [[ $# -ge 2 ]]; then |
| 20 | local dataC=$2 |
| 21 | ssh $CTRL_C "sudo tc qdisc del dev $dataC root" |
| 22 | fi |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 23 | ssh $CTRL_D "sudo killall nfd >> $testLogD 2>&1" |
| 24 | |
| 25 | sudo killall nfd 2>&1 |
| 26 | sleep 2 |
| 27 | } |
| 28 | |
| 29 | echo "Starting nfd on host A" > $testLogA |
| 30 | |
| 31 | # start nfd on localhost (A) and set best-route strategy |
| 32 | nfd-start &> $logDir/nfdA.log |
| 33 | sleep 2 |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 34 | nfdc strategy set / /localhost/nfd/strategy/best-route >> $testLogA |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 35 | |
| 36 | echo "Configure host B..." |
| 37 | # start nfd on hostB and set best-route-v1 |
| 38 | ssh $CTRL_B "mkdir -p $logDir ; nfd-start &> $logDir/nfdB.log &\ |
| 39 | sleep 2 ; echo 'Starting nfd on host B' > $testLogB &\ |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 40 | nfdc strategy set / /localhost/nfd/strategy/best-route/%FD%01 >> $testLogB" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 41 | |
| 42 | echo "Configure host C..." |
| 43 | # start nfd on hostC and set best-route strategy |
| 44 | ssh $CTRL_C "mkdir -p $logDir ; nfd-start &> $logDir/nfdC.log &\ |
| 45 | sleep 2 ; echo 'Starting nfd on host C' > $testLogC &\ |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 46 | nfdc strategy set / /localhost/nfd/strategy/best-route >> $testLogC" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 47 | |
| 48 | echo "Configure host D..." |
| 49 | # start nfd on hostD and set best-route strategy |
| 50 | ssh $CTRL_D "mkdir -p $logDir ; nfd-start &> $logDir/nfdD.log &\ |
| 51 | sleep 2 ; echo 'Starting nfd on host D' > $testLogD &\ |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 52 | nfdc strategy set / /localhost/nfd/strategy/best-route >> $testLogD" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 53 | |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 54 | # A: create faces and routes for prefix /P toward B and C, |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 55 | # where the cost toward B (10) is lower than the cost toward C(20) |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 56 | nfdc face create udp4://$IP4_B1:6363 >> $testLogA |
| 57 | nfdc face create udp4://$IP4_C1:6363 >> $testLogA |
| 58 | nfdc route add /P udp4://$IP4_B1:6363 cost 10 >> $testLogA |
| 59 | nfdc route add /P udp4://$IP4_C1:6363 cost 20 >> $testLogA |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 60 | |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 61 | # D: create a face to A and a route for prefix /P toward A |
| 62 | ssh $CTRL_D "echo 'creating a route toward A and a route for namespace /P toward A' >> $testLogD &\ |
| 63 | nfdc face create udp4://$IP4_A2:6363 >> $testLogD &&\ |
| 64 | nfdc route add /P udp4://$IP4_A2:6363 cost 20 >> $testLogD" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 65 | |
| 66 | echo "Start test 1..." |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 67 | # D: express an Interest for /P/1, no retransmissions, wait 8000ms |
| 68 | ssh $CTRL_D "echo 'express an Interest for /P/1' >> $testLogD &\ |
| 69 | test-nack-consumer -p /P/1 -w 8000 > $logDir/test1.log" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 70 | |
| 71 | scp $CTRL_D:$logDir/test1.log $logDir/test1.log |
| 72 | |
| 73 | echo "Analyzing result of test 1..." |
| 74 | received=$(tail -n 1 $logDir/test1.log | awk '{print $1}') |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 75 | if [[ "$received" == "NACK" ]]; then |
| 76 | echo "FAIL: A returned an unexpected Nack. This test does not retransmit the Interest," |
| 77 | echo "and therefore A did not try all possible nexthops. Check $logDir/test1.log for more details." |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 78 | clean_up |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 79 | exit 1 |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 80 | fi |
| 81 | |
| 82 | echo "Start test 2..." |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 83 | # D: express an Interest for /P/2, retransmit with new nonce, wait 8000ms |
| 84 | ssh $CTRL_D "echo 'express an Interest for /P/2' >> $testLogD &\ |
| 85 | test-nack-consumer -p /P/2 -r 2000 -w 8000 > $logDir/test2.log" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 86 | |
| 87 | scp $CTRL_D:$logDir/test2.log $logDir/test2.log |
| 88 | |
| 89 | echo "Analyzing result of test 2..." |
| 90 | received=$(tail -n 1 $logDir/test2.log | awk '{print $1}') |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 91 | if [[ "$received" == "NACK" ]]; then |
| 92 | echo "FAIL: A returned an unexpected Nack. A Nack is not expected when one or more upstreams" |
| 93 | echo "time out, even if some upstreams return Nacks. Check $logDir/test2.log for more details." |
| 94 | clean_up |
| 95 | exit 1 |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 96 | fi |
| 97 | |
| 98 | echo "Setup test 3..." |
| 99 | # get data interface of host B |
| 100 | dataB=$(ssh $CTRL_B "netstat -ie | grep -B1 $IP4_B1 | head -n1" | awk '{print $1}') |
| 101 | |
| 102 | # B: configure best-route strategy and get the set link delay to 500 ms |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 103 | ssh $CTRL_B "nfdc strategy set / /localhost/nfd/strategy/best-route >> $testLogB &\ |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 104 | sudo /sbin/tc qdisc add dev $dataB root netem delay 500ms >> $testLogB " |
| 105 | |
| 106 | # get data interface of host C |
| 107 | dataC=$(ssh $CTRL_C "netstat -ie | grep -B1 $IP4_C1 | head -n1" | awk '{print $1}') |
| 108 | |
| 109 | # B: configure link delay to 500 ms |
| 110 | ssh $CTRL_C "sudo /sbin/tc qdisc add dev $dataC root netem delay 500ms >> $testLogC" |
| 111 | |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 112 | # get data interface of host D |
| 113 | dataD=$(ssh $CTRL_D "netstat -ie | grep -B1 $IP4_D1 | head -n1" | awk '{print $1}') |
| 114 | |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 115 | echo "Start test 3..." |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 116 | # D: start ndndump for interface to R, express an Interest for /P/3, retransmit with new nonce after |
| 117 | # 200ms, wait 3000ms |
| 118 | ssh $CTRL_D "sudo ndndump -i $dataD > $logDir/ndndump-3.out & sleep 1" |
| 119 | ssh $CTRL_D "echo 'express an Interest for /P/3' >> $testLogD &\ |
| 120 | test-nack-consumer -p /P/3 -r 200 -w 3000 > $logDir/test3.log" |
| 121 | ssh $CTRL_D "sleep 1; sudo killall ndndump" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 122 | |
| 123 | scp $CTRL_D:$logDir/test3.log $logDir/test3.log |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 124 | scp $CTRL_D:$logDir/ndndump-3.out $logDir/ndndump-3.out |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 125 | |
| 126 | echo "Analyzing result of test 3..." |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 127 | NACK_count=$(grep "NACK" $logDir/ndndump-3.out | wc -l) |
| 128 | reason=$(grep -Po "NACK: \K[^,]*" $logDir/ndndump-3.out) |
| 129 | nonce2=$(grep "Sending Interest 2:" $logDir/test3.log | awk '{print $NF}') |
| 130 | NACK_nonce=$(grep -Po "NACK:.*?.*ndn\.Nonce=\K[0-9]*" $logDir/ndndump-3.out) |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 131 | |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 132 | if [[ $NACK_count -ne 1 || "$reason" != NoRoute || "$NACK_nonce" -ne "$nonce2" ]]; then |
| 133 | echo "FAIL: A should return exactly one Nack after both upstreams have returned Nack." |
| 134 | echo "Reason should be 'NoRoute' and Nonce should match the second Interest ($nonce2)." |
| 135 | echo "Test returned $NACK_count Nacks, with reason $reason for Nonce $NACK_nonce." |
| 136 | echo "Check $logDir/test3.log and $logDir/ndndump-3.out for more details." |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 137 | clean_up $dataB $dataC |
| 138 | exit 1 |
| 139 | fi |
| 140 | |
| 141 | echo "Setup test 4..." |
| 142 | |
| 143 | # B: configure link delay to 1000 ms |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 144 | ssh $CTRL_B "nfdc strategy set / /localhost/nfd/strategy/best-route >> $testLogB&\ |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 145 | sudo /sbin/tc qdisc change dev $dataB root netem delay 1000ms >> $testLogB" |
| 146 | |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 147 | # D: start ndndump for interface to R, express an Interest for /P/4, retransmit with new nonce after |
| 148 | # 200ms, wait 3000ms |
| 149 | ssh $CTRL_D "sudo ndndump -i $dataD > $logDir/ndndump-4.out & sleep 1" |
| 150 | ssh $CTRL_D "echo 'express an Interest for /P/4' >> $testLogD &\ |
| 151 | test-nack-consumer -p /P/4 -r 200 -w 3000 > $logDir/test4.log" |
| 152 | ssh $CTRL_D "sleep 1; sudo killall ndndump" |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 153 | |
| 154 | scp $CTRL_D:$logDir/test4.log $logDir/test4.log |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 155 | scp $CTRL_D:$logDir/ndndump-4.out $logDir/ndndump-4.out |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 156 | |
| 157 | echo "Analyzing result of test 4" |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 158 | NACK_count=$(grep "NACK" $logDir/ndndump-4.out | wc -l) |
| 159 | reason=$(grep -Po "NACK: \K[^,]*" $logDir/ndndump-4.out) |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 160 | nonce2=$(grep "Sending Interest 2:" $logDir/test4.log | awk '{print $NF}') |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 161 | NACK_nonce=$(grep -Po "NACK:.*?.*ndn\.Nonce=\K[0-9]*" $logDir/ndndump-4.out) |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 162 | |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 163 | if [[ $NACK_count -ne 1 || "$reason" != NoRoute || "$NACK_nonce" -ne "$nonce2" ]]; then |
| 164 | echo "FAIL: A should return exactly one Nack carrying the latest incoming Nonce from" |
| 165 | echo "downstream ($nonce2). The reason should be 'NoRoute'. The test returned $NACK_count Nacks," |
| 166 | echo "with nonce $NACK_nonce and reason $reason. Check $logDir/test4.log and" |
| 167 | echo "$logDir/ndndump-4.out for more details." |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 168 | clean_up $dataB $dataC |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 169 | exit 1 |
Hila Ben Abraham | e8c22e9 | 2016-10-20 14:30:32 -0500 | [diff] [blame] | 170 | fi |
| 171 | |
| 172 | # cleanup |
| 173 | clean_up $dataB $dataC |
Eric Newberry | 9b70520 | 2017-06-24 21:12:02 -0700 | [diff] [blame] | 174 | echo "Test passed" |
| 175 | exit 0 |