A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
16
namespace
ns3
17
{
18
19
/**
20
* \ingroup tcp
21
*
22
* Defines the TCP option of kind 8 (timestamp option) as in \RFC{1323}
23
*/
24
25
class
TcpOptionTS
:
public
TcpOption
26
{
27
public
:
28
TcpOptionTS
();
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
;
40
uint32_t
Deserialize
(
Buffer::Iterator
start)
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 */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::TcpOption
Base class for all kinds of TCP options.
Definition
tcp-option.h:27
ns3::TcpOptionTS
Defines the TCP option of kind 8 (timestamp option) as in RFC 1323
Definition
tcp-option-ts.h:26
ns3::TcpOptionTS::GetKind
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793 ) of this option.
Definition
tcp-option-ts.cc:93
ns3::TcpOptionTS::SetTimestamp
void SetTimestamp(uint32_t ts)
Set the timestamp stored in the Option.
Definition
tcp-option-ts.cc:111
ns3::TcpOptionTS::TcpOptionTS
TcpOptionTS()
Definition
tcp-option-ts.cc:20
ns3::TcpOptionTS::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
tcp-option-ts.cc:42
ns3::TcpOptionTS::ElapsedTimeFromTsValue
static Time ElapsedTimeFromTsValue(uint32_t echoTime)
Estimate the Time elapsed from a TS echo value.
Definition
tcp-option-ts.cc:133
ns3::TcpOptionTS::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition
tcp-option-ts.cc:54
ns3::TcpOptionTS::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
tcp-option-ts.cc:32
ns3::TcpOptionTS::GetTimestamp
uint32_t GetTimestamp() const
Get the timestamp stored in the Option.
Definition
tcp-option-ts.cc:99
ns3::TcpOptionTS::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition
tcp-option-ts.cc:70
ns3::TcpOptionTS::m_timestamp
uint32_t m_timestamp
local timestamp
Definition
tcp-option-ts.h:94
ns3::TcpOptionTS::~TcpOptionTS
~TcpOptionTS() override
Definition
tcp-option-ts.cc:27
ns3::TcpOptionTS::GetEcho
uint32_t GetEcho() const
Get the timestamp echo stored in the Option.
Definition
tcp-option-ts.cc:105
ns3::TcpOptionTS::NowToTsValue
static uint32_t NowToTsValue()
Return an uint32_t value which represent "now".
Definition
tcp-option-ts.cc:123
ns3::TcpOptionTS::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition
tcp-option-ts.cc:60
ns3::TcpOptionTS::m_echo
uint32_t m_echo
echo timestamp
Definition
tcp-option-ts.h:95
ns3::TcpOptionTS::SetEcho
void SetEcho(uint32_t ts)
Set the timestamp echo stored in the Option.
Definition
tcp-option-ts.cc:117
ns3::TcpOptionTS::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition
tcp-option-ts.cc:48
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
tcp-option.h
src
internet
model
tcp-option-ts.h
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0