A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
40namespace ns3
41{
42namespace dsdv
43{
44/**
45 * \ingroup dsdv
46 * \brief DSDV Update Packet Format
47 * \verbatim
48 | 0 | 1 | 2 | 3 |
49 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
50 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 | Destination Address |
52 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 | HopCount |
54 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 | Sequence Number |
56 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * \endverbatim
58 */
59
60class DsdvHeader : public Header
61{
62 public:
63 /**
64 * Constructor
65 *
66 * \param dst destination IP address
67 * \param hopcount hop count
68 * \param dstSeqNo destination sequence number
69 */
70 DsdvHeader(Ipv4Address dst = Ipv4Address(), uint32_t hopcount = 0, uint32_t dstSeqNo = 0);
71 ~DsdvHeader() override;
72 /**
73 * \brief Get the type ID.
74 * \return the object TypeId
75 */
76 static TypeId GetTypeId();
77 TypeId GetInstanceTypeId() const override;
78 uint32_t GetSerializedSize() const override;
79 void Serialize(Buffer::Iterator start) const override;
81 void Print(std::ostream& os) const override;
82
83 /**
84 * Set destination address
85 * \param destination the destination IPv4 address
86 */
87 void SetDst(Ipv4Address destination)
88 {
89 m_dst = destination;
90 }
91
92 /**
93 * Get destination address
94 * \returns the destination IPv4 address
95 */
97 {
98 return m_dst;
99 }
100
101 /**
102 * Set hop count
103 * \param hopCount the hop count
104 */
105 void SetHopCount(uint32_t hopCount)
106 {
107 m_hopCount = hopCount;
108 }
109
110 /**
111 * Get hop count
112 * \returns the hop count
113 */
115 {
116 return m_hopCount;
117 }
118
119 /**
120 * Set destination sequence number
121 * \param sequenceNumber The sequence number
122 */
123 void SetDstSeqno(uint32_t sequenceNumber)
124 {
125 m_dstSeqNo = sequenceNumber;
126 }
127
128 /**
129 * Get destination sequence number
130 * \returns the destination sequence number
131 */
133 {
134 return m_dstSeqNo;
135 }
136
137 private:
138 Ipv4Address m_dst; ///< Destination IP Address
139 uint32_t m_hopCount; ///< Number of Hops
140 uint32_t m_dstSeqNo; ///< Destination Sequence Number
141};
142
143static inline std::ostream&
144operator<<(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
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
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
uint32_t Deserialize(Buffer::Iterator start) override
Definition: dsdv-packet.cc:84
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.