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-data.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011-2013 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_CONTENT_OBJECT_HEADER_H_
23 #define _NDN_CONTENT_OBJECT_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/ndn-name.h>
31 
32 namespace ns3 {
33 namespace ndn {
34 
39 class Data : public SimpleRefCount<Data>
40 {
41 public:
47  Data (Ptr<Packet> payload = Create<Packet> ());
48 
52  Data (const Data &other);
53 
59  void
60  SetName (Ptr<Name> name);
61 
67  void
68  SetName (const Name &name);
69 
73  const Name&
74  GetName () const;
75 
79  Ptr<const Name>
80  GetNamePtr () const;
81 
86  void
87  SetTimestamp (const Time &timestamp);
88 
92  Time
93  GetTimestamp () const;
94 
99  void
100  SetFreshness (const Time &freshness);
101 
105  Time
106  GetFreshness () const;
107 
114  void
115  SetSignature (uint32_t signature);
116 
122  uint32_t
123  GetSignature () const;
124 
129  void
130  SetKeyLocator (Ptr<Name> keyLocator);
131 
137  Ptr<const Name>
138  GetKeyLocator () const;
139 
141 
146  void
147  SetPayload (Ptr<Packet> payload);
148 
154  Ptr<const Packet>
155  GetPayload () const;
156 
162  inline Ptr<const Packet>
163  GetWire () const;
164 
168  inline void
169  SetWire (Ptr<const Packet> packet) const;
170 
174  void
175  Print (std::ostream &os) const;
176 
177 private:
178  // NO_ASSIGN
179  Data &
180  operator = (const Data &other) { return *this; }
181 
182 private:
183  Ptr<Name> m_name;
184  Time m_freshness;
185  Time m_timestamp;
186  uint32_t m_signature; // 0, means no signature, any other value application dependent (not a real signature)
187  Ptr<Packet> m_payload;
188  Ptr<Name> m_keyLocator;
189 
190  mutable Ptr<const Packet> m_wire;
191 };
192 
193 inline std::ostream &
194 operator << (std::ostream &os, const Data &d)
195 {
196  d.Print (os);
197  return os;
198 }
199 
203 class DataException {};
204 
205 inline Ptr<const Packet>
207 {
208  return m_wire;
209 }
210 
211 inline void
212 Data::SetWire (Ptr<const Packet> packet) const
213 {
214  m_wire = packet;
215 }
216 
217 
218 } // namespace ndn
219 } // namespace ns3
220 
221 #endif // _NDN_CONTENT_OBJECT_HEADER_H_
Data(Ptr< Packet > payload=Create< Packet >())
Constructor.
Definition: ndn-data.cc:33
void Print(std::ostream &os) const
Print Interest in plain-text to the specified output stream.
Definition: ndn-data.cc:141
Class for NDN Name.
Definition: name.h:29
Ptr< const Name > GetNamePtr() const
Get smart pointer to the interest name (to avoid extra memory usage)
Definition: ndn-data.cc:82
Ptr< const Name > GetKeyLocator() const
Get key locator.
Definition: ndn-data.cc:135
void SetTimestamp(const Time &timestamp)
Set content object timestamp.
Definition: ndn-data.cc:89
Data header.
Definition: ndn-data.h:39
const Name & GetName() const
Get name of the content object.
Definition: ndn-data.cc:75
void SetKeyLocator(Ptr< Name > keyLocator)
Set key locator.
Definition: ndn-data.cc:129
Ptr< const Packet > GetWire() const
Get wire formatted packet.
Definition: ndn-data.h:206
void SetFreshness(const Time &freshness)
Set freshness of the content object.
Definition: ndn-data.cc:102
Time GetTimestamp() const
Get timestamp of the content object.
Definition: ndn-data.cc:96
Class for Data parsing exception.
Definition: ndn-data.h:203
void SetPayload(Ptr< Packet > payload)
Get payload of data packet.
Definition: ndn-data.cc:148
void SetName(Ptr< Name > name)
Set content object name.
Definition: ndn-data.cc:61
uint32_t GetSignature() const
Get "fake" signature of the content object.
Definition: ndn-data.cc:123
Time GetFreshness() const
Get freshness of the content object.
Definition: ndn-data.cc:110
void SetWire(Ptr< const Packet > packet) const
Set (cache) wire formatted packet.
Definition: ndn-data.h:212
void SetSignature(uint32_t signature)
Set "fake" signature on the content object.
Definition: ndn-data.cc:116
Ptr< const Packet > GetPayload() const
Set payload of data packet.
Definition: ndn-data.cc:155