A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
35namespace ns3
36{
37namespace dsdv
38{
39
41
43 : m_dst(dst),
44 m_hopCount(hopCount),
45 m_dstSeqNo(dstSeqNo)
46{
47}
48
50{
51}
52
55{
56 static TypeId tid = TypeId("ns3::dsdv::DsdvHeader")
58 .SetGroupName("Dsdv")
59 .AddConstructor<DsdvHeader>();
60 return tid;
61}
62
65{
66 return GetTypeId();
67}
68
71{
72 return 12;
73}
74
75void
77{
78 WriteTo(i, m_dst);
81}
82
85{
86 Buffer::Iterator i = start;
87
88 ReadFrom(i, m_dst);
91
92 uint32_t dist = i.GetDistanceFrom(start);
94 return dist;
95}
96
97void
98DsdvHeader::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
iterator in a Buffer instance
Definition: buffer.h:100
uint32_t ReadNtohU32()
Definition: buffer.h:978
void WriteHtonU32(uint32_t data)
Definition: buffer.h:933
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
Protocol header serialization and deserialization.
Definition: header.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
DSDV Update Packet Format.
Definition: dsdv-packet.h:61
uint32_t m_hopCount
Number of Hops.
Definition: dsdv-packet.h:139
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Definition: dsdv-packet.cc:42
Ipv4Address m_dst
Destination IP Address.
Definition: dsdv-packet.h:138
~DsdvHeader() override
Definition: dsdv-packet.cc:49
void Serialize(Buffer::Iterator start) const override
Definition: dsdv-packet.cc:76
static TypeId GetTypeId()
Get the type ID.
Definition: dsdv-packet.cc:54
uint32_t m_dstSeqNo
Destination Sequence Number.
Definition: dsdv-packet.h:140
void Print(std::ostream &os) const override
Definition: dsdv-packet.cc:98
uint32_t GetSerializedSize() const override
Definition: dsdv-packet.cc:70
uint32_t Deserialize(Buffer::Iterator start) override
Definition: dsdv-packet.cc:84
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: dsdv-packet.cc:64
#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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.