A Discrete-Event Network Simulator
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"
25#include "wifi-utils.h"
26#include "interference-helper.h"
27
28namespace ns3 {
29
30NS_LOG_COMPONENT_DEFINE ("SimpleFrameCaptureModel");
31
32NS_OBJECT_ENSURE_REGISTERED (SimpleFrameCaptureModel);
33
34TypeId
36{
37 static TypeId tid = TypeId ("ns3::SimpleFrameCaptureModel")
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),
47 MakeDoubleChecker<double> ())
48 ;
49 return tid;
50}
51
53{
54 NS_LOG_FUNCTION (this);
55}
56
58{
59 NS_LOG_FUNCTION (this);
60}
61
62void
64{
65 NS_LOG_FUNCTION (this << margin);
66 m_margin = margin;
67}
68
69double
71{
72 return m_margin;
73}
74
75bool
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
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
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:74
A simple threshold-based model for frame capture effect.
double GetMargin(void) const
Return the frame capture margin (dB).
static TypeId GetTypeId(void)
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).
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:45
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:43