| #!/usr/bin/env bash |
| mkdir -p logs |
| |
| clean_up() { |
| r=$(killall ndn-traffic-server 2>&1) |
| r=$(sudo killall nfd 2>&1) |
| } |
| |
| # Start NFD. |
| sudo nfd &> logs/nfd.log & |
| sleep 2 |
| |
| # Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms |
| ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 & |
| sleep 1 |
| |
| # Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered. |
| output=$(ndnpeek -fp ndn:/test-caching/A) |
| if [[ $output != 'AAAAAAAA' ]] |
| then |
| echo "FAIL: Expected data for first interest: 'AAAAAAAA', Actual: '$output'" |
| clean_up |
| exit 1 |
| fi |
| |
| # Pause 1000ms. |
| sleep 1 |
| |
| # Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered. |
| output=$(ndnpeek -fp ndn:/test-caching/A) |
| if [[ $output != 'AAAAAAAA' ]] |
| then |
| echo "FAIL: Expected data for second interest: 'AAAAAAAA', Actual: '$output'" |
| clean_up |
| exit 2 |
| fi |
| |
| # Kill ndn-traffic-server. Check "total Interests received" equals 1. |
| killall ndn-traffic-server |
| sleep 5 |
| output=$(grep 'Total Interests Received' logs/server.log | head -1 | cut -d = -f2 | cut -d' ' -f2) |
| if [[ $output != '1' ]] |
| then |
| echo "FAIL: Expected ndn-traffic-server to receive 1 interest. Actual: $output" |
| clean_up |
| exit 3 |
| fi |
| |
| # Invoke ndnpeek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered with Data. |
| output=$(ndnpeek -fp ndn:/test-caching/A) |
| if [[ $? == "0" ]] |
| then |
| echo "FAIL: Expected no data to be received in response to third interest. Received: '$output'" |
| clean_up |
| exit 4 |
| fi |
| sleep 1 |
| |
| # Invoke ndnpeek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered. |
| output=$(ndnpeek -p ndn:/test-caching/A) |
| if [[ $output != 'AAAAAAAA' ]] |
| then |
| echo "FAIL: Expected data for fourth interest: 'AAAAAAAA', Actual: '$output'" |
| clean_up |
| exit 5 |
| fi |
| |
| # clean up |
| clean_up |
| echo "ContentStore and freshness test scenario PASSED" |