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 * 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
14
15#include "ns3/log.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("TcpOptionSackPermitted");
21
22NS_OBJECT_ENSURE_REGISTERED(TcpOptionSackPermitted);
23
28
32
35{
36 static TypeId tid = TypeId("ns3::TcpOptionSackPermitted")
38 .SetGroupName("Internet")
39 .AddConstructor<TcpOptionSackPermitted>();
40 return tid;
41}
42
48
49void
50TcpOptionSackPermitted::Print(std::ostream& os) const
51{
52 os << "[sack_perm]";
53}
54
57{
58 return 2;
59}
60
61void
63{
64 Buffer::Iterator i = start;
65 i.WriteU8(GetKind()); // Kind
66 i.WriteU8(2); // Length
67}
68
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
90uint8_t
95
96} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
Base class for all kinds of TCP options.
Definition tcp-option.h:27
@ SACKPERMITTED
SACKPERMITTED.
Definition tcp-option.h:51
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:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.