face: allow GenericLinkService to override MTU
refs #5056
Change-Id: I8eb2dd732b1431e0e809deb53792a14be1698ff1
diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp
index e6b85d1..130c85e 100644
--- a/tests/daemon/face/generic-link-service.t.cpp
+++ b/tests/daemon/face/generic-link-service.t.cpp
@@ -132,6 +132,61 @@
BOOST_CHECK(!data1pkt.has<lp::SequenceField>());
}
+BOOST_AUTO_TEST_CASE(SendDataOverrideMtu)
+{
+ // Initialize with Options that disables all services and does not override MTU
+ GenericLinkService::Options options;
+ options.allowLocalFields = false;
+ initialize(options);
+
+ BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
+ BOOST_CHECK_EQUAL(service->getEffectiveMtu(), MTU_UNLIMITED);
+ BOOST_CHECK_EQUAL(face->getMtu(), MTU_UNLIMITED);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(MTU_UNLIMITED), false);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(MTU_INVALID), false);
+ // Attempts to override MTU will fail when transport MTU is unlimited
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(4000), false);
+
+ // Initialize with Options that disables all services and overrides MTU (Transport MTU 8800)
+ options.overrideMtu = MIN_MTU;
+ initialize(options, ndn::MAX_NDN_PACKET_SIZE);
+
+ // Ensure effective MTU is override value
+ BOOST_CHECK_EQUAL(transport->getMtu(), ndn::MAX_NDN_PACKET_SIZE);
+ BOOST_CHECK_EQUAL(service->getEffectiveMtu(), MIN_MTU);
+ BOOST_CHECK_EQUAL(face->getMtu(), MIN_MTU);
+
+ // Check MTU overrides with Transport MTU finite
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(MTU_UNLIMITED), false);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(MTU_INVALID), false);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(MIN_MTU - 1), false);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(MIN_MTU), true);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(4000), true);
+ BOOST_CHECK_EQUAL(service->canOverrideMtuTo(20000), true);
+
+ // Send Data with less than MIN_MTU octets
+ auto data1 = makeData("/localhost");
+ BOOST_CHECK_LE(data1->wireEncode().size(), MIN_MTU);
+ face->sendData(*data1, 0);
+
+ BOOST_CHECK_EQUAL(service->getCounters().nOutData, 1);
+ BOOST_CHECK_EQUAL(service->getCounters().nOutOverMtu, 0);
+
+ // Send Data with more than MIN_MTU octets
+ auto data2 = makeData("/localhost/test/1234567890/1234567890/1234567890/1234567890");
+ BOOST_CHECK_GT(data2->wireEncode().size(), MIN_MTU);
+ face->sendData(*data2, 0);
+
+ BOOST_CHECK_EQUAL(service->getCounters().nOutData, 2);
+ BOOST_CHECK_EQUAL(service->getCounters().nOutOverMtu, 1);
+
+ // Override MTU greater than the Transport's MTU will not be utilized
+ options.overrideMtu = 5000;
+ initialize(options, 4000);
+ BOOST_CHECK_EQUAL(service->getEffectiveMtu(), 4000);
+ BOOST_CHECK_EQUAL(face->getMtu(), 4000);
+}
+
BOOST_AUTO_TEST_CASE(SendNack)
{
// Initialize with Options that disables all services
diff --git a/tests/daemon/face/lp-fragmenter.t.cpp b/tests/daemon/face/lp-fragmenter.t.cpp
index 9421619..7e38a62 100644
--- a/tests/daemon/face/lp-fragmenter.t.cpp
+++ b/tests/daemon/face/lp-fragmenter.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2020, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -76,7 +76,7 @@
BOOST_AUTO_TEST_CASE(FragmentMultipleFragments)
{
- size_t mtu = Transport::MIN_MTU;
+ size_t mtu = MIN_MTU;
lp::Packet packet;
packet.add<lp::IncomingFaceIdField>(123);
@@ -156,7 +156,7 @@
BOOST_AUTO_TEST_CASE(FragmentMtuTooSmall)
{
size_t mtu = 20;
- BOOST_ASSERT(mtu < Transport::MIN_MTU);
+ BOOST_ASSERT(mtu < MIN_MTU);
lp::Packet packet;
packet.add<lp::IncomingFaceIdField>(123);
diff --git a/tests/daemon/face/lp-reliability.t.cpp b/tests/daemon/face/lp-reliability.t.cpp
index 9c14997..1880074 100644
--- a/tests/daemon/face/lp-reliability.t.cpp
+++ b/tests/daemon/face/lp-reliability.t.cpp
@@ -809,7 +809,7 @@
// for Sequence and TxSequence, leaving 6 octets for piggybacking. Each Ack header is 12 octets,
// so there's no room to piggyback any Ack in LpPacket.
- transport->setMtu(Transport::MIN_MTU);
+ transport->setMtu(MIN_MTU);
for (lp::Sequence i = 1000; i < 1100; i++) {
reliability->m_ackQueue.push(i);