A Discrete-Event Network Simulator
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 * 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
25
26#include "ns3/log.h"
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("TcpOptionSackPermitted");
32
33NS_OBJECT_ENSURE_REGISTERED(TcpOptionSackPermitted);
34
36 : TcpOption()
37{
38}
39
41{
42}
43
46{
47 static TypeId tid = TypeId("ns3::TcpOptionSackPermitted")
49 .SetGroupName("Internet")
50 .AddConstructor<TcpOptionSackPermitted>();
51 return tid;
52}
53
56{
57 return GetTypeId();
58}
59
60void
61TcpOptionSackPermitted::Print(std::ostream& os) const
62{
63 os << "[sack_perm]";
64}
65
68{
69 return 2;
70}
71
72void
74{
75 Buffer::Iterator i = start;
76 i.WriteU8(GetKind()); // Kind
77 i.WriteU8(2); // Length
78}
79
82{
83 Buffer::Iterator i = start;
84
85 uint8_t readKind = i.ReadU8();
86 if (readKind != GetKind())
87 {
88 NS_LOG_WARN("Malformed Sack-Permitted option");
89 return 0;
90 }
91
92 uint8_t size = i.ReadU8();
93 if (size != 2)
94 {
95 NS_LOG_WARN("Malformed Sack-Permitted option");
96 return 0;
97 }
98 return GetSerializedSize();
99}
100
101uint8_t
103{
105}
106
107} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
Base class for all kinds of TCP options.
Definition: tcp-option.h:38
@ SACKPERMITTED
SACKPERMITTED.
Definition: tcp-option.h:62
Defines the TCP option of kind 4 (selective acknowledgment permitted option) as in RFC 2018
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
static TypeId GetTypeId()
Get the type ID.
void Print(std::ostream &os) const override
Print the Option contents.
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793) of this option.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.