A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
dsdv-packet.cc
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
#include "
dsdv-packet.h
"
20
21
#include "ns3/address-utils.h"
22
#include "ns3/packet.h"
23
24
namespace
ns3
25
{
26
namespace
dsdv
27
{
28
29
NS_OBJECT_ENSURE_REGISTERED
(DsdvHeader);
30
31
DsdvHeader::DsdvHeader
(
Ipv4Address
dst,
uint32_t
hopCount,
uint32_t
dstSeqNo)
32
: m_dst(dst),
33
m_hopCount(hopCount),
34
m_dstSeqNo(dstSeqNo)
35
{
36
}
37
38
DsdvHeader::~DsdvHeader
()
39
{
40
}
41
42
TypeId
43
DsdvHeader::GetTypeId
()
44
{
45
static
TypeId
tid =
TypeId
(
"ns3::dsdv::DsdvHeader"
)
46
.
SetParent
<
Header
>()
47
.SetGroupName(
"Dsdv"
)
48
.AddConstructor<
DsdvHeader
>();
49
return
tid;
50
}
51
52
TypeId
53
DsdvHeader::GetInstanceTypeId
()
const
54
{
55
return
GetTypeId
();
56
}
57
58
uint32_t
59
DsdvHeader::GetSerializedSize
()
const
60
{
61
return
12;
62
}
63
64
void
65
DsdvHeader::Serialize
(
Buffer::Iterator
i)
const
66
{
67
WriteTo
(i,
m_dst
);
68
i.
WriteHtonU32
(
m_hopCount
);
69
i.
WriteHtonU32
(
m_dstSeqNo
);
70
}
71
72
uint32_t
73
DsdvHeader::Deserialize
(
Buffer::Iterator
start)
74
{
75
Buffer::Iterator
i = start;
76
77
ReadFrom
(i,
m_dst
);
78
m_hopCount
= i.
ReadNtohU32
();
79
m_dstSeqNo
= i.
ReadNtohU32
();
80
81
uint32_t
dist = i.
GetDistanceFrom
(start);
82
NS_ASSERT
(dist ==
GetSerializedSize
());
83
return
dist;
84
}
85
86
void
87
DsdvHeader::Print
(std::ostream& os)
const
88
{
89
os <<
"DestinationIpv4: "
<<
m_dst
<<
" Hopcount: "
<<
m_hopCount
90
<<
" SequenceNumber: "
<<
m_dstSeqNo
;
91
}
92
}
// namespace dsdv
93
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32()
Definition
buffer.h:967
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition
buffer.h:922
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(const Iterator &o) const
Definition
buffer.cc:769
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::dsdv::DsdvHeader
DSDV Update Packet Format.
Definition
dsdv-packet.h:50
ns3::dsdv::DsdvHeader::m_hopCount
uint32_t m_hopCount
Number of Hops.
Definition
dsdv-packet.h:128
ns3::dsdv::DsdvHeader::DsdvHeader
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Definition
dsdv-packet.cc:31
ns3::dsdv::DsdvHeader::m_dst
Ipv4Address m_dst
Destination IP Address.
Definition
dsdv-packet.h:127
ns3::dsdv::DsdvHeader::~DsdvHeader
~DsdvHeader() override
Definition
dsdv-packet.cc:38
ns3::dsdv::DsdvHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
dsdv-packet.cc:65
ns3::dsdv::DsdvHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
dsdv-packet.cc:43
ns3::dsdv::DsdvHeader::m_dstSeqNo
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition
dsdv-packet.h:129
ns3::dsdv::DsdvHeader::Print
void Print(std::ostream &os) const override
Definition
dsdv-packet.cc:87
ns3::dsdv::DsdvHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
dsdv-packet.cc:59
ns3::dsdv::DsdvHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
dsdv-packet.cc:73
ns3::dsdv::DsdvHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
dsdv-packet.cc:53
uint32_t
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:55
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
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:21
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition
address-utils.cc:74
src
dsdv
model
dsdv-packet.cc
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0