A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
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
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("SimpleFrameCaptureModel");
33
34NS_OBJECT_ENSURE_REGISTERED(SimpleFrameCaptureModel);
35
36TypeId
38{
39 static TypeId tid =
40 TypeId("ns3::SimpleFrameCaptureModel")
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),
51 MakeDoubleChecker<double>());
52 return tid;
53}
54
56{
57 NS_LOG_FUNCTION(this);
58}
59
61{
62 NS_LOG_FUNCTION(this);
63}
64
65void
67{
68 NS_LOG_FUNCTION(this << margin);
69 m_margin = margin;
70}
71
72double
74{
75 return m_margin;
76}
77
78bool
80{
81 NS_LOG_FUNCTION(this);
82 return WToDbm(currentEvent->GetRxPowerW()) + GetMargin() < WToDbm(newEvent->GetRxPowerW()) &&
83 IsInCaptureWindow(currentEvent->GetStartTime());
84}
85
86} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
the interface for Wifi's frame capture models
virtual bool IsInCaptureWindow(Time timePreambleDetected) const
This method returns true if the capture window duration has not elapsed yet, false otherwise.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A simple threshold-based model for frame capture effect.
static TypeId GetTypeId()
Get the type ID.
bool CaptureNewFrame(Ptr< Event > currentEvent, Ptr< Event > newEvent) const override
This method returns whether the reception should be switched to a new incoming frame.
double m_margin
margin for determining if a new frame (dB)
void SetMargin(double margin)
Sets the frame capture margin (dB).
double GetMargin() const
Return the frame capture margin (dB).
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:46