Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 2 | /* |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 3 | * Copyright (c) 2011 University of California, Los Angeles |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 4 | * |
| 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 Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 19 | */ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 21 | #ifndef _CCNX_H_ |
| 22 | #define _CCNX_H_ |
| 23 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 24 | #include "ns3/object.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 25 | #include "ns3/callback.h" |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 26 | #include "ns3/traced-callback.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 27 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 28 | namespace ns3 { |
| 29 | |
| 30 | class Node; |
| 31 | class NetDevice; |
| 32 | class Packet; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 33 | class CcnxForwardingStrategy; |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 34 | class CcnxFace; |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 35 | class CcnxContentObjectHeader; |
| 36 | class CcnxInterestHeader; |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * \internal |
| 40 | * \brief Private namespace for CCNx content store implementation |
| 41 | */ |
| 42 | namespace __ccnx_private |
| 43 | { |
| 44 | class i_face {}; |
| 45 | class i_metric {}; |
| 46 | class i_nth {}; |
| 47 | class i_prefix {}; |
| 48 | class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix) |
| 49 | class i_mru {}; |
| 50 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 51 | |
Ilya Moiseenko | bdf78d6 | 2011-10-28 13:20:10 -0700 | [diff] [blame] | 52 | // default data size |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 53 | // #define NDN_DEFAULT_DATA_SIZE 1024 |
| 54 | // #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND) |
| 55 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 56 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 57 | * \defgroup ccnx NDN abstraction |
| 58 | * |
| 59 | * This is an abstract implementation of NDN protocol |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 60 | */ |
| 61 | /** |
| 62 | * \ingroup ccnx |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 63 | * \brief Interface to manage Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 64 | * |
| 65 | * This class defines the API to manipulate the following aspects of |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 66 | * 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 72 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 73 | * 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 79 | */ |
| 80 | class Ccnx : public Object |
| 81 | { |
| 82 | public: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 83 | /** |
| 84 | * \brief Interface ID |
| 85 | * |
| 86 | * \return interface ID |
| 87 | */ |
| 88 | static TypeId GetTypeId (); |
Alexander Afanasyev | 4fa5e84 | 2011-11-21 13:38:39 -0800 | [diff] [blame] | 89 | virtual ~Ccnx (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 90 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 91 | /** |
| 92 | * \brief Register a new forwarding strategy to be used by this Ccnx |
| 93 | * stack |
| 94 | * |
| 95 | * This call will replace any forwarding strategy that has been |
| 96 | * previously registered. |
| 97 | * |
| 98 | * \param forwardingStrategy smart pointer to CcnxForwardingStrategy |
| 99 | * object |
| 100 | */ |
| 101 | virtual void |
| 102 | SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0; |
| 103 | |
| 104 | /** |
| 105 | * \brief Get the forwarding strategy being used by this Ccnx stack |
| 106 | * |
| 107 | * \returns smart pointer to CcnxForwardingStrategy object, or null |
| 108 | * pointer if none |
| 109 | */ |
| 110 | virtual Ptr<CcnxForwardingStrategy> |
| 111 | GetForwardingStrategy (void) const = 0; |
| 112 | |
| 113 | /** |
| 114 | * \brief Add face to CCNx stack |
| 115 | * |
| 116 | * \param face smart pointer to CcnxFace-derived object |
| 117 | * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the |
| 118 | * index of the Ccnx interface added. |
| 119 | * |
| 120 | * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace |
| 121 | */ |
| 122 | virtual uint32_t |
| 123 | AddFace (const Ptr<CcnxFace> &face) = 0; |
| 124 | |
| 125 | /** |
| 126 | * \brief Get current number of faces added to CCNx stack |
| 127 | * |
| 128 | * \returns the number of faces |
| 129 | */ |
| 130 | virtual uint32_t |
| 131 | GetNFaces (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 134 | * \brief Get face by face index |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 135 | * \param face The face number of an Ccnx interface. |
| 136 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 137 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 138 | virtual Ptr<CcnxFace> |
| 139 | GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * \brief Remove face from ccnx stack (remove callbacks) |
| 143 | */ |
| 144 | virtual void |
| 145 | RemoveFace (Ptr<CcnxFace> face) = 0; |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Get face for NetDevice |
| 149 | */ |
| 150 | virtual Ptr<CcnxFace> |
| 151 | GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0; |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 152 | |
| 153 | |
| 154 | /** |
| 155 | * \enum DropReason |
| 156 | * \brief A reason why the packet has been dropped |
| 157 | */ |
| 158 | enum DropReason |
| 159 | { |
| 160 | DUPLICATED, // Interests |
| 161 | SUPPRESSED, // Interests and Nacks |
| 162 | NO_FACES, // Interests |
| 163 | NON_DUPLICATED, // Nacks |
| 164 | AFTER_SATISFIED, // Nacks |
| 165 | UNSOLICITED // data |
| 166 | }; |
| 167 | |
| 168 | protected: |
| 169 | //////////////////////////////////////////////////////////////////// |
| 170 | //////////////////////////////////////////////////////////////////// |
| 171 | //////////////////////////////////////////////////////////////////// |
| 172 | |
| 173 | // transmittedInterestTrace is inside ForwardingStrategy |
| 174 | |
| 175 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 176 | Ptr<const CcnxFace> > m_inInterests; |
| 177 | |
| 178 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 179 | DropReason, |
| 180 | Ptr<const CcnxFace> > m_dropInterests; |
| 181 | |
| 182 | //////////////////////////////////////////////////////////////////// |
| 183 | //////////////////////////////////////////////////////////////////// |
| 184 | //////////////////////////////////////////////////////////////////// |
| 185 | |
| 186 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 187 | Ptr<const CcnxFace> > m_outNacks; |
| 188 | |
| 189 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 190 | Ptr<const CcnxFace> > m_inNacks; |
| 191 | |
| 192 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 193 | DropReason, |
| 194 | Ptr<const CcnxFace> > m_dropNacks; |
| 195 | |
| 196 | //////////////////////////////////////////////////////////////////// |
| 197 | //////////////////////////////////////////////////////////////////// |
| 198 | //////////////////////////////////////////////////////////////////// |
| 199 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 200 | TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 201 | bool /*from cache*/, |
| 202 | Ptr<const CcnxFace> > m_outData; |
| 203 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 204 | TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 205 | Ptr<const CcnxFace> > m_inData; |
| 206 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 207 | TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 208 | DropReason, |
| 209 | Ptr<const CcnxFace> > m_dropData; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | } // namespace ns3 |
| 213 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 214 | #endif /* _CCNX_H_ */ |