blob: 8d29fd3ee73769aba4b6d9c3477ec35e090b1814 [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 &\
18 sleep 3;\
19 nrd &> $workdir/logs/nrd.log &\
20 sleep 3"
Yi Huanga349b2c2014-04-27 16:46:03 -070021ssh $CTRL_C "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070022 sudo nfd &> $workdir/logs/nfd.log &\
23 sleep 3;\
24 nrd &> $workdir/logs/nrd.log &\
25 sleep 3"
Yi Huanga349b2c2014-04-27 16:46:03 -070026ssh $CTRL_D "mkdir -p $workdir/logs;\
Yi Huang53fa8712014-06-10 20:14:26 -070027 sudo nfd &> $workdir/logs/nfd.log &\
28 sleep 3;\
29 nrd &> $workdir/logs/nrd.log &\
30 sleep 3"
Yi Huanga349b2c2014-04-27 16:46:03 -070031sudo nfd &> $workdir/logs/nfd.log &
Yi Huang53fa8712014-06-10 20:14:26 -070032sleep 3
33nrd &> $workdir/logs/nrd.log &
Yi Huanga349b2c2014-04-27 16:46:03 -070034sleep 5
35
36# start ndn-traffic-server on B and C
37echo "starting ndn-traffic-server on B and C"
38ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverB.log &"
39ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverC.log &"
40
41# set up forwarding on A
42echo "setting up forwarding on A..."
43nfdc set-strategy ndn:/test-bcast ndn:/localhost/nfd/strategy/broadcast
44faceid=$(nfdc create udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
45nfdc add-nexthop -c 10 ndn:/test-bcast $faceid
46faceid=$(nfdc create udp4://$IP4_C1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
47nfdc add-nexthop -c 20 ndn:/test-bcast $faceid
48
49# set up forwarding on D
50echo "setting up forwarding on D..."
51faceid=$(ssh $CTRL_D "nfdc create udp4://$IP4_A2" | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
52ssh $CTRL_D "nfdc add-nexthop ndn:/test-bcast $faceid"
53
54# run ndn-traffic client on D
55echo "running ndn-traffic client on D..."
56ssh $CTRL_D "ndn-traffic -c 100 -i 200 $workdir/NDNTrafficClient.conf > $workdir/logs/client.log 2>&1"
57
58# kill ndn-traffic-server on B and C
59echo "killing ndn-traffic-server on B and C..."
60ssh $CTRL_B "sudo killall ndn-traffic-server; sudo killall nfd"
61ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
62
63# collect data from B, C and D
64echo "collecting data from B, C and D..."
65scp $CTRL_B:$workdir/logs/serverB.log $workdir/logs/serverB.log
66scp $CTRL_C:$workdir/logs/serverC.log $workdir/logs/serverC.log
67ssh $CTRL_D "nfd-status -f > $workdir/logs/nfd-status-D.log"
68scp $CTRL_D:$workdir/logs/nfd-status-D.log $workdir/logs/nfd-status-D.log
69scp $CTRL_D:$workdir/logs/client.log $workdir/logs/client.log
70nfd-status > $workdir/logs/nfd-status-A.log
71
72# analyze result
73echo "analyzing result"
74b_received=$(grep "Total Interests Received" $workdir/logs/serverB.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
75if [[ $b_received -lt 80 ]]
76then
77 echo "FAIL: B did not receive at least 80 interests."
78 clean_up
79 exit 1
80fi
81c_received=$(grep "Total Interests Received" $workdir/logs/serverC.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
82if [[ $c_received -lt 80 ]]
83then
84 echo "FAIL: C did not receive at least 80 interests."
85 clean_up
86 exit 2
87fi
88cat $workdir/logs/nfd-status-D.log | grep udp4 | while read line
89do
90 ind=$(echo $line | grep -Po "i .*?d} out" | sed 's/i //g' | sed 's/d} out//g')
91 if [[ $ind -gt 120 ]]
92 then
93 echo "FAIL: incoming data packet in D exceeded 120."
94 echo $line
95 clean_up
96 exit 3
97 fi
98done
99
100# clean up
101clean_up
102echo "Breadcast Test PASSED"