broadcast-test: BroadcastStrategy test scenario

Change-Id: Ie43803f2acadf777bc0832e26f5265094722dbb7
Refs: #1389
diff --git a/test_broadcast/broadcast-test.sh b/test_broadcast/broadcast-test.sh
new file mode 100755
index 0000000..9cbc763
--- /dev/null
+++ b/test_broadcast/broadcast-test.sh
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+source ../multi-host.conf
+mkdir -p logs
+workdir=$(pwd)
+
+clean_up() {
+    echo "cleaning up..."
+    r=$(sudo killall nfd 2>&1)
+    r=$(ssh $CTRL_B "sudo killall ndn-traffic-server 2>&1; sudo killall nfd 2>&1" 2>&1)
+    r=$(ssh $CTRL_C "sudo killall ndn-traffic-server 2>&1; sudo killall nfd 2>&1" 2>&1)
+    r=$(ssh $CTRL_D "sudo killall nfd 2>&1" 2>&1)
+}
+
+# start nfd on all hosts
+echo "starting nfd on all hosts..."
+ssh $CTRL_B "mkdir -p $workdir/logs;\
+    sudo nfd &> $workdir/logs/nfd.log &"
+ssh $CTRL_C "mkdir -p $workdir/logs;\
+    sudo nfd &> $workdir/logs/nfd.log &"
+ssh $CTRL_D "mkdir -p $workdir/logs;\
+    sudo nfd &> $workdir/logs/nfd.log &"
+sudo nfd &> $workdir/logs/nfd.log &
+sleep 5
+
+# start ndn-traffic-server on B and C
+echo "starting ndn-traffic-server on B and C"
+ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverB.log &"
+ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/serverC.log &"
+
+# set up forwarding on A
+echo "setting up forwarding on A..."
+nfdc set-strategy ndn:/test-bcast ndn:/localhost/nfd/strategy/broadcast
+faceid=$(nfdc create udp4://$IP4_B1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
+nfdc add-nexthop -c 10 ndn:/test-bcast $faceid
+faceid=$(nfdc create udp4://$IP4_C1 | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
+nfdc add-nexthop -c 20 ndn:/test-bcast $faceid
+
+# set up forwarding on D
+echo "setting up forwarding on D..."
+faceid=$(ssh $CTRL_D "nfdc create udp4://$IP4_A2" | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
+ssh $CTRL_D "nfdc add-nexthop ndn:/test-bcast $faceid"
+
+# run ndn-traffic client on D
+echo "running ndn-traffic client on D..."
+ssh $CTRL_D "ndn-traffic -c 100 -i 200 $workdir/NDNTrafficClient.conf > $workdir/logs/client.log 2>&1"
+
+# kill ndn-traffic-server on B and C
+echo "killing ndn-traffic-server on B and C..."
+ssh $CTRL_B "sudo killall ndn-traffic-server; sudo killall nfd"
+ssh $CTRL_C "sudo killall ndn-traffic-server; sudo killall nfd"
+
+# collect data from B, C and D
+echo "collecting data from B, C and D..."
+scp $CTRL_B:$workdir/logs/serverB.log $workdir/logs/serverB.log
+scp $CTRL_C:$workdir/logs/serverC.log $workdir/logs/serverC.log
+ssh $CTRL_D "nfd-status -f > $workdir/logs/nfd-status-D.log"
+scp $CTRL_D:$workdir/logs/nfd-status-D.log $workdir/logs/nfd-status-D.log
+scp $CTRL_D:$workdir/logs/client.log $workdir/logs/client.log
+nfd-status > $workdir/logs/nfd-status-A.log
+
+# analyze result
+echo "analyzing result"
+b_received=$(grep "Total Interests Received" $workdir/logs/serverB.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
+if [[ $b_received -lt 80 ]]
+then
+    echo "FAIL: B did not receive at least 80 interests."
+    clean_up
+    exit 1
+fi
+c_received=$(grep "Total Interests Received" $workdir/logs/serverC.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
+if [[ $c_received -lt 80 ]]
+then
+    echo "FAIL: C did not receive at least 80 interests."
+    clean_up
+    exit 2
+fi
+cat $workdir/logs/nfd-status-D.log | grep udp4 | while read line
+do
+    ind=$(echo $line | grep -Po "i .*?d} out" | sed 's/i //g' | sed 's/d} out//g')
+    if [[ $ind -gt 120 ]]
+    then
+        echo "FAIL: incoming data packet in D exceeded 120."
+        echo $line
+        clean_up
+        exit 3
+    fi
+done
+
+# clean up
+clean_up
+echo "Breadcast Test PASSED"