Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | * : Saran Tarnoi <saran.tarnoi@gmail.com> |
| 20 | */ |
| 21 | |
| 22 | #ifndef NDN_LINK_CONTROL_HELPER_H |
| 23 | #define NDN_LINK_CONTROL_HELPER_H |
| 24 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 26 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 27 | #include "ns3/ptr.h" |
| 28 | #include "ns3/node.h" |
| 29 | |
| 30 | namespace ns3 { |
| 31 | namespace ndn { |
| 32 | |
| 33 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 34 | * @ingroup ndn-helpers |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 35 | * @brief Helper class to control the up or down statuss of an NDN link connecting two specific |
| 36 | * nodes |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 37 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 38 | class LinkControlHelper { |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 39 | public: |
| 40 | /** |
| 41 | * @brief Fail NDN link between two nodes |
| 42 | * |
| 43 | * The helper will attempt to find NDN link between node1 and |
| 44 | * node2 and set NDN face to DOWN state |
| 45 | * |
| 46 | * Note that only PointToPointChannels are supported by this helper method |
| 47 | * |
| 48 | * @param node1 one node |
| 49 | * @param node2 another node |
| 50 | */ |
| 51 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 52 | FailLink(Ptr<Node> node1, Ptr<Node> node2); |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * @brief Fail NDN link between two nodes |
| 56 | * |
| 57 | * The helper will attempt to find NDN link between node1 and |
| 58 | * node2 and set NDN face to DOWN state |
| 59 | * |
| 60 | * Note that only PointToPointChannels are supported by this helper method |
| 61 | * |
| 62 | * This variant uses node names registered by Names class |
| 63 | * |
| 64 | * @param node1 one node's name |
| 65 | * @param node2 another node's name |
| 66 | */ |
| 67 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 68 | FailLinkByName(const std::string& node1, const std::string& node2); |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * @brief Re-enable NDN link between two nodes |
| 72 | * |
| 73 | * The helper will attempt to find NDN link between node1 and |
| 74 | * node2 and set NDN face to UP state |
| 75 | * |
| 76 | * Note that only PointToPointChannels are supported by this helper method |
| 77 | * |
| 78 | * @param node1 one node |
| 79 | * @param node2 another node |
| 80 | */ |
| 81 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 82 | UpLink(Ptr<Node> node1, Ptr<Node> node2); |
| 83 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 84 | /** |
| 85 | * @brief Re-enable NDN link between two nodes |
| 86 | * |
| 87 | * The helper will attempt to find NDN link between node1 and |
| 88 | * node2 and set NDN face to UP state |
| 89 | * |
| 90 | * Note that only PointToPointChannels are supported by this helper method |
| 91 | * |
| 92 | * This variant uses node names registered by Names class |
| 93 | * |
| 94 | * @param node1 one node's name |
| 95 | * @param node2 another node's name |
| 96 | */ |
| 97 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 98 | UpLinkByName(const std::string& node1, const std::string& node2); |
Alexander Afanasyev | 3f7dd87 | 2014-12-31 14:10:33 -0800 | [diff] [blame^] | 99 | |
| 100 | private: |
| 101 | static void |
| 102 | setErrorRate(Ptr<Node> node1, Ptr<Node> node2, double errorRate); |
| 103 | }; // LinkControlHelper |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 104 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 105 | } // ndn |
| 106 | } // ns3 |
| 107 | |
| 108 | #endif // NDN_LINK_CONTROL_HELPER_H |