A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-option.h
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 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
7 */
8
9#ifndef TCP_OPTION_H
10#define TCP_OPTION_H
11
12#include "ns3/buffer.h"
13#include "ns3/object-factory.h"
14#include "ns3/object.h"
15
16#include <stdint.h>
17
18namespace ns3
19{
20
21/**
22 * @ingroup tcp
23 *
24 * Base class for all kinds of TCP options
25 */
26class TcpOption : public Object
27{
28 public:
29 TcpOption();
30 ~TcpOption() override;
31
32 /**
33 * @brief Get the type ID.
34 * @return the object TypeId
35 */
36 static TypeId GetTypeId();
37
38 /**
39 * The option Kind, as defined in the respective RFCs.
40 */
41 enum Kind
42 {
43 // Remember to extend IsKindKnown() with new value, when adding values here
44 //
45 END = 0, //!< END
46 NOP = 1, //!< NOP
47 MSS = 2, //!< MSS
48 WINSCALE = 3, //!< WINSCALE
49 SACKPERMITTED = 4, //!< SACKPERMITTED
50 SACK = 5, //!< SACK
51 TS = 8, //!< TS
52 UNKNOWN = 255 //!< not a standardized value; for unknown recv'd options
53 };
54
55 /**
56 * @brief Print the Option contents
57 * @param os the output stream
58 */
59 virtual void Print(std::ostream& os) const = 0;
60 /**
61 * @brief Serialize the Option to a buffer iterator
62 * @param start the buffer iterator
63 */
64 virtual void Serialize(Buffer::Iterator start) const = 0;
65
66 /**
67 * @brief Deserialize the Option from a buffer iterator
68 * @param start the buffer iterator
69 * @returns the number of deserialized bytes
70 */
72
73 /**
74 * @brief Get the `kind' (as in \RFC{793}) of this option
75 * @return the Option Kind
76 */
77 virtual uint8_t GetKind() const = 0;
78 /**
79 * @brief Returns number of bytes required for Option
80 * serialization.
81 *
82 * @returns number of bytes required for Option
83 * serialization
84 */
85 virtual uint32_t GetSerializedSize() const = 0;
86
87 /**
88 * @brief Creates an option
89 * @param kind the option kind
90 * @return the requested option or an ns3::UnknownOption if the option is not supported
91 */
92 static Ptr<TcpOption> CreateOption(uint8_t kind);
93
94 /**
95 * @brief Check if the option is implemented
96 * @param kind the Option kind
97 * @return true if the option is known
98 */
99 static bool IsKindKnown(uint8_t kind);
100};
101
102/**
103 * @ingroup tcp
104 *
105 * @brief An unknown TCP option.
106 *
107 * An unknown option can be deserialized and (only if deserialized previously)
108 * serialized again.
109 */
111{
112 public:
114 ~TcpOptionUnknown() override;
115
116 /**
117 * @brief Get the type ID.
118 * @return the object TypeId
119 */
120 static TypeId GetTypeId();
121
122 void Print(std::ostream& os) const override;
123 void Serialize(Buffer::Iterator start) const override;
124 uint32_t Deserialize(Buffer::Iterator start) override;
125
126 uint8_t GetKind() const override;
127 uint32_t GetSerializedSize() const override;
128
129 private:
130 uint8_t m_kind; //!< The unknown option kind
131 uint32_t m_size; //!< The unknown option size
132 uint8_t m_content[40]; //!< The option data
133};
134
135} // namespace ns3
136
137#endif /* TCP_OPTION */
iterator in a Buffer instance
Definition buffer.h:89
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Base class for all kinds of TCP options.
Definition tcp-option.h:27
static Ptr< TcpOption > CreateOption(uint8_t kind)
Creates an option.
Definition tcp-option.cc:45
virtual void Serialize(Buffer::Iterator start) const =0
Serialize the Option to a buffer iterator.
virtual uint8_t GetKind() const =0
Get the ‘kind’ (as in RFC 793 ) of this option.
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the Option from a buffer iterator.
~TcpOption() override
Definition tcp-option.cc:33
static bool IsKindKnown(uint8_t kind)
Check if the option is implemented.
Definition tcp-option.cc:78
virtual void Print(std::ostream &os) const =0
Print the Option contents.
Kind
The option Kind, as defined in the respective RFCs.
Definition tcp-option.h:42
@ UNKNOWN
not a standardized value; for unknown recv'd options
Definition tcp-option.h:52
@ SACKPERMITTED
SACKPERMITTED.
Definition tcp-option.h:49
@ WINSCALE
WINSCALE.
Definition tcp-option.h:48
virtual uint32_t GetSerializedSize() const =0
Returns number of bytes required for Option serialization.
static TypeId GetTypeId()
Get the type ID.
Definition tcp-option.cc:38
An unknown TCP option.
Definition tcp-option.h:111
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793 ) of this option.
uint8_t m_content[40]
The option data.
Definition tcp-option.h:132
void Print(std::ostream &os) const override
Print the Option contents.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
uint32_t m_size
The unknown option size.
Definition tcp-option.h:131
~TcpOptionUnknown() override
uint8_t m_kind
The unknown option kind.
Definition tcp-option.h:130
a unique identifier for an interface.
Definition type-id.h:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.