A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tcp-option-winscale.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Adrian Sai-wah Tam
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
19
* Documentation, test cases: Natale Patriciello <natale.patriciello@gmail.com>
20
*/
21
22
#include "
tcp-option-winscale.h
"
23
#include "ns3/log.h"
24
25
NS_LOG_COMPONENT_DEFINE
(
"TcpOptionWinScale"
);
26
namespace
ns3 {
27
28
NS_OBJECT_ENSURE_REGISTERED
(TcpOptionWinScale);
29
30
TcpOptionWinScale::TcpOptionWinScale
()
31
:
TcpOption
(),
32
m_scale (0)
33
{
34
}
35
36
TcpOptionWinScale::~TcpOptionWinScale
()
37
{
38
}
39
40
TypeId
41
TcpOptionWinScale::GetTypeId
(
void
)
42
{
43
static
TypeId
tid =
TypeId
(
"ns3::TcpOptionWinScale"
)
44
.
SetParent
<
TcpOption
> ()
45
.AddConstructor<TcpOptionWinScale> ()
46
;
47
return
tid;
48
}
49
50
TypeId
51
TcpOptionWinScale::GetInstanceTypeId
(
void
)
const
52
{
53
return
GetTypeId
();
54
}
55
56
void
57
TcpOptionWinScale::Print
(std::ostream &os)
const
58
{
59
os << static_cast<int> (
m_scale
);
60
}
61
62
uint32_t
63
TcpOptionWinScale::GetSerializedSize
(
void
)
const
64
{
65
return
3;
66
}
67
68
void
69
TcpOptionWinScale::Serialize
(
Buffer::Iterator
start
)
const
70
{
71
Buffer::Iterator
i =
start
;
72
i.
WriteU8
(
GetKind
());
// Kind
73
i.
WriteU8
(3);
// Length
74
i.
WriteU8
(
m_scale
);
// Max segment size
75
}
76
77
uint32_t
78
TcpOptionWinScale::Deserialize
(
Buffer::Iterator
start
)
79
{
80
Buffer::Iterator
i =
start
;
81
82
uint8_t readKind = i.
ReadU8
();
83
if
(readKind !=
GetKind
())
84
{
85
NS_LOG_WARN
(
"Malformed Window Scale option"
);
86
return
0;
87
}
88
uint8_t size = i.
ReadU8
();
89
if
(size != 3)
90
{
91
NS_LOG_WARN
(
"Malformed Window Scale option"
);
92
return
0;
93
}
94
m_scale
= i.
ReadU8
();
95
return
GetSerializedSize
();
96
}
97
98
uint8_t
99
TcpOptionWinScale::GetKind
(
void
)
const
100
{
101
return
TcpOption::WINSCALE
;
102
}
103
104
uint8_t
105
TcpOptionWinScale::GetScale
(
void
)
const
106
{
107
NS_ASSERT
(
m_scale
<= 14);
108
109
return
m_scale
;
110
}
111
112
void
113
TcpOptionWinScale::SetScale
(uint8_t scale)
114
{
115
NS_ASSERT
(scale <= 14);
116
117
m_scale
= scale;
118
}
119
120
}
// namespace ns3
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition:
object-base.h:38
ns3::TcpOptionWinScale::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the Option from a buffer iterator.
Definition:
tcp-option-winscale.cc:78
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:61
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:170
visualizer.core.start
def start
Definition:
core.py:1482
ns3::TcpOptionWinScale::GetKind
virtual uint8_t GetKind(void) const
Get the `kind' (as in RFC 793) of this option.
Definition:
tcp-option-winscale.cc:99
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::TcpOptionWinScale::GetScale
uint8_t GetScale(void) const
Get the scale value (uint8_t)
Definition:
tcp-option-winscale.cc:105
ns3::TcpOptionWinScale::TcpOptionWinScale
TcpOptionWinScale()
Definition:
tcp-option-winscale.cc:30
ns3::TcpOptionWinScale::~TcpOptionWinScale
virtual ~TcpOptionWinScale()
Definition:
tcp-option-winscale.cc:36
ns3::TcpOptionWinScale::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Returns number of bytes required for Option serialization.
Definition:
tcp-option-winscale.cc:63
tcp-option-winscale.h
ns3::TcpOptionWinScale::Serialize
virtual void Serialize(Buffer::Iterator start) const
Serialize the Option to 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:113
ns3::TcpOptionWinScale::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
tcp-option-winscale.cc:51
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:876
ns3::TcpOption::WINSCALE
WINSCALE.
Definition:
tcp-option.h:58
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition:
log.h:203
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:1028
ns3::TcpOption
Base class for all kinds of TCP options.
Definition:
tcp-option.h:34
ns3::TcpOptionWinScale::m_scale
uint8_t m_scale
Window scaling in number of bit shift.
Definition:
tcp-option-winscale.h:84
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TcpOptionWinScale::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
tcp-option-winscale.cc:41
ns3::TcpOptionWinScale::Print
virtual void Print(std::ostream &os) const
Print the Option contents.
Definition:
tcp-option-winscale.cc:57
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
src
internet
model
tcp-option-winscale.cc
Generated on Wed Sep 17 2014 23:33:28 for ns-3 by
1.8.6