A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
seq-ts-echo-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 INRIA
3 * Copyright (c) 2016 Universita' di Firenze (added echo fields)
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
8 */
9
10#ifndef SEQ_TS_ECHO_HEADER_H
11#define SEQ_TS_ECHO_HEADER_H
12
13#include "ns3/header.h"
14#include "ns3/nstime.h"
15
16namespace ns3
17{
18/**
19 * \ingroup applications
20 * \class SeqTsEchoHeader
21 * \brief Packet header to carry sequence number and two timestamps
22 *
23 * The header is made of a 32bits sequence number followed by
24 * two 64bits time stamps (Transmit and Receive).
25 */
26class SeqTsEchoHeader : public Header
27{
28 public:
29 /**
30 * \brief Get the type ID.
31 * \return the object TypeId
32 */
33 static TypeId GetTypeId();
34
35 /**
36 * \brief constructor
37 */
39
40 /**
41 * \param seq the sequence number
42 */
43 void SetSeq(uint32_t seq);
44
45 /**
46 * \return the sequence number
47 */
48 uint32_t GetSeq() const;
49
50 /**
51 * \return A time value set by the sender
52 */
53 Time GetTsValue() const;
54
55 /**
56 * \return A time value echoing the received timestamp
57 */
58 Time GetTsEchoReply() const;
59
60 /**
61 * \brief Set the sender's time value
62 * \param ts Time value to set
63 */
64 void SetTsValue(Time ts);
65
66 /**
67 * \brief Upon SeqTsEchoHeader reception, the host answers via echoing
68 * back the received timestamp
69 * \param ts received timestamp. If not called, will contain 0
70 */
71 void SetTsEchoReply(Time ts);
72
73 // Inherited
74 TypeId GetInstanceTypeId() const override;
75 void Print(std::ostream& os) const override;
76 uint32_t GetSerializedSize() const override;
77 void Serialize(Buffer::Iterator start) const override;
79
80 private:
81 uint32_t m_seq; //!< Sequence number
82 Time m_tsValue; //!< Sender's timestamp
83 Time m_tsEchoReply; //!< Receiver's timestamp
84};
85
86} // namespace ns3
87
88#endif /* SEQ_TS_ECHO_HEADER_H */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
Packet header to carry sequence number and two timestamps.
Time m_tsEchoReply
Receiver's timestamp.
Time m_tsValue
Sender's timestamp.
void SetTsValue(Time ts)
Set the sender's time value.
uint32_t GetSerializedSize() const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t m_seq
Sequence number.
void SetSeq(uint32_t seq)
void Serialize(Buffer::Iterator start) const override
static TypeId GetTypeId()
Get the type ID.
uint32_t Deserialize(Buffer::Iterator start) override
void SetTsEchoReply(Time ts)
Upon SeqTsEchoHeader reception, the host answers via echoing back the received timestamp.
void Print(std::ostream &os) const override
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.