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,
62  SACK = 5,
63  TS = 8,
64  UNKNOWN = 255
65  };
66 
71  virtual void Print (std::ostream &os) const = 0;
76  virtual void Serialize (Buffer::Iterator start) const = 0;
77 
83  virtual uint32_t Deserialize (Buffer::Iterator start) = 0;
84 
89  virtual uint8_t GetKind (void) const = 0;
97  virtual uint32_t GetSerializedSize (void) const = 0;
98 
104  static Ptr<TcpOption> CreateOption (uint8_t kind);
105 
111  static bool IsKindKnown (uint8_t kind);
112 };
113 
123 {
124 public:
125  TcpOptionUnknown ();
126  virtual ~TcpOptionUnknown ();
127 
132  static TypeId GetTypeId (void);
133  virtual TypeId GetInstanceTypeId (void) const;
134 
135  virtual void Print (std::ostream &os) const;
136  virtual void Serialize (Buffer::Iterator start) const;
137  virtual uint32_t Deserialize (Buffer::Iterator start);
138 
139  virtual uint8_t GetKind (void) const;
140  virtual uint32_t GetSerializedSize (void) const;
141 
142 private:
143  uint8_t m_kind;
144  uint32_t m_size;
145  uint8_t m_content[40];
146 
147 };
148 
149 } // namespace ns3
150 
151 #endif /* TCP_OPTION */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: tcp-option.cc:59
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: tcp-option.cc:142
virtual uint32_t GetSerializedSize(void) const
Returns number of bytes required for Option serialization.
Definition: tcp-option.cc:154
def start()
Definition: core.py:1844
virtual uint8_t GetKind(void) const
Get the ‘kind’ (as in RFC 793) of this option.
Definition: tcp-option.cc:194
virtual ~TcpOption()
Definition: tcp-option.cc:44
virtual void Print(std::ostream &os) const =0
Print the Option contents.
virtual void Serialize(Buffer::Iterator start) const
Serialize the Option to a buffer iterator.
Definition: tcp-option.cc:160
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:148
virtual ~TcpOptionUnknown()
Definition: tcp-option.cc:126
An unknown TCP option.
Definition: tcp-option.h:122
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:174
uint8_t m_content[40]
The option data.
Definition: tcp-option.h:145
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:144
not a standardized value; for unknown recv&#39;d options
Definition: tcp-option.h:64
static bool IsKindKnown(uint8_t kind)
Check if the option is implemented.
Definition: tcp-option.cc:99
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-option.cc:49
uint8_t m_kind
The unknown option kind.
Definition: tcp-option.h:143
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:53
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
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:65
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-option.cc:131
virtual uint32_t GetSerializedSize(void) const =0
Returns number of bytes required for Option serialization.