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
43void
44TcpOptionSackPermitted::Print(std::ostream& os) const
45{
46 os << "[sack_perm]";
47}
48
51{
52 return 2;
53}
54
55void
57{
58 Buffer::Iterator i = start;
59 i.WriteU8(GetKind()); // Kind
60 i.WriteU8(2); // Length
61}
62
65{
66 Buffer::Iterator i = start;
67
68 uint8_t readKind = i.ReadU8();
69 if (readKind != GetKind())
70 {
71 NS_LOG_WARN("Malformed Sack-Permitted option");
72 return 0;
73 }
74
75 uint8_t size = i.ReadU8();
76 if (size != 2)
77 {
78 NS_LOG_WARN("Malformed Sack-Permitted option");
79 return 0;
80 }
81 return GetSerializedSize();
82}
83
84uint8_t
89
90} // 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:49
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.
a unique identifier for an interface.
Definition type-id.h:49
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.