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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
10
11#include "interference-helper.h"
12#include "wifi-utils.h"
13
14#include "ns3/double.h"
15#include "ns3/log.h"
16#include "ns3/simulator.h"
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("SimpleFrameCaptureModel");
22
23NS_OBJECT_ENSURE_REGISTERED(SimpleFrameCaptureModel);
24
25TypeId
27{
28 static TypeId tid =
29 TypeId("ns3::SimpleFrameCaptureModel")
31 .SetGroupName("Wifi")
32 .AddConstructor<SimpleFrameCaptureModel>()
33 .AddAttribute(
34 "Margin",
35 "Reception is switched if the newly arrived frame has a power higher than "
36 "this value above the frame currently being received (expressed in dB).",
37 DoubleValue(5),
41 return tid;
42}
43
48
53
54void
56{
57 NS_LOG_FUNCTION(this << margin);
58 m_margin = margin;
59}
60
61dB_u
66
67bool
69{
70 NS_LOG_FUNCTION(this);
71 return WToDbm(currentEvent->GetRxPower()) + GetMargin() < WToDbm(newEvent->GetRxPower()) &&
72 IsInCaptureWindow(currentEvent->GetStartTime());
73}
74
75} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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.
A simple threshold-based model for frame capture effect.
static TypeId GetTypeId()
Get the type ID.
dB_u GetMargin() const
Return the frame capture margin.
dB_u m_margin
margin for determining if a new frame
bool CaptureNewFrame(Ptr< Event > currentEvent, Ptr< Event > newEvent) const override
This method returns whether the reception should be switched to a new incoming frame.
void SetMargin(dB_u margin)
Sets the frame capture margin.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
Definition wifi-utils.cc:37
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
double dB_u
dB weak type
Definition wifi-units.h:28