Add Mobility with Link scenario
refs #3074
Change-Id: I2d4c12195ad0441370c34260425be482ed7a47f4
diff --git a/test_mobility_link/NDNTrafficServer-A.conf b/test_mobility_link/NDNTrafficServer-A.conf
new file mode 100644
index 0000000..35b3f8b
--- /dev/null
+++ b/test_mobility_link/NDNTrafficServer-A.conf
@@ -0,0 +1,4 @@
+##########
+Name=/net/ndnsim/www
+Content=AAAAAAAA
+##########
diff --git a/test_mobility_link/NDNTrafficServer-B.conf b/test_mobility_link/NDNTrafficServer-B.conf
new file mode 100644
index 0000000..7208647
--- /dev/null
+++ b/test_mobility_link/NDNTrafficServer-B.conf
@@ -0,0 +1,4 @@
+##########
+Name=/net/ndnsim/www
+Content=BBBBBBBB
+##########
diff --git a/test_mobility_link/NDNTrafficServer-C.conf b/test_mobility_link/NDNTrafficServer-C.conf
new file mode 100644
index 0000000..00c27e9
--- /dev/null
+++ b/test_mobility_link/NDNTrafficServer-C.conf
@@ -0,0 +1,4 @@
+##########
+Name=/net/ndnsim/www
+Content=CCCCCCCC
+##########
diff --git a/test_mobility_link/NDNTrafficServer-D.conf b/test_mobility_link/NDNTrafficServer-D.conf
new file mode 100644
index 0000000..1f582e9
--- /dev/null
+++ b/test_mobility_link/NDNTrafficServer-D.conf
@@ -0,0 +1,4 @@
+##########
+Name=/net/ndnsim/www
+Content=DDDDDDDD
+##########
diff --git a/test_mobility_link/README.md b/test_mobility_link/README.md
new file mode 100644
index 0000000..c98255f
--- /dev/null
+++ b/test_mobility_link/README.md
@@ -0,0 +1,30 @@
+# Test Mobility with Link
+
+## Topology
+
+C--B--A--D
+
+## Environment Set-up
+
+1. Configure network region names on A, B, C, and D:
+ * C: /arizona/cs
+ * B: /arizona/cs/telecom
+ * A: /ucsd/caida
+ * D: /ucla/cs/irl, /ucla/cs/software
+2. Start NFD on A, B, C, and D.
+3. On C, register a default route toward B.
+4. On B, register a route /ucla toward A.
+5. On A, register a route /ucla/cs toward D.
+6. On C, start ndn-traffic-server on /net/ndnsim/www, serving payload "CCCCCCCC".
+7. On B, start ndn-traffic-server on /net/ndnsim/www, serving payload "BBBBBBBB".
+8. On A, start ndn-traffic-server on /net/ndnsim/www, serving payload "AAAAAAAA".
+9. On D, start ndn-traffic-server on /net/ndnsim/www, serving payload "DDDDDDDD".
+
+## Tests
+
+1. On C, execute a consumer to express an Interest for /net/ndnsim/www/index.html, with a Link object {Name=/net/ndnsim, Delegations={{10, /telia/terabits}, {20, /ucla/cs}}}. Expect Data with payload "DDDDDDDD".
+2. On C, execute a consumer to express an Interest for /net/ndnsim/www/news.html, with a Link object {Name=/net/ndnsim, Delegations={{10, /telia/terabits}, {20, /waseda/cs}}}. Expect Nack with reason NoRoute.
+3. On C, execute a consumer to express an Interest for /net/ndnsim/www/contact.html, with a Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs/telecom}}}. Expect Data with payload "BBBBBBBB".
+4. On C, execute a consumer to express an Interest for /net/ndnsim/www/about.html, with a Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs}}}. Expect Data with payload "CCCCCCCC".
+5. On C, execute a consumer to express an Interest for /net/ndnsim/www/info.html, with a Link object {Name=/net/ndnsim, Delegations={{10, /arizona}}}. Expect Data with payload "CCCCCCCC".
+6. On C, execute a consumer to express an Interest for /net/ndnsim/www/logo.jpg, with a Link object {Name=/net/ndnsim, Delegations{{10, /arizona/cs/telecom/east}}}. Expect Nack with reason NoRoute.
diff --git a/test_mobility_link/mobility-link-test.sh b/test_mobility_link/mobility-link-test.sh
new file mode 100755
index 0000000..e658b01
--- /dev/null
+++ b/test_mobility_link/mobility-link-test.sh
@@ -0,0 +1,188 @@
+#!/bin/bash
+source ../multi-host.conf
+echo "host C IP address $IP4_C1"
+echo "host B IP address $IP4_B1"
+echo "host A IP address $IP4_A1"
+echo "host D IP address $IP4_D1"
+
+clean_up() {
+ r=$(ssh $CTRL_B "sudo killall ndn-traffic-server nfd &&
+ sudo infoedit -f /usr/local/etc/ndn/nfd.conf -d tables.network_region./arizona/cs/telecom" 2>&1)
+ r=$(ssh $CTRL_C "sudo killall nfd &&
+ sudo infoedit -f /usr/local/etc/ndn/nfd.conf -d tables.network_region./arizona/cs" 2>&1)
+ r=$(ssh $CTRL_D "sudo killall ndn-traffic-server nfd &&
+ sudo infoedit -f /usr/local/etc/ndn/nfd.conf -d tables.network_region./ucla/cs/irl &&
+ sudo infoedit -f /usr/local/etc/ndn/nfd.conf -d tables.network_region./ucla/cs/software" 2>&1)
+ r=$(sudo killall ndn-traffic-server nfd 2>&1 &&
+ sudo infoedit -f /usr/local/etc/ndn/nfd.conf -d tables.network_region./ucsd/caida 2>&1)
+}
+
+mkdir -p logs
+workdir=$(pwd)
+
+# Remove any old Link objects
+ssh $CTRL_C "rm -f $workdir/link-object"
+
+# C, B, A, D: Configure network region names
+ssh $CTRL_C "sudo infoedit -f /usr/local/etc/ndn/nfd.conf -r tables.network_region <<EOF
+/arizona/cs
+EOF"
+ssh $CTRL_B "sudo infoedit -f /usr/local/etc/ndn/nfd.conf -r tables.network_region <<EOF
+/arizona/cs/telecom
+EOF"
+sudo infoedit -f /usr/local/etc/ndn/nfd.conf -r tables.network_region <<EOF
+/ucsd/caida
+EOF
+ssh $CTRL_D "sudo infoedit -f /usr/local/etc/ndn/nfd.conf -r tables.network_region <<EOF
+/ucla/cs/irl
+/ucla/cs/software
+EOF"
+
+# C, B, A, D: Start NFD and create UDP tunnels
+echo "starting nfd on host C..."
+ssh $CTRL_C "mkdir -p $workdir/logs;\
+ sudo nfd &> $workdir/logs/nfd.log &"
+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 A..."
+sudo nfd &> $workdir/logs/nfd.log &
+sleep 1
+
+echo "starting nfd on host D..."
+ssh $CTRL_D "mkdir -p $workdir/logs;\
+ sudo nfd &> $workdir/logs/nfd.log &"
+sleep 1
+
+# C: Register default route toward B
+ssh $CTRL_C "nfdc register / udp4://$IP4_B1"
+if [[ $? -ne 0 ]]
+then
+ echo "Failed to create default route on C toward B"
+ clean_up
+ exit 1
+fi
+
+# B: Register route /ucla toward A
+ssh $CTRL_B "nfdc register /ucla udp4://$IP4_A1"
+if [[ $? -ne 0 ]]
+then
+ echo "Failed to create route /ucla on B toward A"
+ clean_up
+ exit 1
+fi
+
+# A: Register route /ucla/cs toward D
+nfdc register /ucla/cs udp4://$IP4_D1
+if [[ $? -ne 0 ]]
+then
+ echo "Failed to create route /ucla/cs on A toward D"
+ clean_up
+ exit 1
+fi
+
+# C: Run ndn-traffic-server for /net/ndnsim/www serving "CCCCCCCC"
+echo "starting ndn-traffic-server on host C..."
+ssh $CTRL_C "ndn-traffic-server $workdir/NDNTrafficServer-C.conf &> $workdir/logs/server.log &"
+
+# B: Run ndn-traffic-server for /net/ndnsim/www serving "BBBBBBBB"
+echo "starting ndn-traffic-server on host B..."
+ssh $CTRL_B "ndn-traffic-server $workdir/NDNTrafficServer-B.conf &> $workdir/logs/server.log &"
+
+# A: Run ndn-traffic-server for /net/ndnsim/www serving "AAAAAAAA"
+echo "starting ndn-traffic-server on host A..."
+ndn-traffic-server $workdir/NDNTrafficServer-A.conf > $workdir/logs/server.log 2>&1 &
+
+# D: Run ndn-traffic-server for /net/ndnsim/www serving "DDDDDDDD"
+echo "starting ndn-traffic-server on host D..."
+ssh $CTRL_D "ndn-traffic-server $workdir/NDNTrafficServer-D.conf &> $workdir/logs/server.log &"
+
+# C: Express Interest for /net/ndnsim/www/index.html w/
+# Link object {Name=/net/ndnsim, Delegations={{10,/telia/terabits}, {20,/ucla/cs}}}
+# Fail if not answered with Data containing "DDDDDDDD"
+echo "From C, sending Interest for /net/ndnsim/www/index.html w/ Link object {Name=/net/ndnsim, Delegations={{10,/telia/terabits}, {20,/ucla/cs}}}"
+ssh $CTRL_C "generate-link-object $workdir/link-object /net/ndnsim 10 /telia/terabits 20 /ucla/cs"
+output=$(ssh $CTRL_C "ndnpeek -p --link-file $workdir/link-object /net/ndnsim/www/index.html 2>&1")
+if [[ $output != "DDDDDDDD" ]]
+then
+ echo "Interest was not answered with Data containing payload 'DDDDDDDD'"
+ echo "Actual: $output"
+ clean_up
+ exit 2
+fi
+
+# C: Express Interest for /net/ndnsim/www/news.html w/
+# Link object {Name=/net/ndnsim, Delegations={{10,/telia/terabits}, {20,/waseda/cs}}}
+# Fail if not answered with Nack with reason "NoRoute"
+echo "From C, sending Interest for /net/ndnsim/www/news.html w/ Link object {Name=/net/ndnsim, Delegations={{10,/telia/terabits}, {20,/waseda/cs}}}"
+ssh $CTRL_C "generate-link-object $workdir/link-object /net/ndnsim 10 /telia/terabits 20 /waseda/cs"
+output=$(ssh $CTRL_C "ndnpeek -p --link-file $workdir/link-object /net/ndnsim/www/news.html 2>&1")
+if [[ $output != "NoRoute" ]]
+then
+ # TODO: Should fail for now - update when CS/PIT partitioning completed
+ echo "EXPECTED FAILURE: Interest was not answered with Nack with reason 'NoRoute'"
+ echo "Actual: $output"
+fi
+
+# C: Express Interest for /net/ndnsim/www/contact.html w/
+# Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs/telecom}}}
+# Fail if not answered with Data containing "BBBBBBBB"
+echo "From C, sending Interest for /net/ndnsim/www/contact.html w/ Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs/telecom}}}"
+ssh $CTRL_C "generate-link-object $workdir/link-object /net/ndnsim 10 /arizona/cs/telecom"
+output=$(ssh $CTRL_C "ndnpeek -p --link-file $workdir/link-object /net/ndnsim/www/contact.html 2>&1")
+if [[ $output != "BBBBBBBB" ]]
+then
+ echo "Interest was not answered with Data containing payload 'BBBBBBBB'"
+ echo "Actual: $output"
+ clean_up
+ exit 4
+fi
+
+# C: Express Interest for /net/ndnsim/www/about.html w/
+# Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs}}}
+# Fail if not answered with Data containing "CCCCCCCC"
+echo "From C, sending Interest for /net/ndnsim/www/about.html w/ Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs}}}"
+ssh $CTRL_C "generate-link-object $workdir/link-object /net/ndnsim 10 /arizona/cs"
+output=$(ssh $CTRL_C "ndnpeek -p --link-file $workdir/link-object /net/ndnsim/www/about.html 2>&1")
+if [[ $output != "CCCCCCCC" ]]
+then
+ echo "Interest was not answered with Data containing payload 'CCCCCCCC'"
+ echo "Actual: $output"
+ clean_up
+ exit 5
+fi
+
+# C: Express Interest for /net/ndnsim/www/info.html w/
+# Link object {Name=/net/ndnsim, Delegations={{10, /arizona}}}
+# Fail if not answered with Data containing "CCCCCCCC"
+echo "From C, sending Interest for /net/ndnsim/www/info.html w/ Link object {Name=/net/ndnsim, Delegations={{10, /arizona}}}"
+ssh $CTRL_C "generate-link-object $workdir/link-object /net/ndnsim 10 /arizona"
+output=$(ssh $CTRL_C "ndnpeek -p --link-file $workdir/link-object /net/ndnsim/www/info.html 2>&1")
+if [[ $output != "CCCCCCCC" ]]
+then
+ echo "Interest was not answered with Data containing payload 'CCCCCCCC'"
+ echo "Actual: $output"
+ clean_up
+ exit 6
+fi
+
+# C: Express Interest for /net/ndnsim/www/logo.jpg w/
+# Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs/telecom/east}}}
+# Fail if not answered with Nack with reason "NoRoute"
+echo "From C, sending Interest for /net/ndnsim/www/logo.jpg w/ Link object {Name=/net/ndnsim, Delegations={{10, /arizona/cs/telecom/east}}}"
+ssh $CTRL_C "generate-link-object $workdir/link-object /net/ndnsim 10 /arizona/cs/telecom/east"
+output=$(ssh $CTRL_C "ndnpeek -p --link-file $workdir/link-object /net/ndnsim/www/logo.jpg 2>&1")
+if [[ $output != "NoRoute" ]]
+then
+ echo "Interest was not answered with Nack with reason 'NoRoute'"
+ echo "Actual: $output"
+ clean_up
+ exit 7
+fi
+
+clean_up
+echo "Mobility with Link Test PASSED"
diff --git a/test_mobility_link/test_mobility_link.py b/test_mobility_link/test_mobility_link.py
new file mode 100644
index 0000000..b1c9d19
--- /dev/null
+++ b/test_mobility_link/test_mobility_link.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python2
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2016 University of Arizona
+# Author: Eric Newberry <enewberry@cs.arizona.edu>
+# See COPYING for copyright and distribution information.
+#
+
+import os
+import unittest
+import subprocess
+
+class test_mobility_link(unittest.TestCase):
+ """Test case for Mobility with Link"""
+
+ def setUp(self):
+ print "\nTesting Mobility with Link"
+ print "*****************"
+ os.chdir("test_mobility_link")
+
+ def tearDown(self):
+ print "*****************"
+ os.chdir("..")
+
+ def test_mobility_link(self):
+ ret = subprocess.call(["./mobility-link-test.sh"], shell=True)
+ print "Test script return value:", ret
+ errormsg = {
+ 1 : "Failed to create required routes",
+ 2 : "Interest /net/ndnsim/www/index.html not answered with Data containing payload 'DDDDDDDD'",
+ 3 : "Interest /net/ndnsim/www/news.html not answered with Nack with reason 'NoRoute'",
+ 4 : "Interest /net/ndnsim/www/contact.html not answered with Data containing payload 'BBBBBBBB'",
+ 5 : "Interest /net/ndnsim/www/about.html not answered with Data containing payload 'CCCCCCCC'",
+ 6 : "Interest /net/ndnsim/www/info.html not answered with Data containing payload 'CCCCCCCC'",
+ 7 : "Interest /net/ndnsim/www/logo.jpg not answered with Nack with reason 'NoRoute'",
+ }
+ if (ret != 0):
+ self.fail(errormsg[ret])