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