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) 2010 University of Washington |
| 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 |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 17 | * |
| 18 | * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef CCNX_TRACE_HELPER_H |
| 22 | #define CCNX_TRACE_HELPER_H |
| 23 | |
| 24 | #include "ns3/assert.h" |
| 25 | #include "ns3/ccnx-face-container.h" |
| 26 | #include "ns3/ccnx.h" |
| 27 | #include "ns3/trace-helper.h" |
| 28 | |
| 29 | namespace ns3 { |
| 30 | |
| 31 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 32 | * \ingroup ccnx-helpers |
| 33 | * |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 34 | * @brief Base class providing common user-level pcap operations for helpers |
| 35 | * representing Ccnx protocols . |
| 36 | */ |
| 37 | class PcapHelperForCcnx |
| 38 | { |
| 39 | public: |
| 40 | /** |
| 41 | * @brief Construct a PcapHelperForCcnx. |
| 42 | */ |
| 43 | PcapHelperForCcnx () {} |
| 44 | |
| 45 | /** |
| 46 | * @brief Destroy a PcapHelperForCcnx. |
| 47 | */ |
| 48 | virtual ~PcapHelperForCcnx () {} |
| 49 | |
| 50 | /** |
| 51 | * @brief Enable pcap output the indicated Ccnx and interface pair. |
| 52 | * @internal |
| 53 | * |
| 54 | * @param prefix Filename prefix to use for pcap files. |
| 55 | * @param Ccnx Ptr<Ccnx> on which you want to enable tracing. |
| 56 | * @param interface Interface on Ccnx on which you want to enable tracing. |
| 57 | * @param explicitFilename Treat the prefix as an explicit filename if true |
| 58 | */ |
| 59 | virtual void EnablePcapCcnxInternal (std::string prefix, |
| 60 | Ptr<Ccnx> ccnx, |
| 61 | uint32_t interface, |
| 62 | bool explicitFilename) = 0; |
| 63 | |
| 64 | /** |
| 65 | * @brief Enable pcap output the indicated Ccnx and interface pair. |
| 66 | * |
| 67 | * @param prefix Filename prefix to use for pcap files. |
| 68 | * @param ccnx Ptr<Ccnx> on which you want to enable tracing. |
| 69 | * @param interface Interface on ccnx on which you want to enable tracing. |
| 70 | * @param explicitFilename Treat the prefix as an explicit filename if true. |
| 71 | */ |
| 72 | void EnablePcapCcnx (std::string prefix, Ptr<Ccnx> ccnx, uint32_t interface, bool explicitFilename = false); |
| 73 | |
| 74 | /** |
| 75 | * @brief Enable pcap output the indicated ccnx and interface pair using a |
| 76 | * Ptr<Ccnx> previously named using the ns-3 object name service. |
| 77 | * |
| 78 | * @param prefix filename prefix to use for pcap files. |
| 79 | * @param ccnxName Name of the Ptr<Ccnx> on which you want to enable tracing. |
| 80 | * @param interface Interface on ccnx on which you want to enable tracing. |
| 81 | * @param explicitFilename Treat the prefix as an explicit filename if true. |
| 82 | */ |
| 83 | void EnablePcapCcnx (std::string prefix, std::string ccnxName, uint32_t interface, bool explicitFilename = false); |
| 84 | |
| 85 | /** |
| 86 | * @brief Enable pcap output on each Ccnx and interface pair in the container. |
| 87 | * |
| 88 | * @param prefix Filename prefix to use for pcap files. |
| 89 | * @param c CcnxFaceContainer of Ccnx and interface pairs |
| 90 | */ |
| 91 | void EnablePcapCcnx (std::string prefix, CcnxFaceContainer c); |
| 92 | |
| 93 | /** |
| 94 | * @brief Enable pcap output on all Ccnx and interface pairs existing in the |
| 95 | * nodes provided in the container. |
| 96 | * |
| 97 | * \param prefix Filename prefix to use for pcap files. |
| 98 | * \param n container of nodes. |
| 99 | */ |
| 100 | void EnablePcapCcnx (std::string prefix, NodeContainer n); |
| 101 | |
| 102 | /** |
| 103 | * @brief Enable pcap output on the Ccnx and interface pair specified by a |
| 104 | * global node-id (of a previously created node) and interface. Since there |
| 105 | * can be only one Ccnx aggregated to a node, the node-id unambiguously |
| 106 | * determines the Ccnx. |
| 107 | * |
| 108 | * @param prefix Filename prefix to use for pcap files. |
| 109 | * @param nodeid The node identifier/number of the node on which to enable tracing. |
| 110 | * @param interface Interface on ccnx on which you want to enable tracing. |
| 111 | * @param explicitFilename Treat the prefix as an explicit filename if true |
| 112 | */ |
| 113 | void EnablePcapCcnx (std::string prefix, uint32_t nodeid, uint32_t interface, bool explicitFilename); |
| 114 | |
| 115 | /** |
| 116 | * @brief Enable pcap output on all Ccnx and interface pairs existing in the |
| 117 | * set of all nodes created in the simulation. |
| 118 | * |
| 119 | * @param prefix Filename prefix to use for pcap files. |
| 120 | */ |
| 121 | void EnablePcapCcnxAll (std::string prefix); |
| 122 | |
| 123 | }; |
| 124 | |
| 125 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 126 | * \ingroup ccnx-helpers |
| 127 | * |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 128 | * @brief Base class providing common user-level ascii trace operations for |
| 129 | * helpers representing Ccnx protocols . |
| 130 | */ |
| 131 | class AsciiTraceHelperForCcnx |
| 132 | { |
| 133 | public: |
| 134 | /** |
| 135 | * @brief Construct an AsciiTraceHelperForCcnx. |
| 136 | */ |
| 137 | AsciiTraceHelperForCcnx () {} |
| 138 | |
| 139 | /** |
| 140 | * @brief Destroy an AsciiTraceHelperForCcnx |
| 141 | */ |
| 142 | virtual ~AsciiTraceHelperForCcnx () {} |
| 143 | |
| 144 | /** |
| 145 | * @brief Enable ascii trace output on the indicated Ccnx and interface pair. |
| 146 | * @internal |
| 147 | * |
| 148 | * The implementation is expected to use a provided Ptr<OutputStreamWrapper> |
| 149 | * if it is non-null. If the OutputStreamWrapper is null, the implementation |
| 150 | * is expected to use a provided prefix to construct a new file name for |
| 151 | * each net device using the rules described in the class overview. |
| 152 | * |
| 153 | * If the prefix is provided, there will be one file per Ccnx and interface pair |
| 154 | * created. In this case, adding a trace context to the file would be pointless, |
| 155 | * so the helper implementation is expected to TraceConnectWithoutContext. |
| 156 | * |
| 157 | * If the output stream object is provided, there may be many different Ccnx |
| 158 | * and interface pairs writing to a single file. In this case, the trace |
| 159 | * context could be important, so the helper implementation is expected to |
| 160 | * TraceConnect. |
| 161 | * |
| 162 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 163 | * when writing trace data. |
| 164 | * @param prefix Filename prefix to use for ascii trace files. |
| 165 | * @param ccnx Ptr<Ccnx> on which you want to enable tracing. |
| 166 | * @param interface The interface on which you want to enable tracing. |
| 167 | * @param explicitFilename Treat the prefix as an explicit filename if true. |
| 168 | */ |
| 169 | virtual void EnableAsciiCcnxInternal (Ptr<OutputStreamWrapper> stream, |
| 170 | std::string prefix, |
| 171 | Ptr<Ccnx> ccnx, |
| 172 | uint32_t interface, |
| 173 | bool explicitFilename) = 0; |
| 174 | |
| 175 | /** |
| 176 | * @brief Enable ascii trace output on the indicated ccnx and interface pair. |
| 177 | * |
| 178 | * @param prefix Filename prefix to use for ascii files. |
| 179 | * @param ccnx Ptr<Ccnx> on which you want to enable tracing. |
| 180 | * @param interface The interface on which you want to enable tracing. |
| 181 | * @param explicitFilename Treat the prefix as an explicit filename if true. |
| 182 | */ |
| 183 | void EnableAsciiCcnx (std::string prefix, Ptr<Ccnx> ccnx, uint32_t interface, bool explicitFilename = false); |
| 184 | |
| 185 | /** |
| 186 | * @brief Enable ascii trace output on the indicated Ccnx and interface pair. |
| 187 | * |
| 188 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 189 | * when writing trace data. |
| 190 | * @param ccnx Ptr<Ccnx> on which you want to enable tracing. |
| 191 | * @param interface The interface on which you want to enable tracing. |
| 192 | */ |
| 193 | void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, Ptr<Ccnx> ccnx, uint32_t interface); |
| 194 | |
| 195 | /** |
| 196 | * @brief Enable ascii trace output the indicated ccnx and interface pair |
| 197 | * using an ccnx previously named using the ns-3 object name service. |
| 198 | * |
| 199 | * @param prefix filename prefix to use for ascii files. |
| 200 | * @param ccnxName The name of the ccnx on which you want to enable tracing. |
| 201 | * @param interface The interface on which you want to enable tracing. |
| 202 | * @param explicitFilename Treat the prefix as an explicit filename if true. |
| 203 | */ |
| 204 | void EnableAsciiCcnx (std::string prefix, std::string ccnxName, uint32_t interface, bool explicitFilename = false); |
| 205 | |
| 206 | /** |
| 207 | * @brief Enable ascii trace output the indicated net device using a device |
| 208 | * previously named using the ns-3 object name service. |
| 209 | * |
| 210 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 211 | * when writing trace data. |
| 212 | * @param ccnxName The name of the ccnx on which you want to enable tracing. |
| 213 | * @param interface The interface on which you want to enable tracing. |
| 214 | */ |
| 215 | void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, std::string ccnxName, uint32_t interface); |
| 216 | |
| 217 | /** |
| 218 | * @brief Enable ascii trace output on each Ccnx and interface pair in the |
| 219 | * container |
| 220 | * |
| 221 | * @param prefix Filename prefix to use for ascii files. |
| 222 | * @param c CcnxFaceContainer of Ccnx and interface pairs on which to |
| 223 | * enable tracing. |
| 224 | */ |
| 225 | void EnableAsciiCcnx (std::string prefix, CcnxFaceContainer c); |
| 226 | |
| 227 | /** |
| 228 | * @brief Enable ascii trace output on each device in the container which is |
| 229 | * of the appropriate type. |
| 230 | * |
| 231 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 232 | * when writing trace data. |
| 233 | * @param c ccnxInterfaceContainer of ccnx and interface pairs on which to |
| 234 | * enable tracing. |
| 235 | */ |
| 236 | void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, CcnxFaceContainer c); |
| 237 | |
| 238 | /** |
| 239 | * @brief Enable ascii trace output on all ccnx and interface pairs existing |
| 240 | * in the nodes provided in the container. |
| 241 | * |
| 242 | * \param prefix Filename prefix to use for ascii files. |
| 243 | * \param n container of nodes. |
| 244 | */ |
| 245 | void EnableAsciiCcnx (std::string prefix, NodeContainer n); |
| 246 | |
| 247 | /** |
| 248 | * @brief Enable ascii trace output on all ccnx and interface pairs existing |
| 249 | * in the nodes provided in the container. |
| 250 | * |
| 251 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 252 | * when writing trace data. |
| 253 | * \param n container of nodes. |
| 254 | */ |
| 255 | void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, NodeContainer n); |
| 256 | |
| 257 | /** |
| 258 | * @brief Enable ascii trace output on all Ccnx and interface pairs existing |
| 259 | * in the set of all nodes created in the simulation. |
| 260 | * |
| 261 | * @param prefix Filename prefix to use for ascii files. |
| 262 | */ |
| 263 | void EnableAsciiCcnxAll (std::string prefix); |
| 264 | |
| 265 | /** |
| 266 | * @brief Enable ascii trace output on each device (which is of the |
| 267 | * appropriate type) in the set of all nodes created in the simulation. |
| 268 | * |
| 269 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 270 | * when writing trace data. |
| 271 | */ |
| 272 | void EnableAsciiCcnxAll (Ptr<OutputStreamWrapper> stream); |
| 273 | |
| 274 | /** |
| 275 | * @brief Enable pcap output on the Ccnx and interface pair specified by a |
| 276 | * global node-id (of a previously created node) and interface. Since there |
| 277 | * can be only one Ccnx aggregated to a node, the node-id unambiguously |
| 278 | * determines the Ccnx. |
| 279 | * |
| 280 | * @param prefix Filename prefix to use when creating ascii trace files |
| 281 | * @param nodeid The node identifier/number of the node on which to enable |
| 282 | * ascii tracing |
| 283 | * @param deviceid The device identifier/index of the device on which to enable |
| 284 | * ascii tracing |
| 285 | * @param explicitFilename Treat the prefix as an explicit filename if true |
| 286 | */ |
| 287 | void EnableAsciiCcnx (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool explicitFilename); |
| 288 | |
| 289 | /** |
| 290 | * @brief Enable pcap output on the ccnx and interface pair specified by a |
| 291 | * global node-id (of a previously created node) and interface. Since there |
| 292 | * can be only one ccnx aggregated to a node, the node-id unambiguously |
| 293 | * determines the ccnx. |
| 294 | * |
| 295 | * @param stream An OutputStreamWrapper representing an existing file to use |
| 296 | * when writing trace data. |
| 297 | * @param nodeid The node identifier/number of the node on which to enable |
| 298 | * ascii tracing |
| 299 | * @param interface The interface on which you want to enable tracing. |
| 300 | * @param explicitFilename Treat the prefix as an explicit filename if true |
| 301 | */ |
| 302 | void EnableAsciiCcnx (Ptr<OutputStreamWrapper> stream, uint32_t nodeid, uint32_t interface, bool explicitFilename); |
| 303 | |
| 304 | private: |
| 305 | /** |
| 306 | * @internal Avoid code duplication. |
| 307 | */ |
| 308 | void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, |
| 309 | std::string prefix, |
| 310 | uint32_t nodeid, |
| 311 | uint32_t interface, |
| 312 | bool explicitFilename); |
| 313 | |
| 314 | /** |
| 315 | * @internal Avoid code duplication. |
| 316 | */ |
| 317 | void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, std::string prefix, NodeContainer n); |
| 318 | |
| 319 | /** |
| 320 | * @internal Avoid code duplication. |
| 321 | */ |
| 322 | void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, std::string prefix, CcnxFaceContainer c); |
| 323 | |
| 324 | /** |
| 325 | * @internal Avoid code duplication. |
| 326 | */ |
| 327 | void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, |
| 328 | std::string prefix, |
| 329 | std::string ccnxName, |
| 330 | uint32_t interface, |
| 331 | bool explicitFilename); |
| 332 | |
| 333 | /** |
| 334 | * @internal Avoid code duplication. |
| 335 | */ |
| 336 | void EnableAsciiCcnxImpl (Ptr<OutputStreamWrapper> stream, |
| 337 | std::string prefix, |
| 338 | Ptr<Ccnx> ccnx, |
| 339 | uint32_t interface, |
| 340 | bool explicitFilename); |
| 341 | }; |
| 342 | |
| 343 | } // namespace ns3 |
| 344 | |
| 345 | #endif /* CCNX_TRACE_HELPER_H */ |