Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 3 | mkdir -p logs/out |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 4 | workdir=$(pwd) |
| 5 | |
| 6 | clean_up() { |
| 7 | r=$(killall nc 2>&1) |
| 8 | r=$(ssh $CTRL_B "sudo killall nfd" 2>&1) |
| 9 | } |
| 10 | |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 11 | ssh $CTRL_B "mkdir -p $workdir/logs/out" |
| 12 | |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 13 | # start NFD on B |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 14 | ssh $CTRL_B "sudo nfd > $workdir/logs/out/nfd.log 2>&1 &\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 15 | sleep 2" |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 16 | |
| 17 | # start netcat on A |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 18 | nc -vul 6363 > $workdir/logs/out/netcat.log 2>&1 & |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 19 | sleep 1 |
| 20 | |
Eric Newberry | 7745c1a | 2017-04-20 00:23:05 -0700 | [diff] [blame] | 21 | # add route to hostA for ndn:/ and ndn:/localhost/test-out |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 22 | if ! status=$(ssh $CTRL_B "source $workdir/out-B.sh udp4://$IP4_A1" 2>&1) |
| 23 | then |
| 24 | echo "Error message from host B:" |
| 25 | echo "$status" |
| 26 | clean_up |
| 27 | exit 4 |
| 28 | fi |
| 29 | |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 30 | # On B, use ndnpeek to request names that starts with ndn:/localhost |
| 31 | r=$(ssh $CTRL_B "ndnpeek -p ndn:/localhost/test-out/B/c39b6fed4ce4464ea136062f80002c7c;\ |
| 32 | ndnpeek -p ndn:/localhost/C/c39b6fed4ce4464ea136062f80002c7c;\ |
| 33 | ndnpeek -p ndn:/ref-out/D/3b5fe3f184ff48adb3523180dee50555") |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 34 | sleep 2 |
| 35 | |
| 36 | # stop netcat and examine netcat.log |
| 37 | ssh $CTRL_B "sudo killall nfd" |
| 38 | output=$(killall nc) |
| 39 | sleep 1 |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 40 | output=$(grep "c39b6fed4ce4464ea136062f80002c7c" $workdir/logs/out/netcat.log) |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 41 | if [[ -n $output ]] |
| 42 | then |
| 43 | echo "FAIL: /localhost Interest reaches remote host." |
| 44 | clean_up |
| 45 | exit 7 |
| 46 | fi |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 47 | output=$(grep "3b5fe3f184ff48adb3523180dee50555" $workdir/logs/out/netcat.log) |
Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame] | 48 | if [[ -z $output ]] |
| 49 | then |
| 50 | echo "FAIL: non-/localhost Interest does not reach remote host." |
| 51 | clean_up |
| 52 | exit 9 |
| 53 | fi |
| 54 | |
| 55 | # clean up |
| 56 | clean_up |
| 57 | echo "localhost outgoing test PASSED" |