22 #include "ns3/assert.h" 
   23 #include "ns3/names.h" 
   24 #include "ns3/point-to-point-net-device.h" 
   25 #include "ns3/point-to-point-channel.h" 
   26 #include "ns3/channel.h" 
   28 #include "ns3/error-model.h" 
   29 #include "ns3/string.h" 
   30 #include "ns3/boolean.h" 
   31 #include "ns3/double.h" 
   32 #include "ns3/pointer.h" 
   39 NS_LOG_COMPONENT_DEFINE(
"ndn.LinkControlHelper");
 
   45 LinkControlHelper::setErrorRate(Ptr<Node> node1, Ptr<Node> node2, 
double errorRate)
 
   47   NS_LOG_FUNCTION(node1 << node2 << errorRate);
 
   49   NS_ASSERT(node1 != 
nullptr && node2 != 
nullptr);
 
   50   NS_ASSERT(errorRate <= 1.0);
 
   55   NS_ASSERT(ndn1 != 
nullptr && ndn2 != 
nullptr);
 
   58   for (
const auto& face : ndn1->getForwarder()->getFaceTable()) {
 
   59     shared_ptr<ndn::NetDeviceFace> ndFace = std::dynamic_pointer_cast<
NetDeviceFace>(face);
 
   60     if (ndFace == 
nullptr)
 
   63     Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice()->GetObject<PointToPointNetDevice>();
 
   67     Ptr<Channel> channel = nd1->GetChannel();
 
   68     if (channel == 
nullptr)
 
   71     Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel>(channel);
 
   73     Ptr<NetDevice> nd2 = ppChannel->GetDevice(0);
 
   74     if (nd2->GetNode() == node1)
 
   75       nd2 = ppChannel->GetDevice(1);
 
   77     ObjectFactory errorFactory(
"ns3::RateErrorModel");
 
   78     errorFactory.Set(
"ErrorUnit", StringValue(
"ERROR_UNIT_PACKET"));
 
   79     errorFactory.Set(
"ErrorRate", DoubleValue(errorRate));
 
   81       errorFactory.Set(
"IsEnabled", BooleanValue(
false));
 
   84     nd1->SetAttribute(
"ReceiveErrorModel", PointerValue(errorFactory.Create<ErrorModel>()));
 
   85     nd2->SetAttribute(
"ReceiveErrorModel", PointerValue(errorFactory.Create<ErrorModel>()));
 
   92   setErrorRate(node1, node2, 1.0);
 
   98   FailLink(Names::Find<Node>(node1), Names::Find<Node>(node2));
 
  104   setErrorRate(node1, node2, -0.1); 
 
  110   UpLink(Names::Find<Node>(node1), Names::Find<Node>(node2));
 
ndn NetDeviceFace
Copyright (c) 2011-2015 Regents of the University of California. 
 
static void UpLinkByName(const std::string &node1, const std::string &node2)
Re-enable NDN link between two nodes. 
 
static void UpLink(Ptr< Node > node1, Ptr< Node > node2)
Re-enable NDN link between two nodes. 
 
static void FailLink(Ptr< Node > node1, Ptr< Node > node2)
Fail NDN link between two nodes. 
 
ndn L3Protocol
Copyright (c) 2011-2015 Regents of the University of California. 
 
static void FailLinkByName(const std::string &node1, const std::string &node2)
Fail NDN link between two nodes.