22 #include "ndn-link-control-helper.h"
24 #include "ns3/assert.h"
25 #include "ns3/names.h"
26 #include "ns3/point-to-point-net-device.h"
27 #include "ns3/point-to-point-channel.h"
28 #include "ns3/channel.h"
31 #include "ns3/ndn-l3-protocol.h"
32 #include "ns3/ndn-net-device-face.h"
34 NS_LOG_COMPONENT_DEFINE (
"ndn.LinkControlHelper");
42 NS_LOG_FUNCTION (node1 << node2);
44 NS_ASSERT (node1 != 0);
45 NS_ASSERT (node2 != 0);
50 NS_ASSERT (ndn1 != 0);
51 NS_ASSERT (ndn2 != 0);
54 for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
56 Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<
ndn::NetDeviceFace> ();
57 if (ndFace == 0)
continue;
59 Ptr<PointToPointNetDevice> nd1 = ndFace->
GetNetDevice ()->GetObject<PointToPointNetDevice> ();
60 if (nd1 == 0)
continue;
62 Ptr<Channel> channel = nd1->GetChannel ();
63 if (channel == 0)
continue;
65 Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel> (channel);
67 Ptr<NetDevice> nd2 = ppChannel->GetDevice (0);
68 if (nd2->GetNode () == node1)
69 nd2 = ppChannel->GetDevice (1);
71 if (nd2->GetNode () == node2)
73 Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
74 Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
85 FailLink (Names::Find<Node> (node1), Names::Find<Node> (node2));
91 NS_LOG_FUNCTION (node1 << node2);
93 NS_ASSERT (node1 != 0);
94 NS_ASSERT (node2 != 0);
99 NS_ASSERT (ndn1 != 0);
100 NS_ASSERT (ndn2 != 0);
103 for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
105 Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<
ndn::NetDeviceFace> ();
106 if (ndFace == 0)
continue;
108 Ptr<PointToPointNetDevice> nd1 = ndFace->
GetNetDevice ()->GetObject<PointToPointNetDevice> ();
109 if (nd1 == 0)
continue;
111 Ptr<Channel> channel = nd1->GetChannel ();
112 if (channel == 0)
continue;
114 Ptr<PointToPointChannel> ppChannel = DynamicCast<PointToPointChannel> (channel);
116 Ptr<NetDevice> nd2 = ppChannel->GetDevice (0);
117 if (nd2->GetNode () == node1)
118 nd2 = ppChannel->GetDevice (1);
120 if (nd2->GetNode () == node2)
122 Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
123 Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
135 UpLink (Names::Find<Node> (node1), Names::Find<Node> (node2));
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.
static void UpLinkByName(const std::string &node1, const std::string &node2)
Re-enable NDN link between two nodes.
Implementation network-layer of NDN stack.
Implementation of layer-2 (Ethernet) Ndn face.
static void FailLinkByName(const std::string &node1, const std::string &node2)
Fail NDN link between two nodes.
Ptr< NetDevice > GetNetDevice() const
Get NetDevice associated with the face.