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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
18 */
19
20#ifndef TCP_OPTION_TS_H
21#define TCP_OPTION_TS_H
22
23#include "tcp-option.h"
24
25#include "ns3/timer.h"
26
27namespace ns3
28{
29
30/**
31 * \ingroup tcp
32 *
33 * Defines the TCP option of kind 8 (timestamp option) as in \RFC{1323}
34 */
35
36class TcpOptionTS : public TcpOption
37{
38 public:
40 ~TcpOptionTS() override;
41
42 /**
43 * \brief Get the type ID.
44 * \return the object TypeId
45 */
46 static TypeId GetTypeId();
47 TypeId GetInstanceTypeId() const override;
48
49 void Print(std::ostream& os) const override;
50 void Serialize(Buffer::Iterator start) const override;
52
53 uint8_t GetKind() const override;
54 uint32_t GetSerializedSize() const override;
55
56 /**
57 * \brief Get the timestamp stored in the Option
58 * \return the timestamp
59 */
60 uint32_t GetTimestamp() const;
61 /**
62 * \brief Get the timestamp echo stored in the Option
63 * \return the timestamp echo
64 */
65 uint32_t GetEcho() const;
66 /**
67 * \brief Set the timestamp stored in the Option
68 * \param ts the timestamp
69 */
70 void SetTimestamp(uint32_t ts);
71 /**
72 * \brief Set the timestamp echo stored in the Option
73 * \param ts the timestamp echo
74 */
75 void SetEcho(uint32_t ts);
76
77 /**
78 * \brief Return an uint32_t value which represent "now"
79 *
80 * The value returned is usually used as Timestamp option for the
81 * TCP header; when the value will be echoed back, calculating the RTT
82 * will be an easy matter.
83 *
84 * The RFC does not mention any units for this value; following what
85 * is implemented in OS, we use milliseconds. Any change to this must be
86 * reflected to EstimateRttFromTs.
87 *
88 * \see EstimateRttFromTs
89 * \return The Timestamp value to use
90 */
91 static uint32_t NowToTsValue();
92
93 /**
94 * \brief Estimate the Time elapsed from a TS echo value
95 *
96 * The echoTime should be a value returned from NowToTsValue.
97 *
98 * \param echoTime Echoed value from other side
99 * \see NowToTsValue
100 * \return The measured RTT
101 */
102 static Time ElapsedTimeFromTsValue(uint32_t echoTime);
103
104 protected:
105 uint32_t m_timestamp; //!< local timestamp
106 uint32_t m_echo; //!< echo timestamp
107};
108
109} // namespace ns3
110
111#endif /* TCP_OPTION_TS */
iterator in a Buffer instance
Definition: buffer.h:100
Base class for all kinds of TCP options.
Definition: tcp-option.h:38
Defines the TCP option of kind 8 (timestamp option) as in RFC 1323
Definition: tcp-option-ts.h:37
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:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.