blob: d4b22b7cb6a23e19b83e7b2913c41ddea7f54dc4 [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
# A: Create route for prefix ndn:/P toward B with cost 10
nfdc register -c 10 ndn:/P udp4://$IP4_B1
if [[ $? -ne 0 ]]
then
echo "Failed to create route for ndn:/P toward host B"
clean_up
exit 1
fi
# A: Create route for prefix ndn:/P toward C with cost 20
nfdc register -c 20 ndn:/P udp4://$IP4_C1
if [[ $? -ne 0 ]]
then
echo "Failed to create route for ndn:/P toward host C"
clean_up
exit 1
fi
# Get face IDs on A
faceB=$(nfdc face list | grep "udp4://$IP4_B1" | cut -d" " -f3 | cut -d"=" -f2)
faceC=$(nfdc face list | grep "udp4://$IP4_C1" | cut -d" " -f3 | cut -d"=" -f2)
# B: Start ndn-traffic-server serving "BBBBBBBB" on ndn:/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 ndn:/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 ndn:/P/1 w/o NextHopFaceId
# Expect Data w/ payload "BBBBBBBB"
echo "From A, sending Interest for ndn:/P/1 (LocalFields=enabled)..."
output=$(test-nexthopfaceid-consumer /P/1 t -1)
if [[ $output != "BBBBBBBB" ]]; then
echo "Interest ndn:/P/1 not answered with Data containing payload 'BBBBBBBB'"
clean_up
exit 2
fi
# A: Start consumer to enable local fields and express Interest for ndn:/P/2 w/ NextHopFaceId=faceB
# Expect Data w/ payload "BBBBBBBB"
echo "From A, sending Interest for ndn:/P/2 (LocalFields=enabled, NextHopFaceId=faceB)..."
output=$(test-nexthopfaceid-consumer /P/2 t $faceB)
if [[ $output != "BBBBBBBB" ]]; then
echo "Interest ndn:/P/2 not answered with Data containing payload 'BBBBBBBB'"
clean_up
exit 3
fi
# A: Start consumer to enable local fields and express Interest for ndn:/P/3 w/ NextHopFaceId=faceC
# Expect Data w/ payload "CCCCCCCC"
echo "From A, sending Interest for ndn:/P/3 (LocalFields=enabled, NextHopFaceId=faceC)..."
output=$(test-nexthopfaceid-consumer /P/3 t $faceC)
if [[ $output != "CCCCCCCC" ]]; then
echo "Interest ndn:/P/3 not answered with Data containing payload 'CCCCCCCC'"
clean_up
exit 4
fi
# A: Start consumer to enable local fields and express Interest for ndn:/P/4 w/ NextHopFaceId=null-face
# Expect either timeout or Nack
echo "From A, sending Interest for ndn:/P/4 (LocalFields=enabled, NextHopFaceId=null-face)..."
output=$(test-nexthopfaceid-consumer /P/4 t 0)
if [[ $output != "Timeout" && $output != "Nack" ]]; then
echo "Interest ndn:/P/4 was not answered with a Nack and did not time out"
clean_up
exit 5
fi
# A: Start consumer to disable local fields and express Interest for ndn:/P/5w/ NextHopFaceId=faceC
# Expect either timeout or Data w/ payload "BBBBBBBB"
echo "From A, sending Interest for ndn:/P/5 (LocalFields=disabled, NextHopFaceId=faceC)..."
output=$(test-nexthopfaceid-consumer /P/5 f $faceC)
if [[ $output != "Timeout" && $output != "BBBBBBBB" ]]; then
echo "Interest ndn:/P/5 was not answered with Data containing payload 'BBBBBBBB' and did not time out"
clean_up
exit 6
fi
clean_up
echo "NextHopFaceId Test PASSED"