A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
timestamp-tag.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Authors: Joe Kopena <tjkopena@cs.drexel.edu>
16 */
17
18#ifndef TIMESTAMP_TAG_H
19#define TIMESTAMP_TAG_H
20
21#include "ns3/nstime.h"
22#include "ns3/tag-buffer.h"
23#include "ns3/tag.h"
24#include "ns3/type-id.h"
25
26#include <iostream>
27
28namespace ns3
29{
30
31/**
32 * Timestamp tag for associating a timestamp with a packet.
33 *
34 * It would have been more realistic to include this info in
35 * a header. Here we show how to avoid the extra overhead in
36 * a simulation.
37 */
38class TimestampTag : public Tag
39{
40 public:
41 /**
42 * \brief Get the type ID.
43 * \return the object TypeId
44 */
45 static TypeId GetTypeId();
46 TypeId GetInstanceTypeId() const override;
47
48 /**
49 * \brief Construct a new TimestampTag object
50 */
52
53 /**
54 * \brief Construct a new TimestampTag object with the given timestamp
55 * \param timestamp The timestamp
56 */
57 TimestampTag(Time timestamp);
58
59 void Serialize(TagBuffer i) const override;
60 void Deserialize(TagBuffer i) override;
61 uint32_t GetSerializedSize() const override;
62 void Print(std::ostream& os) const override;
63
64 /**
65 * \brief Get the Timestamp object
66 * \return Time for this tag
67 */
68 Time GetTimestamp() const;
69
70 /**
71 * \brief Set the Timestamp object
72 * \param timestamp Timestamp to assign to tag
73 */
74 void SetTimestamp(Time timestamp);
75
76 private:
77 Time m_timestamp{0}; //!< Timestamp
78};
79
80} // namespace ns3
81
82#endif // TIMESTAMP_TAG_H
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:39
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Timestamp tag for associating a timestamp with a packet.
Definition: timestamp-tag.h:39
void Deserialize(TagBuffer i) override
Time m_timestamp
Timestamp.
Definition: timestamp-tag.h:77
void SetTimestamp(Time timestamp)
Set the Timestamp object.
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
static TypeId GetTypeId()
Get the type ID.
void Serialize(TagBuffer i) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
TimestampTag()
Construct a new TimestampTag object.
Time GetTimestamp() const
Get the Timestamp object.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.