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-winscale.cc
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
* Documentation, test cases: Natale Patriciello <natale.patriciello@gmail.com>
8
*/
9
10
#include "
tcp-option-winscale.h
"
11
12
#include "ns3/log.h"
13
14
namespace
ns3
15
{
16
17
NS_LOG_COMPONENT_DEFINE
(
"TcpOptionWinScale"
);
18
19
NS_OBJECT_ENSURE_REGISTERED
(TcpOptionWinScale);
20
21
TcpOptionWinScale::TcpOptionWinScale
()
22
:
TcpOption
(),
23
m_scale(0)
24
{
25
}
26
27
TcpOptionWinScale::~TcpOptionWinScale
()
28
{
29
}
30
31
TypeId
32
TcpOptionWinScale::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::TcpOptionWinScale"
)
35
.
SetParent
<
TcpOption
>()
36
.SetGroupName(
"Internet"
)
37
.AddConstructor<
TcpOptionWinScale
>();
38
return
tid;
39
}
40
41
TypeId
42
TcpOptionWinScale::GetInstanceTypeId
()
const
43
{
44
return
GetTypeId
();
45
}
46
47
void
48
TcpOptionWinScale::Print
(std::ostream& os)
const
49
{
50
os << static_cast<int>(
m_scale
);
51
}
52
53
uint32_t
54
TcpOptionWinScale::GetSerializedSize
()
const
55
{
56
return
3;
57
}
58
59
void
60
TcpOptionWinScale::Serialize
(
Buffer::Iterator
start)
const
61
{
62
Buffer::Iterator
i = start;
63
i.
WriteU8
(
GetKind
());
// Kind
64
i.
WriteU8
(3);
// Length
65
i.
WriteU8
(
m_scale
);
// Max segment size
66
}
67
68
uint32_t
69
TcpOptionWinScale::Deserialize
(
Buffer::Iterator
start)
70
{
71
Buffer::Iterator
i = start;
72
73
uint8_t readKind = i.
ReadU8
();
74
if
(readKind !=
GetKind
())
75
{
76
NS_LOG_WARN
(
"Malformed Window Scale option"
);
77
return
0;
78
}
79
uint8_t size = i.
ReadU8
();
80
if
(size != 3)
81
{
82
NS_LOG_WARN
(
"Malformed Window Scale option"
);
83
return
0;
84
}
85
m_scale
= i.
ReadU8
();
86
return
GetSerializedSize
();
87
}
88
89
uint8_t
90
TcpOptionWinScale::GetKind
()
const
91
{
92
return
TcpOption::WINSCALE
;
93
}
94
95
uint8_t
96
TcpOptionWinScale::GetScale
()
const
97
{
98
NS_ASSERT
(
m_scale
<= 14);
99
100
return
m_scale
;
101
}
102
103
void
104
TcpOptionWinScale::SetScale
(uint8_t scale)
105
{
106
NS_ASSERT
(scale <= 14);
107
108
m_scale
= scale;
109
}
110
111
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition
buffer.h:1016
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::TcpOption
Base class for all kinds of TCP options.
Definition
tcp-option.h:27
ns3::TcpOption::WINSCALE
@ WINSCALE
WINSCALE.
Definition
tcp-option.h:50
ns3::TcpOptionWinScale
Defines the TCP option of kind 3 (window scale option) as in RFC 1323
Definition
tcp-option-winscale.h:40
ns3::TcpOptionWinScale::GetScale
uint8_t GetScale() const
Get the scale value (uint8_t)
Definition
tcp-option-winscale.cc:96
ns3::TcpOptionWinScale::TcpOptionWinScale
TcpOptionWinScale()
Definition
tcp-option-winscale.cc:21
ns3::TcpOptionWinScale::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition
tcp-option-winscale.cc:54
ns3::TcpOptionWinScale::~TcpOptionWinScale
~TcpOptionWinScale() override
Definition
tcp-option-winscale.cc:27
ns3::TcpOptionWinScale::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition
tcp-option-winscale.cc:60
ns3::TcpOptionWinScale::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition
tcp-option-winscale.cc:48
ns3::TcpOptionWinScale::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition
tcp-option-winscale.cc:69
ns3::TcpOptionWinScale::SetScale
void SetScale(uint8_t scale)
Set the scale option.
Definition
tcp-option-winscale.cc:104
ns3::TcpOptionWinScale::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
tcp-option-winscale.cc:42
ns3::TcpOptionWinScale::m_scale
uint8_t m_scale
Window scaling in number of bit shift.
Definition
tcp-option-winscale.h:75
ns3::TcpOptionWinScale::GetKind
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793 ) of this option.
Definition
tcp-option-winscale.cc:90
ns3::TcpOptionWinScale::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
tcp-option-winscale.cc:32
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
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:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition
log.h:250
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
tcp-option-winscale.h
src
internet
model
tcp-option-winscale.cc
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0