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.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_H
10
#define TCP_OPTION_H
11
12
#include "ns3/buffer.h"
13
#include "ns3/object-factory.h"
14
#include "ns3/object.h"
15
16
#include <stdint.h>
17
18
namespace
ns3
19
{
20
21
/**
22
* @ingroup tcp
23
*
24
* Base class for all kinds of TCP options
25
*/
26
class
TcpOption
:
public
Object
27
{
28
public
:
29
TcpOption
();
30
~TcpOption
()
override
;
31
32
/**
33
* @brief Get the type ID.
34
* @return the object TypeId
35
*/
36
static
TypeId
GetTypeId
();
37
38
/**
39
* The option Kind, as defined in the respective RFCs.
40
*/
41
enum
Kind
42
{
43
// Remember to extend IsKindKnown() with new value, when adding values here
44
//
45
END
= 0,
//!< END
46
NOP
= 1,
//!< NOP
47
MSS
= 2,
//!< MSS
48
WINSCALE
= 3,
//!< WINSCALE
49
SACKPERMITTED
= 4,
//!< SACKPERMITTED
50
SACK
= 5,
//!< SACK
51
TS
= 8,
//!< TS
52
UNKNOWN
= 255
//!< not a standardized value; for unknown recv'd options
53
};
54
55
/**
56
* @brief Print the Option contents
57
* @param os the output stream
58
*/
59
virtual
void
Print
(std::ostream& os)
const
= 0;
60
/**
61
* @brief Serialize the Option to a buffer iterator
62
* @param start the buffer iterator
63
*/
64
virtual
void
Serialize
(
Buffer::Iterator
start)
const
= 0;
65
66
/**
67
* @brief Deserialize the Option from a buffer iterator
68
* @param start the buffer iterator
69
* @returns the number of deserialized bytes
70
*/
71
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start) = 0;
72
73
/**
74
* @brief Get the `kind' (as in \RFC{793}) of this option
75
* @return the Option Kind
76
*/
77
virtual
uint8_t
GetKind
()
const
= 0;
78
/**
79
* @brief Returns number of bytes required for Option
80
* serialization.
81
*
82
* @returns number of bytes required for Option
83
* serialization
84
*/
85
virtual
uint32_t
GetSerializedSize
()
const
= 0;
86
87
/**
88
* @brief Creates an option
89
* @param kind the option kind
90
* @return the requested option or an ns3::UnknownOption if the option is not supported
91
*/
92
static
Ptr<TcpOption>
CreateOption
(uint8_t kind);
93
94
/**
95
* @brief Check if the option is implemented
96
* @param kind the Option kind
97
* @return true if the option is known
98
*/
99
static
bool
IsKindKnown
(uint8_t kind);
100
};
101
102
/**
103
* @ingroup tcp
104
*
105
* @brief An unknown TCP option.
106
*
107
* An unknown option can be deserialized and (only if deserialized previously)
108
* serialized again.
109
*/
110
class
TcpOptionUnknown
:
public
TcpOption
111
{
112
public
:
113
TcpOptionUnknown
();
114
~TcpOptionUnknown
()
override
;
115
116
/**
117
* @brief Get the type ID.
118
* @return the object TypeId
119
*/
120
static
TypeId
GetTypeId
();
121
122
void
Print
(std::ostream& os)
const override
;
123
void
Serialize
(
Buffer::Iterator
start)
const override
;
124
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
125
126
uint8_t
GetKind
()
const override
;
127
uint32_t
GetSerializedSize
()
const override
;
128
129
private
:
130
uint8_t
m_kind
;
//!< The unknown option kind
131
uint32_t
m_size
;
//!< The unknown option size
132
uint8_t
m_content
[40];
//!< The option data
133
};
134
135
}
// namespace ns3
136
137
#endif
/* TCP_OPTION */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TcpOption
Base class for all kinds of TCP options.
Definition
tcp-option.h:27
ns3::TcpOption::CreateOption
static Ptr< TcpOption > CreateOption(uint8_t kind)
Creates an option.
Definition
tcp-option.cc:45
ns3::TcpOption::Serialize
virtual void Serialize(Buffer::Iterator start) const =0
Serialize the Option to a buffer iterator.
ns3::TcpOption::GetKind
virtual uint8_t GetKind() const =0
Get the ‘kind’ (as in RFC 793 ) of this option.
ns3::TcpOption::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the Option from a buffer iterator.
ns3::TcpOption::~TcpOption
~TcpOption() override
Definition
tcp-option.cc:33
ns3::TcpOption::IsKindKnown
static bool IsKindKnown(uint8_t kind)
Check if the option is implemented.
Definition
tcp-option.cc:78
ns3::TcpOption::Print
virtual void Print(std::ostream &os) const =0
Print the Option contents.
ns3::TcpOption::Kind
Kind
The option Kind, as defined in the respective RFCs.
Definition
tcp-option.h:42
ns3::TcpOption::SACK
@ SACK
SACK.
Definition
tcp-option.h:50
ns3::TcpOption::TS
@ TS
TS.
Definition
tcp-option.h:51
ns3::TcpOption::UNKNOWN
@ UNKNOWN
not a standardized value; for unknown recv'd options
Definition
tcp-option.h:52
ns3::TcpOption::NOP
@ NOP
NOP.
Definition
tcp-option.h:46
ns3::TcpOption::END
@ END
END.
Definition
tcp-option.h:45
ns3::TcpOption::MSS
@ MSS
MSS.
Definition
tcp-option.h:47
ns3::TcpOption::SACKPERMITTED
@ SACKPERMITTED
SACKPERMITTED.
Definition
tcp-option.h:49
ns3::TcpOption::WINSCALE
@ WINSCALE
WINSCALE.
Definition
tcp-option.h:48
ns3::TcpOption::GetSerializedSize
virtual uint32_t GetSerializedSize() const =0
Returns number of bytes required for Option serialization.
ns3::TcpOption::TcpOption
TcpOption()
Definition
tcp-option.cc:29
ns3::TcpOption::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
tcp-option.cc:38
ns3::TcpOptionUnknown
An unknown TCP option.
Definition
tcp-option.h:111
ns3::TcpOptionUnknown::TcpOptionUnknown
TcpOptionUnknown()
Definition
tcp-option.cc:98
ns3::TcpOptionUnknown::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition
tcp-option.cc:146
ns3::TcpOptionUnknown::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition
tcp-option.cc:132
ns3::TcpOptionUnknown::GetKind
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793 ) of this option.
Definition
tcp-option.cc:167
ns3::TcpOptionUnknown::m_content
uint8_t m_content[40]
The option data.
Definition
tcp-option.h:132
ns3::TcpOptionUnknown::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition
tcp-option.cc:120
ns3::TcpOptionUnknown::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
tcp-option.cc:110
ns3::TcpOptionUnknown::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition
tcp-option.cc:126
ns3::TcpOptionUnknown::m_size
uint32_t m_size
The unknown option size.
Definition
tcp-option.h:131
ns3::TcpOptionUnknown::~TcpOptionUnknown
~TcpOptionUnknown() override
Definition
tcp-option.cc:105
ns3::TcpOptionUnknown::m_kind
uint8_t m_kind
The unknown option kind.
Definition
tcp-option.h:130
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.
src
internet
model
tcp-option.h
Generated on Tue Apr 29 2025 18:20:45 for ns-3 by
1.11.0