Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | a_ipaddr=$IP4_A1 |
| 4 | b_ipaddr=$IP4_B1 |
| 5 | c_ipaddr=$IP4_C1 |
| 6 | strategy=$1 |
| 7 | echo "host A IP address $a_ipaddr" |
| 8 | echo "host B IP address $b_ipaddr" |
| 9 | echo "host C IP address $c_ipaddr" |
| 10 | echo "Strategy: $strategy" |
| 11 | mkdir -p logs |
| 12 | workdir=$(pwd) |
| 13 | |
| 14 | clean_up() { |
| 15 | echo "cleaning up..." |
| 16 | r=$(sudo killall nfd 2>&1) |
| 17 | r=$(ssh $b_ipaddr "sudo killall nfd 2>&1" 2>&1) |
| 18 | r=$(ssh $c_ipaddr "sudo killall nfd 2>&1" 2>&1) |
| 19 | } |
| 20 | |
| 21 | # get keys |
| 22 | echo "getting keys..." |
| 23 | cp -r /usr/local/etc/ndn/keys $workdir/ |
| 24 | ssh $CTRL_B "cp -r /usr/local/etc/ndn/keys $workdir/" |
| 25 | ssh $CTRL_C "cp -r /usr/local/etc/ndn/keys $workdir/" |
| 26 | |
| 27 | # start NFD on three nodes and set nexthop to create loop |
| 28 | echo "start NFD on three nodes and set nexthop to create loop..." |
| 29 | ssh $CTRL_B "mkdir -p $workdir/logs;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 30 | sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\ |
| 31 | sleep 2;\ |
| 32 | nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &\ |
| 33 | sleep 2" |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 34 | ssh $CTRL_C "mkdir -p $workdir/logs;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 35 | sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\ |
| 36 | sleep 2;\ |
| 37 | nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &\ |
| 38 | sleep 2" |
| 39 | sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log & |
| 40 | sleep 2 |
| 41 | nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log & |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 42 | sleep 5 |
| 43 | ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy" |
| 44 | ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy" |
| 45 | $workdir/add-nexthop.sh $b_ipaddr $strategy |
| 46 | |
| 47 | # use ndn-traffic client to send 100 interests |
| 48 | echo "using ndn-traffic client to send 100 interests..." |
| 49 | ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/client.log 2>&1 |
| 50 | |
| 51 | # collect nfd-status from B and C |
| 52 | echo "collecting nfd-status from B and C..." |
| 53 | ssh $CTRL_B "nfd-status -f > $workdir/logs/nfd-status-B.log 2>&1" |
| 54 | scp $CTRL_B:$workdir/logs/nfd-status-B.log $workdir/logs/nfd-status-B.log |
| 55 | ssh $CTRL_C "nfd-status -f > $workdir/logs/nfd-status-C.log 2>&1" |
| 56 | scp $CTRL_C:$workdir/logs/nfd-status-C.log $workdir/logs/nfd-status-C.log |
| 57 | nfd-status -f > $workdir/logs/nfd-status-A.log 2>&1 |
| 58 | |
| 59 | # analyze results |
| 60 | echo "analyzing results..." |
| 61 | for host in {A..C} |
| 62 | do |
| 63 | echo "Host $host:" |
| 64 | cat $workdir/logs/nfd-status-$host.log | grep udp4 | while read line |
| 65 | do |
| 66 | ini=$(echo "$line" | grep -Po "in={.*?i" | sed 's/in={//g' | sed 's/i//g') |
| 67 | outi=$(echo "$line" | grep -Po "out={.*?i" | sed 's/out={//g' | sed 's/i//g') |
| 68 | echo " $ini in, $outi out" |
| 69 | if [[ $ini -gt 200 ]] |
| 70 | then |
| 71 | echo "FAIL: counter for incoming interest on host $host is greater than 200" |
| 72 | echo "$line" |
| 73 | clean_up |
| 74 | exit 1 |
| 75 | fi |
| 76 | if [[ $outi -gt 200 ]] |
| 77 | then |
| 78 | echo "FAIL: counter for outgoing interest on host $host is greater than 200" |
| 79 | echo "$line" |
| 80 | clean_up |
| 81 | exit 2 |
| 82 | fi |
| 83 | done |
| 84 | done |
| 85 | |
| 86 | # clean up |
| 87 | clean_up |
| 88 | echo "Interest Loop Test PASSED" |