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" |
| 25 | #include "ns3/socket.h" |
| 26 | #include "ns3/callback.h" |
| 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 | #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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 57 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 58 | * \defgroup ccnx NDN abstraction |
| 59 | * |
| 60 | * This is an abstract implementation of NDN protocol |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 61 | */ |
| 62 | /** |
| 63 | * \ingroup ccnx |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 64 | * \brief Interface to manage Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 65 | * |
| 66 | * This class defines the API to manipulate the following aspects of |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 67 | * 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 73 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 74 | * 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 80 | */ |
| 81 | class Ccnx : public Object |
| 82 | { |
| 83 | public: |
Ilya Moiseenko | 2b4e149 | 2011-09-29 18:55:14 -0700 | [diff] [blame] | 84 | enum ForwardingStrategy |
| 85 | { |
| 86 | NDN_FLOODING = 1, |
| 87 | NDN_BESTROUTE = 2, |
| 88 | NDN_RANKING = 3 |
| 89 | }; |
| 90 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 91 | /** |
| 92 | * \brief Interface ID |
| 93 | * |
| 94 | * \return interface ID |
| 95 | */ |
| 96 | static TypeId GetTypeId (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 99 | * \brief Send an Interest packet to a specified face |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 100 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 101 | * \param face face where to send this packet |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 102 | * \param header Interest header |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 103 | * \param packet fully prepared CCNx packet to send |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 104 | * |
| 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 107 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 108 | virtual void |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 109 | 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 Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 127 | |
| 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 Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 137 | virtual void |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 138 | Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 139 | |
| 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 181 | |
| 182 | /** |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 183 | * \brief Get face by face index |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 184 | * \param face The face number of an Ccnx interface. |
| 185 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 186 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 187 | virtual Ptr<CcnxFace> |
| 188 | GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 189 | |
| 190 | /** |
| 191 | * \brief Remove face from ccnx stack (remove callbacks) |
| 192 | */ |
| 193 | virtual void |
| 194 | RemoveFace (Ptr<CcnxFace> face) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | } // namespace ns3 |
| 198 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 199 | #endif /* _CCNX_H_ */ |