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 | 7f3e49e | 2012-04-30 00:17:07 -0700 | [diff] [blame] | 37 | class CcnxPit; |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 38 | |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 39 | /// @cond include_hidden |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 40 | /** |
| 41 | * \internal |
| 42 | * \brief Private namespace for CCNx content store implementation |
| 43 | */ |
| 44 | namespace __ccnx_private |
| 45 | { |
| 46 | class i_face {}; |
| 47 | class i_metric {}; |
| 48 | class i_nth {}; |
| 49 | class i_prefix {}; |
| 50 | class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix) |
| 51 | class i_mru {}; |
| 52 | } |
Alexander Afanasyev | 6315ef7 | 2012-06-01 20:56:31 -0700 | [diff] [blame] | 53 | /// @endcond |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 54 | |
Ilya Moiseenko | bdf78d6 | 2011-10-28 13:20:10 -0700 | [diff] [blame] | 55 | // default data size |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 56 | // #define NDN_DEFAULT_DATA_SIZE 1024 |
| 57 | // #define NDN_INTEREST_RESET_PERIOD (10*MILLI_SECOND) |
| 58 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 59 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 60 | * \defgroup ccnx NDN abstraction |
| 61 | * |
| 62 | * This is an abstract implementation of NDN protocol |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 63 | */ |
| 64 | /** |
| 65 | * \ingroup ccnx |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 66 | * \brief Interface to manage Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 67 | * |
| 68 | * This class defines the API to manipulate the following aspects of |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 69 | * the Ccnx stack implementation: |
| 70 | * -# register a face (CcnxFace-derived object) for use by the Ccnx |
| 71 | * layer |
| 72 | * -# register forwarding strategy (CcnxForwardingStrategy-derived |
| 73 | * object) to use by Ccnx stack |
| 74 | * -# export Ccnx configuration attributes |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 75 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 76 | * Each CcnxFace-derived object has conceptually a single Ccnx |
| 77 | * interface associated with it. |
| 78 | * |
| 79 | * In addition, this class defines CCNx packet coding constants |
| 80 | * |
| 81 | * \see CcnxFace, CcnxForwardingStrategy |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 82 | */ |
| 83 | class Ccnx : public Object |
| 84 | { |
| 85 | public: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 86 | /** |
| 87 | * \brief Interface ID |
| 88 | * |
| 89 | * \return interface ID |
| 90 | */ |
| 91 | static TypeId GetTypeId (); |
Alexander Afanasyev | 4fa5e84 | 2011-11-21 13:38:39 -0800 | [diff] [blame] | 92 | virtual ~Ccnx (); |
Alexander Afanasyev | 3a4a0b3 | 2012-06-28 14:14:22 -0700 | [diff] [blame] | 93 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 94 | /** |
| 95 | * \brief Add face to CCNx stack |
| 96 | * |
| 97 | * \param face smart pointer to CcnxFace-derived object |
| 98 | * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the |
| 99 | * index of the Ccnx interface added. |
| 100 | * |
| 101 | * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace |
| 102 | */ |
| 103 | virtual uint32_t |
| 104 | AddFace (const Ptr<CcnxFace> &face) = 0; |
| 105 | |
| 106 | /** |
| 107 | * \brief Get current number of faces added to CCNx stack |
| 108 | * |
| 109 | * \returns the number of faces |
| 110 | */ |
| 111 | virtual uint32_t |
| 112 | GetNFaces (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 115 | * \brief Get face by face index |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 116 | * \param face The face number of an Ccnx interface. |
| 117 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 118 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 119 | virtual Ptr<CcnxFace> |
| 120 | GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * \brief Remove face from ccnx stack (remove callbacks) |
| 124 | */ |
| 125 | virtual void |
| 126 | RemoveFace (Ptr<CcnxFace> face) = 0; |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 127 | |
| 128 | /** |
Alexander Afanasyev | 7f3e49e | 2012-04-30 00:17:07 -0700 | [diff] [blame] | 129 | * \brief Get face for NetDevice |
Alexander Afanasyev | 52e9aa9 | 2011-11-15 20:23:20 -0800 | [diff] [blame] | 130 | */ |
| 131 | virtual Ptr<CcnxFace> |
| 132 | GetFaceByNetDevice (Ptr<NetDevice> netDevice) const = 0; |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 133 | |
Alexander Afanasyev | 7f3e49e | 2012-04-30 00:17:07 -0700 | [diff] [blame] | 134 | /** |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 135 | * \enum DropReason |
| 136 | * \brief A reason why the packet has been dropped |
| 137 | */ |
| 138 | enum DropReason |
| 139 | { |
| 140 | DUPLICATED, // Interests |
| 141 | SUPPRESSED, // Interests and Nacks |
| 142 | NO_FACES, // Interests |
| 143 | NON_DUPLICATED, // Nacks |
| 144 | AFTER_SATISFIED, // Nacks |
Alexander Afanasyev | f034cbd | 2012-06-29 14:28:31 -0700 | [diff] [blame] | 145 | UNSOLICITED, // data |
| 146 | PIT_LIMIT // PIT limit reached |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | protected: |
| 150 | //////////////////////////////////////////////////////////////////// |
| 151 | //////////////////////////////////////////////////////////////////// |
| 152 | //////////////////////////////////////////////////////////////////// |
| 153 | |
| 154 | // transmittedInterestTrace is inside ForwardingStrategy |
| 155 | |
| 156 | TracedCallback<Ptr<const CcnxInterestHeader>, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 157 | Ptr<const CcnxFace> > m_inInterests; ///< @brief trace of incoming Interests |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 158 | |
| 159 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 160 | DropReason, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 161 | Ptr<const CcnxFace> > m_dropInterests; ///< @brief trace of dropped Interests |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 162 | |
| 163 | //////////////////////////////////////////////////////////////////// |
| 164 | //////////////////////////////////////////////////////////////////// |
| 165 | //////////////////////////////////////////////////////////////////// |
| 166 | |
| 167 | TracedCallback<Ptr<const CcnxInterestHeader>, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 168 | Ptr<const CcnxFace> > m_outNacks; ///< @brief trace of outgoing NACKs |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 169 | |
| 170 | TracedCallback<Ptr<const CcnxInterestHeader>, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 171 | Ptr<const CcnxFace> > m_inNacks; ///< @brief trace of incoming NACKs |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 172 | |
| 173 | TracedCallback<Ptr<const CcnxInterestHeader>, |
| 174 | DropReason, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 175 | Ptr<const CcnxFace> > m_dropNacks; ///< @brief trace of dropped NACKs |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 176 | |
| 177 | //////////////////////////////////////////////////////////////////// |
| 178 | //////////////////////////////////////////////////////////////////// |
| 179 | //////////////////////////////////////////////////////////////////// |
| 180 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 181 | TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 182 | bool /*from cache*/, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 183 | Ptr<const CcnxFace> > m_outData; ///< @brief trace of outgoing Data |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 184 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 185 | TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 186 | Ptr<const CcnxFace> > m_inData; ///< @brief trace of incoming Data |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 187 | |
Alexander Afanasyev | c86c283 | 2011-12-23 02:56:22 -0800 | [diff] [blame] | 188 | TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>, |
Alexander Afanasyev | f377b33 | 2011-12-16 15:32:12 -0800 | [diff] [blame] | 189 | DropReason, |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 190 | Ptr<const CcnxFace> > m_dropData; ///< @brief trace of dropped Data |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | } // namespace ns3 |
| 194 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 195 | #endif /* _CCNX_H_ */ |