blob: 9d8c800309c7124cba8f5ff48cc866978c359bf9 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070019
20#ifndef NDN_LINK_CONTROL_HELPER_H
21#define NDN_LINK_CONTROL_HELPER_H
22
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
24
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070025#include "ns3/ptr.h"
26#include "ns3/node.h"
27
28namespace ns3 {
29namespace ndn {
30
31/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070032 * @ingroup ndn-helpers
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033 * @brief Helper class to control the up or down statuss of an NDN link connecting two specific
34 * nodes
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070035 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080036class LinkControlHelper {
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070037public:
38 /**
39 * @brief Fail NDN link between two nodes
40 *
41 * The helper will attempt to find NDN link between node1 and
42 * node2 and set NDN face to DOWN state
43 *
44 * Note that only PointToPointChannels are supported by this helper method
45 *
46 * @param node1 one node
47 * @param node2 another node
48 */
49 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 FailLink(Ptr<Node> node1, Ptr<Node> node2);
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070051
52 /**
53 * @brief Fail NDN link between two nodes
54 *
55 * The helper will attempt to find NDN link between node1 and
56 * node2 and set NDN face to DOWN state
57 *
58 * Note that only PointToPointChannels are supported by this helper method
59 *
60 * This variant uses node names registered by Names class
61 *
62 * @param node1 one node's name
63 * @param node2 another node's name
64 */
65 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 FailLinkByName(const std::string& node1, const std::string& node2);
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070067
68 /**
69 * @brief Re-enable NDN link between two nodes
70 *
71 * The helper will attempt to find NDN link between node1 and
72 * node2 and set NDN face to UP state
73 *
74 * Note that only PointToPointChannels are supported by this helper method
75 *
76 * @param node1 one node
77 * @param node2 another node
78 */
79 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 UpLink(Ptr<Node> node1, Ptr<Node> node2);
81
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -070082 /**
83 * @brief Re-enable NDN link between two nodes
84 *
85 * The helper will attempt to find NDN link between node1 and
86 * node2 and set NDN face to UP state
87 *
88 * Note that only PointToPointChannels are supported by this helper method
89 *
90 * This variant uses node names registered by Names class
91 *
92 * @param node1 one node's name
93 * @param node2 another node's name
94 */
95 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080096 UpLinkByName(const std::string& node1, const std::string& node2);
Alexander Afanasyev3f7dd872014-12-31 14:10:33 -080097
98private:
99 static void
100 setErrorRate(Ptr<Node> node1, Ptr<Node> node2, double errorRate);
101}; // LinkControlHelper
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700102
Alexander Afanasyev0fb80b92013-07-20 08:20:50 -0700103} // ndn
104} // ns3
105
106#endif // NDN_LINK_CONTROL_HELPER_H