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
simple-frame-capture-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7
*/
8
9
#include "
simple-frame-capture-model.h
"
10
11
#include "
interference-helper.h
"
12
#include "
wifi-utils.h
"
13
14
#include "ns3/double.h"
15
#include "ns3/log.h"
16
#include "ns3/simulator.h"
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"SimpleFrameCaptureModel"
);
22
23
NS_OBJECT_ENSURE_REGISTERED
(SimpleFrameCaptureModel);
24
25
TypeId
26
SimpleFrameCaptureModel::GetTypeId
()
27
{
28
static
TypeId
tid =
29
TypeId
(
"ns3::SimpleFrameCaptureModel"
)
30
.
SetParent
<
FrameCaptureModel
>()
31
.SetGroupName(
"Wifi"
)
32
.AddConstructor<
SimpleFrameCaptureModel
>()
33
.AddAttribute(
34
"Margin"
,
35
"Reception is switched if the newly arrived frame has a power higher than "
36
"this value above the frame currently being received (expressed in dB)."
,
37
DoubleValue
(5),
38
MakeDoubleAccessor
(&
SimpleFrameCaptureModel::GetMargin
,
39
&
SimpleFrameCaptureModel::SetMargin
),
40
MakeDoubleChecker<dB_u>
());
41
return
tid;
42
}
43
44
SimpleFrameCaptureModel::SimpleFrameCaptureModel
()
45
{
46
NS_LOG_FUNCTION
(
this
);
47
}
48
49
SimpleFrameCaptureModel::~SimpleFrameCaptureModel
()
50
{
51
NS_LOG_FUNCTION
(
this
);
52
}
53
54
void
55
SimpleFrameCaptureModel::SetMargin
(
dB_u
margin)
56
{
57
NS_LOG_FUNCTION
(
this
<< margin);
58
m_margin
= margin;
59
}
60
61
dB_u
62
SimpleFrameCaptureModel::GetMargin
()
const
63
{
64
return
m_margin
;
65
}
66
67
bool
68
SimpleFrameCaptureModel::CaptureNewFrame
(
Ptr<Event>
currentEvent,
Ptr<Event>
newEvent)
const
69
{
70
NS_LOG_FUNCTION
(
this
);
71
return
WToDbm
(currentEvent->GetRxPower()) +
GetMargin
() <
WToDbm
(newEvent->GetRxPower()) &&
72
IsInCaptureWindow
(currentEvent->GetStartTime());
73
}
74
75
}
// namespace ns3
double
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::FrameCaptureModel
the interface for Wifi's frame capture models
Definition
frame-capture-model.h:27
ns3::FrameCaptureModel::IsInCaptureWindow
virtual bool IsInCaptureWindow(Time timePreambleDetected) const
This method returns true if the capture window duration has not elapsed yet, false otherwise.
Definition
frame-capture-model.cc:34
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SimpleFrameCaptureModel
A simple threshold-based model for frame capture effect.
Definition
simple-frame-capture-model.h:28
ns3::SimpleFrameCaptureModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
simple-frame-capture-model.cc:26
ns3::SimpleFrameCaptureModel::~SimpleFrameCaptureModel
~SimpleFrameCaptureModel() override
Definition
simple-frame-capture-model.cc:49
ns3::SimpleFrameCaptureModel::GetMargin
dB_u GetMargin() const
Return the frame capture margin.
Definition
simple-frame-capture-model.cc:62
ns3::SimpleFrameCaptureModel::SimpleFrameCaptureModel
SimpleFrameCaptureModel()
Definition
simple-frame-capture-model.cc:44
ns3::SimpleFrameCaptureModel::m_margin
dB_u m_margin
margin for determining if a new frame
Definition
simple-frame-capture-model.h:65
ns3::SimpleFrameCaptureModel::CaptureNewFrame
bool CaptureNewFrame(Ptr< Event > currentEvent, Ptr< Event > newEvent) const override
This method returns whether the reception should be switched to a new incoming frame.
Definition
simple-frame-capture-model.cc:68
ns3::SimpleFrameCaptureModel::SetMargin
void SetMargin(dB_u margin)
Sets the frame capture margin.
Definition
simple-frame-capture-model.cc:55
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
interference-helper.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::WToDbm
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
Definition
wifi-utils.cc:37
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
ns3::dB_u
double dB_u
dB weak type
Definition
wifi-units.h:28
simple-frame-capture-model.h
wifi-utils.h
src
wifi
model
simple-frame-capture-model.cc
Generated on Fri Nov 8 2024 13:59:08 for ns-3 by
1.11.0