Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * 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 Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 19 | |
| 20 | #ifndef NDN_LINK_CONTROL_HELPER_H |
| 21 | #define NDN_LINK_CONTROL_HELPER_H |
| 22 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 24 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 25 | #include "ns3/ptr.h" |
| 26 | #include "ns3/node.h" |
| 27 | |
| 28 | namespace ns3 { |
| 29 | namespace ndn { |
| 30 | |
| 31 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 32 | * @ingroup ndn-helpers |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 33 | * @brief Helper class to control the up or down statuss of an NDN link connecting two specific |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame^] | 34 | * nodes |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 35 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 36 | class LinkControlHelper { |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 37 | public: |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 50 | FailLink(Ptr<Node> node1, Ptr<Node> node2); |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 51 | |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | FailLinkByName(const std::string& node1, const std::string& node2); |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 67 | |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 80 | UpLink(Ptr<Node> node1, Ptr<Node> node2); |
| 81 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 82 | /** |
| 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 Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 96 | UpLinkByName(const std::string& node1, const std::string& node2); |
Alexander Afanasyev | 3f7dd87 | 2014-12-31 14:10:33 -0800 | [diff] [blame] | 97 | |
| 98 | private: |
| 99 | static void |
| 100 | setErrorRate(Ptr<Node> node1, Ptr<Node> node2, double errorRate); |
| 101 | }; // LinkControlHelper |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 102 | |
Alexander Afanasyev | 0fb80b9 | 2013-07-20 08:20:50 -0700 | [diff] [blame] | 103 | } // ndn |
| 104 | } // ns3 |
| 105 | |
| 106 | #endif // NDN_LINK_CONTROL_HELPER_H |