blob: 7d0a81faed8c2dc7097ac69403573742b13d2b6f [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}
Hila Ben Abrahamd5033e92015-01-15 20:30:55 -060020# generate nfd.conf: disable multicast faces
21cp /usr/local/etc/ndn/nfd.conf $workdir/nfd.conf
22ssh $CTRL_B "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
23ssh $CTRL_C "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
Yi Huang3d230672014-04-26 04:25:24 -070024
25# get keys
26echo "getting keys..."
27cp -r /usr/local/etc/ndn/keys $workdir/
28ssh $CTRL_B "cp -r /usr/local/etc/ndn/keys $workdir/"
29ssh $CTRL_C "cp -r /usr/local/etc/ndn/keys $workdir/"
30
31# start NFD on three nodes and set nexthop to create loop
32echo "start NFD on three nodes and set nexthop to create loop..."
33ssh $CTRL_B "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070034 sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\
35 sleep 2;\
36 nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &\
37 sleep 2"
Yi Huang3d230672014-04-26 04:25:24 -070038ssh $CTRL_C "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070039 sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\
40 sleep 2;\
41 nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &\
42 sleep 2"
43sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &
44sleep 2
45nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &
Yi Huang3d230672014-04-26 04:25:24 -070046sleep 5
47ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy"
48ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy"
49$workdir/add-nexthop.sh $b_ipaddr $strategy
50
51# use ndn-traffic client to send 100 interests
52echo "using ndn-traffic client to send 100 interests..."
53ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/client.log 2>&1
54
55# collect nfd-status from B and C
56echo "collecting nfd-status from B and C..."
57ssh $CTRL_B "nfd-status -f > $workdir/logs/nfd-status-B.log 2>&1"
58scp $CTRL_B:$workdir/logs/nfd-status-B.log $workdir/logs/nfd-status-B.log
59ssh $CTRL_C "nfd-status -f > $workdir/logs/nfd-status-C.log 2>&1"
60scp $CTRL_C:$workdir/logs/nfd-status-C.log $workdir/logs/nfd-status-C.log
61nfd-status -f > $workdir/logs/nfd-status-A.log 2>&1
62
63# analyze results
64echo "analyzing results..."
65for host in {A..C}
66do
67 echo "Host $host:"
68 cat $workdir/logs/nfd-status-$host.log | grep udp4 | while read line
69 do
70 ini=$(echo "$line" | grep -Po "in={.*?i" | sed 's/in={//g' | sed 's/i//g')
71 outi=$(echo "$line" | grep -Po "out={.*?i" | sed 's/out={//g' | sed 's/i//g')
72 echo " $ini in, $outi out"
73 if [[ $ini -gt 200 ]]
74 then
75 echo "FAIL: counter for incoming interest on host $host is greater than 200"
76 echo "$line"
77 clean_up
78 exit 1
79 fi
80 if [[ $outi -gt 200 ]]
81 then
82 echo "FAIL: counter for outgoing interest on host $host is greater than 200"
83 echo "$line"
84 clean_up
85 exit 2
86 fi
87 done
88done
89
90# clean up
91clean_up
92echo "Interest Loop Test PASSED"