A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sixlowpan-simple-flooding.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/nstime.h"
13#include "ns3/pointer.h"
14#include "ns3/simulator.h"
15#include "ns3/string.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("SixLowPanSimpleFlooding");
22
25{
26 static TypeId tid =
27 TypeId("ns3::SixLowPanSimpleFlooding")
29 .SetGroupName("SixLowPan")
30 .AddConstructor<SixLowPanSimpleFlooding>()
31 .AddAttribute("MeshUnderJitter",
32 "The jitter (in ms) before each mesh-under rebroadcast. "
33 "Same name and default as the historical SixLowPanNetDevice "
34 "attribute, preserving backward-compatible behavior.",
35 StringValue("ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
38 return tid;
39}
40
45
50
51void
58
59void
61 const Address& originator,
62 uint8_t seqNo,
63 uint8_t hopsLeft,
64 ForwardCallback forwardCb)
65{
66 NS_LOG_FUNCTION(this << packet << originator << +seqNo << +hopsLeft);
67 Time jitter = MilliSeconds(m_jitter->GetValue());
68 // Rebroadcast after the jitter delay. Simulator::Schedule does not
69 // accept a Callback with unbound arguments, hence the small lambda.
70 Simulator::Schedule(jitter, [forwardCb, packet]() { forwardCb(packet); });
71}
72
73int64_t
75{
76 NS_LOG_FUNCTION(this << stream);
77 m_jitter->SetStream(stream);
78 return 1;
79}
80
81} // namespace ns3
a polymophic address class
Definition address.h:114
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:580
Callback< void, Ptr< Packet > > ForwardCallback
Callback used by a policy to forward a packet.
void DoDispose() override
Destructor implementation.
Default mesh-under forwarding policy: unconditional rebroadcast with jitter.
static TypeId GetTypeId()
Get the type ID.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random stream number to RNGs used by the policy.
void OnPacketForward(Ptr< Packet > packet, const Address &originator, uint8_t seqNo, uint8_t hopsLeft, ForwardCallback forwardCb) override
Decide whether (and when) to forward a new mesh-under packet.
Ptr< RandomVariableStream > m_jitter
Random variable (in milliseconds) used to schedule each rebroadcast.
void DoDispose() override
Destructor implementation.
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1003
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:250
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:273
#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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1330
Every class exported by the ns3 library is enclosed in the ns3 namespace.