A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
dsdv
model
dsdv-packet.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Hemanth Narra
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Hemanth Narra <hemanth@ittc.ku.com>
19
*
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
* Work supported in part by NSF FIND (Future Internet Design) Program
27
* under grant CNS-0626918 (Postmodern Internet Architecture),
28
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29
* US Department of Defense (DoD), and ITTC at The University of Kansas.
30
*/
31
#include "
dsdv-packet.h
"
32
#include "ns3/address-utils.h"
33
#include "ns3/packet.h"
34
35
namespace
ns3
{
36
namespace
dsdv {
37
38
NS_OBJECT_ENSURE_REGISTERED
(DsdvHeader);
39
40
DsdvHeader::DsdvHeader
(
Ipv4Address
dst, uint32_t hopCount, uint32_t dstSeqNo)
41
: m_dst (dst),
42
m_hopCount (hopCount),
43
m_dstSeqNo (dstSeqNo)
44
{
45
}
46
47
DsdvHeader::~DsdvHeader
()
48
{
49
}
50
51
TypeId
52
DsdvHeader::GetTypeId
(
void
)
53
{
54
static
TypeId
tid =
TypeId
(
"ns3::dsdv::DsdvHeader"
)
55
.
SetParent
<
Header
> ()
56
.SetGroupName (
"Dsdv"
)
57
.AddConstructor<
DsdvHeader
> ();
58
return
tid;
59
}
60
61
TypeId
62
DsdvHeader::GetInstanceTypeId
()
const
63
{
64
return
GetTypeId
();
65
}
66
67
uint32_t
68
DsdvHeader::GetSerializedSize
()
const
69
{
70
return
12;
71
}
72
73
void
74
DsdvHeader::Serialize
(
Buffer::Iterator
i)
const
75
{
76
WriteTo
(i,
m_dst
);
77
i.
WriteHtonU32
(
m_hopCount
);
78
i.
WriteHtonU32
(
m_dstSeqNo
);
79
80
}
81
82
uint32_t
83
DsdvHeader::Deserialize
(
Buffer::Iterator
start
)
84
{
85
Buffer::Iterator
i =
start
;
86
87
ReadFrom
(i,
m_dst
);
88
m_hopCount
= i.
ReadNtohU32
();
89
m_dstSeqNo
= i.
ReadNtohU32
();
90
91
uint32_t dist = i.
GetDistanceFrom
(
start
);
92
NS_ASSERT
(dist ==
GetSerializedSize
());
93
return
dist;
94
}
95
96
void
97
DsdvHeader::Print
(std::ostream &os)
const
98
{
99
os <<
"DestinationIpv4: "
<<
m_dst
100
<<
" Hopcount: "
<<
m_hopCount
101
<<
" SequenceNumber: "
<<
m_dstSeqNo
;
102
}
103
}
104
}
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::dsdv::DsdvHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
dsdv-packet.cc:62
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition:
address-utils.cc:70
visualizer.core.start
def start()
Definition:
core.py:1844
ns3::dsdv::DsdvHeader::GetSerializedSize
virtual uint32_t GetSerializedSize() const
Definition:
dsdv-packet.cc:68
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:67
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition:
address-utils.cc:28
ns3::dsdv::DsdvHeader::m_hopCount
uint32_t m_hopCount
Number of Hops.
Definition:
dsdv-packet.h:137
ns3::dsdv::DsdvHeader::m_dstSeqNo
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition:
dsdv-packet.h:138
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32(void)
Definition:
buffer.h:970
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:783
ns3::dsdv::DsdvHeader::Print
virtual void Print(std::ostream &os) const
Definition:
dsdv-packet.cc:97
ns3::dsdv::DsdvHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
dsdv-packet.cc:52
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition:
buffer.h:924
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:40
dsdv-packet.h
ns3::dsdv::DsdvHeader::m_dst
Ipv4Address m_dst
Destination IP Address.
Definition:
dsdv-packet.h:136
ns3::dsdv::DsdvHeader
DSDV Update Packet Format
Definition:
dsdv-packet.h:58
ns3::dsdv::DsdvHeader::~DsdvHeader
virtual ~DsdvHeader()
Definition:
dsdv-packet.cc:47
ns3::dsdv::DsdvHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
dsdv-packet.cc:74
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:915
ns3::dsdv::DsdvHeader::DsdvHeader
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Definition:
dsdv-packet.cc:40
ns3::dsdv::DsdvHeader::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
dsdv-packet.cc:83
Generated on Wed Nov 7 2018 10:01:51 for ns-3 by
1.8.14