blob: 93677f8fb6b06131d6bc9596bc817ce752c10afb [file] [log] [blame]
#!/bin/bash
source ../multi-host.conf
echo "host B IP address $IP4_B1"
echo "host C IP address $IP4_C1"
clean_up() {
r=$(ssh $CTRL_B "sudo killall ndn-traffic-server" 2>&1)
r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
r=$(ssh $CTRL_C "sudo killall ndn-traffic-server" 2>&1)
r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
r=$(sudo killall nfd 2>&1)
}
mkdir -p logs
# Start NFD on hosts A, B, and C
workdir=$(pwd)
echo "starting nfd on host A..."
sudo nfd > $workdir/logs/nfd.log 2>&1 &
sleep 1
echo "starting nfd on host B..."
ssh $CTRL_B "mkdir -p $workdir/logs;\
sudo nfd &> $workdir/logs/nfd.log &"
sleep 1
echo "starting nfd on host C..."
ssh $CTRL_C "mkdir -p $workdir/logs;\
sudo nfd &> $workdir/logs/nfd.log &"
sleep 1
# Create faces
nfdc face create udp4://$IP4_B1
nfdc face create udp4://$IP4_C1
# A: Create route for prefix /P toward B with cost 10
nfdc route add /P udp4://$IP4_B1 cost 10
if [[ $? -ne 0 ]]
then
echo "Failed to create route for /P toward host B"
clean_up
exit 1
fi
# A: Create route for prefix /P toward C with cost 20
nfdc route add /P udp4://$IP4_C1 cost 20
if [[ $? -ne 0 ]]
then
echo "Failed to create route for /P toward host C"
clean_up
exit 1
fi
# Get face IDs on A
faceB=$(nfdc face list | grep "udp4://$IP4_B1" | cut -d" " -f1 | cut -d"=" -f2)
faceC=$(nfdc face list | grep "udp4://$IP4_C1" | cut -d" " -f1 | cut -d"=" -f2)
# B: Start ndn-traffic-server serving "BBBBBBBB" on /P
echo "starting ndn-traffic-server on host B..."
ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer-B.conf > $workdir/logs/server.log 2>&1 &"
# C: Start ndn-traffic-server serving "CCCCCCCC" on /P
echo "starting ndn-traffic-server on host C..."
ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer-C.conf > $workdir/logs/server.log 2>&1 &"
# A: Start consumer to enable local fields and express Interest for /P/1 w/o NextHopFaceId
# Expect Data w/ payload "BBBBBBBB"
echo "From A, sending Interest for /P/1 (LocalFields=enabled)..."
output=$(test-nexthopfaceid-consumer /P/1 t -1)
if [[ $output != "BBBBBBBB" ]]; then
echo "Interest /P/1 not answered with Data containing payload 'BBBBBBBB'"
echo "Actual: $output"
clean_up
exit 2
fi
# A: Start consumer to enable local fields and express Interest for /P/2 w/ NextHopFaceId=faceB
# Expect Data w/ payload "BBBBBBBB"
echo "From A, sending Interest for /P/2 (LocalFields=enabled, NextHopFaceId=faceB)..."
output=$(test-nexthopfaceid-consumer /P/2 t $faceB)
if [[ $output != "BBBBBBBB" ]]; then
echo "Interest /P/2 not answered with Data containing payload 'BBBBBBBB'"
echo "Actual: $output"
clean_up
exit 3
fi
# A: Start consumer to enable local fields and express Interest for /P/3 w/ NextHopFaceId=faceC
# Expect Data w/ payload "CCCCCCCC"
echo "From A, sending Interest for /P/3 (LocalFields=enabled, NextHopFaceId=faceC)..."
output=$(test-nexthopfaceid-consumer /P/3 t $faceC)
if [[ $output != "CCCCCCCC" ]]; then
echo "Interest /P/3 not answered with Data containing payload 'CCCCCCCC'"
echo "Actual: $output"
clean_up
exit 4
fi
# A: Start consumer to enable local fields and express Interest for /P/4 w/ NextHopFaceId=null-face
# Expect either timeout or Nack
echo "From A, sending Interest for /P/4 (LocalFields=enabled, NextHopFaceId=null-face)..."
output=$(test-nexthopfaceid-consumer /P/4 t 0)
if [[ $output != "Timeout" && $output != "Nack" ]]; then
echo "Interest /P/4 was not answered with a Nack and did not time out"
echo "Actual: $output"
clean_up
exit 5
fi
# A: Start consumer to disable local fields and express Interest for /P/5w/ NextHopFaceId=faceC
# Expect either timeout or Data w/ payload "BBBBBBBB"
echo "From A, sending Interest for /P/5 (LocalFields=disabled, NextHopFaceId=faceC)..."
output=$(test-nexthopfaceid-consumer /P/5 f $faceC)
if [[ $output != "Timeout" && $output != "BBBBBBBB" ]]; then
echo "Interest /P/5 was not answered with Data containing payload 'BBBBBBBB' and did not time out"
echo "Actual: $output"
clean_up
exit 6
fi
clean_up
echo "NextHopFaceId Test PASSED"