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 "wifi-phy.h"
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("SimpleFrameCaptureModel");
31 
32 NS_OBJECT_ENSURE_REGISTERED (SimpleFrameCaptureModel);
33 
34 TypeId
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 
62 void
64 {
65  NS_LOG_FUNCTION (this << margin);
66  m_margin = margin;
67 }
68 
69 double
71 {
72  return m_margin;
73 }
74 
75 bool
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
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:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
A simple threshold-based model for frame capture effect.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
static TypeId GetTypeId(void)
Get the type ID.
the interface for Wifi&#39;s frame capture models
double GetMargin(void) const
Return the frame capture margin (dB).
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:47
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
bool CaptureNewFrame(Ptr< Event > currentEvent, Ptr< Event > newEvent) const
This method returns whether the reception should be switched to a new incoming frame.
void SetMargin(double margin)
Sets the frame capture margin (dB).
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
double m_margin
margin for determining if a new frame (dB)