blob: 1e587e33caefec9e9cb7c564ce37b7bb9ccaaf78 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07002/*
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 *
18 * Author:
19 */
20
21#ifndef CCNX_STACK_HELPER_H
22#define CCNX_STACK_HELPER_H
23
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070024#include "ns3/packet.h"
25#include "ns3/ptr.h"
26#include "ns3/object-factory.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070027
28#include "ccnx-trace-helper.h"
29
30namespace ns3 {
31
32class Node;
33class CcnxForwardingHelper;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070034class CcnxFaceContainer;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070035
36/**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070037 * \ingroup ccnx
38 * \defgroup ccnx-helpers Helpers
39 */
40/**
41 * \ingroup ccnx-helpers
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070042 * \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 */
57class CcnxStackHelper : public PcapHelperForCcnx, public AsciiTraceHelperForCcnx
58{
59public:
60 /**
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -070061 * \brief Create a new CcnxStackHelper with empty forwarding by default.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070062 *
63 * \todo set non-empty default forwarding
64 */
65 CcnxStackHelper ();
66
67 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070068 * \brief Destroy the CcnxStackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070069 */
70 virtual ~CcnxStackHelper ();
71 CcnxStackHelper (const CcnxStackHelper &);
72 CcnxStackHelper &operator = (const CcnxStackHelper &o);
73
74 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070075 * Set forwarding strategy helper
76 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070077 * \param forwarding a new forwarding helper
78 *
79 * Set the forwarding helper to use during Install. The forwarding helper is
80 * really an object factory which is used to create an object of type
81 * ns3::CcnxFrProtocol per node. This forwarding object is then associated to
82 * a single ns3::Ccnx object through its ns3::Ccnx::SetforwardingProtocol.
83 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070084 void
85 SetForwardingHelper (const CcnxForwardingHelper &forwarding);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070086
87 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070088 * \brief Install CCNx stack on the node
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070089 *
90 * This method will assert if called on a node that already has Ccnx object
91 * installed on it
92 *
93 * \param nodeName The name of the node on which to install the stack.
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070094 *
95 * \returns list of installed faces in the form of a smart pointer
96 * to CcnxFaceContainer object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070098 Ptr<CcnxFaceContainer>
99 Install (std::string nodeName) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100
101 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700102 * \brief Install CCNx stack on the node
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700103 *
104 * This method will assert if called on a node that already has Ccnx object
105 * installed on it
106 *
107 * \param node The node on which to install the stack.
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700108 *
109 * \returns list of installed faces in the form of a smart pointer
110 * to CcnxFaceContainer object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700111 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700112 Ptr<CcnxFaceContainer>
113 Install (Ptr<Node> node) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700114
115 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700116 * \brief Install CCNx stack on each node in the input container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700117 *
118 * The program will assert if this method is called on a container with a node
119 * that already has an ccnx object aggregated to it.
120 *
121 * \param c NodeContainer that holds the set of nodes on which to install the
122 * new stacks.
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700123 *
124 * \returns list of installed faces in the form of a smart pointer
125 * to CcnxFaceContainer object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700126 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700127 Ptr<CcnxFaceContainer>
128 Install (NodeContainer c) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700129
130 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700131 * \brief Install CCNx stack on all nodes in the simulation
132 *
133 * \returns list of installed faces in the form of a smart pointer
134 * to CcnxFaceContainer object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700135 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700136 Ptr<CcnxFaceContainer>
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700137 InstallAll () const;
138
139 /**
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700140 * \brief Add forwarding entry in FIB
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700141 *
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700142 * \param nodeName Node name
143 * \param prefix Routing prefix
144 * \param faceId Face index
145 * \param metric Routing metric
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700146 */
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700147 void
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700148 AddRoute (std::string nodeName, std::string prefix, uint32_t faceId, int32_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700149
150private:
151 /**
152 * @brief Enable pcap output the indicated Ccnx and interface pair.
153 * @internal
154 *
155 * @param prefix Filename prefix to use for pcap files.
156 * @param ccnx Ptr to the Ccnx interface on which you want to enable tracing.
157 * @param interface Interface ID on the Ccnx on which you want to enable tracing.
158 */
159 virtual void EnablePcapCcnxInternal (std::string prefix,
160 Ptr<Ccnx> ccnx,
161 uint32_t interface,
162 bool explicitFilename);
163
164 /**
165 * @brief Enable ascii trace output on the indicated Ccnx and interface pair.
166 * @internal
167 *
168 * @param stream An OutputStreamWrapper representing an existing file to use
169 * when writing trace data.
170 * @param prefix Filename prefix to use for ascii trace files.
171 * @param ccnx Ptr to the Ccnx interface on which you want to enable tracing.
172 * @param interface Interface ID on the Ccnx on which you want to enable tracing.
173 */
174 virtual void EnableAsciiCcnxInternal (Ptr<OutputStreamWrapper> stream,
175 std::string prefix,
176 Ptr<Ccnx> ccnx,
177 uint32_t interface,
178 bool explicitFilename);
179
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700180 // /**
181 // * \internal
182 // */
183 // static void CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::string typeId);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700184
185 /**
186 * \internal
187 */
188 static void Cleanup (void);
189
190 /**
191 * \internal
192 */
193 bool PcapHooked (Ptr<Ccnx> ccnx);
194
195 /**
196 * \internal
197 */
198 bool AsciiHooked (Ptr<Ccnx> ccnx);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700199};
200
201} // namespace ns3
202
203#endif /* CCNX_STACK_HELPER_H */