A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
tcp-option-sack-permitted.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
* Original Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
18
* Documentation, test cases: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
19
* ResiliNets Research Group https://resilinets.org/
20
* The University of Kansas
21
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
22
*/
23
24
#include "
tcp-option-sack-permitted.h
"
25
26
#include "ns3/log.h"
27
#include "ns3/tcp-header.h"
28
29
namespace
ns3
30
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"TcpOptionSackPermitted"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(TcpOptionSackPermitted);
35
36
TcpOptionSackPermitted::TcpOptionSackPermitted
()
37
:
TcpOption
()
38
{
39
}
40
41
TcpOptionSackPermitted::~TcpOptionSackPermitted
()
42
{
43
}
44
45
TypeId
46
TcpOptionSackPermitted::GetTypeId
()
47
{
48
static
TypeId
tid =
TypeId
(
"ns3::TcpOptionSackPermitted"
)
49
.
SetParent
<
TcpOption
>()
50
.SetGroupName(
"Internet"
)
51
.AddConstructor<
TcpOptionSackPermitted
>();
52
return
tid;
53
}
54
55
TypeId
56
TcpOptionSackPermitted::GetInstanceTypeId
()
const
57
{
58
return
GetTypeId
();
59
}
60
61
void
62
TcpOptionSackPermitted::Print
(std::ostream& os)
const
63
{
64
os <<
"[sack_perm]"
;
65
}
66
67
uint32_t
68
TcpOptionSackPermitted::GetSerializedSize
()
const
69
{
70
return
2;
71
}
72
73
void
74
TcpOptionSackPermitted::Serialize
(
Buffer::Iterator
start
)
const
75
{
76
Buffer::Iterator
i =
start
;
77
i.
WriteU8
(
GetKind
());
// Kind
78
i.
WriteU8
(2);
// Length
79
}
80
81
uint32_t
82
TcpOptionSackPermitted::Deserialize
(
Buffer::Iterator
start
)
83
{
84
Buffer::Iterator
i =
start
;
85
86
uint8_t readKind = i.
ReadU8
();
87
if
(readKind !=
GetKind
())
88
{
89
NS_LOG_WARN
(
"Malformed Sack-Permitted option"
);
90
return
0;
91
}
92
93
uint8_t size = i.
ReadU8
();
94
if
(size != 2)
95
{
96
NS_LOG_WARN
(
"Malformed Sack-Permitted option"
);
97
return
0;
98
}
99
return
GetSerializedSize
();
100
}
101
102
uint8_t
103
TcpOptionSackPermitted::GetKind
()
const
104
{
105
return
TcpOption::SACKPERMITTED
;
106
}
107
108
}
// 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::SACKPERMITTED
@ SACKPERMITTED
SACKPERMITTED.
Definition:
tcp-option.h:62
ns3::TcpOptionSackPermitted
Defines the TCP option of kind 4 (selective acknowledgment permitted option) as in RFC 2018
Definition:
tcp-option-sack-permitted.h:43
ns3::TcpOptionSackPermitted::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition:
tcp-option-sack-permitted.cc:74
ns3::TcpOptionSackPermitted::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition:
tcp-option-sack-permitted.cc:82
ns3::TcpOptionSackPermitted::~TcpOptionSackPermitted
~TcpOptionSackPermitted() override
Definition:
tcp-option-sack-permitted.cc:41
ns3::TcpOptionSackPermitted::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
tcp-option-sack-permitted.cc:46
ns3::TcpOptionSackPermitted::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition:
tcp-option-sack-permitted.cc:62
ns3::TcpOptionSackPermitted::TcpOptionSackPermitted
TcpOptionSackPermitted()
Definition:
tcp-option-sack-permitted.cc:36
ns3::TcpOptionSackPermitted::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition:
tcp-option-sack-permitted.cc:68
ns3::TcpOptionSackPermitted::GetKind
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793) of this option.
Definition:
tcp-option-sack-permitted.cc:103
ns3::TcpOptionSackPermitted::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
tcp-option-sack-permitted.cc:56
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:60
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:935
uint32_t
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:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
visualizer.core.start
def start()
Definition:
core.py:1861
tcp-option-sack-permitted.h
src
internet
model
tcp-option-sack-permitted.cc
Generated on Tue Nov 1 2022 22:59:58 for ns-3 by
1.9.3