Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | usage=$'Usage: tcp-udp-tunnel-test.sh [tcp|udp][4|6]' |
| 3 | if [ $# != 1 ] |
| 4 | then |
| 5 | echo "$usage" |
| 6 | exit |
| 7 | fi |
| 8 | source ../multi-host.conf |
| 9 | if [[ ($1 = "tcp4") || ($1 = "udp4") ]] |
| 10 | then |
| 11 | ipaddr="$IP4_D1" |
| 12 | else |
| 13 | ipaddr="[$IP6_D1]" |
| 14 | fi |
| 15 | echo "host D IP address $ipaddr" |
| 16 | |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 17 | mkdir -p logs/$1 |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 18 | |
| 19 | clean_up() { |
| 20 | r=$(ssh $CTRL_D "sudo killall ndn-traffic-server;\ |
| 21 | sleep 1;\ |
| 22 | sudo killall nfd" 2>&1) |
| 23 | r=$(sudo killall nfd 2>&1) |
| 24 | } |
| 25 | |
| 26 | # start nfd on host A |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 27 | sudo nfd &> logs/$1/nfd.log & |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 28 | sleep 2 |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 29 | |
| 30 | # start nfd and ndn-traffic-server on host D |
| 31 | echo "starting nfd and ndn-traffic-server on host D..." |
| 32 | workdir=$(pwd) |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 33 | ssh $CTRL_D "mkdir -p $workdir/logs/$1;\ |
| 34 | sudo nfd &> $workdir/logs/$1/nfd.log &\ |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 35 | sleep 3;\ |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 36 | ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/$1/server.log 2>&1 &" |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 37 | sleep 5 |
| 38 | |
| 39 | # open a tunnel from host A to host D and set nexthop of ndn:/tunnel-test to D |
| 40 | echo "preparing tunnel..." |
Eric Newberry | 7745c1a | 2017-04-20 00:23:05 -0700 | [diff] [blame] | 41 | nfdc face create $1://$ipaddr |
| 42 | nfdc route add ndn:/tunnel-test $1://$ipaddr |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 43 | |
| 44 | # run ndn-traffic client |
| 45 | echo "running ndn-traffic client..." |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 46 | ndn-traffic -c 100 -i 100 NDNTrafficClient.conf > logs/$1/client.log 2>&1 |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 47 | |
| 48 | # stop nfd on hostA |
| 49 | echo "stopping nfd on host A..." |
| 50 | sudo killall nfd |
| 51 | |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 52 | # stop ndn-traffic-server and nfd on hostD |
| 53 | echo "stopping ndn-traffic-server and nfd on host D..." |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 54 | clean_up |
| 55 | |
| 56 | # examine client log |
| 57 | echo "analyzing results..." |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 58 | output=$(grep "Total Interest Loss" $workdir/logs/$1/client.log | head -1 | cut -d= -f2 | cut -d' ' -f2 | cut -d% -f1) |
Eric Newberry | afb5c5f | 2015-06-09 08:57:58 -0700 | [diff] [blame] | 59 | if [[ $output != 0?(.+(0)) ]] |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 60 | then |
| 61 | echo "Expected no Interest Loss. Actual: $output%" |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 62 | echo "For more information, please examine the log at \"$(pwd)/logs/$1\"" |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 63 | exit 2 |
| 64 | fi |
| 65 | echo "Tunnel Test PASSED" |