Eric Newberry | c22afde | 2018-06-19 01:28:31 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | source ../multi-host.conf |
| 3 | |
| 4 | clean_up() { |
| 5 | r=$(sudo killall ndn-traffic-server 2>&1) |
| 6 | r=$(sudo killall ndnpeek 2>&1) |
| 7 | r=$(sudo killall nfd 2>&1) |
| 8 | } |
| 9 | |
| 10 | check_peek_exit() { |
| 11 | ps -p $2 > /dev/null |
| 12 | if [[ $? -ne 1 ]]; then |
| 13 | echo "Peek Client $1 did not exit" |
| 14 | clean_up |
| 15 | exit 1 |
| 16 | fi |
| 17 | } |
| 18 | |
| 19 | check_peek_output() { |
| 20 | local out=$(cat $2) |
| 21 | if [[ "$out" != "$3" ]]; then |
| 22 | echo "Peek Client $1 did not receive a Data containing '$3'. Actual: $out" |
| 23 | clean_up |
| 24 | exit 2 |
| 25 | fi |
| 26 | } |
| 27 | |
| 28 | check_server_receive_count() { |
| 29 | local actual=$(cat $2 | grep "Total Interests Received" | head -1 | cut -d"=" -f2 | tr -d " ") |
| 30 | if [[ $actual -ne $3 ]]; then |
| 31 | echo "Traffic Server $1 did not received expected $3 Interests. Actual: $actual" |
| 32 | clean_up |
| 33 | exit 3 |
| 34 | fi |
| 35 | } |
| 36 | |
| 37 | # A: Start NFD |
| 38 | workdir=$(pwd) |
| 39 | echo "Starting nfd on A..." |
| 40 | mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log & |
| 41 | sleep 1 |
| 42 | |
| 43 | # A: Set NFD to use best-route v1 strategy |
| 44 | echo "Setting strategy to best-route v1" |
| 45 | nfdc strategy set / /localhost/nfd/strategy/best-route/%FD%01 |
| 46 | sleep 1 |
| 47 | |
| 48 | # A: Start ndn-traffic-server (Prefix=/text-agg, ContentDelay=2000ms) |
| 49 | echo "Starting Traffic Server 1 (Prefix=/test-agg, ContentDelay=2000ms)..." |
| 50 | ndn-traffic-server $workdir/test-traffic-server.conf &> $workdir/logs/test-server-output-1.txt & |
| 51 | sleep 1 |
| 52 | |
| 53 | # A: Start two instances of ndnpeek to request /test-agg/A |
| 54 | echo "Starting Peek Client 1 (Prefix=/test-agg/A)..." |
| 55 | ndnpeek -p /test-agg/A &> $workdir/logs/test-peek-output-1.txt & |
| 56 | peek1pid=$! |
| 57 | echo "Starting Peek Client 2 (Prefix=/test-agg/A)..." |
| 58 | ndnpeek -p /test-agg/A &> $workdir/logs/test-peek-output-2.txt & |
| 59 | peek2pid=$! |
| 60 | sleep 1 |
| 61 | |
| 62 | # A: Stop ndn-traffic-server instance |
| 63 | echo "Stopping Traffic Server 1..." |
| 64 | sudo killall ndn-traffic-server 2>&1 |
| 65 | sleep 2 |
| 66 | |
| 67 | # A: Ensure ndnpeek instances have quit |
| 68 | check_peek_exit 1 $peek1pid |
| 69 | check_peek_exit 2 $peek2pid |
| 70 | |
| 71 | # A: Ensure ndnpeek instances both received Data packets with correct payloads in response to their Interests |
| 72 | check_peek_output 1 $workdir/logs/test-peek-output-1.txt AAAAAAAA |
| 73 | check_peek_output 2 $workdir/logs/test-peek-output-2.txt AAAAAAAA |
| 74 | |
| 75 | # A: Ensure that Traffic Server 1 received only one Interest |
| 76 | check_server_receive_count 1 $workdir/logs/test-server-output-1.txt 1 |
| 77 | |
| 78 | # A: Start ndn-traffic-server (Prefix=/test-agg, ContentDelay=2000ms) |
| 79 | echo "Starting Traffic Server 2 (Prefix=/test-agg, ContentDelay=2000ms)..." |
| 80 | ndn-traffic-server $workdir/test-traffic-server.conf &> $workdir/logs/test-server-output-2.txt & |
| 81 | sleep 1 |
| 82 | |
| 83 | # A: Start two instances of ndnpeek to request /test-agg/B, with one setting CanBePrefix=false and |
| 84 | # the other setting CanBePrefix=true |
| 85 | echo "Starting Peek Client 3 (Prefix=/test-agg/B, CanBePrefix=false)..." |
| 86 | ndnpeek -p /test-agg/B &> $workdir/logs/test-peek-output-3.txt & |
| 87 | peek3pid=$! |
| 88 | echo "Starting Peek Client 4 (Prefix=/test-agg/B, CanBePrefix=true)..." |
| 89 | ndnpeek -P -p /test-agg/B &> $workdir/logs/test-peek-output-4.txt & |
| 90 | peek4pid=$! |
| 91 | sleep 1 |
| 92 | |
| 93 | # A: Stop ndn-traffic-server instance |
| 94 | echo "Stopping Traffic Server 2..." |
| 95 | sudo killall ndn-traffic-server 2>&1 |
| 96 | sleep 2 |
| 97 | |
| 98 | # A: Ensure ndnpeek instances have quit |
| 99 | check_peek_exit 3 $peek3pid |
| 100 | check_peek_exit 4 $peek4pid |
| 101 | |
| 102 | # A: Ensure ndnpeek instances both received Data packets with correct payload in response to their interests |
| 103 | check_peek_output 3 $workdir/logs/test-peek-output-3.txt AAAAAAAA |
| 104 | check_peek_output 4 $workdir/logs/test-peek-output-4.txt AAAAAAAA |
| 105 | |
| 106 | # A: Ensure that Traffic Server 2 received two Interests |
| 107 | check_server_receive_count 2 $workdir/logs/test-server-output-2.txt 2 |
| 108 | |
| 109 | # A: Start ndn-traffic-server (Prefix=/test-agg, ContentDelay=2000ms) |
| 110 | echo "Starting Traffic Server 3 (Prefix=/test-agg, ContentDelay=2000ms)..." |
| 111 | ndn-traffic-server $workdir/test-traffic-server.conf &> $workdir/logs/test-server-output-3.txt & |
| 112 | sleep 1 |
| 113 | |
| 114 | # A: Start two instances of ndnpeek to request /test-agg/C, with one setting InterestLifetime=6000ms |
| 115 | # and the other setting InterestLifetime=8000ms |
| 116 | echo "Starting Peek Client 5 (Prefix=/test-agg/C, InterestLifetime=6000ms)" |
| 117 | ndnpeek --lifetime 6000 -p /test-agg/C > $workdir/logs/test-peek-output-5.txt & |
| 118 | peek5pid=$! |
| 119 | echo "Starting Peek Client 6 (Prefix=/test-agg/C, InterestLifetime=8000ms)..." |
| 120 | ndnpeek --lifetime 8000 -p /test-agg/C > $workdir/logs/test-peek-output-6.txt & |
| 121 | peek6pid=$! |
| 122 | sleep 1 |
| 123 | |
| 124 | # A: Stop ndn-traffic-server instance |
| 125 | echo "Stopping Traffic Server 3..." |
| 126 | sudo killall ndn-traffic-server 2>&1 |
| 127 | sleep 2 |
| 128 | |
| 129 | # A: Ensure ndnpeek instances have quit |
| 130 | check_peek_exit 5 $peek5pid |
| 131 | check_peek_exit 6 $peek6pid |
| 132 | |
| 133 | # A: Ensure ndnpek instances both received Data packets with correct payload in response to their Interests |
| 134 | check_peek_output 5 $workdir/logs/test-peek-output-5.txt AAAAAAAA |
| 135 | check_peek_output 6 $workdir/logs/test-peek-output-6.txt AAAAAAAA |
| 136 | |
| 137 | # A: Ensure that Traffic Server 3 received only one Interest |
| 138 | check_server_receive_count 3 $workdir/logs/test-server-output-3.txt 1 |
| 139 | |
| 140 | clean_up |