Examples: incorporate latest change of NDNPing Class
Change-Id: I01d59de621992a87c082074766dc18e9a7b549a2
diff --git a/examples/nlsr/mcn_failure.py b/examples/nlsr/mcn_failure.py
index 1bd0449..decb586 100644
--- a/examples/nlsr/mcn_failure.py
+++ b/examples/nlsr/mcn_failure.py
@@ -1,6 +1,6 @@
# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
-# Copyright (C) 2015-2019, The University of Memphis,
+# Copyright (C) 2015-2021, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
@@ -32,7 +32,7 @@
from minindn.apps.nlsr import Nlsr
from minindn.helpers.experiment import Experiment
from minindn.helpers.nfdc import Nfdc
-from minindn.helpers.ndnpingclient import NDNPingClient
+from minindn.helpers.ndnping import NDNPing
from nlsr_common import getParser
@@ -63,7 +63,7 @@
if args.nPings != 0:
Experiment.setupPing([mcn], Nfdc.STRATEGY_BEST_ROUTE)
for nodeToPing in pingedDict[mcn]:
- NDNPingClient.ping(mcn, nodeToPing, PING_COLLECTION_TIME_AFTER_RECOVERY)
+ NDNPing.ping(mcn, nodeToPing, nPings=PING_COLLECTION_TIME_AFTER_RECOVERY)
time.sleep(PING_COLLECTION_TIME_AFTER_RECOVERY)
diff --git a/examples/nlsr/multiple_failure.py b/examples/nlsr/multiple_failure.py
index 48d1afd..0833ff1 100644
--- a/examples/nlsr/multiple_failure.py
+++ b/examples/nlsr/multiple_failure.py
@@ -1,6 +1,6 @@
# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
-# Copyright (C) 2015-2019, The University of Memphis,
+# Copyright (C) 2015-2021, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
@@ -32,7 +32,7 @@
from minindn.apps.nlsr import Nlsr
from minindn.helpers.experiment import Experiment
from minindn.helpers.nfdc import Nfdc
-from minindn.helpers.ndnpingclient import NDNPingClient
+from minindn.helpers.ndnping import NDNPing
from nlsr_common import getParser
@@ -45,7 +45,7 @@
FAILURE_INTERVAL = 60
RECOVERY_INTERVAL = 60
- # This is the number of pings required to make it through the full experiment
+ # Number of pings required to make it through the full experiment
nInitialPings = (PING_COLLECTION_TIME_BEFORE_FAILURE +
len(ndn.net.hosts) * (FAILURE_INTERVAL + RECOVERY_INTERVAL))
print('Scheduling with {} initial pings'.format(nInitialPings))
@@ -82,11 +82,11 @@
# Restart pings
for nodeToPing in pingedDict[host]:
- NDNPingClient.ping(host, nodeToPing, nPings)
+ NDNPing.ping(host, nodeToPing, nPings=nPings)
time.sleep(RECOVERY_INTERVAL - recovery_time)
- #Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+ Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
if __name__ == '__main__':
setLogLevel('info')
diff --git a/examples/wifi/wifi_ping.py b/examples/wifi/wifi_ping.py
index bd48b15..a712342 100644
--- a/examples/wifi/wifi_ping.py
+++ b/examples/wifi/wifi_ping.py
@@ -27,7 +27,7 @@
from minindn.apps.app_manager import AppManager
from minindn.apps.nfd import Nfd
from minindn.helpers.nfdc import Nfdc
-from minindn.helpers.ndnpingclient import NDNPingClient
+from minindn.helpers.ndnping import NDNPing
from time import sleep
# This experiment uses the singleap topology and is intended to be a basic
# test case where we see if two nodes can send interests to each other.
@@ -64,13 +64,14 @@
nfds = AppManager(ndnwifi, ndnwifi.net.stations, Nfd)
info("Starting pingserver...")
- ping_server_proc = getPopen(b, "ndnpingserver /example")
+ NDNPing.startPingServer(b, "/example")
Nfdc.createFace(a, b.IP())
Nfdc.registerRoute(a, "/example", b.IP())
info("Starting ping...")
- NDNPingClient.ping(a, "/example", 10)
+ NDNPing.ping(a, "/example", nPings=10)
+ sleep(10)
# Start the CLI
MiniNDNWifiCLI(ndnwifi.net)
ndnwifi.net.stop()
diff --git a/minindn/helpers/ndnping.py b/minindn/helpers/ndnping.py
index 5d2f3d4..b1a4081 100644
--- a/minindn/helpers/ndnping.py
+++ b/minindn/helpers/ndnping.py
@@ -1,6 +1,6 @@
# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
-# Copyright (C) 2015-2020, The University of Memphis,
+# Copyright (C) 2015-2021, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
@@ -28,7 +28,8 @@
class NDNPing(object):
@staticmethod
def ping(source, prefix, pingDataFile="output-client", nPings=1, interval=None, timeout=None,
- starting_seq_num=None, identifier=None, allow_stale_data=False, print_timestamp=True, sleepTime=0.2):
+ starting_seq_num=None, identifier=None, allow_stale_data=False, print_timestamp=True,
+ sleepTime=0.2):
print('Scheduling ping(s) from {} for {}'.format(source.name, prefix))
# Use '&' to run in background and perform parallel pings
source.cmd("mkdir -p ping-data")
@@ -46,8 +47,9 @@
))
time.sleep(sleepTime)
- def startPingServer(source, prefix, pingDataFile="output-server", freshness=None, satisfy=None,
- size=None, timestamp=False, quiet=False):
+ @staticmethod
+ def startPingServer(source, prefix, pingDataFile="output-server", freshness=None, satisfy=None,
+ size=None, timestamp=False, quiet=False):
"""
Start a pingserver
:param string preifx: prefix to start pingserver on