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;\ |
| 30 | sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &" |
| 31 | ssh $CTRL_C "mkdir -p $workdir/logs;\ |
| 32 | sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &" |
| 33 | sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 & |
| 34 | sleep 5 |
| 35 | ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy" |
| 36 | ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy" |
| 37 | $workdir/add-nexthop.sh $b_ipaddr $strategy |
| 38 | |
| 39 | # use ndn-traffic client to send 100 interests |
| 40 | echo "using ndn-traffic client to send 100 interests..." |
| 41 | ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/client.log 2>&1 |
| 42 | |
| 43 | # collect nfd-status from B and C |
| 44 | echo "collecting nfd-status from B and C..." |
| 45 | ssh $CTRL_B "nfd-status -f > $workdir/logs/nfd-status-B.log 2>&1" |
| 46 | scp $CTRL_B:$workdir/logs/nfd-status-B.log $workdir/logs/nfd-status-B.log |
| 47 | ssh $CTRL_C "nfd-status -f > $workdir/logs/nfd-status-C.log 2>&1" |
| 48 | scp $CTRL_C:$workdir/logs/nfd-status-C.log $workdir/logs/nfd-status-C.log |
| 49 | nfd-status -f > $workdir/logs/nfd-status-A.log 2>&1 |
| 50 | |
| 51 | # analyze results |
| 52 | echo "analyzing results..." |
| 53 | for host in {A..C} |
| 54 | do |
| 55 | echo "Host $host:" |
| 56 | cat $workdir/logs/nfd-status-$host.log | grep udp4 | while read line |
| 57 | do |
| 58 | ini=$(echo "$line" | grep -Po "in={.*?i" | sed 's/in={//g' | sed 's/i//g') |
| 59 | outi=$(echo "$line" | grep -Po "out={.*?i" | sed 's/out={//g' | sed 's/i//g') |
| 60 | echo " $ini in, $outi out" |
| 61 | if [[ $ini -gt 200 ]] |
| 62 | then |
| 63 | echo "FAIL: counter for incoming interest on host $host is greater than 200" |
| 64 | echo "$line" |
| 65 | clean_up |
| 66 | exit 1 |
| 67 | fi |
| 68 | if [[ $outi -gt 200 ]] |
| 69 | then |
| 70 | echo "FAIL: counter for outgoing interest on host $host is greater than 200" |
| 71 | echo "$line" |
| 72 | clean_up |
| 73 | exit 2 |
| 74 | fi |
| 75 | done |
| 76 | done |
| 77 | |
| 78 | # clean up |
| 79 | clean_up |
| 80 | echo "Interest Loop Test PASSED" |