blob: 4f463949783aec0cbf0ea8fc9e52c2f572c8b61e [file] [log] [blame]
Yi Huanga349b2c2014-04-27 16:46:03 -07001#!/usr/bin/env bash
2source ../multi-host.conf
3mkdir -p logs
4workdir=$(pwd)
5
6clean_up() {
7 echo "cleaning up..."
8 r=$(sudo killall nfd 2>&1)
9 r=$(ssh $CTRL_B "sudo killall ndn-traffic-server 2>&1; sudo killall nfd 2>&1" 2>&1)
10 r=$(ssh $CTRL_C "sudo killall ndn-traffic-server 2>&1; sudo killall nfd 2>&1" 2>&1)
11 r=$(ssh $CTRL_D "sudo killall nfd 2>&1" 2>&1)
12}
13
14# start nfd on all hosts
15echo "starting nfd on all hosts..."
16ssh $CTRL_B "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070017 sudo nfd &> $workdir/logs/nfd.log &\
Yi Huang53fa8712014-06-10 20:14:26 -070018 sleep 3"
Yi Huanga349b2c2014-04-27 16:46:03 -070019ssh $CTRL_C "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070020 sudo nfd &> $workdir/logs/nfd.log &\
Yi Huang53fa8712014-06-10 20:14:26 -070021 sleep 3"
Yi Huanga349b2c2014-04-27 16:46:03 -070022ssh $CTRL_D "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070023 sudo nfd &> $workdir/logs/nfd.log &\
Yi Huang53fa8712014-06-10 20:14:26 -070024 sleep 3"
Yi Huanga349b2c2014-04-27 16:46:03 -070025sudo nfd &> $workdir/logs/nfd.log &
Yi Huanga349b2c2014-04-27 16:46:03 -070026sleep 5
27
28# start ndn-traffic-server on B and C
29echo "starting ndn-traffic-server on B and C"
30ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverB.log &"
31ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverC.log &"
32
33# set up forwarding on A
34echo "setting up forwarding on A..."
Eric Newberry7745c1a2017-04-20 00:23:05 -070035nfdc strategy set ndn:/test-mcast ndn:/localhost/nfd/strategy/multicast
36nfdc face create udp4://$IP4_B1
37nfdc face create udp4://$IP4_C1
38nfdc route add ndn:/test-mcast udp4://$IP4_B1 cost 10
39nfdc route add ndn:/test-mcast udp4://$IP4_C1 cost 20
Yi Huanga349b2c2014-04-27 16:46:03 -070040
41# set up forwarding on D
42echo "setting up forwarding on D..."
Eric Newberry7745c1a2017-04-20 00:23:05 -070043ssh $CTRL_D "nfdc face create udp4://$IP4_A2"
44ssh $CTRL_D "nfdc route add ndn:/test-mcast udp4://$IP4_A2"
Yi Huanga349b2c2014-04-27 16:46:03 -070045
46# run ndn-traffic client on D
47echo "running ndn-traffic client on D..."
48ssh $CTRL_D "ndn-traffic -c 100 -i 200 $workdir/NDNTrafficClient.conf > $workdir/logs/client.log 2>&1"
49
50# kill ndn-traffic-server on B and C
51echo "killing ndn-traffic-server on B and C..."
52ssh $CTRL_B "sudo killall ndn-traffic-server; sudo killall nfd"
53ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
54
55# collect data from B, C and D
56echo "collecting data from B, C and D..."
57scp $CTRL_B:$workdir/logs/serverB.log $workdir/logs/serverB.log
58scp $CTRL_C:$workdir/logs/serverC.log $workdir/logs/serverC.log
Eric Newberry7745c1a2017-04-20 00:23:05 -070059ssh $CTRL_D "nfdc face list > $workdir/logs/nfdc-face-list-D.log"
60scp $CTRL_D:$workdir/logs/nfdc-face-list-D.log $workdir/logs/nfdc-face-list-D.log
Yi Huanga349b2c2014-04-27 16:46:03 -070061scp $CTRL_D:$workdir/logs/client.log $workdir/logs/client.log
Yi Huanga349b2c2014-04-27 16:46:03 -070062
63# analyze result
64echo "analyzing result"
65b_received=$(grep "Total Interests Received" $workdir/logs/serverB.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
66if [[ $b_received -lt 80 ]]
67then
68 echo "FAIL: B did not receive at least 80 interests."
69 clean_up
70 exit 1
71fi
72c_received=$(grep "Total Interests Received" $workdir/logs/serverC.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
73if [[ $c_received -lt 80 ]]
74then
75 echo "FAIL: C did not receive at least 80 interests."
76 clean_up
77 exit 2
78fi
Eric Newberry7745c1a2017-04-20 00:23:05 -070079cat $workdir/logs/nfdc-face-list-D.log | grep udp4 | while read line
Yi Huanga349b2c2014-04-27 16:46:03 -070080do
81 ind=$(echo $line | grep -Po "i .*?d} out" | sed 's/i //g' | sed 's/d} out//g')
82 if [[ $ind -gt 120 ]]
83 then
84 echo "FAIL: incoming data packet in D exceeded 120."
85 echo $line
86 clean_up
87 exit 3
88 fi
89done
90
91# clean up
92clean_up
Junxiao Shif9ecac22015-08-28 10:02:51 -070093echo "MulticastStrategy PASSED"