A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
sixlowpan-mesh-under-routing.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2026 SRM Institute of Science and Technology, India
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Usham Roy <ushamroy80@gmail.com>
7
*/
8
9
#include "
sixlowpan-mesh-under-routing.h
"
10
11
#include "ns3/log.h"
12
#include "ns3/uinteger.h"
13
14
#include <algorithm>
15
16
namespace
ns3
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"SixLowPanMeshUnderRouting"
);
20
NS_OBJECT_ENSURE_REGISTERED
(
SixLowPanMeshUnderRouting
);
21
22
TypeId
23
SixLowPanMeshUnderRouting::GetTypeId
()
24
{
25
static
TypeId
tid =
26
TypeId
(
"ns3::SixLowPanMeshUnderRouting"
)
27
.
SetParent
<
Object
>()
28
.SetGroupName(
"SixLowPan"
)
29
.AddAttribute(
"MeshCacheLength"
,
30
"Per-originator cache size used for duplicate detection."
,
31
UintegerValue
(10),
32
MakeUintegerAccessor
(&
SixLowPanMeshUnderRouting::m_meshCacheLength
),
33
MakeUintegerChecker<uint16_t>
());
34
return
tid;
35
}
36
37
SixLowPanMeshUnderRouting::SixLowPanMeshUnderRouting
()
38
{
39
NS_LOG_FUNCTION
(
this
);
40
}
41
42
SixLowPanMeshUnderRouting::~SixLowPanMeshUnderRouting
()
43
{
44
NS_LOG_FUNCTION
(
this
);
45
}
46
47
void
48
SixLowPanMeshUnderRouting::DoDispose
()
49
{
50
NS_LOG_FUNCTION
(
this
);
51
m_seenPkts
.clear();
52
Object::DoDispose
();
53
}
54
55
bool
56
SixLowPanMeshUnderRouting::IsDuplicate
(
const
Address
& originator, uint8_t seqNo)
const
57
{
58
NS_LOG_FUNCTION
(
this
<< originator << +seqNo);
59
auto
it =
m_seenPkts
.find(originator);
60
if
(it ==
m_seenPkts
.end())
61
{
62
return
false
;
63
}
64
return
std::find(it->second.begin(), it->second.end(), seqNo) != it->second.end();
65
}
66
67
void
68
SixLowPanMeshUnderRouting::RecordPacket
(
const
Address
& originator, uint8_t seqNo)
69
{
70
NS_LOG_FUNCTION
(
this
<< originator << +seqNo);
71
auto
& queue =
m_seenPkts
[originator];
72
queue.push_back(seqNo);
73
if
(queue.size() >
m_meshCacheLength
)
74
{
75
queue.pop_front();
76
}
77
}
78
79
void
80
SixLowPanMeshUnderRouting::OnDuplicateReceived
(
const
Address
& originator, uint8_t seqNo)
81
{
82
NS_LOG_FUNCTION
(
this
<< originator << +seqNo);
83
// Default no-op. Subclasses may override to react to duplicates.
84
}
85
86
}
// namespace ns3
ns3::Address
a polymophic address class
Definition
address.h:114
ns3::Object::Object
Object()
Caller graph was not generated because of its size.
Definition
object.cc:93
ns3::Object::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition
object.cc:431
ns3::SixLowPanMeshUnderRouting
Abstract base class for 6LoWPAN mesh-under forwarding policies.
Definition
sixlowpan-mesh-under-routing.h:50
ns3::SixLowPanMeshUnderRouting::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
sixlowpan-mesh-under-routing.cc:23
ns3::SixLowPanMeshUnderRouting::SixLowPanMeshUnderRouting
SixLowPanMeshUnderRouting()
Definition
sixlowpan-mesh-under-routing.cc:37
ns3::SixLowPanMeshUnderRouting::RecordPacket
void RecordPacket(const Address &originator, uint8_t seqNo)
Record a (originator, sequence) pair in the cache.
Definition
sixlowpan-mesh-under-routing.cc:68
ns3::SixLowPanMeshUnderRouting::DoDispose
void DoDispose() override
Destructor implementation.
Definition
sixlowpan-mesh-under-routing.cc:48
ns3::SixLowPanMeshUnderRouting::m_meshCacheLength
uint16_t m_meshCacheLength
Maximum cache size per originator. Oldest entry dropped beyond this (FIFO).
Definition
sixlowpan-mesh-under-routing.h:144
ns3::SixLowPanMeshUnderRouting::IsDuplicate
bool IsDuplicate(const Address &originator, uint8_t seqNo) const
Check whether a (originator, sequence) pair has already been seen.
Definition
sixlowpan-mesh-under-routing.cc:56
ns3::SixLowPanMeshUnderRouting::OnDuplicateReceived
virtual void OnDuplicateReceived(const Address &originator, uint8_t seqNo)
React to a duplicate packet reception.
Definition
sixlowpan-mesh-under-routing.cc:80
ns3::SixLowPanMeshUnderRouting::~SixLowPanMeshUnderRouting
~SixLowPanMeshUnderRouting() override
Definition
sixlowpan-mesh-under-routing.cc:42
ns3::SixLowPanMeshUnderRouting::m_seenPkts
std::map< Address, std::deque< uint8_t > > m_seenPkts
Per-originator FIFO of recently seen BC0 sequence numbers.
Definition
sixlowpan-mesh-under-routing.h:141
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1003
ns3::UintegerValue
Hold an unsigned integer type.
Definition
uinteger.h:34
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:201
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:214
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeUintegerChecker
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition
uinteger.h:85
ns3::MakeUintegerAccessor
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition
uinteger.h:35
sixlowpan-mesh-under-routing.h
src
sixlowpan
model
sixlowpan-mesh-under-routing.cc
Generated on
for ns-3 by
1.16.1