blob: 10087534d3e4e114e99db8e2cc2586673044770f [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
39/**
40 * \internal
41 * \brief Private namespace for CCNx content store implementation
42 */
43namespace __ccnx_private
44{
45class i_face {};
46class i_metric {};
47class i_nth {};
48class i_prefix {};
49class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix)
50class i_mru {};
51}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070052
Ilya Moiseenkobdf78d62011-10-28 13:20:10 -070053// default data size
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080054// #define NDN_DEFAULT_DATA_SIZE 1024
55// #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND)
56
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070057/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070058 * \defgroup ccnx NDN abstraction
59 *
60 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070061 */
62/**
63 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070064 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070065 *
66 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070067 * the Ccnx stack implementation:
68 * -# register a face (CcnxFace-derived object) for use by the Ccnx
69 * layer
70 * -# register forwarding strategy (CcnxForwardingStrategy-derived
71 * object) to use by Ccnx stack
72 * -# export Ccnx configuration attributes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070073 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070074 * Each CcnxFace-derived object has conceptually a single Ccnx
75 * interface associated with it.
76 *
77 * In addition, this class defines CCNx packet coding constants
78 *
79 * \see CcnxFace, CcnxForwardingStrategy
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070080 */
81class Ccnx : public Object
82{
83public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070084 /**
85 * \brief Interface ID
86 *
87 * \return interface ID
88 */
89 static TypeId GetTypeId ();
Alexander Afanasyev4fa5e842011-11-21 13:38:39 -080090 virtual ~Ccnx ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070091
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070092 /**
93 * \brief Register a new forwarding strategy to be used by this Ccnx
94 * stack
95 *
96 * This call will replace any forwarding strategy that has been
97 * previously registered.
98 *
99 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
100 * object
101 */
102 virtual void
103 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
104
105 /**
106 * \brief Get the forwarding strategy being used by this Ccnx stack
107 *
108 * \returns smart pointer to CcnxForwardingStrategy object, or null
109 * pointer if none
110 */
111 virtual Ptr<CcnxForwardingStrategy>
112 GetForwardingStrategy (void) const = 0;
113
114 /**
115 * \brief Add face to CCNx stack
116 *
117 * \param face smart pointer to CcnxFace-derived object
118 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
119 * index of the Ccnx interface added.
120 *
121 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
122 */
123 virtual uint32_t
124 AddFace (const Ptr<CcnxFace> &face) = 0;
125
126 /**
127 * \brief Get current number of faces added to CCNx stack
128 *
129 * \returns the number of faces
130 */
131 virtual uint32_t
132 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700133
134 /**
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700135 * \brief Get face by face index
Alexander Afanasyev98256102011-08-14 01:00:02 -0700136 * \param face The face number of an Ccnx interface.
137 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700138 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700139 virtual Ptr<CcnxFace>
140 GetFace (uint32_t face) const = 0;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700141
142 /**
143 * \brief Remove face from ccnx stack (remove callbacks)
144 */
145 virtual void
146 RemoveFace (Ptr<CcnxFace> face) = 0;
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800147
148 /**
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700149 * \brief Get face for NetDevice
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800150 */
151 virtual Ptr<CcnxFace>
152 GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800153
Alexander Afanasyev7f3e49e2012-04-30 00:17:07 -0700154 /**
155 * \brief Get PIT associated with Node
156 */
157 virtual Ptr<CcnxPit>
158 GetPit() const = 0;
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800159
160 /**
161 * \enum DropReason
162 * \brief A reason why the packet has been dropped
163 */
164 enum DropReason
165 {
166 DUPLICATED, // Interests
167 SUPPRESSED, // Interests and Nacks
168 NO_FACES, // Interests
169 NON_DUPLICATED, // Nacks
170 AFTER_SATISFIED, // Nacks
171 UNSOLICITED // data
172 };
173
174protected:
175 ////////////////////////////////////////////////////////////////////
176 ////////////////////////////////////////////////////////////////////
177 ////////////////////////////////////////////////////////////////////
178
179 // transmittedInterestTrace is inside ForwardingStrategy
180
181 TracedCallback<Ptr<const CcnxInterestHeader>,
182 Ptr<const CcnxFace> > m_inInterests;
183
184 TracedCallback<Ptr<const CcnxInterestHeader>,
185 DropReason,
186 Ptr<const CcnxFace> > m_dropInterests;
187
188 ////////////////////////////////////////////////////////////////////
189 ////////////////////////////////////////////////////////////////////
190 ////////////////////////////////////////////////////////////////////
191
192 TracedCallback<Ptr<const CcnxInterestHeader>,
193 Ptr<const CcnxFace> > m_outNacks;
194
195 TracedCallback<Ptr<const CcnxInterestHeader>,
196 Ptr<const CcnxFace> > m_inNacks;
197
198 TracedCallback<Ptr<const CcnxInterestHeader>,
199 DropReason,
200 Ptr<const CcnxFace> > m_dropNacks;
201
202 ////////////////////////////////////////////////////////////////////
203 ////////////////////////////////////////////////////////////////////
204 ////////////////////////////////////////////////////////////////////
205
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800206 TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800207 bool /*from cache*/,
208 Ptr<const CcnxFace> > m_outData;
209
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800210 TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800211 Ptr<const CcnxFace> > m_inData;
212
Alexander Afanasyevc86c2832011-12-23 02:56:22 -0800213 TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
Alexander Afanasyevf377b332011-12-16 15:32:12 -0800214 DropReason,
215 Ptr<const CcnxFace> > m_dropData;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700216};
217
218} // namespace ns3
219
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700220#endif /* _CCNX_H_ */