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 
36 class TcpOption : public Object
37 {
38 public:
39  TcpOption ();
40  virtual ~TcpOption ();
41 
46  static TypeId GetTypeId (void);
47 
48  virtual TypeId GetInstanceTypeId (void) const;
49 
53  enum Kind
54  {
55  // Remember to extend IsKindKnown() with new value, when adding values here
56  //
57  END = 0,
58  NOP = 1,
59  MSS = 2,
60  WINSCALE = 3,
61  TS = 8,
62  UNKNOWN = 255
63  };
64 
69  virtual void Print (std::ostream &os) const = 0;
74  virtual void Serialize (Buffer::Iterator start) const = 0;
75 
81  virtual uint32_t Deserialize (Buffer::Iterator start) = 0;
82 
87  virtual uint8_t GetKind (void) const = 0;
95  virtual uint32_t GetSerializedSize (void) const = 0;
96 
102  static Ptr<TcpOption> CreateOption (uint8_t kind);
103 
109  static bool IsKindKnown (uint8_t kind);
110 };
111 
121 {
122 public:
123  TcpOptionUnknown ();
124  virtual ~TcpOptionUnknown ();
125 
130  static TypeId GetTypeId (void);
131  virtual TypeId GetInstanceTypeId (void) const;
132 
133  virtual void Print (std::ostream &os) const;
134  virtual void Serialize (Buffer::Iterator start) const;
135  virtual uint32_t Deserialize (Buffer::Iterator start);
136 
137  virtual uint8_t GetKind (void) const;
138  virtual uint32_t GetSerializedSize (void) const;
139 
140 private:
141  uint8_t m_kind;
142  uint32_t m_size;
143  uint8_t m_content[40];
144 
145 };
146 
147 } // namespace ns3
148 
149 #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
not a standardized value; for unknown recv'd options
Definition: tcp-option.h:62
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:120
Kind
The option Kind, as defined in the respective RFCs.
Definition: tcp-option.h:53
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:143
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:142
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:141
virtual uint8_t GetKind(void) const =0
Get the `kind' (as in RFC 793) of this option.
Base class for all kinds of TCP options.
Definition: tcp-option.h:36
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.