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