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 | |
| 17 | mkdir -p logs |
| 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 |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 27 | sudo nfd &> logs/nfd.log & |
| 28 | sleep 2 |
| 29 | nrd &> logs/nrd.log & |
| 30 | sleep 2 |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 31 | |
| 32 | # start nfd and ndn-traffic-server on host D |
| 33 | echo "starting nfd and ndn-traffic-server on host D..." |
| 34 | workdir=$(pwd) |
| 35 | ssh $CTRL_D "mkdir -p $workdir/logs;\ |
| 36 | sudo nfd &> $workdir/logs/nfd.log &\ |
| 37 | sleep 3;\ |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 38 | nrd &> $workdir/logs/nrd.log &\ |
| 39 | sleep 3;\ |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 40 | ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &" |
| 41 | sleep 5 |
| 42 | |
| 43 | # open a tunnel from host A to host D and set nexthop of ndn:/tunnel-test to D |
| 44 | echo "preparing tunnel..." |
| 45 | faceid=$(nfdc create $1://$ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//') |
| 46 | if [[ -z $faceid ]] |
| 47 | then |
| 48 | echo "Fail to create face" |
| 49 | clean_up |
| 50 | exit 1 |
| 51 | fi |
| 52 | nfdc add-nexthop ndn:/tunnel-test $faceid |
| 53 | |
| 54 | # run ndn-traffic client |
| 55 | echo "running ndn-traffic client..." |
| 56 | ndn-traffic -c 100 -i 100 NDNTrafficClient.conf > logs/client.log 2>&1 |
| 57 | |
| 58 | # stop nfd on hostA |
| 59 | echo "stopping nfd on host A..." |
| 60 | sudo killall nfd |
| 61 | |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 62 | # stop ndn-traffic-server and nfd on hostD |
| 63 | echo "stopping ndn-traffic-server and nfd on host D..." |
Yi Huang | 9a118b3 | 2014-04-22 15:17:51 -0700 | [diff] [blame] | 64 | clean_up |
| 65 | |
| 66 | # examine client log |
| 67 | echo "analyzing results..." |
| 68 | output=$(grep "Total Interest Loss" $workdir/logs/client.log | head -1 | cut -d= -f2 | cut -d' ' -f2 | cut -d% -f1) |
| 69 | if [ $output != '0' ] |
| 70 | then |
| 71 | echo "Expected no Interest Loss. Actual: $output%" |
| 72 | echo "For more information, please examine the log at \"$(pwd)/logs\"" |
| 73 | exit 2 |
| 74 | fi |
| 75 | echo "Tunnel Test PASSED" |