NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-interest.h
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
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 
22 #ifndef _NDN_INTEREST_HEADER_H_
23 #define _NDN_INTEREST_HEADER_H_
24 
25 #include "ns3/simple-ref-count.h"
26 #include "ns3/nstime.h"
27 #include "ns3/packet.h"
28 #include "ns3/ptr.h"
29 
30 #include <ns3/ndnSIM/ndn.cxx/name.h>
31 #include <ns3/ndnSIM/ndn.cxx/exclude.h>
32 
33 namespace ns3 {
34 
35 class Packet;
36 
37 namespace ndn {
38 
43 class Interest : public SimpleRefCount<Interest>
44 {
45 public:
51  Interest (Ptr<Packet> payload = Create<Packet> ());
52 
56  Interest (const Interest &interest);
57 
64  void
65  SetName (Ptr<Name> name);
66 
73  void
74  SetName (const Name &name);
75 
81  const Name&
82  GetName () const;
83 
87  Ptr<const Name>
88  GetNamePtr () const;
89 
100  void
101  SetScope (int8_t scope);
102 
112  int8_t
113  GetScope () const;
114 
122  void
123  SetInterestLifetime (Time time);
124 
131  Time
132  GetInterestLifetime () const;
133 
139  void
140  SetNonce (uint32_t nonce);
141 
147  uint32_t
148  GetNonce () const;
149 
154  enum
155  {
156  NORMAL_INTEREST = 0,
157  NACK_LOOP = 10,
158  NACK_CONGESTION = 11,
159  NACK_GIVEUP_PIT = 12,
160  };
161 
170  void
171  SetNack (uint8_t nackType); //using reserved field
172 
178  uint8_t
179  GetNack () const;
180 
186  void
187  SetExclude (Ptr<Exclude> exclude);
188 
192  Ptr<const Exclude>
193  GetExclude () const;
194 
200  void
201  SetPayload (Ptr<Packet> payload);
202 
208  Ptr<const Packet>
209  GetPayload () const;
210 
216  inline Ptr<const Packet>
217  GetWire () const;
218 
222  inline void
223  SetWire (Ptr<const Packet> packet) const;
224 
228  void
229  Print (std::ostream &os) const;
230 
231 private:
232  // NO_ASSIGN
233  Interest &
234  operator = (const Interest &other) { return *this; }
235 
236 private:
237  Ptr<Name> m_name;
238  uint8_t m_scope;
239  Time m_interestLifetime;
240  uint32_t m_nonce;
241  uint8_t m_nackType;
242 
243  Ptr<Exclude> m_exclude;
244  Ptr<Packet> m_payload;
245 
246  mutable Ptr<const Packet> m_wire;
247 };
248 
249 inline std::ostream &
250 operator << (std::ostream &os, const Interest &i)
251 {
252  i.Print (os);
253  return os;
254 }
255 
256 inline Ptr<const Packet>
258 {
259  return m_wire;
260 }
261 
262 inline void
263 Interest::SetWire (Ptr<const Packet> packet) const
264 {
265  m_wire = packet;
266 }
267 
272 
273 } // namespace ndn
274 } // namespace ns3
275 
276 #endif // _NDN_INTEREST_HEADER_H_
void SetWire(Ptr< const Packet > packet) const
Set (cache) wire formatted packet.
Definition: ndn-interest.h:263
void SetScope(int8_t scope)
Set Scope Scope limits where the Interest may propagate.
Definition: ndn-interest.cc:89
Class for NDN Name.
Definition: name.h:29
const Name & GetName() const
Get interest name.
Definition: ndn-interest.cc:76
void SetNack(uint8_t nackType)
Mark the Interest as a Negative Acknowledgement Three types of NACKs are supported.
Ptr< const Name > GetNamePtr() const
Get smart pointer to the interest name (to avoid extra memory usage)
Definition: ndn-interest.cc:83
Class for Interest parsing exception.
Definition: ndn-interest.h:271
void SetInterestLifetime(Time time)
Set InterestLifetime InterestLifetime indicates the (approximate) time remaining before the interest ...
void Print(std::ostream &os) const
Print Interest in plain-text to the specified output stream.
uint32_t GetNonce() const
Get Nonce value Nonce carries a randomly-genenerated bytestring that is used to detect and discard du...
Ptr< const Packet > GetPayload() const
Get virtual "payload" to interest packet.
Time GetInterestLifetime() const
Get InterestLifetime value InterestLifetime indicates the (approximate) time remaining before the int...
void SetExclude(Ptr< Exclude > exclude)
Set exclude filter of interest packet.
Interest(Ptr< Packet > payload=Create< Packet >())
Constructor.
Definition: ndn-interest.cc:32
uint8_t GetNack() const
Get NACK type Returns NACK_LOOP, NACK_CONGESTION or NACK_GIVEUP_PIT.
NDN Interest (wire formats are defined in wire)
Definition: ndn-interest.h:43
void SetPayload(Ptr< Packet > payload)
Set virtual "payload" of interest packet.
int8_t GetScope() const
Get Scope value Scope limits where the Interest may propagate.
Definition: ndn-interest.cc:96
void SetName(Ptr< Name > name)
Set interest name.
Definition: ndn-interest.cc:62
void SetNonce(uint32_t nonce)
Set Nonce Nonce carries a randomly-genenerated bytestring that is used to detect and discard duplicat...
Ptr< const Packet > GetWire() const
Get wire formatted packet.
Definition: ndn-interest.h:257
Ptr< const Exclude > GetExclude() const
Get exclude filter of interest packet.