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 | |
| 52 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 53 | * \defgroup ccnx NDN abstraction |
| 54 | * |
| 55 | * This is an abstract implementation of NDN protocol |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 56 | */ |
| 57 | /** |
| 58 | * \ingroup ccnx |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 59 | * \brief Interface to manage Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 60 | * |
| 61 | * This class defines the API to manipulate the following aspects of |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 62 | * 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 68 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 69 | * 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 75 | */ |
| 76 | class Ccnx : public Object |
| 77 | { |
| 78 | public: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 79 | /** |
| 80 | * \brief Interface ID |
| 81 | * |
| 82 | * \return interface ID |
| 83 | */ |
| 84 | static TypeId GetTypeId (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 85 | |
| 86 | /** |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame^] | 87 | * \brief Send an Interest packet to a specified face |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 88 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 89 | * \param face face where to send this packet |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame^] | 90 | * \param header Interest header |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 91 | * \param packet fully prepared CCNx packet to send |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 92 | * |
| 93 | * Higher-level layers (forwarding strategy in particular) call this |
| 94 | * 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] | 95 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 96 | virtual void |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame^] | 97 | SendInterest (const Ptr<CcnxFace> &face, |
| 98 | const Ptr<CcnxInterestHeader> &header, |
| 99 | const Ptr<Packet> &packet) = 0; |
| 100 | |
| 101 | /** |
| 102 | * \brief Send a ContentObject packet to a specified face |
| 103 | * |
| 104 | * \param face face where to send this packet |
| 105 | * \param header ContentObject header |
| 106 | * \param packet fully prepared CCNx packet to send |
| 107 | * |
| 108 | * Higher-level layers (forwarding strategy in particular) call this |
| 109 | * method to send a packet down the stack to the MAC and PHY layers. |
| 110 | */ |
| 111 | virtual void |
| 112 | SendContentObject (const Ptr<CcnxFace> &face, |
| 113 | const Ptr<CcnxContentObjectHeader> &header, |
| 114 | const Ptr<Packet> &packet) = 0; |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * \brief Lower layers calls this method after demultiplexing |
| 118 | * |
| 119 | * Lower-layer-dependent implementation of CcnxFace will do actual work |
| 120 | * to set up demultiplexing and call this function as a callback |
| 121 | * |
| 122 | * \param face face from which packet came from |
| 123 | * \param p the packet |
| 124 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 125 | virtual void |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 126 | Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * \brief Register a new forwarding strategy to be used by this Ccnx |
| 130 | * stack |
| 131 | * |
| 132 | * This call will replace any forwarding strategy that has been |
| 133 | * previously registered. |
| 134 | * |
| 135 | * \param forwardingStrategy smart pointer to CcnxForwardingStrategy |
| 136 | * object |
| 137 | */ |
| 138 | virtual void |
| 139 | SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0; |
| 140 | |
| 141 | /** |
| 142 | * \brief Get the forwarding strategy being used by this Ccnx stack |
| 143 | * |
| 144 | * \returns smart pointer to CcnxForwardingStrategy object, or null |
| 145 | * pointer if none |
| 146 | */ |
| 147 | virtual Ptr<CcnxForwardingStrategy> |
| 148 | GetForwardingStrategy (void) const = 0; |
| 149 | |
| 150 | /** |
| 151 | * \brief Add face to CCNx stack |
| 152 | * |
| 153 | * \param face smart pointer to CcnxFace-derived object |
| 154 | * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the |
| 155 | * index of the Ccnx interface added. |
| 156 | * |
| 157 | * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace |
| 158 | */ |
| 159 | virtual uint32_t |
| 160 | AddFace (const Ptr<CcnxFace> &face) = 0; |
| 161 | |
| 162 | /** |
| 163 | * \brief Get current number of faces added to CCNx stack |
| 164 | * |
| 165 | * \returns the number of faces |
| 166 | */ |
| 167 | virtual uint32_t |
| 168 | GetNFaces (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 169 | |
| 170 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 171 | * \param face The face number of an Ccnx interface. |
| 172 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 173 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 174 | virtual Ptr<CcnxFace> |
| 175 | GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | } // namespace ns3 |
| 179 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 180 | #endif /* _CCNX_H_ */ |