[ndnSIM] Bug in Default Network Device of ndnSIM's ndn-stack-helper.cpp

Andre Madureira andreluizromanomadureira at gmail.com
Fri Jun 9 16:07:11 PDT 2023


Hello,

I've tried building a custom forwarding strategy that checks the LinkType
to see if the NDN face is operating as Adhoc, Multi-access or
Point-to-Point. But to my surprise this link type field was not working, as
the NDN Face was always being created as if the NS3 network device is a
Point-to-Point one. I figured that the function responsible by the NDN Face
creation was the following:

shared_ptr<Face>
StackHelper::DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
                                      Ptr<NetDevice> netDevice)

So I've checked the function and found that no checks have been done to
identify the NS3's network device operation (Adhoc, Multiaccess or
Point-to-point). So I've modified the function to look like this:

shared_ptr<Face>
StackHelper::DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
                                      Ptr<NetDevice> netDevice) const
{
  NS_LOG_DEBUG("Creating default Face on node " << node->GetId());

  // Create an ndnSIM-specific transport instance
  ::nfd::face::GenericLinkService::Options opts;
  opts.allowFragmentation = true;
  opts.allowReassembly = true;
  opts.allowCongestionMarking = true;

  auto linkService = make_unique<::nfd::face::GenericLinkService>(opts);

  auto linkType = ::ndn::nfd::LINK_TYPE_POINT_TO_POINT;
  if (netDevice->IsPointToPoint() == 0)
    linkType = ::ndn::nfd::LINK_TYPE_MULTI_ACCESS;
  // check for Adhoc communication
  auto wifiNetDev = dynamic_cast<ns3::WifiNetDevice*>(&(*netDevice));
  if (wifiNetDev != NULL) {
    auto wifiMac = wifiNetDev->GetMac();
    if (dynamic_cast<ns3::AdhocWifiMac*>(&(*wifiMac)) != NULL)
      linkType = ::ndn::nfd::LINK_TYPE_AD_HOC;
  }

  auto transport =
    make_unique<NetDeviceTransport>(node, netDevice, constructFaceUri(
netDevice),
                                    "netdev://[ff:ff:ff:ff:ff:ff]",
                                    ::ndn::nfd::FACE_SCOPE_NON_LOCAL,
                                    ::ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
linkType);

  auto face = std::make_shared<Face>(std::move(linkService), std::move(
transport));
  face->setMetric(1);

  ndn->addFace(face);
  NS_LOG_LOGIC("Node " << node->GetId() << ": added Face as face #" << face
->getLocalUri()
                       << " - remoteURI = " << face->getRemoteUri() << " -
linkType " << linkType);

  return face;
}

I've tested the code with Point-to-Point network devices and WifiNetDevice
with ns3::AdhocWifiMac configured and in both cases the linkType was
properly identified when the NDN Face was created. But I don't know if it
will work under other network devices or MAC's. I'm sending this message in
the hopes that there's another way to solve this problem and as an attempt
to improve ndnSIM code.

Best regards,
Andre Madureira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20230609/a07b9454/attachment.html>


More information about the ndnSIM mailing list