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 * 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 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
18 */
19
20#ifndef TCP_OPTION_H
21#define TCP_OPTION_H
22
23#include "ns3/buffer.h"
24#include "ns3/object-factory.h"
25#include "ns3/object.h"
26
27#include <stdint.h>
28
29namespace ns3
30{
31
37class TcpOption : public Object
38{
39 public:
40 TcpOption();
41 ~TcpOption() override;
42
47 static TypeId GetTypeId();
48
49 TypeId GetInstanceTypeId() const override;
50
54 enum Kind
55 {
56 // Remember to extend IsKindKnown() with new value, when adding values here
57 //
58 END = 0,
59 NOP = 1,
60 MSS = 2,
63 SACK = 5,
64 TS = 8,
65 UNKNOWN = 255
66 };
67
72 virtual void Print(std::ostream& os) const = 0;
77 virtual void Serialize(Buffer::Iterator start) const = 0;
78
85
90 virtual uint8_t GetKind() const = 0;
98 virtual uint32_t GetSerializedSize() const = 0;
99
105 static Ptr<TcpOption> CreateOption(uint8_t kind);
106
112 static bool IsKindKnown(uint8_t kind);
113};
114
124{
125 public:
127 ~TcpOptionUnknown() override;
128
133 static TypeId GetTypeId();
134 TypeId GetInstanceTypeId() const override;
135
136 void Print(std::ostream& os) const override;
137 void Serialize(Buffer::Iterator start) const override;
138 uint32_t Deserialize(Buffer::Iterator start) override;
139
140 uint8_t GetKind() const override;
141 uint32_t GetSerializedSize() const override;
142
143 private:
144 uint8_t m_kind;
146 uint8_t m_content[40];
147};
148
149} // namespace ns3
150
151#endif /* TCP_OPTION */
iterator in a Buffer instance
Definition: buffer.h:100
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Base class for all kinds of TCP options.
Definition: tcp-option.h:38
static Ptr< TcpOption > CreateOption(uint8_t kind)
Creates an option.
Definition: tcp-option.cc:62
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: tcp-option.cc:56
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:44
static bool IsKindKnown(uint8_t kind)
Check if the option is implemented.
Definition: tcp-option.cc:95
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:55
@ UNKNOWN
not a standardized value; for unknown recv'd options
Definition: tcp-option.h:65
@ SACKPERMITTED
SACKPERMITTED.
Definition: tcp-option.h:62
@ WINSCALE
WINSCALE.
Definition: tcp-option.h:61
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:49
An unknown TCP option.
Definition: tcp-option.h:124
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the Option from a buffer iterator.
Definition: tcp-option.cc:169
void Serialize(Buffer::Iterator start) const override
Serialize the Option to a buffer iterator.
Definition: tcp-option.cc:155
uint8_t GetKind() const override
Get the ‘kind’ (as in RFC 793) of this option.
Definition: tcp-option.cc:190
uint8_t m_content[40]
The option data.
Definition: tcp-option.h:146
void Print(std::ostream &os) const override
Print the Option contents.
Definition: tcp-option.cc:143
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-option.cc:127
uint32_t GetSerializedSize() const override
Returns number of bytes required for Option serialization.
Definition: tcp-option.cc:149
uint32_t m_size
The unknown option size.
Definition: tcp-option.h:145
~TcpOptionUnknown() override
Definition: tcp-option.cc:122
uint8_t m_kind
The unknown option kind.
Definition: tcp-option.h:144
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: tcp-option.cc:137
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.