A Discrete-Event Network Simulator
API
tcp-option.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Adrian Sai-wah Tam
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
19  */
20 
21 #ifndef TCP_OPTION_H
22 #define TCP_OPTION_H
23 
24 #include <stdint.h>
25 #include "ns3/object.h"
26 #include "ns3/buffer.h"
27 #include "ns3/object-factory.h"
28 
29 namespace ns3 {
30 
34 class TcpOption : public Object
35 {
36 public:
37  TcpOption ();
38  virtual ~TcpOption ();
39 
44  static TypeId GetTypeId (void);
45 
46  virtual TypeId GetInstanceTypeId (void) const;
47 
51  enum Kind
52  {
53  // Remember to extend IsKindKnown() with new value, when adding values here
54  //
55  END = 0,
56  NOP = 1,
57  MSS = 2,
58  WINSCALE = 3,
59  TS = 8,
60  UNKNOWN = 255
61  };
62 
67  virtual void Print (std::ostream &os) const = 0;
72  virtual void Serialize (Buffer::Iterator start) const = 0;
73 
79  virtual uint32_t Deserialize (Buffer::Iterator start) = 0;
80 
85  virtual uint8_t GetKind (void) const = 0;
93  virtual uint32_t GetSerializedSize (void) const = 0;
94 
100  static Ptr<TcpOption> CreateOption (uint8_t kind);
101 
107  static bool IsKindKnown (uint8_t kind);
108 };
109 
117 {
118 public:
119  TcpOptionUnknown ();
120  virtual ~TcpOptionUnknown ();
121 
126  static TypeId GetTypeId (void);
127  virtual TypeId GetInstanceTypeId (void) const;
128 
129  virtual void Print (std::ostream &os) const;
130  virtual void Serialize (Buffer::Iterator start) const;
131  virtual uint32_t Deserialize (Buffer::Iterator start);
132 
133  virtual uint8_t GetKind (void) const;
134  virtual uint32_t GetSerializedSize (void) const;
135 
136 private:
137  uint8_t m_kind;
138  uint32_t m_size;
139  uint8_t m_content[40];
140 
141 };
142 
143 } // namespace ns3
144 
145 #endif /* TCP_OPTION */
virtual uint8_t GetKind(void) const
Get the `kind' (as in RFC 793) of this option.
Definition: tcp-option.cc:188
def start()
Definition: core.py:1482
virtual ~TcpOption()
Definition: tcp-option.cc:42
virtual void Print(std::ostream &os) const =0
Print the Option contents.
iterator in a Buffer instance
Definition: buffer.h:98
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the Option from a buffer iterator.
virtual void Print(std::ostream &os) const
Print the Option contents.
Definition: tcp-option.cc:142
virtual ~TcpOptionUnknown()
Definition: tcp-option.cc:120
virtual void Serialize(Buffer::Iterator start) const
Serialize the Option to a buffer iterator.
Definition: tcp-option.cc:154
An unknown TCP option.
Definition: tcp-option.h:116
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the Option from a buffer iterator.
Definition: tcp-option.cc:168
uint8_t m_content[40]
The option data.
Definition: tcp-option.h:139
virtual void Serialize(Buffer::Iterator start) const =0
Serialize the Option to a buffer iterator.
uint32_t m_size
The unknown option size.
Definition: tcp-option.h:138
not a standardized value; for unknown recv'd options
Definition: tcp-option.h:60
virtual uint32_t GetSerializedSize(void) const
Returns number of bytes required for Option serialization.
Definition: tcp-option.cc:148
static bool IsKindKnown(uint8_t kind)
Check if the option is implemented.
Definition: tcp-option.cc:95
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-option.cc:47
uint8_t m_kind
The unknown option kind.
Definition: tcp-option.h:137
virtual uint8_t GetKind(void) const =0
Get the `kind' (as in RFC 793) of this option.
Kind
The option Kind, as defined in the respective RFCs.
Definition: tcp-option.h:51
Base class for all kinds of TCP options.
Definition: tcp-option.h:34
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual TypeId GetInstanceTypeId(void) const
Implement the GetInstanceTypeId method defined in ObjectBase.
Definition: tcp-option.cc:57
virtual TypeId GetInstanceTypeId(void) const
Implement the GetInstanceTypeId method defined in ObjectBase.
Definition: tcp-option.cc:136
a unique identifier for an interface.
Definition: type-id.h:58
static Ptr< TcpOption > CreateOption(uint8_t kind)
Creates an option.
Definition: tcp-option.cc:63
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-option.cc:125
virtual uint32_t GetSerializedSize(void) const =0
Returns number of bytes required for Option serialization.