ndn: bug fixes in nfdc and experiments

Change-Id: I8cb9b0a9e53e0319e3f18ab6a52867d406a31fd5
diff --git a/ndn/apps/nfdc.py b/ndn/apps/nfdc.py
index 2d38530..4b28a64 100644
--- a/ndn/apps/nfdc.py
+++ b/ndn/apps/nfdc.py
@@ -22,18 +22,23 @@
 # If not, see <http://www.gnu.org/licenses/>.
 
 import time
+from mininet.log import setLogLevel, output, info, debug
 
 class Nfdc:
     STRATEGY_ASF = "asf"
     STRATEGY_BEST_ROUTE = "best-route"
     STRATEGY_MULTICAST = "multicast"
     STRATEGY_NCC = "ncc"
+    PROTOCOL_UDP = "udp"
+    PROTOCOL_TCP = "tcp"
+    PROTOCOL_ETHER = "ether"
 
     @staticmethod
-    def registerRoute(node, namePrefix, remoteNode, origin=255, cost=0,
+    def registerRoute(node, namePrefix, remoteNode, protocol=PROTOCOL_UDP, origin=255, cost=0,
                       inheritFlag=True, captureFlag=False, expirationInMillis=0):
-        node.cmd("nfdc route add {} {} {} {} {}{}{}").format(
+        cmd = ("nfdc route add {} {}://{} origin {} cost {} {}{}{}").format(
             namePrefix,
+            protocol,
             remoteNode,
             origin,
             cost,
@@ -41,33 +46,36 @@
             "capture " if captureFlag else "",
             "expires {}".format(expirationInMillis)
         )
+        debug(node.cmd(cmd))
         time.sleep(0.5)
 
     @staticmethod
     def unregisterRoute(node, namePrefix, remoteNode, origin=255):
-        node.cmd("nfdc route remove {} {} {}".format(namePrefix, remoteNode, origin))
+        cmd = "nfdc route remove {} {} {}".format(namePrefix, remoteNode, origin)
         time.sleep(0.5)
 
     @staticmethod
     def createFace(node, remoteNode, protocol="udp", isPermanent=False):
-        node.cmd("nfdc face create {}://{} {}".format(
+        cmd = ("nfdc face create {}://{} {}".format(
             protocol,
             remoteNode,
             "permanent" if isPermanent else "persistent"
         ))
+        debug(node.cmd(cmd))
         time.sleep(0.5)
 
     @staticmethod
     def destroyFace(node, remoteNode, protocol="udp"):
-        node.cmd("nfdc face destroy {}://{}".format(protocol, remoteNode))
+        debug(node.cmd("nfdc face destroy {}://{}".format(protocol, remoteNode)))
         time.sleep(0.5)
 
     @staticmethod
     def setStrategy(node, namePrefix, strategy):
-        node.cmd("nfdc strategy set {} ndn:/localhost/nfd/strategy/{}".format(namePrefix, strategy))
+        cmd = "nfdc strategy set {} ndn:/localhost/nfd/strategy/{}".format(namePrefix, strategy)
+        debug(node.cmd(cmd))
         time.sleep(0.5)
 
     @staticmethod
     def unsetStrategy(node, namePrefix):
-        node.cmd("nfdc strategy unset {}".format(namePrefix))
+        debug(node.cmd("nfdc strategy unset {}".format(namePrefix)))
         time.sleep(0.5)
\ No newline at end of file
diff --git a/ndn/experiments/failure_experiment.py b/ndn/experiments/failure_experiment.py
index b25cbfe..a27b0a6 100644
--- a/ndn/experiments/failure_experiment.py
+++ b/ndn/experiments/failure_experiment.py
@@ -23,6 +23,7 @@
 
 from ndn.experiments.experiment import Experiment
 from ndn.nlsr import Nlsr
+from ndn.apps.ndn_ping_client import NDNPingClient
 
 import time
 
@@ -57,7 +58,7 @@
 
                 for other in self.net.hosts:
                     if host.name != other.name:
-                        self.ping(host, other, self.PING_COLLECTION_TIME_AFTER_RECOVERY)
+                        NDNPingClient.ping(host, other, self.PING_COLLECTION_TIME_AFTER_RECOVERY)
 
         # Collect pings for more seconds after CSU is up
         time.sleep(self.PING_COLLECTION_TIME_AFTER_RECOVERY)
diff --git a/ndn/experiments/mcn_failure_experiment.py b/ndn/experiments/mcn_failure_experiment.py
index 019c214..62bdcab 100644
--- a/ndn/experiments/mcn_failure_experiment.py
+++ b/ndn/experiments/mcn_failure_experiment.py
@@ -22,6 +22,7 @@
 # If not, see <http://www.gnu.org/licenses/>.
 
 from ndn.experiments.experiment import Experiment
+from ndn.apps.ndn_ping_client import NDNPingClient
 
 import time
 
@@ -58,7 +59,7 @@
 
         # Restart pings
         for nodeToPing in self.pingedDict[mostConnectedNode]:
-            self.ping(mostConnectedNode, nodeToPing, self.PING_COLLECTION_TIME_AFTER_RECOVERY)
+            NDNPingClient.ping(mostConnectedNode, nodeToPing, self.PING_COLLECTION_TIME_AFTER_RECOVERY)
 
         # Collect pings for more seconds after MCN is up
         time.sleep(self.PING_COLLECTION_TIME_AFTER_RECOVERY)
diff --git a/ndn/experiments/multiple_failure_experiment.py b/ndn/experiments/multiple_failure_experiment.py
index 0836949..6b4ce6b 100644
--- a/ndn/experiments/multiple_failure_experiment.py
+++ b/ndn/experiments/multiple_failure_experiment.py
@@ -23,6 +23,7 @@
 
 from ndn.experiments.experiment import Experiment
 from ndn.nlsr import Nlsr
+from ndn.apps.ndn_ping_client import NDNPingClient
 
 import time
 
@@ -74,7 +75,7 @@
 
             # Restart pings
             for nodeToPing in self.pingedDict[host]:
-                self.ping(host, nodeToPing, nPings)
+                NDNPingClient.ping(host, nodeToPing, nPings)
 
             time.sleep(self.RECOVERY_INTERVAL - recovery_time)