A Discrete-Event Network Simulator
API
dsdv-packet.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Hemanth Narra
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: Hemanth Narra <hemanth@ittc.ku.com>
18  *
19  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20  * ResiliNets Research Group https://resilinets.org/
21  * Information and Telecommunication Technology Center (ITTC)
22  * and Department of Electrical Engineering and Computer Science
23  * The University of Kansas Lawrence, KS USA.
24  *
25  * Work supported in part by NSF FIND (Future Internet Design) Program
26  * under grant CNS-0626918 (Postmodern Internet Architecture),
27  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28  * US Department of Defense (DoD), and ITTC at The University of Kansas.
29  */
30 
31 #ifndef DSDV_PACKET_H
32 #define DSDV_PACKET_H
33 
34 #include "ns3/header.h"
35 #include "ns3/ipv4-address.h"
36 #include "ns3/nstime.h"
37 
38 #include <iostream>
39 
40 namespace ns3
41 {
42 namespace dsdv
43 {
60 class DsdvHeader : public Header
61 {
62  public:
70  DsdvHeader(Ipv4Address dst = Ipv4Address(), uint32_t hopcount = 0, uint32_t dstSeqNo = 0);
71  ~DsdvHeader() override;
76  static TypeId GetTypeId();
77  TypeId GetInstanceTypeId() const override;
78  uint32_t GetSerializedSize() const override;
79  void Serialize(Buffer::Iterator start) const override;
80  uint32_t Deserialize(Buffer::Iterator start) override;
81  void Print(std::ostream& os) const override;
82 
87  void SetDst(Ipv4Address destination)
88  {
89  m_dst = destination;
90  }
91 
97  {
98  return m_dst;
99  }
100 
105  void SetHopCount(uint32_t hopCount)
106  {
107  m_hopCount = hopCount;
108  }
109 
114  uint32_t GetHopCount() const
115  {
116  return m_hopCount;
117  }
118 
123  void SetDstSeqno(uint32_t sequenceNumber)
124  {
125  m_dstSeqNo = sequenceNumber;
126  }
127 
132  uint32_t GetDstSeqno() const
133  {
134  return m_dstSeqNo;
135  }
136 
137  private:
139  uint32_t m_hopCount;
140  uint32_t m_dstSeqNo;
141 };
142 
143 static inline std::ostream&
144 operator<<(std::ostream& os, const DsdvHeader& packet)
145 {
146  packet.Print(os);
147  return os;
148 }
149 } // namespace dsdv
150 } // namespace ns3
151 
152 #endif /* DSDV_PACKET_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a unique identifier for an interface.
Definition: type-id.h:59
DSDV Update Packet Format.
Definition: dsdv-packet.h:61
uint32_t m_hopCount
Number of Hops.
Definition: dsdv-packet.h:139
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Definition: dsdv-packet.cc:42
Ipv4Address GetDst() const
Get destination address.
Definition: dsdv-packet.h:96
void SetDstSeqno(uint32_t sequenceNumber)
Set destination sequence number.
Definition: dsdv-packet.h:123
uint32_t GetHopCount() const
Get hop count.
Definition: dsdv-packet.h:114
Ipv4Address m_dst
Destination IP Address.
Definition: dsdv-packet.h:138
uint32_t GetDstSeqno() const
Get destination sequence number.
Definition: dsdv-packet.h:132
~DsdvHeader() override
Definition: dsdv-packet.cc:49
void Serialize(Buffer::Iterator start) const override
Definition: dsdv-packet.cc:76
static TypeId GetTypeId()
Get the type ID.
Definition: dsdv-packet.cc:54
void SetDst(Ipv4Address destination)
Set destination address.
Definition: dsdv-packet.h:87
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition: dsdv-packet.h:140
void Print(std::ostream &os) const override
Definition: dsdv-packet.cc:98
uint32_t GetSerializedSize() const override
Definition: dsdv-packet.cc:70
void SetHopCount(uint32_t hopCount)
Set hop count.
Definition: dsdv-packet.h:105
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: dsdv-packet.cc:64
static std::ostream & operator<<(std::ostream &os, const DsdvHeader &packet)
Definition: dsdv-packet.h:144
Every class exported by the ns3 library is enclosed in the ns3 namespace.