A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
tcp-option-winscale.cc
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
* Documentation, test cases: Natale Patriciello <natale.patriciello@gmail.com>
19
*/
20
21
#include "
tcp-option-winscale.h
"
22
23
#include "ns3/log.h"
24
25
namespace
ns3
26
{
27
28
NS_LOG_COMPONENT_DEFINE
(
"TcpOptionWinScale"
);
29
30
NS_OBJECT_ENSURE_REGISTERED
(TcpOptionWinScale);
31
32
TcpOptionWinScale::TcpOptionWinScale
()
33
:
TcpOption
(),
34
m_scale(0)
35
{
36
}
37
38
TcpOptionWinScale::~TcpOptionWinScale
()
39
{
40
}
41
42
TypeId
43
TcpOptionWinScale::GetTypeId
()
44
{
45
static
TypeId
tid =
TypeId
(
"ns3::TcpOptionWinScale"
)
46
.
SetParent
<
TcpOption
>()
47
.SetGroupName(
"Internet"
)
48
.AddConstructor<
TcpOptionWinScale
>();
49
return
tid;
50
}
51
52
TypeId
53
TcpOptionWinScale::GetInstanceTypeId
()
const
54
{
55
return
GetTypeId
();
56
}
57
58
void
59
TcpOptionWinScale::Print
(std::ostream& os)
const
60
{
61
os << static_cast<int>(
m_scale
);
62
}
63
64
uint32_t
65
TcpOptionWinScale::GetSerializedSize
()
const
66
{
67
return
3;
68
}
69
70
void
71
TcpOptionWinScale::Serialize
(
Buffer::Iterator
start
)
const
72
{
73
Buffer::Iterator
i =
start
;
74
i.
WriteU8
(
GetKind
());
// Kind
75
i.
WriteU8
(3);
// Length
76
i.
WriteU8
(
m_scale
);
// Max segment size
77
}
78
79
uint32_t
80
TcpOptionWinScale::Deserialize
(
Buffer::Iterator
start
)
81
{
82
Buffer::Iterator
i =
start
;
83
84
uint8_t readKind = i.
ReadU8
();
85
if
(readKind !=
GetKind
())
86
{
87
NS_LOG_WARN
(
"Malformed Window Scale option"
);
88
return
0;
89
}
90
uint8_t size = i.
ReadU8
();
91
if
(size != 3)
92
{
93
NS_LOG_WARN
(
"Malformed Window Scale option"
);
94
return
0;
95
}
96
m_scale
= i.
ReadU8
();
97
return
GetSerializedSize
();
98
}
99
100
uint8_t
101
TcpOptionWinScale::GetKind
()
const
102
{
103
return
TcpOption::WINSCALE
;
104
}
105
106
uint8_t
107
TcpOptionWinScale::GetScale
()
const
108
{
109
NS_ASSERT
(
m_scale
<= 14);
110
111
return
m_scale
;
112
}
113
114
void
115
TcpOptionWinScale::SetScale
(uint8_t scale)
116
{
117
NS_ASSERT
(scale <= 14);
118
119
m_scale
= scale;
120
}
121
122
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition:
buffer.h:1027
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:881
ns3::TcpOption
Base class for all kinds of TCP options.
Definition:
tcp-option.h:38
ns3::TcpOption::WINSCALE
@ WINSCALE
WINSCALE.
Definition:
tcp-option.h:61
ns3::TcpOptionWinScale
Defines the TCP option of kind 3 (window scale option) as in RFC 1323
Definition:
tcp-option-winscale.h:51
ns3::TcpOptionWinScale::GetScale
uint8_t GetScale() const
Get the scale value (uint8_t)
Definition:
tcp-option-winscale.cc:107
ns3::TcpOptionWinScale::TcpOptionWinScale
TcpOptionWinScale()
Definition:
tcp-option-winscale.cc:32
ns3::TcpOptionWinScale::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition:
tcp-option-winscale.cc:65
ns3::TcpOptionWinScale::~TcpOptionWinScale
~TcpOptionWinScale() override
Definition:
tcp-option-winscale.cc:38
ns3::TcpOptionWinScale::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition:
tcp-option-winscale.cc:71
ns3::TcpOptionWinScale::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition:
tcp-option-winscale.cc:59
ns3::TcpOptionWinScale::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition:
tcp-option-winscale.cc:80
ns3::TcpOptionWinScale::SetScale
void SetScale(uint8_t scale)
Set the scale option.
Definition:
tcp-option-winscale.cc:115
ns3::TcpOptionWinScale::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
tcp-option-winscale.cc:53
ns3::TcpOptionWinScale::m_scale
uint8_t m_scale
Window scaling in number of bit shift.
Definition:
tcp-option-winscale.h:86
ns3::TcpOptionWinScale::GetKind
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793) of this option.
Definition:
tcp-option-winscale.cc:101
ns3::TcpOptionWinScale::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
tcp-option-winscale.cc:43
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition:
log.h:261
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
tcp-option-winscale.h
src
internet
model
tcp-option-winscale.cc
Generated on Sun Mar 3 2024 17:10:59 for ns-3 by
1.9.1