blob: 40e50ca3d9a80d62c743756e1b4ddbe963d010a6 [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..."
35nfdc set-strategy ndn:/test-bcast ndn:/localhost/nfd/strategy/broadcast
Eric Newberry271f3582015-06-18 20:00:26 -070036nfdc add-nexthop -c 10 ndn:/test-bcast udp4://$IP4_B1
37nfdc add-nexthop -c 20 ndn:/test-bcast udp4://$IP4_C1
Yi Huanga349b2c2014-04-27 16:46:03 -070038
39# set up forwarding on D
40echo "setting up forwarding on D..."
Eric Newberry271f3582015-06-18 20:00:26 -070041ssh $CTRL_D "nfdc add-nexthop ndn:/test-bcast udp4://$IP4_A2"
Yi Huanga349b2c2014-04-27 16:46:03 -070042
43# run ndn-traffic client on D
44echo "running ndn-traffic client on D..."
45ssh $CTRL_D "ndn-traffic -c 100 -i 200 $workdir/NDNTrafficClient.conf > $workdir/logs/client.log 2>&1"
46
47# kill ndn-traffic-server on B and C
48echo "killing ndn-traffic-server on B and C..."
49ssh $CTRL_B "sudo killall ndn-traffic-server; sudo killall nfd"
50ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
51
52# collect data from B, C and D
53echo "collecting data from B, C and D..."
54scp $CTRL_B:$workdir/logs/serverB.log $workdir/logs/serverB.log
55scp $CTRL_C:$workdir/logs/serverC.log $workdir/logs/serverC.log
56ssh $CTRL_D "nfd-status -f > $workdir/logs/nfd-status-D.log"
57scp $CTRL_D:$workdir/logs/nfd-status-D.log $workdir/logs/nfd-status-D.log
58scp $CTRL_D:$workdir/logs/client.log $workdir/logs/client.log
59nfd-status > $workdir/logs/nfd-status-A.log
60
61# analyze result
62echo "analyzing result"
63b_received=$(grep "Total Interests Received" $workdir/logs/serverB.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
64if [[ $b_received -lt 80 ]]
65then
66 echo "FAIL: B did not receive at least 80 interests."
67 clean_up
68 exit 1
69fi
70c_received=$(grep "Total Interests Received" $workdir/logs/serverC.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
71if [[ $c_received -lt 80 ]]
72then
73 echo "FAIL: C did not receive at least 80 interests."
74 clean_up
75 exit 2
76fi
77cat $workdir/logs/nfd-status-D.log | grep udp4 | while read line
78do
79 ind=$(echo $line | grep -Po "i .*?d} out" | sed 's/i //g' | sed 's/d} out//g')
80 if [[ $ind -gt 120 ]]
81 then
82 echo "FAIL: incoming data packet in D exceeded 120."
83 echo $line
84 clean_up
85 exit 3
86 fi
87done
88
89# clean up
90clean_up
91echo "Breadcast Test PASSED"