catchunks: remove iterative version discovery method

refs: #4556
Change-Id: I22f35ea3c96a9eea32d478b13a52f9b3fba8442f
diff --git a/tools/chunks/catchunks/discover-version-iterative.cpp b/tools/chunks/catchunks/discover-version-iterative.cpp
deleted file mode 100644
index adeb48e..0000000
--- a/tools/chunks/catchunks/discover-version-iterative.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2016-2019, Regents of the University of California,
- *                          Colorado State University,
- *                          University Pierre & Marie Curie, Sorbonne University.
- *
- * This file is part of ndn-tools (Named Data Networking Essential Tools).
- * See AUTHORS.md for complete list of ndn-tools authors and contributors.
- *
- * ndn-tools is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * ndn-tools, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Wentao Shang
- * @author Steve DiBenedetto
- * @author Andrea Tosatto
- * @author Klaus Schneider
- */
-
-#include "discover-version-iterative.hpp"
-
-namespace ndn {
-namespace chunks {
-
-DiscoverVersionIterative::DiscoverVersionIterative(const Name& prefix, Face& face,
-                                                   const Options& options)
-  : chunks::Options(options)
-  , DiscoverVersion(prefix, face)
-  , Options(options)
-  , m_latestVersion(0)
-  , m_foundVersion(false)
-{
-}
-
-void
-DiscoverVersionIterative::run()
-{
-  m_latestVersion = 0;
-  m_foundVersion = false;
-
-  Interest interest(m_prefix);
-  interest.setInterestLifetime(interestLifetime);
-  interest.setMustBeFresh(mustBeFresh);
-  interest.setMinSuffixComponents(3);
-  interest.setMaxSuffixComponents(3);
-  interest.setChildSelector(1);
-
-  expressInterest(interest, maxRetriesOnTimeoutOrNack, maxRetriesOnTimeoutOrNack);
-}
-
-void
-DiscoverVersionIterative::handleData(const Interest& interest, const Data& data)
-{
-  size_t versionindex = m_prefix.size();
-
-  const Name& name = data.getName();
-  Exclude exclude;
-
-  if (isVerbose)
-    std::cerr << "Data: " << data << std::endl;
-
-  BOOST_ASSERT(name.size() > m_prefix.size());
-  if (name[versionindex].isVersion()) {
-    m_latestVersion = name[versionindex].toVersion();
-    m_latestVersionData = make_shared<Data>(data);
-    m_foundVersion = true;
-
-    exclude.excludeBefore(name[versionindex]);
-
-    if (isVerbose)
-      std::cerr << "Discovered version = " << m_latestVersion << std::endl;
-  }
-  else {
-    // didn't find a version number at expected index.
-    m_strayExcludes.excludeOne(name[versionindex]);
-  }
-
-  for (const Exclude::Range& range : m_strayExcludes) {
-    BOOST_ASSERT(range.isSingular());
-    exclude.excludeOne(range.from);
-  }
-
-  Interest newInterest(interest);
-  newInterest.refreshNonce();
-  newInterest.setExclude(exclude);
-  newInterest.setInterestLifetime(discoveryTimeout);
-
-  if (m_foundVersion)
-    expressInterest(newInterest, maxRetriesOnTimeoutOrNack, maxRetriesAfterVersionFound);
-  else
-    expressInterest(interest, maxRetriesOnTimeoutOrNack, maxRetriesOnTimeoutOrNack);
-}
-
-void
-DiscoverVersionIterative::handleTimeout(const Interest& interest, const std::string& reason)
-{
-  if (m_foundVersion) {
-    // a version has been found and after a timeout error this version can be used as the latest.
-    if (isVerbose)
-      std::cerr << "Found data with the latest version: " << m_latestVersion << std::endl;
-
-    // we discovered at least one version. assume what we have is the latest.
-    this->emitSignal(onDiscoverySuccess, Name(interest.getName()).appendVersion(m_latestVersion));
-  }
-  else {
-    DiscoverVersion::handleTimeout(interest, reason);
-  }
-}
-
-void
-DiscoverVersionIterative::handleNack(const Interest& interest, const std::string& reason)
-{
-  if (m_foundVersion) {
-    // a version has been found and after a nack this version can be used as the latest.
-    if (isVerbose)
-      std::cerr << "Found data with the latest version: " << m_latestVersion << std::endl;
-
-    // we discovered at least one version. assume what we have is the latest.
-    this->emitSignal(onDiscoverySuccess, Name(interest.getName()).appendVersion(m_latestVersion));
-  }
-  else {
-    DiscoverVersion::handleNack(interest, reason);
-  }
-}
-
-} // namespace chunks
-} // namespace ndn
diff --git a/tools/chunks/catchunks/discover-version-iterative.hpp b/tools/chunks/catchunks/discover-version-iterative.hpp
deleted file mode 100644
index 8880a6d..0000000
--- a/tools/chunks/catchunks/discover-version-iterative.hpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2016-2019, Regents of the University of California,
- *                          Colorado State University,
- *                          University Pierre & Marie Curie, Sorbonne University.
- *
- * This file is part of ndn-tools (Named Data Networking Essential Tools).
- * See AUTHORS.md for complete list of ndn-tools authors and contributors.
- *
- * ndn-tools is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * ndn-tools, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- *
- * @author Wentao Shang
- * @author Steve DiBenedetto
- * @author Andrea Tosatto
- * @author Klaus Schneider
- */
-
-#ifndef NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_ITERATIVE_HPP
-#define NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_ITERATIVE_HPP
-
-#include "discover-version.hpp"
-
-namespace ndn {
-namespace chunks {
-
-/**
- * @brief Options for discover version iterative DiscoverVersionIterative
- *
- * The canonical name to use is DiscoverVersionIterative::Options
- */
-class DiscoverVersionIterativeOptions : public virtual Options
-{
-public:
-  explicit
-  DiscoverVersionIterativeOptions(const Options& opts = Options())
-    : Options(opts)
-  {
-  }
-
-public:
-  int maxRetriesAfterVersionFound{0};       ///< how many times to retry after a discoveryTimeout
-  time::milliseconds discoveryTimeout{300}; ///< timeout for version discovery
-};
-
-/**
- * @brief Service for discovering the latest Data version in the iterative way
- *
- * Identifies the latest retrievable version published under the specified namespace
- * (as specified by the Version marker).
- *
- * DiscoverVersionIterative declares the largest discovered version to be the latest after some
- * Interest timeouts (i.e. failed retrieval after exclusion and retransmission). The number of
- * timeouts are specified by the value of maxRetriesAfterVersionFound inside the iterative options.
- *
- * The received name component after version can be an invalid segment number, this component will
- * be excluded in the next interests. In the unlikely case that there are too many excluded
- * components such that the Interest cannot fit in ndn::MAX_NDN_PACKET_SIZE, the discovery
- * procedure will throw Face::Error.
- *
- * DiscoverVersionIterative's user is notified once after identifying the latest retrievable
- * version or on failure to find any version Data.
- */
-class DiscoverVersionIterative : public DiscoverVersion, protected DiscoverVersionIterativeOptions
-{
-public:
-  typedef DiscoverVersionIterativeOptions Options;
-
-public:
-  /**
-   * @brief create a DiscoverVersionIterative service
-   */
-  DiscoverVersionIterative(const Name& prefix, Face& face, const Options& options);
-
-  /**
-   * @brief identify the latest Data version published.
-   */
-  void
-  run() final;
-
-private:
-  void
-  handleData(const Interest& interest, const Data& data) final;
-
-  void
-  handleTimeout(const Interest& interest, const std::string& reason) final;
-
-  void
-  handleNack(const Interest& interest, const std::string& reason) final;
-
-private:
-  uint64_t m_latestVersion;
-  shared_ptr<const Data> m_latestVersionData;
-  Exclude m_strayExcludes;
-  bool m_foundVersion;
-};
-
-} // namespace chunks
-} // namespace ndn
-
-#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_ITERATIVE_HPP
diff --git a/tools/chunks/catchunks/ndncatchunks.cpp b/tools/chunks/catchunks/ndncatchunks.cpp
index 2224f48..92d5401 100644
--- a/tools/chunks/catchunks/ndncatchunks.cpp
+++ b/tools/chunks/catchunks/ndncatchunks.cpp
@@ -33,7 +33,6 @@
 #include "aimd-rtt-estimator.hpp"
 #include "consumer.hpp"
 #include "discover-version-fixed.hpp"
-#include "discover-version-iterative.hpp"
 #include "discover-version-realtime.hpp"
 #include "pipeline-interests-aimd.hpp"
 #include "pipeline-interests-fixed-window.hpp"
@@ -51,11 +50,10 @@
 {
   std::string programName(argv[0]);
   Options options;
-  std::string discoverType("iterative");
+  std::string discoverType("realtime");
   std::string pipelineType("aimd");
   size_t maxPipelineSize(1);
-  int maxRetriesAfterVersionFound(0);
-  int64_t discoveryTimeoutMs(300);
+  int64_t discoveryTimeoutMs(DEFAULT_INTEREST_LIFETIME.count());
   std::string uri;
 
   // congestion control parameters, CWA refers to conservative window adaptation,
@@ -71,7 +69,7 @@
   basicDesc.add_options()
     ("help,h",      "print this help message and exit")
     ("discover-version,d", po::value<std::string>(&discoverType)->default_value(discoverType),
-                            "version discovery algorithm to use; valid values are: 'fixed', 'iterative', 'realtime'")
+                            "version discovery algorithm to use; valid values are: 'fixed', 'realtime'")
     ("pipeline-type,p", po::value<std::string>(&pipelineType)->default_value(pipelineType),
                          "type of Interest pipeline to use; valid values are: 'fixed', 'aimd'")
     ("fresh,f",     po::bool_switch(&options.mustBeFresh), "only return fresh content")
@@ -84,14 +82,10 @@
     ("version,V",   "print program version and exit")
     ;
 
-  po::options_description iterDiscoveryDesc("Iterative version discovery options");
-  iterDiscoveryDesc.add_options()
-    ("retries-iterative,i", po::value<int>(&maxRetriesAfterVersionFound)->default_value(maxRetriesAfterVersionFound),
-                            "number of timeouts that have to occur in order to confirm a discovered Data "
-                            "version as the latest one")
+  po::options_description realDiscoveryDesc("Realtime version discovery options");
+  realDiscoveryDesc.add_options()
     ("discovery-timeout,t", po::value<int64_t>(&discoveryTimeoutMs)->default_value(discoveryTimeoutMs),
-                            "discovery timeout (in milliseconds)")
-    ;
+                            "discovery timeout (in milliseconds)");
 
   po::options_description fixedPipeDesc("Fixed pipeline options");
   fixedPipeDesc.add_options()
@@ -136,7 +130,7 @@
     ;
 
   po::options_description visibleDesc;
-  visibleDesc.add(basicDesc).add(iterDiscoveryDesc).add(fixedPipeDesc).add(aimdPipeDesc);
+  visibleDesc.add(basicDesc).add(realDiscoveryDesc).add(fixedPipeDesc).add(aimdPipeDesc);
 
   po::options_description hiddenDesc;
   hiddenDesc.add_options()
@@ -196,11 +190,6 @@
     return 2;
   }
 
-  if (maxRetriesAfterVersionFound < 0 || maxRetriesAfterVersionFound > 1024) {
-    std::cerr << "ERROR: retries iterative value must be between 0 and 1024" << std::endl;
-    return 2;
-  }
-
   if (discoveryTimeoutMs < 0) {
     std::cerr << "ERROR: timeout cannot be negative" << std::endl;
     return 2;
@@ -224,14 +213,9 @@
     if (discoverType == "fixed") {
       discover = make_unique<DiscoverVersionFixed>(prefix, face, options);
     }
-    else if (discoverType == "iterative") {
-      DiscoverVersionIterative::Options optionsIterative(options);
-      optionsIterative.maxRetriesAfterVersionFound = maxRetriesAfterVersionFound;
-      optionsIterative.discoveryTimeout = time::milliseconds(discoveryTimeoutMs);
-      discover = make_unique<DiscoverVersionIterative>(prefix, face, optionsIterative);
-    }
     else if (discoverType == "realtime") {
       DiscoverVersionRealtime::Options optionsRealtime(options);
+      optionsRealtime.discoveryTimeout = time::milliseconds(discoveryTimeoutMs);
       discover = make_unique<DiscoverVersionRealtime>(prefix, face, optionsRealtime);
     }
     else {