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 | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 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 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
| 21 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 22 | #ifndef _NDN_INTEREST_HEADER_H_ |
| 23 | #define _NDN_INTEREST_HEADER_H_ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 2536e20 | 2011-08-12 14:13:10 -0700 | [diff] [blame] | 25 | #include "ns3/integer.h" |
| 26 | #include "ns3/header.h" |
Alexander Afanasyev | e275cf8 | 2012-04-18 14:25:02 -0700 | [diff] [blame] | 27 | #include "ns3/simple-ref-count.h" |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 28 | #include "ns3/nstime.h" |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 29 | |
| 30 | #include <string> |
| 31 | #include <vector> |
| 32 | #include <list> |
| 33 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 34 | #include "ndn-name-components.h" |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 35 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 36 | namespace ns3 { |
| 37 | namespace ndn { |
Alexander Afanasyev | 2536e20 | 2011-08-12 14:13:10 -0700 | [diff] [blame] | 38 | |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 39 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 40 | * Ndn XML definition of Interest |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 41 | * |
| 42 | * Only few important fields are actually implemented in the simulation |
| 43 | * |
| 44 | * <xs:element name="Interest" type="InterestType"/> |
| 45 | * <xs:complexType name="InterestType"> |
| 46 | * <xs:sequence> |
| 47 | * <xs:element name="Name" type="NameType"/> |
| 48 | * <xs:element name="MinSuffixComponents" type="xs:nonNegativeInteger" |
| 49 | * minOccurs="0" maxOccurs="1"/> |
| 50 | * <xs:element name="MaxSuffixComponents" type="xs:nonNegativeInteger" |
| 51 | * minOccurs="0" maxOccurs="1"/> |
| 52 | * <xs:choice minOccurs="0" maxOccurs="1"> |
| 53 | * <xs:element name="PublisherPublicKeyDigest" type="DigestType"/> |
| 54 | * <xs:element name="PublisherCertificateDigest" type="DigestType"/> |
| 55 | * <xs:element name="PublisherIssuerKeyDigest" type="DigestType"/> |
| 56 | * <xs:element name="PublisherIssuerCertificateDigest" type="DigestType"/> |
| 57 | * </xs:choice> |
| 58 | * <xs:element name="Exclude" type="ExcludeType" |
| 59 | * minOccurs="0" maxOccurs="1"/> |
| 60 | * <xs:element name="ChildSelector" type="xs:nonNegativeInteger" |
| 61 | * minOccurs="0" maxOccurs="1"/> |
| 62 | * <xs:element name="AnswerOriginKind" type="xs:nonNegativeInteger" |
| 63 | * minOccurs="0" maxOccurs="1"/> |
| 64 | * <xs:element name="Scope" type="xs:nonNegativeInteger" |
| 65 | * minOccurs="0" maxOccurs="1"/> |
| 66 | * <xs:element name="InterestLifetime" type="FinegrainLifetimeType" |
| 67 | * minOccurs="0" maxOccurs="1"/> |
| 68 | * <xs:element name="Nonce" type="Base64BinaryType" |
| 69 | * minOccurs="0" maxOccurs="1"/> |
| 70 | * </xs:sequence> |
| 71 | * </xs:complexType> |
| 72 | * |
| 73 | * <xs:complexType name="NameType"> |
| 74 | * <xs:sequence> |
| 75 | * <xs:element name="Component" type="Base64BinaryType" |
| 76 | * minOccurs="0" maxOccurs="unbounded"/> |
| 77 | * </xs:sequence> |
| 78 | * </xs:complexType> |
| 79 | * |
| 80 | * <xs:complexType name="ExcludeType"> |
| 81 | * <xs:sequence> |
| 82 | * <xs:choice minOccurs="0" maxOccurs="1"> |
| 83 | * <xs:element name="Any" type="EmptyType"/> |
| 84 | * <xs:element name="Bloom" type="Base64BinaryType"/> <!-- Bloom is deprecated --!> |
| 85 | * </xs:choice> |
| 86 | * <xs:sequence minOccurs="0" maxOccurs="unbounded"> |
| 87 | * <xs:element name="Component" type="Base64BinaryType"/> |
| 88 | * <xs:choice minOccurs="0" maxOccurs="1"> |
| 89 | * <xs:element name="Any" type="EmptyType"/> |
| 90 | * <xs:element name="Bloom" type="Base64BinaryType"/> <!-- Bloom is deprecated --!> |
| 91 | * </xs:choice> |
| 92 | * </xs:sequence> |
| 93 | * </xs:sequence> |
| 94 | * </xs:complexType> |
| 95 | * |
| 96 | * <!-- Binary representation of time, Unix time epoch, units 2**-12 sec (0.000244140625 sec) --> |
| 97 | * <!-- The length limit limit of 6 bytes is not actually to be enforced, but |
| 98 | * it will be a loooooooong time before anyone cares. --> |
| 99 | * |
| 100 | * <!-- Binary representation of relative time, relative to "now" --> |
| 101 | * <xs:complexType name="FinegrainLifetimeType"> |
| 102 | * <xs:simpleContent> |
| 103 | * <xs:extension base="BinaryTime12"> |
| 104 | * <xs:attribute name="ccnbencoding" type="xs:string" fixed="base64Binary"/> |
| 105 | * </xs:extension> |
| 106 | * </xs:simpleContent> |
| 107 | * </xs:complexType> |
| 108 | * |
| 109 | * <xs:simpleType name="BinaryTime12"> |
| 110 | * <xs:restriction base="xs:base64Binary"> |
| 111 | * <xs:length value="6" fixed="true"/> |
| 112 | * </xs:restriction> |
| 113 | * </xs:simpleType> |
| 114 | * |
| 115 | **/ |
| 116 | |
| 117 | /** |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 118 | * @brief NDN InterestHeader and routines to serialize/deserialize |
| 119 | * |
| 120 | * Simplifications: |
| 121 | * - Name: binary name components are not supported |
| 122 | * - MinSuffixComponents and MasSuffixComponents: if value is negative (default), will not be serialized |
| 123 | * - ChildSelector, AnswerOriginKind: 0 - false, 1 - true, -1 not set |
| 124 | * - Publisher* elements are not supported |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 125 | * - Exclude: only simple name matching is supported (Bloom support has been deprecated in Ndn) |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 126 | * - InterestLifetime: ? |
| 127 | * - Nonce: 32 bit random integer. If value is 0, will not be serialized |
| 128 | **/ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 129 | class InterestHeader : public SimpleRefCount<InterestHeader, Header> |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 130 | { |
| 131 | public: |
| 132 | /** |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 133 | * \brief Constructor |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 134 | * |
| 135 | * Creates a null header |
| 136 | **/ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 137 | InterestHeader (); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 140 | * @brief Copy constructor |
| 141 | */ |
| 142 | InterestHeader (const InterestHeader &interest); |
| 143 | |
| 144 | /** |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 145 | * \brief Set interest name |
| 146 | * |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 147 | * Sets name of the interest. For example, SetName( ndnNameComponents("prefix")("postfix") ); |
| 148 | * @param[in] name const pointer to ndnNameComponents object that contains an interest name |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 149 | **/ |
| 150 | void |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 151 | SetName (Ptr<NameComponents> name); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 152 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * \brief Get interest name |
| 156 | * |
| 157 | * Gets name of the interest. |
| 158 | **/ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 159 | const NameComponents& |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 160 | GetName () const; |
| 161 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 162 | /** |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 163 | * @brief Get smart pointer to the interest name (to avoid extra memory usage) |
| 164 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 165 | Ptr<const NameComponents> |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 166 | GetNamePtr () const; |
| 167 | |
| 168 | /** |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 169 | * \brief Set interest MinSuffixComponents |
| 170 | * |
| 171 | * MinSuffixComponents refer to the number of name components beyond those in the prefix, |
| 172 | * and counting the implicit digest, that may occur in the matching ContentObject. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 173 | * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information. |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 174 | * @param[in] value minimum length of suffix components |
| 175 | **/ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 176 | void |
| 177 | SetMinSuffixComponents (int32_t value); |
| 178 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 179 | /** |
| 180 | * \brief Get interest MinSuffixComponents |
| 181 | * |
| 182 | * MinSuffixComponents refer to the number of name components beyond those in the prefix, |
| 183 | * and counting the implicit digest, that may occur in the matching ContentObject. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 184 | * For more information, see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 185 | **/ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 186 | int32_t |
| 187 | GetMinSuffixComponents () const; |
| 188 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 189 | |
| 190 | /** |
| 191 | * \brief Set interest MaxSuffixComponents |
| 192 | * |
| 193 | * MaxSuffixComponents refer to the number of name components beyond those in the prefix, |
| 194 | * and counting the implicit digest, that may occur in the matching ContentObject. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 195 | * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information. |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 196 | * @param[in] value maximum length of suffix components |
| 197 | **/ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 198 | void |
| 199 | SetMaxSuffixComponents (int32_t value); |
| 200 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 201 | /** |
| 202 | * \brief Get interest MaxSuffixComponents |
| 203 | * |
| 204 | * MaxSuffixComponents refer to the number of name components beyond those in the prefix, |
| 205 | * and counting the implicit digest, that may occur in the matching ContentObject. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 206 | * For more information, see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 207 | **/ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 208 | int32_t |
| 209 | GetMaxSuffixComponents () const; |
| 210 | |
| 211 | /** |
| 212 | * \brief Set exclude filer |
| 213 | * |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 214 | * For example, SetExclude (ndnNameComponents("exclude1")("exclude2")("exclude3")) |
| 215 | * @param[in] exclude const pointer to ndnNameComponents to be excluded |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 216 | **/ |
| 217 | void |
Alexander Afanasyev | ec1e395 | 2012-08-20 13:48:15 -0700 | [diff] [blame] | 218 | SetExclude (Ptr<NameComponents> exclude); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 219 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 220 | /** |
| 221 | * \brief Check if interest conatins exclude filter |
| 222 | * |
| 223 | */ |
Alexander Afanasyev | 85a3bca | 2011-08-31 16:51:03 -0700 | [diff] [blame] | 224 | bool |
| 225 | IsEnabledExclude () const; |
| 226 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 227 | /** |
| 228 | * \brief Get exclude filter |
| 229 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 230 | const NameComponents& |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 231 | GetExclude () const; |
| 232 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 233 | /** |
| 234 | * \brief Set ChildSelector |
| 235 | * Often a given interest will match more than one ContentObject within a given content store. |
| 236 | * The ChildSelector provides a way of expressing a preference for which of these should be returned. |
| 237 | * If the value is false, the leftmost child is preferred. If true, the rightmost child is preferred. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 238 | * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information. |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 239 | * @param[in] value boolean ChildSelector value |
| 240 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 241 | void |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 242 | SetChildSelector (bool value); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 243 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 244 | /** |
| 245 | * \brief Return ChildSelector value |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 246 | * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information. |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 247 | * |
| 248 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 249 | bool |
| 250 | IsEnabledChildSelector () const; |
| 251 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 252 | /** |
| 253 | * \brief Set AnswerOriginKind |
| 254 | * Default value for AnswerOriginKind is false. |
| 255 | * @param[in] value boolean AnswerOriginKind value |
| 256 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 257 | void |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 258 | SetAnswerOriginKind (bool value); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 259 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 260 | /** |
| 261 | * \brief Check the value of AnswerOriginKind |
| 262 | * |
| 263 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 264 | bool |
| 265 | IsEnabledAnswerOriginKind () const; |
| 266 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 267 | /** |
| 268 | * \brief Set Scope |
| 269 | * Scope limits where the Interest may propagate. |
| 270 | * Scope 0 prevents propagation beyond the local ccnd (even to other applications on the same host). |
| 271 | * Scope 1 limits propagation to the applications on the originating host. |
| 272 | * Scope 2 limits propagation to no further than the next host. |
| 273 | * Other values are not defined, and will cause the Interest message to be dropped. |
| 274 | * Note that this is not a hop count - the value is not decremented as the interest is forwarded. |
| 275 | * @param[in] scope interest scope |
| 276 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 277 | void |
| 278 | SetScope (int8_t scope); |
| 279 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 280 | /** |
| 281 | * \brief Get Scope value |
| 282 | * Scope limits where the Interest may propagate. |
| 283 | * Scope 0 prevents propagation beyond the local ccnd (even to other applications on the same host). |
| 284 | * Scope 1 limits propagation to the applications on the originating host. |
| 285 | * Scope 2 limits propagation to no further than the next host. |
| 286 | * Other values are not defined, and will cause the Interest message to be dropped. |
| 287 | * Note that this is not a hop count - the value is not decremented as the interest is forwarded. |
| 288 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 289 | int8_t |
| 290 | GetScope () const; |
| 291 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 292 | /** |
| 293 | * \brief Set InterestLifetime |
| 294 | * InterestLifetime indicates the (approximate) time remaining before the interest times out. |
| 295 | * The timeout is relative to the arrival time of the interest at the current node. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 296 | * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information. |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 297 | * @param[in] time interest lifetime |
| 298 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 299 | void |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 300 | SetInterestLifetime (Time time); |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 301 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 302 | /** |
| 303 | * \brief Get InterestLifetime value |
| 304 | * InterestLifetime indicates the (approximate) time remaining before the interest times out. |
| 305 | * The timeout is relative to the arrival time of the interest at the current node. |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 306 | * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information. |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 307 | */ |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 308 | Time |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 309 | GetInterestLifetime () const; |
| 310 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 311 | /** |
| 312 | * \brief Set Nonce |
| 313 | * Nonce carries a randomly-genenerated bytestring that is used to detect and discard duplicate Interest messages. |
| 314 | * @param[in] nonce Unique packet identification number |
| 315 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 316 | void |
| 317 | SetNonce (uint32_t nonce); |
| 318 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 319 | /** |
| 320 | * \brief Get Nonce value |
| 321 | * Nonce carries a randomly-genenerated bytestring that is used to detect and discard duplicate Interest messages. |
| 322 | * |
| 323 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 324 | uint32_t |
| 325 | GetNonce () const; |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 326 | |
| 327 | /** |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 328 | * @brief NACK Type |
| 329 | * Specifies the type of Interest packet |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 330 | */ |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 331 | enum |
| 332 | { |
| 333 | NORMAL_INTEREST = 0, |
Alexander Afanasyev | 23d2b54 | 2011-12-07 18:54:46 -0800 | [diff] [blame] | 334 | NACK_LOOP = 10, |
| 335 | NACK_CONGESTION = 11, |
| 336 | NACK_GIVEUP_PIT = 12, |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 337 | }; |
| 338 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 339 | /** |
| 340 | * \brief Mark the Interest as a Negative Acknowledgement |
| 341 | * Three types of NACKs are supported |
| 342 | * 1. NACK_LOOP |
| 343 | * 2. NACK_CONGESTION |
| 344 | * 3. NACK_GIVEUP_PIT |
| 345 | * @param[in] nackType NACK_LOOP or NACK_CONGESTION or NACK_GIVEUP_PIT or NORMAL_INTEREST |
| 346 | */ |
Ilya Moiseenko | 75d9bf5 | 2011-10-28 13:18:32 -0700 | [diff] [blame] | 347 | void |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 348 | SetNack (uint32_t nackType); |
Ilya Moiseenko | 75d9bf5 | 2011-10-28 13:18:32 -0700 | [diff] [blame] | 349 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 350 | /** |
| 351 | * \brief Get NACK type |
| 352 | * Returns NACK_LOOP, NACK_CONGESTION or NACK_GIVEUP_PIT. |
| 353 | * Otherwise, in case of normal interest packet, returns NORMAL_INTEREST (equals 0). |
| 354 | */ |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 355 | uint32_t |
| 356 | GetNack () const; |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 357 | |
| 358 | ////////////////////////////////////////////////////////////////// |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 359 | |
| 360 | static TypeId GetTypeId (void); ///< @brief Get TypeId of the class |
| 361 | virtual TypeId GetInstanceTypeId (void) const; ///< @brief Get TypeId of the instance |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 362 | |
| 363 | /** |
| 364 | * \brief Print Interest packet |
| 365 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 366 | virtual void Print (std::ostream &os) const; |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 367 | |
| 368 | /** |
| 369 | * \brief Get the size of Interest packet |
| 370 | * Returns the Interest packet size after serialization |
| 371 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 372 | virtual uint32_t GetSerializedSize (void) const; |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 373 | |
| 374 | /** |
| 375 | * \brief Serialize Interest packet |
| 376 | * Serializes Interest packet into Buffer::Iterator |
| 377 | * @param[in] start buffer to contain serialized Interest packet |
| 378 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 379 | virtual void Serialize (Buffer::Iterator start) const; |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 380 | |
| 381 | /** |
| 382 | * \brief Deserialize Interest packet |
| 383 | * Deserializes Buffer::Iterator into Interest packet |
| 384 | * @param[in] start buffer that contains serialized Interest packet |
| 385 | */ |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 386 | virtual uint32_t Deserialize (Buffer::Iterator start); |
| 387 | |
| 388 | private: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 389 | Ptr<NameComponents> m_name; ///< Interest name |
| 390 | int32_t m_minSuffixComponents; ///< Minimum suffix components. not used if negative |
| 391 | int32_t m_maxSuffixComponents; ///< Maximum suffix components. not used if negative |
| 392 | Ptr<NameComponents> m_exclude; ///< Exclude filter |
| 393 | bool m_childSelector; ///< Default value for ChildSelector is false |
| 394 | bool m_answerOriginKind; ///< Default value for AnswerOriginKind is false |
| 395 | int8_t m_scope; ///< -1 not set, 0 local scope, 1 this host, 2 immediate neighborhood |
| 396 | Time m_interestLifetime; ///< InterestLifetime |
| 397 | uint32_t m_nonce; ///< Nonce. not used if zero |
| 398 | uint32_t m_nackType; ///< Negative Acknowledgement type |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 399 | }; |
| 400 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 401 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 402 | * @ingroup ndn-exceptions |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 403 | * @brief Class for Interest parsing exception |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 404 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 405 | class InterestHeaderException {}; |
Alexander Afanasyev | 85a3bca | 2011-08-31 16:51:03 -0700 | [diff] [blame] | 406 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 407 | } // namespace ndn |
Alexander Afanasyev | 8a677dd | 2011-08-12 13:08:15 -0700 | [diff] [blame] | 408 | } // namespace ns3 |
| 409 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 410 | #endif // _NDN_INTEREST_HEADER_H_ |