A Discrete-Event Network Simulator
API
dsr-fs-header.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
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: Yufei Cheng <yfcheng@ittc.ku.edu>
19  *
20  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22  * Information and Telecommunication Technology Center (ITTC)
23  * and Department of Electrical Engineering and Computer Science
24  * The University of Kansas Lawrence, KS USA.
25  *
26  * Work supported in part by NSF FIND (Future Internet Design) Program
27  * under grant CNS-0626918 (Postmodern Internet Architecture),
28  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29  * US Department of Defense (DoD), and ITTC at The University of Kansas.
30  */
31 
32 #ifndef DSR_FS_HEADER_H
33 #define DSR_FS_HEADER_H
34 
35 #include <vector>
36 #include <list>
37 #include <ostream>
38 
39 #include "ns3/header.h"
40 #include "ns3/ipv4-address.h"
41 #include "dsr-option-header.h"
42 
43 namespace ns3 {
44 namespace dsr {
79 class DsrFsHeader : public Header
80 {
81 public:
86  static TypeId GetTypeId ();
91  virtual TypeId GetInstanceTypeId () const;
95  DsrFsHeader ();
99  virtual ~DsrFsHeader ();
104  void SetNextHeader (uint8_t protocol);
109  uint8_t GetNextHeader () const;
114  void SetMessageType (uint8_t messageType);
119  uint8_t GetMessageType () const;
124  void SetSourceId (uint16_t sourceId);
129  uint16_t GetSourceId () const;
134  void SetDestId (uint16_t destId);
139  uint16_t GetDestId () const;
144  void SetPayloadLength (uint16_t length);
149  uint16_t GetPayloadLength () const;
154  virtual void Print (std::ostream &os) const;
159  virtual uint32_t GetSerializedSize () const;
164  virtual void Serialize (Buffer::Iterator start) const;
170  virtual uint32_t Deserialize (Buffer::Iterator start);
171 
172 private:
176  uint8_t m_nextHeader;
180  uint8_t m_messageType;
184  uint16_t m_payloadLen;
188  uint16_t m_sourceId;
192  uint16_t m_destId;
197 };
198 
210 {
211 public:
216  DsrOptionField (uint32_t optionsOffset);
220  ~DsrOptionField ();
225  uint32_t GetSerializedSize () const;
230  void Serialize (Buffer::Iterator start) const;
237  uint32_t Deserialize (Buffer::Iterator start, uint32_t length);
242  void AddDsrOption (DsrOptionHeader const& option);
248  uint32_t GetDsrOptionsOffset ();
254 
255 private:
261  uint32_t CalculatePad (DsrOptionHeader::Alignment alignment) const;
269  uint32_t m_optionsOffset;
270 };
271 
277  public DsrOptionField
278 {
279 public:
284  static TypeId GetTypeId ();
289  virtual TypeId GetInstanceTypeId () const;
293  DsrRoutingHeader ();
297  virtual ~DsrRoutingHeader ();
302  virtual void Print (std::ostream &os) const;
307  virtual uint32_t GetSerializedSize () const;
312  virtual void Serialize (Buffer::Iterator start) const;
318  virtual uint32_t Deserialize (Buffer::Iterator start);
319 };
320 
321 static inline std::ostream & operator<< (std::ostream& os, const DsrRoutingHeader & dsr)
322 {
323  dsr.Print (os);
324  return os;
325 }
326 
327 } // namespace dsr
328 } // namespace ns3
329 
330 #endif /* DSR_FS_HEADER_H */
331 
~DsrOptionField()
Destructor.
Protocol header serialization and deserialization.
Definition: header.h:42
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
uint32_t CalculatePad(DsrOptionHeader::Alignment alignment) const
Calculate padding.
static TypeId GetTypeId()
Get the type identificator.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
DsrRoutingHeader()
Constructor.
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint16_t GetDestId() const
brief Get the dest ID of the header.
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
uint8_t GetNextHeader() const
Get the next header.
automatically resized byte buffer
Definition: buffer.h:92
def start()
Definition: core.py:1855
uint32_t m_optionsOffset
Offset.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
void SetNextHeader(uint8_t protocol)
Set the "Next header" field.
virtual ~DsrFsHeader()
Destructor.
void SetSourceId(uint16_t sourceId)
brief Set the source ID of the header.
Dsr fixed size header Format.
Definition: dsr-fs-header.h:79
void SetDestId(uint16_t destId)
brief Set the dest ID of the header.
Option field for an DsrFsHeader Enables adding options to an DsrFsHeader.
represents the alignment requirements of an option header
iterator in a Buffer instance
Definition: buffer.h:98
virtual void Print(std::ostream &os) const
Print some information about the packet.
uint16_t GetPayloadLength() const
Get the payload length of the header.
uint32_t GetDsrOptionsOffset()
Get the offset where the options begin, measured from the start of the extension header.
uint16_t GetSourceId() const
brief Get the source ID of the header.
uint16_t m_destId
The destination node id.
uint8_t GetMessageType() const
brief Get the message type of the header.
uint8_t m_nextHeader
The "next header" field.
uint16_t m_payloadLen
The "payload length" field.
void SetPayloadLength(uint16_t length)
brief Set the payload length of the header.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
DsrFsHeader()
Constructor.
uint8_t m_messageType
The type of the message.
void SetMessageType(uint8_t messageType)
brief Set the message type of the header.
uint16_t m_sourceId
The source node id.
static TypeId GetTypeId()
Get the type identificator.
Buffer m_data
The data of the extension.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
DsrOptionField(uint32_t optionsOffset)
Constructor.
void AddDsrOption(DsrOptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary.
Header for Dsr Options.
virtual ~DsrRoutingHeader()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void Serialize(Buffer::Iterator start) const
Serialize all added options.
static std::ostream & operator<<(std::ostream &os, const DsrRoutingHeader &dsr)
Header of Dsr Routing.
a unique identifier for an interface.
Definition: type-id.h:58
Buffer m_optionData
Data payload.
Buffer GetDsrOptionBuffer()
Get the buffer.