blob: 9df944c8202208c37dedd392c65aef743ec75ec8 [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
Eric Newberry6fc88222015-06-19 10:43:24 -07007logprefix=$2
Yi Huang3d230672014-04-26 04:25:24 -07008echo "host A IP address $a_ipaddr"
9echo "host B IP address $b_ipaddr"
10echo "host C IP address $c_ipaddr"
11echo "Strategy: $strategy"
12mkdir -p logs
13workdir=$(pwd)
14
15clean_up() {
16 echo "cleaning up..."
Eric Newberry4aeadeb2015-06-23 21:21:12 -070017 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 Huang3d230672014-04-26 04:25:24 -070020}
Eric Newberry4aeadeb2015-06-23 21:21:12 -070021trap clean_up EXIT
22
Hila Ben Abrahamd5033e92015-01-15 20:30:55 -060023# generate nfd.conf: disable multicast faces
24cp /usr/local/etc/ndn/nfd.conf $workdir/nfd.conf
25ssh $CTRL_B "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
26ssh $CTRL_C "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
Yi Huang3d230672014-04-26 04:25:24 -070027
28# get keys
29echo "getting keys..."
30cp -r /usr/local/etc/ndn/keys $workdir/
31ssh $CTRL_B "cp -r /usr/local/etc/ndn/keys $workdir/"
32ssh $CTRL_C "cp -r /usr/local/etc/ndn/keys $workdir/"
33
34# start NFD on three nodes and set nexthop to create loop
35echo "start NFD on three nodes and set nexthop to create loop..."
36ssh $CTRL_B "mkdir -p $workdir/logs;\
Eric Newberry6fc88222015-06-19 10:43:24 -070037 sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &\
Yi Huang53fa8712014-06-10 20:14:26 -070038 sleep 2"
Yi Huang3d230672014-04-26 04:25:24 -070039ssh $CTRL_C "mkdir -p $workdir/logs;\
Eric Newberry6fc88222015-06-19 10:43:24 -070040 sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &\
Yi Huang53fa8712014-06-10 20:14:26 -070041 sleep 2"
Eric Newberry6fc88222015-06-19 10:43:24 -070042sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &
Yi Huang3d230672014-04-26 04:25:24 -070043sleep 5
Eric Newberry4aeadeb2015-06-23 21:21:12 -070044ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy" || exit 3
45ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy" || exit 3
46$workdir/add-nexthop.sh $b_ipaddr $strategy || exit 3
Yi Huang3d230672014-04-26 04:25:24 -070047
48# use ndn-traffic client to send 100 interests
49echo "using ndn-traffic client to send 100 interests..."
Eric Newberry6fc88222015-06-19 10:43:24 -070050ndn-traffic -c 100 -i 200 NDNTrafficClient.conf > $workdir/logs/${logprefix}_client.log 2>&1
Yi Huang3d230672014-04-26 04:25:24 -070051
52# collect nfd-status from B and C
53echo "collecting nfd-status from B and C..."
Eric Newberry4aeadeb2015-06-23 21:21:12 -070054ssh $CTRL_B "nfd-status -f > $workdir/logs/${logprefix}_nfd-status-B.log 2>&1" || exit 4
Eric Newberry6fc88222015-06-19 10:43:24 -070055scp $CTRL_B:$workdir/logs/${logprefix}_nfd-status-B.log $workdir/logs/${logprefix}_nfd-status-B.log
Eric Newberry4aeadeb2015-06-23 21:21:12 -070056ssh $CTRL_C "nfd-status -f > $workdir/logs/${logprefix}_nfd-status-C.log 2>&1" || exit 4
Eric Newberry6fc88222015-06-19 10:43:24 -070057scp $CTRL_C:$workdir/logs/${logprefix}_nfd-status-C.log $workdir/logs/${logprefix}_nfd-status-C.log
Eric Newberry4aeadeb2015-06-23 21:21:12 -070058nfd-status -f > $workdir/logs/${logprefix}_nfd-status-A.log 2>&1 || exit 4
Yi Huang3d230672014-04-26 04:25:24 -070059
60# analyze results
61echo "analyzing results..."
62for host in {A..C}
63do
64 echo "Host $host:"
Eric Newberry6fc88222015-06-19 10:43:24 -070065 cat $workdir/logs/${logprefix}_nfd-status-$host.log | grep udp4 | while read line
Yi Huang3d230672014-04-26 04:25:24 -070066 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 Huang3d230672014-04-26 04:25:24 -070074 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 Huang3d230672014-04-26 04:25:24 -070080 exit 2
81 fi
82 done
83done
84
85# clean up
86clean_up
87echo "Interest Loop Test PASSED"