blob: 32e2f576349f4b5f691b5be5cbca65eade57f4de [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"
25#include "ns3/socket.h"
26#include "ns3/callback.h"
27
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 Afanasyev78cf0c92011-09-01 19:57:14 -070037
38/**
39 * \internal
40 * \brief Private namespace for CCNx content store implementation
41 */
42namespace __ccnx_private
43{
44class i_face {};
45class i_metric {};
46class i_nth {};
47class i_prefix {};
48class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix)
49class i_mru {};
50}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070051
Ilya Moiseenkobdf78d62011-10-28 13:20:10 -070052#define MILLI_SECOND 1
53#define SECOND 1000
54// default data size
55#define NDN_DEFAULT_DATA_SIZE 1024
56#define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND)
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:
Ilya Moiseenko2b4e1492011-09-29 18:55:14 -070084 enum ForwardingStrategy
85 {
86 NDN_FLOODING = 1,
87 NDN_BESTROUTE = 2,
88 NDN_RANKING = 3
89 };
90
Alexander Afanasyev7112f482011-08-17 14:05:57 -070091 /**
92 * \brief Interface ID
93 *
94 * \return interface ID
95 */
96 static TypeId GetTypeId ();
Alexander Afanasyev4fa5e842011-11-21 13:38:39 -080097 virtual ~Ccnx ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070098
99 /**
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700100 * \brief Send an Interest packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700101 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700102 * \param face face where to send this packet
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700103 * \param header Interest header
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700104 * \param packet fully prepared CCNx packet to send
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700105 *
106 * Higher-level layers (forwarding strategy in particular) call this
107 * method to send a packet down the stack to the MAC and PHY layers.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700108 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700109 virtual void
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700110 SendInterest (const Ptr<CcnxFace> &face,
111 const Ptr<CcnxInterestHeader> &header,
112 const Ptr<Packet> &packet) = 0;
113
114 /**
115 * \brief Send a ContentObject packet to a specified face
116 *
117 * \param face face where to send this packet
118 * \param header ContentObject header
119 * \param packet fully prepared CCNx packet to send
120 *
121 * Higher-level layers (forwarding strategy in particular) call this
122 * method to send a packet down the stack to the MAC and PHY layers.
123 */
124 virtual void
125 SendContentObject (const Ptr<CcnxFace> &face,
126 const Ptr<CcnxContentObjectHeader> &header,
127 const Ptr<Packet> &packet) = 0;
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700128
129 /**
130 * \brief Lower layers calls this method after demultiplexing
131 *
132 * Lower-layer-dependent implementation of CcnxFace will do actual work
133 * to set up demultiplexing and call this function as a callback
134 *
135 * \param face face from which packet came from
136 * \param p the packet
137 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700138 virtual void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700139 Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700140
141 /**
142 * \brief Register a new forwarding strategy to be used by this Ccnx
143 * stack
144 *
145 * This call will replace any forwarding strategy that has been
146 * previously registered.
147 *
148 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
149 * object
150 */
151 virtual void
152 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
153
154 /**
155 * \brief Get the forwarding strategy being used by this Ccnx stack
156 *
157 * \returns smart pointer to CcnxForwardingStrategy object, or null
158 * pointer if none
159 */
160 virtual Ptr<CcnxForwardingStrategy>
161 GetForwardingStrategy (void) const = 0;
162
163 /**
164 * \brief Add face to CCNx stack
165 *
166 * \param face smart pointer to CcnxFace-derived object
167 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
168 * index of the Ccnx interface added.
169 *
170 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
171 */
172 virtual uint32_t
173 AddFace (const Ptr<CcnxFace> &face) = 0;
174
175 /**
176 * \brief Get current number of faces added to CCNx stack
177 *
178 * \returns the number of faces
179 */
180 virtual uint32_t
181 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700182
183 /**
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700184 * \brief Get face by face index
Alexander Afanasyev98256102011-08-14 01:00:02 -0700185 * \param face The face number of an Ccnx interface.
186 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700187 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700188 virtual Ptr<CcnxFace>
189 GetFace (uint32_t face) const = 0;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700190
191 /**
192 * \brief Remove face from ccnx stack (remove callbacks)
193 */
194 virtual void
195 RemoveFace (Ptr<CcnxFace> face) = 0;
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800196
197 /**
198 * Get face for NetDevice
199 */
200 virtual Ptr<CcnxFace>
201 GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700202};
203
204} // namespace ns3
205
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700206#endif /* _CCNX_H_ */