[ndnSIM] Regard LinkFail issue

Hitesh Wadekar wadekahn at clarkson.edu
Sat Jul 4 17:52:15 PDT 2015


Hi Alex,

I have updated this code and compiled it, however, I couldn't see effect of
link down.

http://ndnsim.net/2.0/helpers.html#link-control-helper

void
LinkControlHelper::setErrorRate(Ptr<Node> node1, Ptr<Node> node2, double
errorRate)
{
  std::cout<<"\n setErrorRate called: -> "<<std::endl;

  NS_LOG_FUNCTION(node1 << node2 << errorRate);
  NS_ASSERT(node1 != nullptr && node2 != nullptr);
  NS_ASSERT(errorRate <= 1.0);

  Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol>();
  Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol>();

  NS_ASSERT(ndn1 != nullptr && ndn2 != nullptr);

  // iterate over all faces to find the right one
  for (const auto& face : ndn1->getForwarder()->getFaceTable()) {
    shared_ptr<ndn::NetDeviceFace> ndFace =
std::dynamic_pointer_cast<NetDeviceFace>(face);
    if (ndFace == nullptr)
      continue;

    Ptr<PointToPointNetDevice> nd1 =
ndFace->GetNetDevice()->GetObject<PointToPointNetDevice>();
    if (nd1 == nullptr)
      continue;

    Ptr<Channel> channel = nd1->GetChannel();
    if (channel == nullptr)
      continue;

    Ptr<PointToPointChannel> ppChannel =
DynamicCast<PointToPointChannel>(channel);

    Ptr<NetDevice> nd2 = ppChannel->GetDevice(0);
    if (nd2->GetNode() == node1)
      nd2 = ppChannel->GetDevice(1);

    if (nd2->GetNode() == node2) {
      ObjectFactory errorFactory("ns3::RateErrorModel");
      errorFactory.Set("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
      errorFactory.Set("ErrorRate", DoubleValue(errorRate));
      if (errorRate <= 0) {
        errorFactory.Set("IsEnabled", BooleanValue(false));
      }

      nd1->SetAttribute("ReceiveErrorModel",
PointerValue(errorFactory.Create<ErrorModel>()));
      nd2->SetAttribute("ReceiveErrorModel",
PointerValue(errorFactory.Create<ErrorModel>()));
      return;
    }
  }
  NS_FATAL_ERROR("There is no link to fail between the requested nodes");
}


Looks like  "ErrorModel" isn't taking place. I am still debugging let me
know if I am doing something wrong.

Regards,
Hitesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20150704/4a453bf5/attachment.html>


More information about the ndnSIM mailing list