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
37 void Print(std::ostream& os) const override;
38 void Serialize(Buffer::Iterator start) const override;
40
41 uint8_t GetKind() const override;
42 uint32_t GetSerializedSize() const override;
43
44 /**
45 * @brief Get the timestamp stored in the Option
46 * @return the timestamp
47 */
48 uint32_t GetTimestamp() const;
49 /**
50 * @brief Get the timestamp echo stored in the Option
51 * @return the timestamp echo
52 */
53 uint32_t GetEcho() const;
54 /**
55 * @brief Set the timestamp stored in the Option
56 * @param ts the timestamp
57 */
58 void SetTimestamp(uint32_t ts);
59 /**
60 * @brief Set the timestamp echo stored in the Option
61 * @param ts the timestamp echo
62 */
63 void SetEcho(uint32_t ts);
64
65 /**
66 * @brief Return an uint32_t value which represent "now"
67 *
68 * The value returned is usually used as Timestamp option for the
69 * TCP header; when the value will be echoed back, calculating the RTT
70 * will be an easy matter.
71 *
72 * The RFC does not mention any units for this value; following what
73 * is implemented in OS, we use milliseconds. Any change to this must be
74 * reflected to EstimateRttFromTs.
75 *
76 * @see EstimateRttFromTs
77 * @return The Timestamp value to use
78 */
79 static uint32_t NowToTsValue();
80
81 /**
82 * @brief Estimate the Time elapsed from a TS echo value
83 *
84 * The echoTime should be a value returned from NowToTsValue.
85 *
86 * @param echoTime Echoed value from other side
87 * @see NowToTsValue
88 * @return The measured RTT
89 */
90 static Time ElapsedTimeFromTsValue(uint32_t echoTime);
91
92 protected:
93 uint32_t m_timestamp; //!< local timestamp
94 uint32_t m_echo; //!< echo timestamp
95};
96
97} // namespace ns3
98
99#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.
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:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.