blob: cafa354aa9074441ca937824e90be9c524ce5c4e [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 Afanasyev08d984e2011-08-13 19:20:22 -070097
98 /**
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070099 * \brief Send an Interest packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700100 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700101 * \param face face where to send this packet
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700102 * \param header Interest header
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700103 * \param packet fully prepared CCNx packet to send
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700104 *
105 * Higher-level layers (forwarding strategy in particular) call this
106 * method to send a packet down the stack to the MAC and PHY layers.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700107 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700108 virtual void
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700109 SendInterest (const Ptr<CcnxFace> &face,
110 const Ptr<CcnxInterestHeader> &header,
111 const Ptr<Packet> &packet) = 0;
112
113 /**
114 * \brief Send a ContentObject packet to a specified face
115 *
116 * \param face face where to send this packet
117 * \param header ContentObject header
118 * \param packet fully prepared CCNx packet to send
119 *
120 * Higher-level layers (forwarding strategy in particular) call this
121 * method to send a packet down the stack to the MAC and PHY layers.
122 */
123 virtual void
124 SendContentObject (const Ptr<CcnxFace> &face,
125 const Ptr<CcnxContentObjectHeader> &header,
126 const Ptr<Packet> &packet) = 0;
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700127
128 /**
129 * \brief Lower layers calls this method after demultiplexing
130 *
131 * Lower-layer-dependent implementation of CcnxFace will do actual work
132 * to set up demultiplexing and call this function as a callback
133 *
134 * \param face face from which packet came from
135 * \param p the packet
136 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700137 virtual void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700138 Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700139
140 /**
141 * \brief Register a new forwarding strategy to be used by this Ccnx
142 * stack
143 *
144 * This call will replace any forwarding strategy that has been
145 * previously registered.
146 *
147 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
148 * object
149 */
150 virtual void
151 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
152
153 /**
154 * \brief Get the forwarding strategy being used by this Ccnx stack
155 *
156 * \returns smart pointer to CcnxForwardingStrategy object, or null
157 * pointer if none
158 */
159 virtual Ptr<CcnxForwardingStrategy>
160 GetForwardingStrategy (void) const = 0;
161
162 /**
163 * \brief Add face to CCNx stack
164 *
165 * \param face smart pointer to CcnxFace-derived object
166 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
167 * index of the Ccnx interface added.
168 *
169 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
170 */
171 virtual uint32_t
172 AddFace (const Ptr<CcnxFace> &face) = 0;
173
174 /**
175 * \brief Get current number of faces added to CCNx stack
176 *
177 * \returns the number of faces
178 */
179 virtual uint32_t
180 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700181
182 /**
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700183 * \brief Get face by face index
Alexander Afanasyev98256102011-08-14 01:00:02 -0700184 * \param face The face number of an Ccnx interface.
185 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700186 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700187 virtual Ptr<CcnxFace>
188 GetFace (uint32_t face) const = 0;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700189
190 /**
191 * \brief Remove face from ccnx stack (remove callbacks)
192 */
193 virtual void
194 RemoveFace (Ptr<CcnxFace> face) = 0;
Alexander Afanasyev52e9aa92011-11-15 20:23:20 -0800195
196 /**
197 * Get face for NetDevice
198 */
199 virtual Ptr<CcnxFace>
200 GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700201};
202
203} // namespace ns3
204
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700205#endif /* _CCNX_H_ */