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