blob: ebb1292ddcb17a16b1dba24191bfd5251a2b4b4d [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
36faceid=$(nfdc create udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
37nfdc add-nexthop -c 10 ndn:/test-bcast $faceid
38faceid=$(nfdc create udp4://$IP4_C1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
39nfdc add-nexthop -c 20 ndn:/test-bcast $faceid
40
41# set up forwarding on D
42echo "setting up forwarding on D..."
43faceid=$(ssh $CTRL_D "nfdc create udp4://$IP4_A2" | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
44ssh $CTRL_D "nfdc add-nexthop ndn:/test-bcast $faceid"
45
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
59ssh $CTRL_D "nfd-status -f > $workdir/logs/nfd-status-D.log"
60scp $CTRL_D:$workdir/logs/nfd-status-D.log $workdir/logs/nfd-status-D.log
61scp $CTRL_D:$workdir/logs/client.log $workdir/logs/client.log
62nfd-status > $workdir/logs/nfd-status-A.log
63
64# analyze result
65echo "analyzing result"
66b_received=$(grep "Total Interests Received" $workdir/logs/serverB.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
67if [[ $b_received -lt 80 ]]
68then
69 echo "FAIL: B did not receive at least 80 interests."
70 clean_up
71 exit 1
72fi
73c_received=$(grep "Total Interests Received" $workdir/logs/serverC.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
74if [[ $c_received -lt 80 ]]
75then
76 echo "FAIL: C did not receive at least 80 interests."
77 clean_up
78 exit 2
79fi
80cat $workdir/logs/nfd-status-D.log | grep udp4 | while read line
81do
82 ind=$(echo $line | grep -Po "i .*?d} out" | sed 's/i //g' | sed 's/d} out//g')
83 if [[ $ind -gt 120 ]]
84 then
85 echo "FAIL: incoming data packet in D exceeded 120."
86 echo $line
87 clean_up
88 exit 3
89 fi
90done
91
92# clean up
93clean_up
94echo "Breadcast Test PASSED"