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-sack-permitted.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
* Original Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
7
* Documentation, test cases: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
8
* ResiliNets Research Group https://resilinets.org/
9
* The University of Kansas
10
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
11
*/
12
13
#include "
tcp-option-sack-permitted.h
"
14
15
#include "ns3/log.h"
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"TcpOptionSackPermitted"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(TcpOptionSackPermitted);
23
24
TcpOptionSackPermitted::TcpOptionSackPermitted
()
25
:
TcpOption
()
26
{
27
}
28
29
TcpOptionSackPermitted::~TcpOptionSackPermitted
()
30
{
31
}
32
33
TypeId
34
TcpOptionSackPermitted::GetTypeId
()
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::TcpOptionSackPermitted"
)
37
.
SetParent
<
TcpOption
>()
38
.SetGroupName(
"Internet"
)
39
.AddConstructor<
TcpOptionSackPermitted
>();
40
return
tid;
41
}
42
43
TypeId
44
TcpOptionSackPermitted::GetInstanceTypeId
()
const
45
{
46
return
GetTypeId
();
47
}
48
49
void
50
TcpOptionSackPermitted::Print
(std::ostream& os)
const
51
{
52
os <<
"[sack_perm]"
;
53
}
54
55
uint32_t
56
TcpOptionSackPermitted::GetSerializedSize
()
const
57
{
58
return
2;
59
}
60
61
void
62
TcpOptionSackPermitted::Serialize
(
Buffer::Iterator
start)
const
63
{
64
Buffer::Iterator
i = start;
65
i.
WriteU8
(
GetKind
());
// Kind
66
i.
WriteU8
(2);
// Length
67
}
68
69
uint32_t
70
TcpOptionSackPermitted::Deserialize
(
Buffer::Iterator
start)
71
{
72
Buffer::Iterator
i = start;
73
74
uint8_t readKind = i.
ReadU8
();
75
if
(readKind !=
GetKind
())
76
{
77
NS_LOG_WARN
(
"Malformed Sack-Permitted option"
);
78
return
0;
79
}
80
81
uint8_t size = i.
ReadU8
();
82
if
(size != 2)
83
{
84
NS_LOG_WARN
(
"Malformed Sack-Permitted option"
);
85
return
0;
86
}
87
return
GetSerializedSize
();
88
}
89
90
uint8_t
91
TcpOptionSackPermitted::GetKind
()
const
92
{
93
return
TcpOption::SACKPERMITTED
;
94
}
95
96
}
// 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::SACKPERMITTED
@ SACKPERMITTED
SACKPERMITTED.
Definition
tcp-option.h:51
ns3::TcpOptionSackPermitted
Defines the TCP option of kind 4 (selective acknowledgment permitted option) as in RFC 2018
Definition
tcp-option-sack-permitted.h:32
ns3::TcpOptionSackPermitted::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition
tcp-option-sack-permitted.cc:62
ns3::TcpOptionSackPermitted::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition
tcp-option-sack-permitted.cc:70
ns3::TcpOptionSackPermitted::~TcpOptionSackPermitted
~TcpOptionSackPermitted() override
Definition
tcp-option-sack-permitted.cc:29
ns3::TcpOptionSackPermitted::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
tcp-option-sack-permitted.cc:34
ns3::TcpOptionSackPermitted::Print
void Print(std::ostream &os) const override
Print the Option contents.
Definition
tcp-option-sack-permitted.cc:50
ns3::TcpOptionSackPermitted::TcpOptionSackPermitted
TcpOptionSackPermitted()
Definition
tcp-option-sack-permitted.cc:24
ns3::TcpOptionSackPermitted::GetSerializedSize
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition
tcp-option-sack-permitted.cc:56
ns3::TcpOptionSackPermitted::GetKind
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793 ) of this option.
Definition
tcp-option-sack-permitted.cc:91
ns3::TcpOptionSackPermitted::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
tcp-option-sack-permitted.cc:44
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_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-sack-permitted.h
src
internet
model
tcp-option-sack-permitted.cc
Generated on Sat Nov 2 2024 19:37:24 for ns-3 by
1.11.0