blob: 7c90de9d8dbf21c7e338820b1c4aa0ea14201b20 [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
52/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070053 * \defgroup ccnx NDN abstraction
54 *
55 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070056 */
57/**
58 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070059 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070060 *
61 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070062 * the Ccnx stack implementation:
63 * -# register a face (CcnxFace-derived object) for use by the Ccnx
64 * layer
65 * -# register forwarding strategy (CcnxForwardingStrategy-derived
66 * object) to use by Ccnx stack
67 * -# export Ccnx configuration attributes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070068 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070069 * Each CcnxFace-derived object has conceptually a single Ccnx
70 * interface associated with it.
71 *
72 * In addition, this class defines CCNx packet coding constants
73 *
74 * \see CcnxFace, CcnxForwardingStrategy
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070075 */
76class Ccnx : public Object
77{
78public:
Ilya Moiseenko2b4e1492011-09-29 18:55:14 -070079 enum ForwardingStrategy
80 {
81 NDN_FLOODING = 1,
82 NDN_BESTROUTE = 2,
83 NDN_RANKING = 3
84 };
85
Alexander Afanasyev7112f482011-08-17 14:05:57 -070086 /**
87 * \brief Interface ID
88 *
89 * \return interface ID
90 */
91 static TypeId GetTypeId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070092
93 /**
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070094 * \brief Send an Interest packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070095 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070096 * \param face face where to send this packet
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070097 * \param header Interest header
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070098 * \param packet fully prepared CCNx packet to send
Alexander Afanasyev7112f482011-08-17 14:05:57 -070099 *
100 * Higher-level layers (forwarding strategy in particular) call this
101 * method to send a packet down the stack to the MAC and PHY layers.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700102 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700103 virtual void
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700104 SendInterest (const Ptr<CcnxFace> &face,
105 const Ptr<CcnxInterestHeader> &header,
106 const Ptr<Packet> &packet) = 0;
107
108 /**
109 * \brief Send a ContentObject packet to a specified face
110 *
111 * \param face face where to send this packet
112 * \param header ContentObject header
113 * \param packet fully prepared CCNx packet to send
114 *
115 * Higher-level layers (forwarding strategy in particular) call this
116 * method to send a packet down the stack to the MAC and PHY layers.
117 */
118 virtual void
119 SendContentObject (const Ptr<CcnxFace> &face,
120 const Ptr<CcnxContentObjectHeader> &header,
121 const Ptr<Packet> &packet) = 0;
Alexander Afanasyevab1d5602011-08-17 19:17:18 -0700122
123 /**
124 * \brief Lower layers calls this method after demultiplexing
125 *
126 * Lower-layer-dependent implementation of CcnxFace will do actual work
127 * to set up demultiplexing and call this function as a callback
128 *
129 * \param face face from which packet came from
130 * \param p the packet
131 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700132 virtual void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700133 Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700134
135 /**
136 * \brief Register a new forwarding strategy to be used by this Ccnx
137 * stack
138 *
139 * This call will replace any forwarding strategy that has been
140 * previously registered.
141 *
142 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
143 * object
144 */
145 virtual void
146 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
147
148 /**
149 * \brief Get the forwarding strategy being used by this Ccnx stack
150 *
151 * \returns smart pointer to CcnxForwardingStrategy object, or null
152 * pointer if none
153 */
154 virtual Ptr<CcnxForwardingStrategy>
155 GetForwardingStrategy (void) const = 0;
156
157 /**
158 * \brief Add face to CCNx stack
159 *
160 * \param face smart pointer to CcnxFace-derived object
161 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
162 * index of the Ccnx interface added.
163 *
164 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
165 */
166 virtual uint32_t
167 AddFace (const Ptr<CcnxFace> &face) = 0;
168
169 /**
170 * \brief Get current number of faces added to CCNx stack
171 *
172 * \returns the number of faces
173 */
174 virtual uint32_t
175 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700176
177 /**
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700178 * \brief Get face by face index
Alexander Afanasyev98256102011-08-14 01:00:02 -0700179 * \param face The face number of an Ccnx interface.
180 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700181 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700182 virtual Ptr<CcnxFace>
183 GetFace (uint32_t face) const = 0;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700184
185 /**
186 * \brief Remove face from ccnx stack (remove callbacks)
187 */
188 virtual void
189 RemoveFace (Ptr<CcnxFace> face) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700190};
191
192} // namespace ns3
193
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700194#endif /* _CCNX_H_ */