blob: 93677f8fb6b06131d6bc9596bc817ce752c10afb [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;\
Eric Newberry7745c1a2017-04-20 00:23:05 -070024 sudo nfd &> $workdir/logs/nfd.log &"
Eric Newberrya9907782016-11-30 13:37:14 -070025sleep 1
26
27echo "starting nfd on host C..."
28ssh $CTRL_C "mkdir -p $workdir/logs;\
Eric Newberry7745c1a2017-04-20 00:23:05 -070029 sudo nfd &> $workdir/logs/nfd.log &"
Eric Newberrya9907782016-11-30 13:37:14 -070030sleep 1
31
Eric Newberry7745c1a2017-04-20 00:23:05 -070032# Create faces
33nfdc face create udp4://$IP4_B1
34nfdc face create udp4://$IP4_C1
35
36# A: Create route for prefix /P toward B with cost 10
37nfdc route add /P udp4://$IP4_B1 cost 10
Eric Newberrya9907782016-11-30 13:37:14 -070038if [[ $? -ne 0 ]]
39then
Eric Newberry7745c1a2017-04-20 00:23:05 -070040 echo "Failed to create route for /P toward host B"
41 clean_up
42 exit 1
Eric Newberrya9907782016-11-30 13:37:14 -070043fi
44
Eric Newberry7745c1a2017-04-20 00:23:05 -070045# A: Create route for prefix /P toward C with cost 20
46nfdc route add /P udp4://$IP4_C1 cost 20
Eric Newberrya9907782016-11-30 13:37:14 -070047if [[ $? -ne 0 ]]
48then
Eric Newberry7745c1a2017-04-20 00:23:05 -070049 echo "Failed to create route for /P toward host C"
50 clean_up
51 exit 1
Eric Newberrya9907782016-11-30 13:37:14 -070052fi
53
54# Get face IDs on A
Eric Newberry7745c1a2017-04-20 00:23:05 -070055faceB=$(nfdc face list | grep "udp4://$IP4_B1" | cut -d" " -f1 | cut -d"=" -f2)
56faceC=$(nfdc face list | grep "udp4://$IP4_C1" | cut -d" " -f1 | cut -d"=" -f2)
Eric Newberrya9907782016-11-30 13:37:14 -070057
Eric Newberry7745c1a2017-04-20 00:23:05 -070058# B: Start ndn-traffic-server serving "BBBBBBBB" on /P
Eric Newberrya9907782016-11-30 13:37:14 -070059echo "starting ndn-traffic-server on host B..."
60ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer-B.conf > $workdir/logs/server.log 2>&1 &"
61
Eric Newberry7745c1a2017-04-20 00:23:05 -070062# C: Start ndn-traffic-server serving "CCCCCCCC" on /P
Eric Newberrya9907782016-11-30 13:37:14 -070063echo "starting ndn-traffic-server on host C..."
64ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer-C.conf > $workdir/logs/server.log 2>&1 &"
65
Eric Newberry7745c1a2017-04-20 00:23:05 -070066# A: Start consumer to enable local fields and express Interest for /P/1 w/o NextHopFaceId
Eric Newberrya9907782016-11-30 13:37:14 -070067# Expect Data w/ payload "BBBBBBBB"
Eric Newberry7745c1a2017-04-20 00:23:05 -070068echo "From A, sending Interest for /P/1 (LocalFields=enabled)..."
Eric Newberrya9907782016-11-30 13:37:14 -070069output=$(test-nexthopfaceid-consumer /P/1 t -1)
70if [[ $output != "BBBBBBBB" ]]; then
Eric Newberry7745c1a2017-04-20 00:23:05 -070071 echo "Interest /P/1 not answered with Data containing payload 'BBBBBBBB'"
72 echo "Actual: $output"
Eric Newberrya9907782016-11-30 13:37:14 -070073 clean_up
74 exit 2
75fi
76
Eric Newberry7745c1a2017-04-20 00:23:05 -070077# A: Start consumer to enable local fields and express Interest for /P/2 w/ NextHopFaceId=faceB
Eric Newberrya9907782016-11-30 13:37:14 -070078# Expect Data w/ payload "BBBBBBBB"
Eric Newberry7745c1a2017-04-20 00:23:05 -070079echo "From A, sending Interest for /P/2 (LocalFields=enabled, NextHopFaceId=faceB)..."
Eric Newberrya9907782016-11-30 13:37:14 -070080output=$(test-nexthopfaceid-consumer /P/2 t $faceB)
81if [[ $output != "BBBBBBBB" ]]; then
Eric Newberry7745c1a2017-04-20 00:23:05 -070082 echo "Interest /P/2 not answered with Data containing payload 'BBBBBBBB'"
83 echo "Actual: $output"
Eric Newberrya9907782016-11-30 13:37:14 -070084 clean_up
85 exit 3
86fi
87
Eric Newberry7745c1a2017-04-20 00:23:05 -070088# A: Start consumer to enable local fields and express Interest for /P/3 w/ NextHopFaceId=faceC
Eric Newberrya9907782016-11-30 13:37:14 -070089# Expect Data w/ payload "CCCCCCCC"
Eric Newberry7745c1a2017-04-20 00:23:05 -070090echo "From A, sending Interest for /P/3 (LocalFields=enabled, NextHopFaceId=faceC)..."
Eric Newberrya9907782016-11-30 13:37:14 -070091output=$(test-nexthopfaceid-consumer /P/3 t $faceC)
92if [[ $output != "CCCCCCCC" ]]; then
Eric Newberry7745c1a2017-04-20 00:23:05 -070093 echo "Interest /P/3 not answered with Data containing payload 'CCCCCCCC'"
94 echo "Actual: $output"
Eric Newberrya9907782016-11-30 13:37:14 -070095 clean_up
96 exit 4
97fi
98
Eric Newberry7745c1a2017-04-20 00:23:05 -070099# A: Start consumer to enable local fields and express Interest for /P/4 w/ NextHopFaceId=null-face
Eric Newberrya9907782016-11-30 13:37:14 -0700100# Expect either timeout or Nack
Eric Newberry7745c1a2017-04-20 00:23:05 -0700101echo "From A, sending Interest for /P/4 (LocalFields=enabled, NextHopFaceId=null-face)..."
Eric Newberrya9907782016-11-30 13:37:14 -0700102output=$(test-nexthopfaceid-consumer /P/4 t 0)
103if [[ $output != "Timeout" && $output != "Nack" ]]; then
Eric Newberry7745c1a2017-04-20 00:23:05 -0700104 echo "Interest /P/4 was not answered with a Nack and did not time out"
105 echo "Actual: $output"
Eric Newberrya9907782016-11-30 13:37:14 -0700106 clean_up
107 exit 5
108fi
109
Eric Newberry7745c1a2017-04-20 00:23:05 -0700110# A: Start consumer to disable local fields and express Interest for /P/5w/ NextHopFaceId=faceC
Eric Newberrya9907782016-11-30 13:37:14 -0700111# Expect either timeout or Data w/ payload "BBBBBBBB"
Eric Newberry7745c1a2017-04-20 00:23:05 -0700112echo "From A, sending Interest for /P/5 (LocalFields=disabled, NextHopFaceId=faceC)..."
Eric Newberrya9907782016-11-30 13:37:14 -0700113output=$(test-nexthopfaceid-consumer /P/5 f $faceC)
114if [[ $output != "Timeout" && $output != "BBBBBBBB" ]]; then
Eric Newberry7745c1a2017-04-20 00:23:05 -0700115 echo "Interest /P/5 was not answered with Data containing payload 'BBBBBBBB' and did not time out"
116 echo "Actual: $output"
Eric Newberrya9907782016-11-30 13:37:14 -0700117 clean_up
118 exit 6
119fi
120
121clean_up
122echo "NextHopFaceId Test PASSED"