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
37
void
Print
(std::ostream& os)
const override
;
38
void
Serialize
(
Buffer::Iterator
start)
const override
;
39
uint32_t
Deserialize
(
Buffer::Iterator
start)
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 */
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:87
ns3::TcpOptionTS::SetTimestamp
void SetTimestamp(uint32_t ts)
Set the timestamp stored in the Option.
Definition
tcp-option-ts.cc:105
ns3::TcpOptionTS::TcpOptionTS
TcpOptionTS()
Definition
tcp-option-ts.cc:20
ns3::TcpOptionTS::ElapsedTimeFromTsValue
static Time ElapsedTimeFromTsValue(uint32_t echoTime)
Estimate the Time elapsed from a TS echo value.
Definition
tcp-option-ts.cc:127
ns3::TcpOptionTS::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition
tcp-option-ts.cc:48
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:93
ns3::TcpOptionTS::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition
tcp-option-ts.cc:64
ns3::TcpOptionTS::m_timestamp
uint32_t m_timestamp
local timestamp
Definition
tcp-option-ts.h:93
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:99
ns3::TcpOptionTS::NowToTsValue
static uint32_t NowToTsValue()
Return an uint32_t value which represent "now".
Definition
tcp-option-ts.cc:117
ns3::TcpOptionTS::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition
tcp-option-ts.cc:54
ns3::TcpOptionTS::m_echo
uint32_t m_echo
echo timestamp
Definition
tcp-option-ts.h:94
ns3::TcpOptionTS::SetEcho
void SetEcho(uint32_t ts)
Set the timestamp echo stored in the Option.
Definition
tcp-option-ts.cc:111
ns3::TcpOptionTS::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition
tcp-option-ts.cc:42
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:49
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 Tue Apr 29 2025 18:20:45 for ns-3 by
1.11.0