A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-option-ts.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Adrian Sai-wah Tam
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
7 */
8
9#ifndef TCP_OPTION_TS_H
10#define TCP_OPTION_TS_H
11
12#include "tcp-option.h"
13
14#include "ns3/timer.h"
15
16namespace ns3
17{
18
19/**
20 * \ingroup tcp
21 *
22 * Defines the TCP option of kind 8 (timestamp option) as in \RFC{1323}
23 */
24
25class TcpOptionTS : public TcpOption
26{
27 public:
29 ~TcpOptionTS() override;
30
31 /**
32 * \brief Get the type ID.
33 * \return the object TypeId
34 */
35 static TypeId GetTypeId();
36 TypeId GetInstanceTypeId() const override;
37
38 void Print(std::ostream& os) const override;
39 void Serialize(Buffer::Iterator start) const override;
41
42 uint8_t GetKind() const override;
43 uint32_t GetSerializedSize() const override;
44
45 /**
46 * \brief Get the timestamp stored in the Option
47 * \return the timestamp
48 */
49 uint32_t GetTimestamp() const;
50 /**
51 * \brief Get the timestamp echo stored in the Option
52 * \return the timestamp echo
53 */
54 uint32_t GetEcho() const;
55 /**
56 * \brief Set the timestamp stored in the Option
57 * \param ts the timestamp
58 */
59 void SetTimestamp(uint32_t ts);
60 /**
61 * \brief Set the timestamp echo stored in the Option
62 * \param ts the timestamp echo
63 */
64 void SetEcho(uint32_t ts);
65
66 /**
67 * \brief Return an uint32_t value which represent "now"
68 *
69 * The value returned is usually used as Timestamp option for the
70 * TCP header; when the value will be echoed back, calculating the RTT
71 * will be an easy matter.
72 *
73 * The RFC does not mention any units for this value; following what
74 * is implemented in OS, we use milliseconds. Any change to this must be
75 * reflected to EstimateRttFromTs.
76 *
77 * \see EstimateRttFromTs
78 * \return The Timestamp value to use
79 */
80 static uint32_t NowToTsValue();
81
82 /**
83 * \brief Estimate the Time elapsed from a TS echo value
84 *
85 * The echoTime should be a value returned from NowToTsValue.
86 *
87 * \param echoTime Echoed value from other side
88 * \see NowToTsValue
89 * \return The measured RTT
90 */
91 static Time ElapsedTimeFromTsValue(uint32_t echoTime);
92
93 protected:
94 uint32_t m_timestamp; //!< local timestamp
95 uint32_t m_echo; //!< echo timestamp
96};
97
98} // namespace ns3
99
100#endif /* TCP_OPTION_TS */
iterator in a Buffer instance
Definition buffer.h:89
Base class for all kinds of TCP options.
Definition tcp-option.h:27
Defines the TCP option of kind 8 (timestamp option) as in RFC 1323
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793 ) of this option.
void SetTimestamp(uint32_t ts)
Set the timestamp stored in the Option.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static Time ElapsedTimeFromTsValue(uint32_t echoTime)
Estimate the Time elapsed from a TS echo value.
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetTimestamp() const
Get the timestamp stored in the Option.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
uint32_t m_timestamp
local timestamp
~TcpOptionTS() override
uint32_t GetEcho() const
Get the timestamp echo stored in the Option.
static uint32_t NowToTsValue()
Return an uint32_t value which represent "now".
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
uint32_t m_echo
echo timestamp
void SetEcho(uint32_t ts)
Set the timestamp echo stored in the Option.
void Print(std::ostream &os) const override
Print the Option contents.
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.