blob: f917a06656237544f3e128daed8256544fb1a29b [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;\
Yi Huang53fa8712014-06-10 20:14:26 -070030 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 Huang3d230672014-04-26 04:25:24 -070034ssh $CTRL_C "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070035 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"
39sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &
40sleep 2
41nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &
Yi Huang3d230672014-04-26 04:25:24 -070042sleep 5
43ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy"
44ssh $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
48echo "using ndn-traffic client to send 100 interests..."
49ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/client.log 2>&1
50
51# collect nfd-status from B and C
52echo "collecting nfd-status from B and C..."
53ssh $CTRL_B "nfd-status -f > $workdir/logs/nfd-status-B.log 2>&1"
54scp $CTRL_B:$workdir/logs/nfd-status-B.log $workdir/logs/nfd-status-B.log
55ssh $CTRL_C "nfd-status -f > $workdir/logs/nfd-status-C.log 2>&1"
56scp $CTRL_C:$workdir/logs/nfd-status-C.log $workdir/logs/nfd-status-C.log
57nfd-status -f > $workdir/logs/nfd-status-A.log 2>&1
58
59# analyze results
60echo "analyzing results..."
61for host in {A..C}
62do
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
84done
85
86# clean up
87clean_up
88echo "Interest Loop Test PASSED"