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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Hemanth Narra <hemanth@ittc.ku.com>
7 *
8 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
9 * ResiliNets Research Group https://resilinets.org/
10 * Information and Telecommunication Technology Center (ITTC)
11 * and Department of Electrical Engineering and Computer Science
12 * The University of Kansas Lawrence, KS USA.
13 *
14 * Work supported in part by NSF FIND (Future Internet Design) Program
15 * under grant CNS-0626918 (Postmodern Internet Architecture),
16 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
17 * US Department of Defense (DoD), and ITTC at The University of Kansas.
18 */
19
20#ifndef DSDV_PACKET_H
21#define DSDV_PACKET_H
22
23#include "ns3/header.h"
24#include "ns3/ipv4-address.h"
25#include "ns3/nstime.h"
26
27#include <iostream>
28
29namespace ns3
30{
31namespace dsdv
32{
33/**
34 * \ingroup dsdv
35 * \brief DSDV Update Packet Format
36 * \verbatim
37 | 0 | 1 | 2 | 3 |
38 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
39 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 | Destination Address |
41 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 | HopCount |
43 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 | Sequence Number |
45 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * \endverbatim
47 */
48
49class DsdvHeader : public Header
50{
51 public:
52 /**
53 * Constructor
54 *
55 * \param dst destination IP address
56 * \param hopcount hop count
57 * \param dstSeqNo destination sequence number
58 */
59 DsdvHeader(Ipv4Address dst = Ipv4Address(), uint32_t hopcount = 0, uint32_t dstSeqNo = 0);
60 ~DsdvHeader() override;
61 /**
62 * \brief Get the type ID.
63 * \return the object TypeId
64 */
65 static TypeId GetTypeId();
66 TypeId GetInstanceTypeId() const override;
67 uint32_t GetSerializedSize() const override;
68 void Serialize(Buffer::Iterator start) const override;
70 void Print(std::ostream& os) const override;
71
72 /**
73 * Set destination address
74 * \param destination the destination IPv4 address
75 */
76 void SetDst(Ipv4Address destination)
77 {
78 m_dst = destination;
79 }
80
81 /**
82 * Get destination address
83 * \returns the destination IPv4 address
84 */
86 {
87 return m_dst;
88 }
89
90 /**
91 * Set hop count
92 * \param hopCount the hop count
93 */
94 void SetHopCount(uint32_t hopCount)
95 {
96 m_hopCount = hopCount;
97 }
98
99 /**
100 * Get hop count
101 * \returns the hop count
102 */
104 {
105 return m_hopCount;
106 }
107
108 /**
109 * Set destination sequence number
110 * \param sequenceNumber The sequence number
111 */
112 void SetDstSeqno(uint32_t sequenceNumber)
113 {
114 m_dstSeqNo = sequenceNumber;
115 }
116
117 /**
118 * Get destination sequence number
119 * \returns the destination sequence number
120 */
122 {
123 return m_dstSeqNo;
124 }
125
126 private:
127 Ipv4Address m_dst; ///< Destination IP Address
128 uint32_t m_hopCount; ///< Number of Hops
129 uint32_t m_dstSeqNo; ///< Destination Sequence Number
130};
131
132static inline std::ostream&
133operator<<(std::ostream& os, const DsdvHeader& packet)
134{
135 packet.Print(os);
136 return os;
137}
138} // namespace dsdv
139} // namespace ns3
140
141#endif /* DSDV_PACKET_H */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
Ipv4 addresses are stored in host order in this class.
a unique identifier for an interface.
Definition type-id.h:48
DSDV Update Packet Format.
Definition dsdv-packet.h:50
uint32_t m_hopCount
Number of Hops.
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Ipv4Address GetDst() const
Get destination address.
Definition dsdv-packet.h:85
void SetDstSeqno(uint32_t sequenceNumber)
Set destination sequence number.
uint32_t GetHopCount() const
Get hop count.
Ipv4Address m_dst
Destination IP Address.
uint32_t GetDstSeqno() const
Get destination sequence number.
void Serialize(Buffer::Iterator start) const override
static TypeId GetTypeId()
Get the type ID.
void SetDst(Ipv4Address destination)
Set destination address.
Definition dsdv-packet.h:76
uint32_t m_dstSeqNo
Destination Sequence Number.
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
void SetHopCount(uint32_t hopCount)
Set hop count.
Definition dsdv-packet.h:94
uint32_t Deserialize(Buffer::Iterator start) override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static std::ostream & operator<<(std::ostream &os, const DsdvHeader &packet)
Every class exported by the ns3 library is enclosed in the ns3 namespace.