Eric Newberry | 608211e | 2017-11-27 21:59:37 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | source ../multi-host.conf |
| 3 | |
| 4 | echo "host A IP addresses $IP4_A1 and $IP4_A2" |
| 5 | echo "host C IP address $IP4_C1" |
| 6 | echo "host D IP address $IP4_D1" |
| 7 | |
| 8 | clean_up() { |
| 9 | r=$(ssh $CTRL_C "sudo killall nfd" 2>&1) |
| 10 | r=$(ssh $CTRL_D "sudo killall test-congestionmark-producer" 2>&1) |
| 11 | r=$(ssh $CTRL_D "sudo killall nfd" 2>&1) |
| 12 | r=$(sudo killall nfd 2>&1) |
| 13 | } |
| 14 | |
| 15 | ### Setup |
| 16 | |
| 17 | # Start NFD on hosts A, C, and D |
| 18 | workdir=$(pwd) |
| 19 | echo "starting nfd on host A..." |
| 20 | mkdir -p $workdir/logs; sudo nfd > $workdir/logs/nfd.log 2>&1 & |
| 21 | sleep 1 |
| 22 | |
| 23 | echo "starting nfd on host C..." |
| 24 | ssh $CTRL_C "mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log &" |
| 25 | sleep 1 |
| 26 | |
| 27 | echo "starting nfd on host D..." |
| 28 | ssh $CTRL_D "mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log &" |
| 29 | sleep 1 |
| 30 | |
| 31 | # Create faces |
| 32 | ssh $CTRL_C "nfdc face create udp4://$IP4_A1" |
| 33 | nfdc face create udp4://$IP4_D1 |
| 34 | |
| 35 | # Set up routes |
| 36 | ssh $CTRL_C "nfdc route add /arizona/cs udp4://$IP4_A1" |
| 37 | if [[ $? -ne 0 ]]; then |
| 38 | echo "C: Failed to create route for /arizona/cs toward A" |
| 39 | clean_up |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | ssh $CTRL_C "nfdc route add /ucla/cs udp4://$IP4_A1" |
| 44 | if [[ $? -ne 0 ]]; then |
| 45 | echo "C: Failed to create route for /ucla/cs toward A" |
| 46 | clean_up |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | ssh $CTRL_C "nfdc route add /ucsd/caida udp4://$IP4_A1" |
| 51 | if [[ $? -ne 0 ]]; then |
| 52 | echo "C: Failed to create route for /ucsd/caida toward A" |
| 53 | clean_up |
| 54 | exit 1 |
| 55 | fi |
| 56 | |
| 57 | nfdc route add /arizona/cs udp4://$IP4_D1 |
| 58 | if [[ $? -ne 0 ]]; then |
| 59 | echo "A: Failed to create route for /arizona/cs toward D" |
| 60 | clean_up |
| 61 | exit 1 |
| 62 | fi |
| 63 | |
| 64 | nfdc route add /ucla/cs udp4://$IP4_D1 |
| 65 | if [[ $? -ne 0 ]]; then |
| 66 | echo "A: Failed to create route for /ucla/cs toward D" |
| 67 | clean_up |
| 68 | exit 1 |
| 69 | fi |
| 70 | |
| 71 | nfdc route add /ucsd/caida udp4://$IP4_D1 |
| 72 | if [[ $? -ne 0 ]]; then |
| 73 | echo "A: Failed to create route for /ucsd/caida toward D" |
| 74 | clean_up |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | ### TestCase 1 |
| 79 | |
| 80 | # A: Use CongestionMarkStrategy (value=7) strategy for /arizona/cs namespace |
| 81 | nfdc strategy set /arizona/cs /localhost/nfd/strategy/congestion-mark/%FD%01/7/true |
| 82 | if [[ $? -ne 0 ]]; then |
| 83 | echo "A: Failed to set CongestionMarkStrategy for /arizona/cs prefix" |
| 84 | clean_up |
| 85 | exit 2 |
| 86 | fi |
| 87 | |
| 88 | # D: Start producer for /arizona/cs |
| 89 | ssh $CTRL_D "test-congestionmark-producer /arizona/cs &>/dev/null &" |
| 90 | |
| 91 | # C: Send Interest for /arizona/cs |
| 92 | output=$(ssh $CTRL_C "test-congestionmark-consumer /arizona/cs") |
| 93 | status=$? |
| 94 | if [[ $? -ne 0 ]]; then |
| 95 | echo "Consumer for Interest /arizona/cs did not exit with status 0" |
| 96 | echo "Actual: $status" |
| 97 | clean_up |
| 98 | exit 6 |
| 99 | fi |
| 100 | if [[ $output != "CongestionMark=7" ]]; then |
| 101 | echo "Interest /arizona/cs not answered with a Data containing a congestion mark with a value of 7" |
| 102 | echo "Actual: $output" |
| 103 | clean_up |
| 104 | exit 3 |
| 105 | fi |
| 106 | |
| 107 | ### TestCase 2 |
| 108 | |
| 109 | # D: Start producer for /ucla/cs |
| 110 | ssh $CTRL_D "test-congestionmark-producer /ucla/cs &>/dev/null &" |
| 111 | |
| 112 | # C: Send Interest for /ucla/cs |
| 113 | output=$(ssh $CTRL_C "test-congestionmark-consumer /ucla/cs") |
| 114 | status=$? |
| 115 | if [[ $? -ne 0 ]]; then |
| 116 | echo "Consumer for Interest /ucla/cs did not exit with status 0" |
| 117 | echo "Actual: $status" |
| 118 | clean_up |
| 119 | exit 6 |
| 120 | fi |
| 121 | if [[ $output != "CongestionMark=0" ]]; then |
| 122 | echo "Interest /ucla/cs not answered with a Data without a congestion mark" |
| 123 | echo "Actual: $output" |
| 124 | clean_up |
| 125 | exit 4 |
| 126 | fi |
| 127 | |
| 128 | ### TestCase 3 |
| 129 | |
| 130 | # D: Start producer for /ucsd/caida |
| 131 | ssh $CTRL_D "test-congestionmark-producer /ucsd/caida &>/dev/null &" |
| 132 | sleep 1 |
| 133 | |
| 134 | # C: Use CongestionMarkStrategy (value=2) strategy for /ucsd/caida namespace |
| 135 | ssh $CTRL_C "nfdc strategy set /ucsd/caida /localhost/nfd/strategy/congestion-mark/%FD%01/2/true" |
| 136 | if [[ $? -ne 0 ]]; then |
| 137 | echo "C: Failed to set CongestionMarkStrategy for /ucsd/caida prefix" |
| 138 | clean_up |
| 139 | exit 2 |
| 140 | fi |
| 141 | |
| 142 | # A: Use CongestionMarkStrategy (value=3, override) strategy for /ucsd/caida namespace |
| 143 | nfdc strategy set /ucsd/caida /localhost/nfd/strategy/congestion-mark/%FD%01/3/false |
| 144 | if [[ $? -ne 0 ]]; then |
| 145 | echo "A: Failed to set CongestionMarkStrategy for /ucsd/caida prefix" |
| 146 | clean_up |
| 147 | exit 2 |
| 148 | fi |
| 149 | |
| 150 | # C: Send Interest for /ucsd/caida |
| 151 | output=$(ssh $CTRL_C "test-congestionmark-consumer /ucsd/caida") |
| 152 | status=$? |
| 153 | if [[ $? -ne 0 ]]; then |
| 154 | echo "Consumer for Interest /ucsd/caida did not exit with status 0" |
| 155 | echo "Actual: $status" |
| 156 | clean_up |
| 157 | exit 6 |
| 158 | fi |
| 159 | if [[ $output != "CongestionMark=3" ]]; then |
| 160 | echo "Interest /ucsd/caida not answered with a Data containing a congestion mark with a value of 3" |
| 161 | echo "Actual: $output" |
| 162 | clean_up |
| 163 | exit 5 |
| 164 | fi |