face+mgmt: allow congestion marking parameters to be enabled and set
refs #4465
Change-Id: I9d49135ab32bacb2885b70031c573f7c8709ac1f
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index 4274efa..698a525 100644
--- a/tests/daemon/mgmt/face-manager-create-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -24,6 +24,7 @@
*/
#include "mgmt/face-manager.hpp"
+#include "face/generic-link-service.hpp"
#include "face-manager-command-fixture.hpp"
#include "nfd-manager-common-fixture.hpp"
@@ -192,7 +193,7 @@
getParameters()
{
return ControlParameters()
- .setUri("tcp4://127.0.0.1:26363")
+ .setUri("udp4://127.0.0.1:26363")
.setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true);
}
@@ -205,12 +206,42 @@
getParameters()
{
return ControlParameters()
- .setUri("tcp4://127.0.0.1:26363")
+ .setUri("udp4://127.0.0.1:26363")
.setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false);
}
};
+class TcpFaceCongestionMarkingEnabled
+{
+public:
+ static ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setBaseCongestionMarkingInterval(50_ms)
+ .setDefaultCongestionThreshold(1000)
+ .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true);
+ }
+};
+
+class TcpFaceCongestionMarkingDisabled
+{
+public:
+ static ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setBaseCongestionMarkingInterval(50_ms)
+ .setDefaultCongestionThreshold(1000)
+ .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, false);
+ }
+};
+
class FaceUriMalformed
{
public:
@@ -262,6 +293,8 @@
mpl::pair<TcpFaceLpReliabilityDisabled, CommandSuccess>,
mpl::pair<UdpFaceLpReliabilityEnabled, CommandSuccess>,
mpl::pair<UdpFaceLpReliabilityDisabled, CommandSuccess>,
+ mpl::pair<TcpFaceCongestionMarkingEnabled, CommandSuccess>,
+ mpl::pair<TcpFaceCongestionMarkingDisabled, CommandSuccess>,
mpl::pair<FaceUriMalformed, CommandFailure<400>>,
mpl::pair<FaceUriNonCanonical, CommandFailure<400>>,
mpl::pair<FaceUriUnsupportedScheme, CommandFailure<406>>>;
@@ -297,11 +330,30 @@
actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED));
BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED),
actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED));
+ BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED),
+ actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED));
}
else {
// local fields are disabled by default
BOOST_CHECK_EQUAL(actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED), false);
BOOST_CHECK_EQUAL(actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED), false);
+ BOOST_CHECK_EQUAL(actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED), false);
+ }
+
+ if (expectedParams.hasBaseCongestionMarkingInterval()) {
+ BOOST_CHECK_EQUAL(expectedParams.getBaseCongestionMarkingInterval(),
+ actualParams.getBaseCongestionMarkingInterval());
+ }
+ else {
+ BOOST_CHECK_EQUAL(actualParams.getBaseCongestionMarkingInterval(), 100_ms);
+ }
+
+ if (expectedParams.hasDefaultCongestionThreshold()) {
+ BOOST_CHECK_EQUAL(expectedParams.getDefaultCongestionThreshold(),
+ actualParams.getDefaultCongestionThreshold());
+ }
+ else {
+ BOOST_CHECK_EQUAL(actualParams.getDefaultCongestionThreshold(), 65536);
}
}
else {
@@ -327,7 +379,7 @@
});
this->node1.face.receive(req);
- this->advanceClocks(time::milliseconds(1), 5);
+ this->advanceClocks(1_ms, 5);
BOOST_CHECK(hasCallbackFired);
}
@@ -340,7 +392,7 @@
// create face
Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
this->node1.face.receive(req);
- this->advanceClocks(time::milliseconds(1), 5);
+ this->advanceClocks(1_ms, 5);
}
// find the created face
@@ -365,12 +417,17 @@
BOOST_CHECK_EQUAL(foundFace->getId(), actualParams.getFaceId());
BOOST_CHECK_EQUAL(foundFace->getRemoteUri().toString(), actualParams.getUri());
BOOST_CHECK_EQUAL(foundFace->getPersistency(), actualParams.getFacePersistency());
+ auto linkService = dynamic_cast<face::GenericLinkService*>(foundFace->getLinkService());
+ BOOST_CHECK_EQUAL(linkService->getOptions().baseCongestionMarkingInterval,
+ actualParams.getBaseCongestionMarkingInterval());
+ BOOST_CHECK_EQUAL(linkService->getOptions().defaultCongestionThreshold,
+ actualParams.getDefaultCongestionThreshold());
hasCallbackFired = true;
});
this->node1.face.receive(req);
- this->advanceClocks(time::milliseconds(1), 5);
+ this->advanceClocks(1_ms, 5);
BOOST_CHECK(hasCallbackFired);
}
diff --git a/tests/daemon/mgmt/face-manager-update-face.t.cpp b/tests/daemon/mgmt/face-manager-update-face.t.cpp
index 9a6825e..dd34fd8 100644
--- a/tests/daemon/mgmt/face-manager-update-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-update-face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,6 +32,8 @@
#include <thread>
+#include <boost/logic/tribool.hpp>
+
namespace nfd {
namespace tests {
@@ -54,15 +56,31 @@
void
createFace(const std::string& uri = "tcp4://127.0.0.1:26363",
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ ndn::optional<time::nanoseconds> baseCongestionMarkingInterval = {},
+ ndn::optional<uint64_t> defaultCongestionThreshold = {},
bool enableLocalFields = false,
- bool enableReliability = false)
+ bool enableReliability = false,
+ boost::logic::tribool enableCongestionMarking = boost::logic::indeterminate)
{
ControlParameters params;
params.setUri(uri);
params.setFacePersistency(persistency);
+
+ if (baseCongestionMarkingInterval) {
+ params.setBaseCongestionMarkingInterval(*baseCongestionMarkingInterval);
+ }
+
+ if (defaultCongestionThreshold) {
+ params.setDefaultCongestionThreshold(*defaultCongestionThreshold);
+ }
+
params.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, enableLocalFields);
params.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, enableReliability);
+ if (!boost::logic::indeterminate(enableCongestionMarking)) {
+ params.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, enableCongestionMarking);
+ }
+
createFace(params);
}
@@ -474,7 +492,8 @@
typedef typename T::first TestType;
typedef typename T::second ResultType;
- createFace(TestType().getUri(), TestType().getPersistency(), TestType().getInitLocalFieldsEnabled());
+ createFace(TestType().getUri(), TestType().getPersistency(), {}, {},
+ TestType().getInitLocalFieldsEnabled());
ControlParameters requestParams;
requestParams.setFaceId(faceId);
@@ -601,6 +620,71 @@
});
}
+BOOST_AUTO_TEST_CASE(UpdateCongestionMarkingEnableDisable)
+{
+ createFace("udp4://127.0.0.1:26363");
+
+ ControlParameters enableParams;
+ enableParams.setFaceId(faceId);
+ enableParams.setBaseCongestionMarkingInterval(time::milliseconds(50));
+ enableParams.setDefaultCongestionThreshold(10000);
+ enableParams.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true);
+
+ ControlParameters disableParams;
+ disableParams.setFaceId(faceId);
+ disableParams.setBaseCongestionMarkingInterval(time::milliseconds(70));
+ disableParams.setDefaultCongestionThreshold(5000);
+ disableParams.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, false);
+
+ updateFace(enableParams, false, [] (const ControlResponse& actual) {
+ ControlResponse expected(200, "OK");
+ BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode());
+ BOOST_TEST_MESSAGE(actual.getText());
+
+ if (actual.getBody().hasWire()) {
+ ControlParameters actualParams(actual.getBody());
+
+ BOOST_CHECK(actualParams.hasFaceId());
+ BOOST_CHECK(actualParams.hasFacePersistency());
+ // Check that congestion marking parameters changed
+ BOOST_REQUIRE(actualParams.hasBaseCongestionMarkingInterval());
+ BOOST_CHECK_EQUAL(actualParams.getBaseCongestionMarkingInterval(), time::milliseconds(50));
+ BOOST_REQUIRE(actualParams.hasDefaultCongestionThreshold());
+ BOOST_CHECK_EQUAL(actualParams.getDefaultCongestionThreshold(), 10000);
+ BOOST_REQUIRE(actualParams.hasFlags());
+ // Check if flags indicate congestion marking enabled
+ BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED));
+ }
+ else {
+ BOOST_ERROR("Enable: Response does not contain ControlParameters");
+ }
+ });
+
+ updateFace(disableParams, false, [] (const ControlResponse& actual) {
+ ControlResponse expected(200, "OK");
+ BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode());
+ BOOST_TEST_MESSAGE(actual.getText());
+
+ if (actual.getBody().hasWire()) {
+ ControlParameters actualParams(actual.getBody());
+
+ BOOST_CHECK(actualParams.hasFaceId());
+ BOOST_CHECK(actualParams.hasFacePersistency());
+ // Check that congestion marking parameters changed, even though feature disabled
+ BOOST_REQUIRE(actualParams.hasBaseCongestionMarkingInterval());
+ BOOST_CHECK_EQUAL(actualParams.getBaseCongestionMarkingInterval(), time::milliseconds(70));
+ BOOST_REQUIRE(actualParams.hasDefaultCongestionThreshold());
+ BOOST_CHECK_EQUAL(actualParams.getDefaultCongestionThreshold(), 5000);
+ BOOST_REQUIRE(actualParams.hasFlags());
+ // Check if flags indicate marking disabled
+ BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED));
+ }
+ else {
+ BOOST_ERROR("Disable: Response does not contain ControlParameters");
+ }
+ });
+}
+
BOOST_AUTO_TEST_CASE(SelfUpdating)
{
createFace();