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" |
| 26 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 27 | namespace ns3 { |
| 28 | |
| 29 | class Node; |
| 30 | class NetDevice; |
| 31 | class Packet; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 32 | class CcnxForwardingStrategy; |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 33 | class CcnxFace; |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 34 | class CcnxContentObjectHeader; |
| 35 | class CcnxInterestHeader; |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * \internal |
| 39 | * \brief Private namespace for CCNx content store implementation |
| 40 | */ |
| 41 | namespace __ccnx_private |
| 42 | { |
| 43 | class i_face {}; |
| 44 | class i_metric {}; |
| 45 | class i_nth {}; |
| 46 | class i_prefix {}; |
| 47 | class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix) |
| 48 | class i_mru {}; |
| 49 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 50 | |
Ilya Moiseenko | bdf78d6 | 2011-10-28 13:20:10 -0700 | [diff] [blame] | 51 | // default data size |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 52 | // #define NDN_DEFAULT_DATA_SIZE 1024 |
| 53 | // #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND) |
| 54 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 55 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 56 | * \defgroup ccnx NDN abstraction |
| 57 | * |
| 58 | * This is an abstract implementation of NDN protocol |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 59 | */ |
| 60 | /** |
| 61 | * \ingroup ccnx |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 62 | * \brief Interface to manage Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 63 | * |
| 64 | * This class defines the API to manipulate the following aspects of |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 65 | * the Ccnx stack implementation: |
| 66 | * -# register a face (CcnxFace-derived object) for use by the Ccnx |
| 67 | * layer |
| 68 | * -# register forwarding strategy (CcnxForwardingStrategy-derived |
| 69 | * object) to use by Ccnx stack |
| 70 | * -# export Ccnx configuration attributes |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 71 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 72 | * Each CcnxFace-derived object has conceptually a single Ccnx |
| 73 | * interface associated with it. |
| 74 | * |
| 75 | * In addition, this class defines CCNx packet coding constants |
| 76 | * |
| 77 | * \see CcnxFace, CcnxForwardingStrategy |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 78 | */ |
| 79 | class Ccnx : public Object |
| 80 | { |
| 81 | public: |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 82 | enum ForwardingStrategy |
Ilya Moiseenko | 2b4e149 | 2011-09-29 18:55:14 -0700 | [diff] [blame] | 83 | { |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 84 | NDN_FLOODING = 1, |
| 85 | NDN_BESTROUTE = 2, |
| 86 | NDN_RANKING = 3 |
Ilya Moiseenko | 2b4e149 | 2011-09-29 18:55:14 -0700 | [diff] [blame] | 87 | }; |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 88 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 89 | /** |
| 90 | * \brief Interface ID |
| 91 | * |
| 92 | * \return interface ID |
| 93 | */ |
| 94 | static TypeId GetTypeId (); |
Alexander Afanasyev | 4fa5e84 | 2011-11-21 13:38:39 -0800 | [diff] [blame] | 95 | virtual ~Ccnx (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 96 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 97 | // /** |
| 98 | // * \brief Send an Interest packet to a specified face |
| 99 | // * |
| 100 | // * \param face face where to send this packet |
| 101 | // * \param header Interest header |
| 102 | // * \param packet fully prepared CCNx packet to send |
| 103 | // * |
| 104 | // * Higher-level layers (forwarding strategy in particular) call this |
| 105 | // * method to send a packet down the stack to the MAC and PHY layers. |
| 106 | // */ |
| 107 | // virtual void |
| 108 | // SendInterest (const Ptr<CcnxFace> &face, |
| 109 | // const Ptr<const CcnxInterestHeader> &header, |
| 110 | // const Ptr<Packet> &packet) = 0; |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 111 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 112 | // /** |
| 113 | // * \brief Send a ContentObject packet to a specified face |
| 114 | // * |
| 115 | // * \param face face where to send this packet |
| 116 | // * \param header ContentObject header |
| 117 | // * \param packet fully prepared CCNx packet to send |
| 118 | // * |
| 119 | // * Higher-level layers (forwarding strategy in particular) call this |
| 120 | // * method to send a packet down the stack to the MAC and PHY layers. |
| 121 | // */ |
| 122 | // virtual void |
| 123 | // SendContentObject (const Ptr<CcnxFace> &face, |
| 124 | // const Ptr<const CcnxContentObjectHeader> &header, |
| 125 | // const Ptr<Packet> &packet) = 0; |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 126 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 127 | // /** |
| 128 | // * \brief Lower layers calls this method after demultiplexing |
| 129 | // * |
| 130 | // * Lower-layer-dependent implementation of CcnxFace will do actual work |
| 131 | // * to set up demultiplexing and call this function as a callback |
| 132 | // * |
| 133 | // * \param face face from which packet came from |
| 134 | // * \param p the packet |
| 135 | // */ |
| 136 | // virtual void |
| 137 | // Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * \brief Register a new forwarding strategy to be used by this Ccnx |
| 141 | * stack |
| 142 | * |
| 143 | * This call will replace any forwarding strategy that has been |
| 144 | * previously registered. |
| 145 | * |
| 146 | * \param forwardingStrategy smart pointer to CcnxForwardingStrategy |
| 147 | * object |
| 148 | */ |
| 149 | virtual void |
| 150 | SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0; |
| 151 | |
| 152 | /** |
| 153 | * \brief Get the forwarding strategy being used by this Ccnx stack |
| 154 | * |
| 155 | * \returns smart pointer to CcnxForwardingStrategy object, or null |
| 156 | * pointer if none |
| 157 | */ |
| 158 | virtual Ptr<CcnxForwardingStrategy> |
| 159 | GetForwardingStrategy (void) const = 0; |
| 160 | |
| 161 | /** |
| 162 | * \brief Add face to CCNx stack |
| 163 | * |
| 164 | * \param face smart pointer to CcnxFace-derived object |
| 165 | * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the |
| 166 | * index of the Ccnx interface added. |
| 167 | * |
| 168 | * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace |
| 169 | */ |
| 170 | virtual uint32_t |
| 171 | AddFace (const Ptr<CcnxFace> &face) = 0; |
| 172 | |
| 173 | /** |
| 174 | * \brief Get current number of faces added to CCNx stack |
| 175 | * |
| 176 | * \returns the number of faces |
| 177 | */ |
| 178 | virtual uint32_t |
| 179 | GetNFaces (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 180 | |
| 181 | /** |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 182 | * \brief Get face by face index |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 183 | * \param face The face number of an Ccnx interface. |
| 184 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 185 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 186 | virtual Ptr<CcnxFace> |
| 187 | GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 188 | |
| 189 | /** |
| 190 | * \brief Remove face from ccnx stack (remove callbacks) |
| 191 | */ |
| 192 | virtual void |
| 193 | RemoveFace (Ptr<CcnxFace> face) = 0; |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 194 | |
| 195 | /** |
| 196 | * Get face for NetDevice |
| 197 | */ |
| 198 | virtual Ptr<CcnxFace> |
| 199 | GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | } // namespace ns3 |
| 203 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 204 | #endif /* _CCNX_H_ */ |