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 * 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
24namespace ns3
25{
26namespace dsdv
27{
28
30
32 : m_dst(dst),
33 m_hopCount(hopCount),
34 m_dstSeqNo(dstSeqNo)
35{
36}
37
41
44{
45 static TypeId tid = TypeId("ns3::dsdv::DsdvHeader")
47 .SetGroupName("Dsdv")
48 .AddConstructor<DsdvHeader>();
49 return tid;
50}
51
54{
55 return GetTypeId();
56}
57
60{
61 return 12;
62}
63
64void
71
74{
75 Buffer::Iterator i = start;
76
77 ReadFrom(i, m_dst);
80
81 uint32_t dist = i.GetDistanceFrom(start);
83 return dist;
84}
85
86void
87DsdvHeader::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
iterator in a Buffer instance
Definition buffer.h:89
uint32_t ReadNtohU32()
Definition buffer.h:967
void WriteHtonU32(uint32_t data)
Definition buffer.h:922
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
Protocol header serialization and deserialization.
Definition header.h:33
Ipv4 addresses are stored in host order in this class.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
DSDV Update Packet Format.
Definition dsdv-packet.h:50
uint32_t m_hopCount
Number of Hops.
DsdvHeader(Ipv4Address dst=Ipv4Address(), uint32_t hopcount=0, uint32_t dstSeqNo=0)
Constructor.
Ipv4Address m_dst
Destination IP Address.
void Serialize(Buffer::Iterator start) const override
static TypeId GetTypeId()
Get the type ID.
uint32_t m_dstSeqNo
Destination Sequence Number.
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
#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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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.