A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
flame-header.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 IITP RAS
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: Kirill Andreev <andreev@iitp.ru>
19
*/
20
#include "ns3/assert.h"
21
#include "ns3/address-utils.h"
22
#include "ns3/packet.h"
23
24
#include "
flame-header.h
"
25
26
namespace
ns3
{
27
namespace
flame {
28
29
NS_OBJECT_ENSURE_REGISTERED
(
FlameHeader
);
30
31
FlameHeader::FlameHeader
() :
32
m_cost (0), m_seqno (0), m_origDst (
Mac48Address
()), m_origSrc (
Mac48Address
())
33
{
34
}
35
FlameHeader::~FlameHeader
()
36
{
37
}
38
TypeId
39
FlameHeader::GetTypeId
(
void
)
40
{
41
static
TypeId
tid =
TypeId
(
"ns3::flame::FlameHeader"
)
42
.
SetParent
<
Header
> ()
43
.SetGroupName (
"Mesh"
)
44
.AddConstructor<
FlameHeader
> ();
45
return
tid;
46
}
47
TypeId
48
FlameHeader::GetInstanceTypeId
(
void
)
const
49
{
50
return
GetTypeId
();
51
}
52
void
53
FlameHeader::Print
(std::ostream &os)
const
54
{
55
os <<
"Cost= "
<< (uint16_t)
m_cost
<<
", Sequence number= "
<<
m_seqno
56
<<
", Orig Destination= "
<<
m_origDst
<<
", Orig Source= "
<<
m_origSrc
;
57
}
58
uint32_t
59
FlameHeader::GetSerializedSize
(
void
)
const
60
{
61
return
1
// Reserved
62
+ 1
// Cost
63
+ 2
// Seqno
64
+ 6
// Orig Dst
65
+ 6
// Orig Src
66
+ 2
// Flame Port
67
;
68
}
69
void
70
FlameHeader::Serialize
(
Buffer::Iterator
start
)
const
71
{
72
Buffer::Iterator
i =
start
;
73
i.
WriteU8
(0);
//Reserved
74
i.
WriteU8
(
m_cost
);
//Cost
75
i.
WriteHtonU16
(
m_seqno
);
//Seqno
76
WriteTo
(i,
m_origDst
);
77
WriteTo
(i,
m_origSrc
);
78
i.
WriteHtonU16
(
m_protocol
);
79
}
80
uint32_t
81
FlameHeader::Deserialize
(
Buffer::Iterator
start
)
82
{
83
Buffer::Iterator
i =
start
;
84
i.
Next
(1);
85
m_cost
= i.
ReadU8
();
86
m_seqno
= i.
ReadNtohU16
();
87
ReadFrom
(i,
m_origDst
);
88
ReadFrom
(i,
m_origSrc
);
89
m_protocol
= i.
ReadNtohU16
();
90
return
i.
GetDistanceFrom
(
start
);
91
}
92
void
93
FlameHeader::AddCost
(uint8_t cost)
94
{
95
m_cost
= (((uint16_t) cost + (uint16_t)
m_cost
) > 255) ? 255 : cost +
m_cost
;
96
}
97
uint8_t
98
FlameHeader::GetCost
()
const
99
{
100
return
m_cost
;
101
}
102
void
103
FlameHeader::SetSeqno
(uint16_t seqno)
104
{
105
m_seqno
= seqno;
106
}
107
uint16_t
108
FlameHeader::GetSeqno
()
const
109
{
110
return
m_seqno
;
111
}
112
void
113
FlameHeader::SetOrigDst
(
Mac48Address
dst)
114
{
115
m_origDst
= dst;
116
}
117
Mac48Address
118
FlameHeader::GetOrigDst
()
const
119
{
120
return
m_origDst
;
121
}
122
void
123
FlameHeader::SetOrigSrc
(
Mac48Address
src)
124
{
125
m_origSrc
= src;
126
}
127
Mac48Address
128
FlameHeader::GetOrigSrc
()
const
129
{
130
return
m_origSrc
;
131
}
132
void
133
FlameHeader::SetProtocol
(uint16_t protocol)
134
{
135
m_protocol
= protocol;
136
}
137
uint16_t
138
FlameHeader::GetProtocol
()
const
139
{
140
return
m_protocol
;
141
}
142
bool
143
operator==
(
const
FlameHeader
& a,
const
FlameHeader
& b)
144
{
145
return
((a.
m_cost
== b.
m_cost
) && (a.
m_seqno
== b.
m_seqno
) && (a.
m_origDst
== b.
m_origDst
) && (a.
m_origSrc
146
== b.
m_origSrc
) && (a.
m_protocol
== b.
m_protocol
));
147
}
148
149
}
// namespace flame
150
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:99
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16(void)
Definition:
buffer.h:946
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:869
ns3::Buffer::Iterator::Next
void Next(void)
go forward by one byte
Definition:
buffer.h:845
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:1021
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition:
buffer.h:905
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:788
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:43
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:44
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:922
ns3::flame::FlameHeader
Flame header.
Definition:
flame-header.h:38
ns3::flame::FlameHeader::m_cost
uint8_t m_cost
cost
Definition:
flame-header.h:109
ns3::flame::FlameHeader::m_origDst
Mac48Address m_origDst
origin destination
Definition:
flame-header.h:111
ns3::flame::FlameHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
flame-header.cc:48
ns3::flame::FlameHeader::m_protocol
uint16_t m_protocol
protocol
Definition:
flame-header.h:113
ns3::flame::FlameHeader::GetCost
uint8_t GetCost() const
Get cost value.
Definition:
flame-header.cc:98
ns3::flame::FlameHeader::~FlameHeader
~FlameHeader()
Definition:
flame-header.cc:35
ns3::flame::FlameHeader::m_seqno
uint16_t m_seqno
sequence number
Definition:
flame-header.h:110
ns3::flame::FlameHeader::FlameHeader
FlameHeader()
Definition:
flame-header.cc:31
ns3::flame::FlameHeader::GetOrigDst
Mac48Address GetOrigDst() const
Get origin destination address.
Definition:
flame-header.cc:118
ns3::flame::FlameHeader::GetOrigSrc
Mac48Address GetOrigSrc() const
Get origin source address.
Definition:
flame-header.cc:128
ns3::flame::FlameHeader::SetOrigSrc
void SetOrigSrc(Mac48Address OrigSrc)
Set origin source function.
Definition:
flame-header.cc:123
ns3::flame::FlameHeader::AddCost
void AddCost(uint8_t cost)
Add cost value.
Definition:
flame-header.cc:93
ns3::flame::FlameHeader::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
flame-header.cc:70
ns3::flame::FlameHeader::GetSeqno
uint16_t GetSeqno() const
Get sequence number value.
Definition:
flame-header.cc:108
ns3::flame::FlameHeader::SetOrigDst
void SetOrigDst(Mac48Address dst)
Set origin destination address.
Definition:
flame-header.cc:113
ns3::flame::FlameHeader::SetProtocol
void SetProtocol(uint16_t protocol)
Set protocol value.
Definition:
flame-header.cc:133
ns3::flame::FlameHeader::m_origSrc
Mac48Address m_origSrc
origin source
Definition:
flame-header.h:112
ns3::flame::FlameHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
flame-header.cc:59
ns3::flame::FlameHeader::Print
virtual void Print(std::ostream &os) const
Definition:
flame-header.cc:53
ns3::flame::FlameHeader::GetProtocol
uint16_t GetProtocol() const
Get protocol value.
Definition:
flame-header.cc:138
ns3::flame::FlameHeader::SetSeqno
void SetSeqno(uint16_t seqno)
Set sequence number value.
Definition:
flame-header.cc:103
ns3::flame::FlameHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
flame-header.cc:39
flame-header.h
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::flame::operator==
bool operator==(const FlameHeader &a, const FlameHeader &b)
Definition:
flame-header.cc:143
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:28
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:1853
src
mesh
model
flame
flame-header.cc
Generated on Tue Feb 6 2024 19:21:24 for ns-3 by
1.9.1