blob: d4b22b7cb6a23e19b83e7b2913c41ddea7f54dc4 [file] [log] [blame]
Eric Newberrya9907782016-11-30 13:37:14 -07001#!/bin/bash
2source ../multi-host.conf
3echo "host B IP address $IP4_B1"
4echo "host C IP address $IP4_C1"
5
6clean_up() {
7 r=$(ssh $CTRL_B "sudo killall ndn-traffic-server" 2>&1)
8 r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
9 r=$(ssh $CTRL_C "sudo killall ndn-traffic-server" 2>&1)
10 r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
11 r=$(sudo killall nfd 2>&1)
12}
13
14mkdir -p logs
15
16# Start NFD on hosts A, B, and C
17workdir=$(pwd)
18echo "starting nfd on host A..."
19sudo nfd > $workdir/logs/nfd.log 2>&1 &
20sleep 1
21
22echo "starting nfd on host B..."
23ssh $CTRL_B "mkdir -p $workdir/logs;\
24 sudo nfd &> $workdir/logs/nfd.log &"
25sleep 1
26
27echo "starting nfd on host C..."
28ssh $CTRL_C "mkdir -p $workdir/logs;\
29 sudo nfd &> $workdir/logs/nfd.log &"
30sleep 1
31
32# A: Create route for prefix ndn:/P toward B with cost 10
33nfdc register -c 10 ndn:/P udp4://$IP4_B1
34if [[ $? -ne 0 ]]
35then
36 echo "Failed to create route for ndn:/P toward host B"
37 clean_up
38 exit 1
39fi
40
41# A: Create route for prefix ndn:/P toward C with cost 20
42nfdc register -c 20 ndn:/P udp4://$IP4_C1
43if [[ $? -ne 0 ]]
44then
45 echo "Failed to create route for ndn:/P toward host C"
46 clean_up
47 exit 1
48fi
49
50# Get face IDs on A
51faceB=$(nfdc face list | grep "udp4://$IP4_B1" | cut -d" " -f3 | cut -d"=" -f2)
52faceC=$(nfdc face list | grep "udp4://$IP4_C1" | cut -d" " -f3 | cut -d"=" -f2)
53
54# B: Start ndn-traffic-server serving "BBBBBBBB" on ndn:/P
55echo "starting ndn-traffic-server on host B..."
56ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer-B.conf > $workdir/logs/server.log 2>&1 &"
57
58# C: Start ndn-traffic-server serving "CCCCCCCC" on ndn:/P
59echo "starting ndn-traffic-server on host C..."
60ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer-C.conf > $workdir/logs/server.log 2>&1 &"
61
62# A: Start consumer to enable local fields and express Interest for ndn:/P/1 w/o NextHopFaceId
63# Expect Data w/ payload "BBBBBBBB"
64echo "From A, sending Interest for ndn:/P/1 (LocalFields=enabled)..."
65output=$(test-nexthopfaceid-consumer /P/1 t -1)
66if [[ $output != "BBBBBBBB" ]]; then
67 echo "Interest ndn:/P/1 not answered with Data containing payload 'BBBBBBBB'"
68 clean_up
69 exit 2
70fi
71
72# A: Start consumer to enable local fields and express Interest for ndn:/P/2 w/ NextHopFaceId=faceB
73# Expect Data w/ payload "BBBBBBBB"
74echo "From A, sending Interest for ndn:/P/2 (LocalFields=enabled, NextHopFaceId=faceB)..."
75output=$(test-nexthopfaceid-consumer /P/2 t $faceB)
76if [[ $output != "BBBBBBBB" ]]; then
77 echo "Interest ndn:/P/2 not answered with Data containing payload 'BBBBBBBB'"
78 clean_up
79 exit 3
80fi
81
82# A: Start consumer to enable local fields and express Interest for ndn:/P/3 w/ NextHopFaceId=faceC
83# Expect Data w/ payload "CCCCCCCC"
84echo "From A, sending Interest for ndn:/P/3 (LocalFields=enabled, NextHopFaceId=faceC)..."
85output=$(test-nexthopfaceid-consumer /P/3 t $faceC)
86if [[ $output != "CCCCCCCC" ]]; then
87 echo "Interest ndn:/P/3 not answered with Data containing payload 'CCCCCCCC'"
88 clean_up
89 exit 4
90fi
91
92# A: Start consumer to enable local fields and express Interest for ndn:/P/4 w/ NextHopFaceId=null-face
93# Expect either timeout or Nack
94echo "From A, sending Interest for ndn:/P/4 (LocalFields=enabled, NextHopFaceId=null-face)..."
95output=$(test-nexthopfaceid-consumer /P/4 t 0)
96if [[ $output != "Timeout" && $output != "Nack" ]]; then
97 echo "Interest ndn:/P/4 was not answered with a Nack and did not time out"
98 clean_up
99 exit 5
100fi
101
102# A: Start consumer to disable local fields and express Interest for ndn:/P/5w/ NextHopFaceId=faceC
103# Expect either timeout or Data w/ payload "BBBBBBBB"
104echo "From A, sending Interest for ndn:/P/5 (LocalFields=disabled, NextHopFaceId=faceC)..."
105output=$(test-nexthopfaceid-consumer /P/5 f $faceC)
106if [[ $output != "Timeout" && $output != "BBBBBBBB" ]]; then
107 echo "Interest ndn:/P/5 was not answered with Data containing payload 'BBBBBBBB' and did not time out"
108 clean_up
109 exit 6
110fi
111
112clean_up
113echo "NextHopFaceId Test PASSED"