blob: 0cc616eb6ea25110c82ba06fc24d1eba7db9c5b6 [file] [log] [blame]
Yi Huang3d230672014-04-26 04:25:24 -07001#!/usr/bin/env bash
2source ../multi-host.conf
3a_ipaddr=$IP4_A1
4b_ipaddr=$IP4_B1
5c_ipaddr=$IP4_C1
6strategy=$1
7echo "host A IP address $a_ipaddr"
8echo "host B IP address $b_ipaddr"
9echo "host C IP address $c_ipaddr"
10echo "Strategy: $strategy"
11mkdir -p logs
12workdir=$(pwd)
13
14clean_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
22echo "getting keys..."
23cp -r /usr/local/etc/ndn/keys $workdir/
24ssh $CTRL_B "cp -r /usr/local/etc/ndn/keys $workdir/"
25ssh $CTRL_C "cp -r /usr/local/etc/ndn/keys $workdir/"
26
27# start NFD on three nodes and set nexthop to create loop
28echo "start NFD on three nodes and set nexthop to create loop..."
29ssh $CTRL_B "mkdir -p $workdir/logs;\
30 sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &"
31ssh $CTRL_C "mkdir -p $workdir/logs;\
32 sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &"
33sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &
34sleep 5
35ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy"
36ssh $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
40echo "using ndn-traffic client to send 100 interests..."
41ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/client.log 2>&1
42
43# collect nfd-status from B and C
44echo "collecting nfd-status from B and C..."
45ssh $CTRL_B "nfd-status -f > $workdir/logs/nfd-status-B.log 2>&1"
46scp $CTRL_B:$workdir/logs/nfd-status-B.log $workdir/logs/nfd-status-B.log
47ssh $CTRL_C "nfd-status -f > $workdir/logs/nfd-status-C.log 2>&1"
48scp $CTRL_C:$workdir/logs/nfd-status-C.log $workdir/logs/nfd-status-C.log
49nfd-status -f > $workdir/logs/nfd-status-A.log 2>&1
50
51# analyze results
52echo "analyzing results..."
53for host in {A..C}
54do
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
76done
77
78# clean up
79clean_up
80echo "Interest Loop Test PASSED"