A Discrete-Event Network Simulator
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
10
11#include "ns3/log.h"
12#include "ns3/uinteger.h"
13
14#include <algorithm>
15
16namespace ns3
17{
18
19NS_LOG_COMPONENT_DEFINE("SixLowPanMeshUnderRouting");
21
24{
25 static TypeId tid =
26 TypeId("ns3::SixLowPanMeshUnderRouting")
28 .SetGroupName("SixLowPan")
29 .AddAttribute("MeshCacheLength",
30 "Per-originator cache size used for duplicate detection.",
31 UintegerValue(10),
34 return tid;
35}
36
41
46
47void
54
55bool
56SixLowPanMeshUnderRouting::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
67void
68SixLowPanMeshUnderRouting::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
79void
81{
82 NS_LOG_FUNCTION(this << originator << +seqNo);
83 // Default no-op. Subclasses may override to react to duplicates.
84}
85
86} // namespace ns3
a polymophic address class
Definition address.h:114
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
virtual void DoDispose()
Destructor implementation.
Definition object.cc:431
Abstract base class for 6LoWPAN mesh-under forwarding policies.
static TypeId GetTypeId()
Get the type ID.
void RecordPacket(const Address &originator, uint8_t seqNo)
Record a (originator, sequence) pair in the cache.
void DoDispose() override
Destructor implementation.
uint16_t m_meshCacheLength
Maximum cache size per originator. Oldest entry dropped beyond this (FIFO).
bool IsDuplicate(const Address &originator, uint8_t seqNo) const
Check whether a (originator, sequence) pair has already been seen.
virtual void OnDuplicateReceived(const Address &originator, uint8_t seqNo)
React to a duplicate packet reception.
std::map< Address, std::deque< uint8_t > > m_seenPkts
Per-originator FIFO of recently seen BC0 sequence numbers.
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1003
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#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.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35