blob: 4d6f636497018ae16fa4eb0d35d72e947c5a54a6 [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// default data size
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080053// #define NDN_DEFAULT_DATA_SIZE 1024
54// #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND)
55
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070056/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057 * \defgroup ccnx NDN abstraction
58 *
59 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070060 */
61/**
62 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070063 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070064 *
65 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070066 * the Ccnx stack implementation:
67 * -# register a face (CcnxFace-derived object) for use by the Ccnx
68 * layer
69 * -# register forwarding strategy (CcnxForwardingStrategy-derived
70 * object) to use by Ccnx stack
71 * -# export Ccnx configuration attributes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070072 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070073 * Each CcnxFace-derived object has conceptually a single Ccnx
74 * interface associated with it.
75 *
76 * In addition, this class defines CCNx packet coding constants
77 *
78 * \see CcnxFace, CcnxForwardingStrategy
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070079 */
80class Ccnx : public Object
81{
82public:
Ilya Moiseenko2b4e1492011-09-29 18:55:14 -070083 enum ForwardingStrategy
84 {
85 NDN_FLOODING = 1,
86 NDN_BESTROUTE = 2,
87 NDN_RANKING = 3
88 };
89
Alexander Afanasyev7112f482011-08-17 14:05:57 -070090 /**
91 * \brief Interface ID
92 *
93 * \return interface ID
94 */
95 static TypeId GetTypeId ();
Alexander Afanasyev4fa5e842011-11-21 13:38:39 -080096 virtual ~Ccnx ();
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,
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800110 const Ptr<const CcnxInterestHeader> &header,
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700111 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,
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -0800125 const Ptr<const CcnxContentObjectHeader> &header,
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700126 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_ */