A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
simple-frame-capture-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
18
*/
19
20
#include "
simple-frame-capture-model.h
"
21
22
#include "
interference-helper.h
"
23
#include "
wifi-utils.h
"
24
25
#include "ns3/double.h"
26
#include "ns3/log.h"
27
#include "ns3/simulator.h"
28
29
namespace
ns3
30
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"SimpleFrameCaptureModel"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(SimpleFrameCaptureModel);
35
36
TypeId
37
SimpleFrameCaptureModel::GetTypeId
()
38
{
39
static
TypeId
tid =
40
TypeId
(
"ns3::SimpleFrameCaptureModel"
)
41
.
SetParent
<
FrameCaptureModel
>()
42
.SetGroupName(
"Wifi"
)
43
.AddConstructor<
SimpleFrameCaptureModel
>()
44
.AddAttribute(
45
"Margin"
,
46
"Reception is switched if the newly arrived frame has a power higher than "
47
"this value above the frame currently being received (expressed in dB)."
,
48
DoubleValue
(5),
49
MakeDoubleAccessor
(&
SimpleFrameCaptureModel::GetMargin
,
50
&
SimpleFrameCaptureModel::SetMargin
),
51
MakeDoubleChecker<double>());
52
return
tid;
53
}
54
55
SimpleFrameCaptureModel::SimpleFrameCaptureModel
()
56
{
57
NS_LOG_FUNCTION
(
this
);
58
}
59
60
SimpleFrameCaptureModel::~SimpleFrameCaptureModel
()
61
{
62
NS_LOG_FUNCTION
(
this
);
63
}
64
65
void
66
SimpleFrameCaptureModel::SetMargin
(
double
margin)
67
{
68
NS_LOG_FUNCTION
(
this
<< margin);
69
m_margin
= margin;
70
}
71
72
double
73
SimpleFrameCaptureModel::GetMargin
()
const
74
{
75
return
m_margin
;
76
}
77
78
bool
79
SimpleFrameCaptureModel::CaptureNewFrame
(
Ptr<Event>
currentEvent,
Ptr<Event>
newEvent)
const
80
{
81
NS_LOG_FUNCTION
(
this
);
82
return
WToDbm
(currentEvent->GetRxPowerW()) +
GetMargin
() <
WToDbm
(newEvent->GetRxPowerW()) &&
83
IsInCaptureWindow
(currentEvent->GetStartTime());
84
}
85
86
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::FrameCaptureModel
the interface for Wifi's frame capture models
Definition:
frame-capture-model.h:38
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:45
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::SimpleFrameCaptureModel
A simple threshold-based model for frame capture effect.
Definition:
simple-frame-capture-model.h:38
ns3::SimpleFrameCaptureModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
simple-frame-capture-model.cc:37
ns3::SimpleFrameCaptureModel::~SimpleFrameCaptureModel
~SimpleFrameCaptureModel() override
Definition:
simple-frame-capture-model.cc:60
ns3::SimpleFrameCaptureModel::SimpleFrameCaptureModel
SimpleFrameCaptureModel()
Definition:
simple-frame-capture-model.cc:55
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:79
ns3::SimpleFrameCaptureModel::m_margin
double m_margin
margin for determining if a new frame (dB)
Definition:
simple-frame-capture-model.h:75
ns3::SimpleFrameCaptureModel::SetMargin
void SetMargin(double margin)
Sets the frame capture margin (dB).
Definition:
simple-frame-capture-model.cc:66
ns3::SimpleFrameCaptureModel::GetMargin
double GetMargin() const
Return the frame capture margin (dB).
Definition:
simple-frame-capture-model.cc:73
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:931
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
interference-helper.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WToDbm
double WToDbm(double w)
Convert from Watts to dBm.
Definition:
wifi-utils.cc:46
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition:
double.h:43
simple-frame-capture-model.h
wifi-utils.h
src
wifi
model
simple-frame-capture-model.cc
Generated on Sun Mar 3 2024 17:11:11 for ns-3 by
1.9.1