blob: e72ddecd38983333964da674942b3470390b3502 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07002/*
Alexander Afanasyev7112f482011-08-17 14:05:57 -07003 * Copyright (c) 2011 University of California, Los Angeles
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07004 *
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 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070018 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070019 */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070020
Alexander Afanasyev7112f482011-08-17 14:05:57 -070021#ifndef _CCNX_H_
22#define _CCNX_H_
23
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070024#include "ns3/object.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070025#include "ns3/callback.h"
Alexander Afanasyevf377b332011-12-16 15:32:12 -080026#include "ns3/traced-callback.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070027
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070028namespace ns3 {
29
30class Node;
31class NetDevice;
32class Packet;
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070033class CcnxForwardingStrategy;
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -070034class CcnxFace;
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070035class CcnxContentObjectHeader;
36class CcnxInterestHeader;
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -070037class CcnxPit;
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -070038
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070039/// @cond include_hidden
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -070040/**
41 * \internal
42 * \brief Private namespace for CCNx content store implementation
43 */
44namespace __ccnx_private
45{
46class i_face {};
47class i_metric {};
48class i_nth {};
49class i_prefix {};
50class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix)
51class i_mru {};
52}
Alexander Afanasyev6315ef72012-06-01 20:56:31 -070053/// @endcond
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070054
Ilya Moiseenkobdf78d62011-10-28 13:20:10 -070055// default data size
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080056// #define NDN_DEFAULT_DATA_SIZE 1024
57// #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND)
58
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070059/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070060 * \defgroup ccnx NDN abstraction
61 *
62 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070063 */
64/**
65 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070066 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070067 *
68 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070069 * the Ccnx stack implementation:
70 * -# register a face (CcnxFace-derived object) for use by the Ccnx
71 * layer
72 * -# register forwarding strategy (CcnxForwardingStrategy-derived
73 * object) to use by Ccnx stack
74 * -# export Ccnx configuration attributes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070075 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070076 * Each CcnxFace-derived object has conceptually a single Ccnx
77 * interface associated with it.
78 *
79 * In addition, this class defines CCNx packet coding constants
80 *
81 * \see CcnxFace, CcnxForwardingStrategy
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070082 */
83class Ccnx : public Object
84{
85public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070086 /**
87 * \brief Interface ID
88 *
89 * \return interface ID
90 */
91 static TypeId GetTypeId ();
Alexander Afanasyev4fa5e842011-11-21 13:38:39 -080092 virtual ~Ccnx ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070093
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070094 /**
95 * \brief Register a new forwarding strategy to be used by this Ccnx
96 * stack
97 *
98 * This call will replace any forwarding strategy that has been
99 * previously registered.
100 *
101 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
102 * object
103 */
104 virtual void
105 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
106
107 /**
108 * \brief Get the forwarding strategy being used by this Ccnx stack
109 *
110 * \returns smart pointer to CcnxForwardingStrategy object, or null
111 * pointer if none
112 */
113 virtual Ptr<CcnxForwardingStrategy>
114 GetForwardingStrategy (void) const = 0;
115
116 /**
117 * \brief Add face to CCNx stack
118 *
119 * \param face smart pointer to CcnxFace-derived object
120 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
121 * index of the Ccnx interface added.
122 *
123 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
124 */
125 virtual uint32_t
126 AddFace (const Ptr<CcnxFace> &face) = 0;
127
128 /**
129 * \brief Get current number of faces added to CCNx stack
130 *
131 * \returns the number of faces
132 */
133 virtual uint32_t
134 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700135
136 /**
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700137 * \brief Get face by face index
Alexander Afanasyev98256102011-08-14 01:00:02 -0700138 * \param face The face number of an Ccnx interface.
139 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700140 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700141 virtual Ptr<CcnxFace>
142 GetFace (uint32_t face) const = 0;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700143
144 /**
145 * \brief Remove face from ccnx stack (remove callbacks)
146 */
147 virtual void
148 RemoveFace (Ptr<CcnxFace> face) = 0;
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800149
150 /**
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700151 * \brief Get face for NetDevice
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800152 */
153 virtual Ptr<CcnxFace>
154 GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800155
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700156 /**
157 * \brief Get PIT associated with Node
158 */
159 virtual Ptr<CcnxPit>
160 GetPit() const = 0;
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800161
162 /**
163 * \enum DropReason
164 * \brief A reason why the packet has been dropped
165 */
166 enum DropReason
167 {
168 DUPLICATED, // Interests
169 SUPPRESSED, // Interests and Nacks
170 NO_FACES, // Interests
171 NON_DUPLICATED, // Nacks
172 AFTER_SATISFIED, // Nacks
173 UNSOLICITED // data
174 };
175
176protected:
177 ////////////////////////////////////////////////////////////////////
178 ////////////////////////////////////////////////////////////////////
179 ////////////////////////////////////////////////////////////////////
180
181 // transmittedInterestTrace is inside ForwardingStrategy
182
183 TracedCallback<Ptr<const CcnxInterestHeader>,
184 Ptr<const CcnxFace> > m_inInterests;
185
186 TracedCallback<Ptr<const CcnxInterestHeader>,
187 DropReason,
188 Ptr<const CcnxFace> > m_dropInterests;
189
190 ////////////////////////////////////////////////////////////////////
191 ////////////////////////////////////////////////////////////////////
192 ////////////////////////////////////////////////////////////////////
193
194 TracedCallback<Ptr<const CcnxInterestHeader>,
195 Ptr<const CcnxFace> > m_outNacks;
196
197 TracedCallback<Ptr<const CcnxInterestHeader>,
198 Ptr<const CcnxFace> > m_inNacks;
199
200 TracedCallback<Ptr<const CcnxInterestHeader>,
201 DropReason,
202 Ptr<const CcnxFace> > m_dropNacks;
203
204 ////////////////////////////////////////////////////////////////////
205 ////////////////////////////////////////////////////////////////////
206 ////////////////////////////////////////////////////////////////////
207
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800208 TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800209 bool /*from cache*/,
210 Ptr<const CcnxFace> > m_outData;
211
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800212 TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800213 Ptr<const CcnxFace> > m_inData;
214
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800215 TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800216 DropReason,
217 Ptr<const CcnxFace> > m_dropData;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700218};
219
220} // namespace ns3
221
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700222#endif /* _CCNX_H_ */