Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 UCLA |
| 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 | * |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | * Ilya Moiseenko <iliamo@cs.ucla.edu> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef CCNX_STACK_HELPER_H |
| 23 | #define CCNX_STACK_HELPER_H |
| 24 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 25 | #include "ns3/packet.h" |
| 26 | #include "ns3/ptr.h" |
| 27 | #include "ns3/object-factory.h" |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 28 | #include "ns3/nstime.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ns3 { |
| 31 | |
| 32 | class Node; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 33 | class CcnxFaceContainer; |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 34 | class CcnxFace; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 37 | * \ingroup ccnx |
| 38 | * \defgroup ccnx-helpers Helpers |
| 39 | */ |
| 40 | /** |
| 41 | * \ingroup ccnx-helpers |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 42 | * \brief Adding CCNx functionality to existing Nodes. |
| 43 | * |
| 44 | * This helper enables pcap and ascii tracing of events in the ccnx stack |
| 45 | * associated with a node. This is substantially similar to the tracing that |
| 46 | * happens in device helpers, but the important difference is that, well, there |
| 47 | * is no device. This means that the creation of output file names will change, |
| 48 | * and also the user-visible methods will not reference devices and therefore |
| 49 | * the number of trace enable methods is reduced. |
| 50 | * |
| 51 | * Normally we eschew multiple inheritance, however, the classes |
| 52 | * PcapUserHelperForCcnx and AsciiTraceUserHelperForCcnx are treated as |
| 53 | * "mixins". A mixin is a self-contained class that encapsulates a general |
| 54 | * attribute or a set of functionality that may be of interest to many other |
| 55 | * classes. |
| 56 | */ |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 57 | class CcnxStackHelper |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 58 | { |
| 59 | public: |
| 60 | /** |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 61 | * \brief Create a new CcnxStackHelper with a default NDN_FLOODING forwarding stategy |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 62 | */ |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 63 | CcnxStackHelper(); |
| 64 | |
| 65 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 66 | * \brief Destroy the CcnxStackHelper |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 67 | */ |
| 68 | virtual ~CcnxStackHelper (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 71 | * @brief Set forwarding strategy class |
| 72 | * @param forwardingStrategy string containing name of the forwarding strategy class |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 73 | * |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 74 | * Valid options are "ns3::CcnxFloodingStrategy" (default) and "ns3::CcnxBestRouteStrategy" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 75 | * |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 76 | * Other strategies can be implemented, inheriting ns3::CcnxForwardingStrategy class |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 77 | */ |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 78 | void |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 79 | SetForwardingStrategy (const std::string &forwardingStrategy); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 82 | * @brief Set content store class |
| 83 | * @param contentStore string, representing class of the content store |
| 84 | */ |
| 85 | void |
| 86 | SetContentStore (const std::string &contentStore); |
| 87 | |
| 88 | /** |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 89 | * @brief Enable Interest limits (disabled by default) |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 90 | * |
| 91 | * @param enable Enable or disable limits |
| 92 | * @param avgRtt Average RTT |
| 93 | * @param avgContentObject Average size of contentObject packets (including all headers) |
| 94 | * @param avgInterest Average size of interest packets (including all headers) |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 95 | */ |
| 96 | void |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 97 | EnableLimits (bool enable = true, Time avgRtt=Seconds(0.1), uint32_t avgContentObject=1100, uint32_t avgInterest=40); |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 98 | |
| 99 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 100 | * \brief Install CCNx stack on the node |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 101 | * |
| 102 | * This method will assert if called on a node that already has Ccnx object |
| 103 | * installed on it |
| 104 | * |
| 105 | * \param nodeName The name of the node on which to install the stack. |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 106 | * |
| 107 | * \returns list of installed faces in the form of a smart pointer |
| 108 | * to CcnxFaceContainer object |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 109 | */ |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 110 | Ptr<CcnxFaceContainer> |
| 111 | Install (std::string nodeName) const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 114 | * \brief Install CCNx stack on the node |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 115 | * |
| 116 | * This method will assert if called on a node that already has Ccnx object |
| 117 | * installed on it |
| 118 | * |
| 119 | * \param node The node on which to install the stack. |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 120 | * |
| 121 | * \returns list of installed faces in the form of a smart pointer |
| 122 | * to CcnxFaceContainer object |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 123 | */ |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 124 | Ptr<CcnxFaceContainer> |
| 125 | Install (Ptr<Node> node) const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 126 | |
| 127 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 128 | * \brief Install CCNx stack on each node in the input container |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 129 | * |
| 130 | * The program will assert if this method is called on a container with a node |
| 131 | * that already has an ccnx object aggregated to it. |
| 132 | * |
| 133 | * \param c NodeContainer that holds the set of nodes on which to install the |
| 134 | * new stacks. |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 135 | * |
| 136 | * \returns list of installed faces in the form of a smart pointer |
| 137 | * to CcnxFaceContainer object |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 138 | */ |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 139 | Ptr<CcnxFaceContainer> |
| 140 | Install (NodeContainer c) const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 143 | * \brief Install CCNx stack on all nodes in the simulation |
| 144 | * |
| 145 | * \returns list of installed faces in the form of a smart pointer |
| 146 | * to CcnxFaceContainer object |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 147 | */ |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 148 | Ptr<CcnxFaceContainer> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 149 | InstallAll () const; |
| 150 | |
| 151 | /** |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 152 | * \brief Add forwarding entry in FIB |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 153 | * |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 154 | * \param nodeName Node name |
| 155 | * \param prefix Routing prefix |
| 156 | * \param faceId Face index |
| 157 | * \param metric Routing metric |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 158 | */ |
Alexander Afanasyev | b762684 | 2012-01-12 13:43:33 -0800 | [diff] [blame] | 159 | static void |
| 160 | AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric); |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 161 | |
| 162 | /** |
| 163 | * \brief Add forwarding entry in FIB |
| 164 | * |
| 165 | * \param node Node |
| 166 | * \param prefix Routing prefix |
| 167 | * \param face Face |
| 168 | * \param metric Routing metric |
| 169 | */ |
Alexander Afanasyev | b762684 | 2012-01-12 13:43:33 -0800 | [diff] [blame] | 170 | static void |
| 171 | AddRoute (Ptr<Node> node, std::string prefix, Ptr<CcnxFace> face, int32_t metric); |
Alexander Afanasyev | 4a5c2c1 | 2011-12-12 18:50:57 -0800 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * \brief Set flag indicating necessity to install default routes in FIB |
| 175 | */ |
| 176 | void |
| 177 | SetDefaultRoutes (bool needSet); |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 178 | |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 179 | private: |
| 180 | CcnxStackHelper (const CcnxStackHelper &); |
| 181 | CcnxStackHelper &operator = (const CcnxStackHelper &o); |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 182 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 183 | private: |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 184 | ObjectFactory m_strategyFactory; |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 185 | ObjectFactory m_contentStoreFactory; |
Alexander Afanasyev | 1145314 | 2011-11-25 16:13:33 -0800 | [diff] [blame] | 186 | bool m_limitsEnabled; |
Alexander Afanasyev | c39f0b4 | 2011-11-28 12:51:12 -0800 | [diff] [blame] | 187 | Time m_avgRtt; |
| 188 | uint32_t m_avgContentObjectSize; |
| 189 | uint32_t m_avgInterestSize; |
Alexander Afanasyev | 8e2f112 | 2012-04-17 15:01:11 -0700 | [diff] [blame] | 190 | bool m_needSetDefaultRoutes; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | } // namespace ns3 |
| 194 | |
| 195 | #endif /* CCNX_STACK_HELPER_H */ |