helper+docs+examples: New helper to simplify link failing
Thanks to Saran Tarnoi for providing base implementation of the code
diff --git a/docs/source/faq.rst b/docs/source/faq.rst
index c660492..a7ce4bd 100644
--- a/docs/source/faq.rst
+++ b/docs/source/faq.rst
@@ -133,47 +133,7 @@
Right now, NS-3 does not provide ability to actually "break" the link between nodes in NS-3.
However, exactly the same effect can be achieved by making an interface (:ndnsim:`ndn::Face`) up or down (:ndnsim:`ndn::Face::SetUp(true)` or :ndnsim:`ndn::Face::SetUp(false)`).
-Here is an example of function to "fail" a point-to-point link between two NDN nodes:
-
-.. code-block:: c++
-
- // hijacker is more than an application. just disable all faces
- void
- FailLinks (Ptr<Node> node1, Ptr<Node> node2)
- {
- Ptr<ndn::L3Protocol> ndn1 = node1->GetObject<ndn::L3Protocol> ();
- Ptr<ndn::L3Protocol> ndn2 = node2->GetObject<ndn::L3Protocol> ();
-
- // iterate over all faces to find the right one
- for (uint32_t faceId = 0; faceId < ndn1->GetNFaces (); faceId++)
- {
- Ptr<ndn::NetDeviceFace> ndFace = ndn1->GetFace (faceId)->GetObject<ndn::NetDeviceFace> ();
- if (ndFace == 0) continue;
-
- Ptr<PointToPointNetDevice> nd1 = ndFace->GetNetDevice ()->GetObject<PointToPointNetDevice> ();
- if (nd1 == 0) continue;
-
- Ptr<Channel> channel = nd1->GetChannel ();
- if (channel == 0) 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)
- {
- Ptr<ndn::Face> face1 = ndn1->GetFaceByNetDevice (nd1);
- Ptr<ndn::Face> face2 = ndn2->GetFaceByNetDevice (nd2);
-
- face1->SetUp (false);
- face2->SetUp (false);
- break;
- }
- }
- }
-
+You can use :ndnsim:`ndn::LinkControlHelper` to schedule failing links. For example, refer to :ref:`Simple scenario with link failures` example.
General questions
-----------------