A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
NS_OBJECT_ENSURE_REGISTERED
(DsdvHeader);
38
DsdvHeader::DsdvHeader
(
Ipv4Address
dst, uint32_t hopCount, uint32_t dstSeqNo)
39
: m_dst (dst),
40
m_hopCount (hopCount),
41
m_dstSeqNo (dstSeqNo)
42
{
43
}
44
45
DsdvHeader::~DsdvHeader
()
46
{
47
}
48
49
TypeId
50
DsdvHeader::GetTypeId
(
void
)
51
{
52
static
TypeId
tid =
TypeId
(
"ns3::dsdv::DsdvHeader"
)
53
.
SetParent
<
Header
> ()
54
.AddConstructor<DsdvHeader> ();
55
return
tid;
56
}
57
58
TypeId
59
DsdvHeader::GetInstanceTypeId
()
const
60
{
61
return
GetTypeId
();
62
}
63
64
uint32_t
65
DsdvHeader::GetSerializedSize
()
const
66
{
67
return
12;
68
}
69
70
void
71
DsdvHeader::Serialize
(
Buffer::Iterator
i)
const
72
{
73
WriteTo
(i,
m_dst
);
74
i.
WriteHtonU32
(
m_hopCount
);
75
i.
WriteHtonU32
(
m_dstSeqNo
);
76
77
}
78
79
uint32_t
80
DsdvHeader::Deserialize
(
Buffer::Iterator
start
)
81
{
82
Buffer::Iterator
i =
start
;
83
84
ReadFrom
(i,
m_dst
);
85
m_hopCount
= i.
ReadNtohU32
();
86
m_dstSeqNo
= i.
ReadNtohU32
();
87
88
uint32_t dist = i.
GetDistanceFrom
(start);
89
NS_ASSERT
(dist ==
GetSerializedSize
());
90
return
dist;
91
}
92
93
void
94
DsdvHeader::Print
(std::ostream &os)
const
95
{
96
os <<
"DestinationIpv4: "
<<
m_dst
97
<<
" Hopcount: "
<<
m_hopCount
98
<<
" SequenceNumber: "
<<
m_dstSeqNo
;
99
}
100
}
101
}
src
dsdv
model
dsdv-packet.cc
Generated on Tue May 14 2013 11:08:19 for ns-3 by
1.8.1.2