A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
dsdv-packet.cc
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
#include "
dsdv-packet.h
"
31
32
#include "ns3/address-utils.h"
33
#include "ns3/packet.h"
34
35
namespace
ns3
36
{
37
namespace
dsdv
38
{
39
40
NS_OBJECT_ENSURE_REGISTERED
(DsdvHeader);
41
42
DsdvHeader::DsdvHeader
(
Ipv4Address
dst, uint32_t hopCount, uint32_t dstSeqNo)
43
: m_dst(dst),
44
m_hopCount(hopCount),
45
m_dstSeqNo(dstSeqNo)
46
{
47
}
48
49
DsdvHeader::~DsdvHeader
()
50
{
51
}
52
53
TypeId
54
DsdvHeader::GetTypeId
()
55
{
56
static
TypeId
tid =
TypeId
(
"ns3::dsdv::DsdvHeader"
)
57
.
SetParent
<
Header
>()
58
.SetGroupName(
"Dsdv"
)
59
.AddConstructor<
DsdvHeader
>();
60
return
tid;
61
}
62
63
TypeId
64
DsdvHeader::GetInstanceTypeId
()
const
65
{
66
return
GetTypeId
();
67
}
68
69
uint32_t
70
DsdvHeader::GetSerializedSize
()
const
71
{
72
return
12;
73
}
74
75
void
76
DsdvHeader::Serialize
(
Buffer::Iterator
i)
const
77
{
78
WriteTo
(i,
m_dst
);
79
i.
WriteHtonU32
(
m_hopCount
);
80
i.
WriteHtonU32
(
m_dstSeqNo
);
81
}
82
83
uint32_t
84
DsdvHeader::Deserialize
(
Buffer::Iterator
start
)
85
{
86
Buffer::Iterator
i =
start
;
87
88
ReadFrom
(i,
m_dst
);
89
m_hopCount
= i.
ReadNtohU32
();
90
m_dstSeqNo
= i.
ReadNtohU32
();
91
92
uint32_t dist = i.
GetDistanceFrom
(
start
);
93
NS_ASSERT
(dist ==
GetSerializedSize
());
94
return
dist;
95
}
96
97
void
98
DsdvHeader::Print
(std::ostream& os)
const
99
{
100
os <<
"DestinationIpv4: "
<<
m_dst
<<
" Hopcount: "
<<
m_hopCount
101
<<
" SequenceNumber: "
<<
m_dstSeqNo
;
102
}
103
}
// namespace dsdv
104
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32()
Definition:
buffer.h:978
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition:
buffer.h:933
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(const Iterator &o) const
Definition:
buffer.cc:780
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
ns3::dsdv::DsdvHeader
DSDV Update Packet Format.
Definition:
dsdv-packet.h:61
ns3::dsdv::DsdvHeader::m_hopCount
uint32_t m_hopCount
Number of Hops.
Definition:
dsdv-packet.h:139
ns3::dsdv::DsdvHeader::DsdvHeader
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Definition:
dsdv-packet.cc:42
ns3::dsdv::DsdvHeader::m_dst
Ipv4Address m_dst
Destination IP Address.
Definition:
dsdv-packet.h:138
ns3::dsdv::DsdvHeader::~DsdvHeader
~DsdvHeader() override
Definition:
dsdv-packet.cc:49
ns3::dsdv::DsdvHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
dsdv-packet.cc:76
ns3::dsdv::DsdvHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
dsdv-packet.cc:54
ns3::dsdv::DsdvHeader::m_dstSeqNo
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition:
dsdv-packet.h:140
ns3::dsdv::DsdvHeader::Print
void Print(std::ostream &os) const override
Definition:
dsdv-packet.cc:98
ns3::dsdv::DsdvHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
dsdv-packet.cc:70
ns3::dsdv::DsdvHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
dsdv-packet.cc:64
dsdv-packet.h
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition:
address-utils.cc:31
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition:
address-utils.cc:84
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
src
dsdv
model
dsdv-packet.cc
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1