A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
timestamp-tag.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Authors: Joe Kopena <tjkopena@cs.drexel.edu>
5 */
6
7#ifndef TIMESTAMP_TAG_H
8#define TIMESTAMP_TAG_H
9
10#include "ns3/nstime.h"
11#include "ns3/tag-buffer.h"
12#include "ns3/tag.h"
13#include "ns3/type-id.h"
14
15#include <iostream>
16
17namespace ns3
18{
19
20/**
21 * Timestamp tag for associating a timestamp with a packet.
22 *
23 * It would have been more realistic to include this info in
24 * a header. Here we show how to avoid the extra overhead in
25 * a simulation.
26 */
27class TimestampTag : public Tag
28{
29 public:
30 /**
31 * \brief Get the type ID.
32 * \return the object TypeId
33 */
34 static TypeId GetTypeId();
35 TypeId GetInstanceTypeId() const override;
36
37 /**
38 * \brief Construct a new TimestampTag object
39 */
41
42 /**
43 * \brief Construct a new TimestampTag object with the given timestamp
44 * \param timestamp The timestamp
45 */
46 TimestampTag(Time timestamp);
47
48 void Serialize(TagBuffer i) const override;
49 void Deserialize(TagBuffer i) override;
50 uint32_t GetSerializedSize() const override;
51 void Print(std::ostream& os) const override;
52
53 /**
54 * \brief Get the Timestamp object
55 * \return Time for this tag
56 */
57 Time GetTimestamp() const;
58
59 /**
60 * \brief Set the Timestamp object
61 * \param timestamp Timestamp to assign to tag
62 */
63 void SetTimestamp(Time timestamp);
64
65 private:
66 Time m_timestamp{0}; //!< Timestamp
67};
68
69} // namespace ns3
70
71#endif // TIMESTAMP_TAG_H
read and write tag data
Definition tag-buffer.h:41
tag a set of bytes in a packet
Definition tag.h:28
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Timestamp tag for associating a timestamp with a packet.
void Deserialize(TagBuffer i) override
Time m_timestamp
Timestamp.
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:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.