src/devices/wifi/yans-wifi-phy.cc
author Timo Bingmann <tbns@idlebox.net>
Mon, 30 Nov 2009 18:40:35 +0100
changeset 5820 1c02054740eb
parent 5747 a171e73c4dae
child 6342 a2bdd767bb67
permissions -rw-r--r--
Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    21
#include "yans-wifi-phy.h"
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    22
#include "yans-wifi-channel.h"
1891
add6fb8761f3 use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1890
diff changeset
    23
#include "wifi-mode.h"
1920
1d4864775cf8 replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1919
diff changeset
    24
#include "wifi-preamble.h"
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    25
#include "wifi-phy-state-helper.h"
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3900
diff changeset
    26
#include "error-rate-model.h"
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/simulator.h"
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include "ns3/packet.h"
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
#include "ns3/random-variable.h"
1974
0d6b3bead74a replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
    30
#include "ns3/assert.h"
1979
d535a38b7fc4 convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1978
diff changeset
    31
#include "ns3/log.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    32
#include "ns3/double.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    33
#include "ns3/uinteger.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    34
#include "ns3/enum.h"
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    35
#include "ns3/pointer.h"
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
    36
#include "ns3/net-device.h"
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4039
diff changeset
    37
#include "ns3/trace-source-accessor.h"
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
#include <math.h>
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    40
NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
1891
add6fb8761f3 use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1890
diff changeset
    41
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
namespace ns3 {
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    44
NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    45
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    46
TypeId 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    47
YansWifiPhy::GetTypeId (void)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    48
{
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    49
  static TypeId tid = TypeId ("ns3::YansWifiPhy")
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    50
    .SetParent<WifiPhy> ()
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    51
    .AddConstructor<YansWifiPhy> ()
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    52
    .AddAttribute ("EnergyDetectionThreshold",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    53
                   "The energy of a received signal should be higher than "
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    54
                   "this threshold (dbm) to allow the PHY layer to detect the signal.",
5495
7f6bb3ad07b4 Bug 689: default energy detection and CCA thresholds are changed to be more realistic.
Pavel Boyko <boyko@iitp.ru>
parents: 5422
diff changeset
    55
                   DoubleValue (-96.0),
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    56
                   MakeDoubleAccessor (&YansWifiPhy::SetEdThreshold,
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    57
                                       &YansWifiPhy::GetEdThreshold),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    58
                   MakeDoubleChecker<double> ())
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    59
    .AddAttribute ("CcaMode1Threshold",
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    60
                   "The energy of a received signal should be higher than "
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    61
                   "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state",
5495
7f6bb3ad07b4 Bug 689: default energy detection and CCA thresholds are changed to be more realistic.
Pavel Boyko <boyko@iitp.ru>
parents: 5422
diff changeset
    62
                   DoubleValue (-99.0),
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    63
                   MakeDoubleAccessor (&YansWifiPhy::SetCcaMode1Threshold,
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    64
                                       &YansWifiPhy::GetCcaMode1Threshold),
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    65
                   MakeDoubleChecker<double> ())
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    66
    .AddAttribute ("TxGain",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    67
                   "Transmission gain (dB).",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
    68
                   DoubleValue (1.0),
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    69
                   MakeDoubleAccessor (&YansWifiPhy::SetTxGain,
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    70
                                       &YansWifiPhy::GetTxGain),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    71
                   MakeDoubleChecker<double> ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    72
    .AddAttribute ("RxGain",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    73
                   "Reception gain (dB).",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
    74
                   DoubleValue (1.0),
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    75
                   MakeDoubleAccessor (&YansWifiPhy::SetRxGain,
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    76
                                       &YansWifiPhy::GetRxGain),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    77
                   MakeDoubleChecker<double> ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    78
    .AddAttribute ("TxPowerLevels",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    79
                   "Number of transmission power levels available between "
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    80
                   "TxPowerBase and TxPowerEnd included.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
    81
                   UintegerValue (1),
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    82
                   MakeUintegerAccessor (&YansWifiPhy::m_nTxPower),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    83
                   MakeUintegerChecker<uint32_t> ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    84
    .AddAttribute ("TxPowerEnd",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    85
                   "Maximum available transmission level (dbm).",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
    86
                   DoubleValue (16.0206),
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    87
                   MakeDoubleAccessor (&YansWifiPhy::SetTxPowerEnd, 
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    88
                                       &YansWifiPhy::GetTxPowerEnd),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    89
                   MakeDoubleChecker<double> ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    90
    .AddAttribute ("TxPowerStart",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    91
                   "Minimum available transmission level (dbm).",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
    92
                   DoubleValue (16.0206),
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    93
                   MakeDoubleAccessor (&YansWifiPhy::SetTxPowerStart, 
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
    94
                                       &YansWifiPhy::GetTxPowerStart),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    95
                   MakeDoubleChecker<double> ())
4315
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
    96
    .AddAttribute ("RxNoiseFigure",
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
    97
                   "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
    98
                   " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
    99
                   "\"the difference in decibels (dB) between"
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   100
                   " the noise output of the actual receiver to the noise output of an "
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   101
                   " ideal receiver with the same overall gain and bandwidth when the receivers "
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   102
                   " are connected to sources at the standard noise temperature T0 (usually 290 K)\"."
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   103
                   " For",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   104
                   DoubleValue (7),
4315
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   105
                   MakeDoubleAccessor (&YansWifiPhy::SetRxNoiseFigure,
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   106
                                       &YansWifiPhy::GetRxNoiseFigure),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   107
                   MakeDoubleChecker<double> ())
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   108
    .AddAttribute ("State", "The state of the PHY layer",
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   109
                   PointerValue (),
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   110
                   MakePointerAccessor (&YansWifiPhy::m_state),
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   111
                   MakePointerChecker<WifiPhyStateHelper> ())
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   112
    .AddAttribute ("ChannelSwitchDelay",
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   113
                   "Delay between two short frames transmitted on different frequencies. NOTE: Unused now.",
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   114
                   TimeValue (MicroSeconds (250)),
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   115
                   MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay), 
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   116
                   MakeTimeChecker ())
5511
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   117
    .AddAttribute ("ChannelNumber",
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   118
                   "Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)",
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   119
                   UintegerValue (1),
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   120
                   MakeUintegerAccessor (&YansWifiPhy::SetChannelNumber, 
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   121
                                         &YansWifiPhy::GetChannelNumber),
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   122
                   MakeUintegerChecker<uint16_t> ())
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   123
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   124
    ;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   125
  return tid;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   126
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   127
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   128
YansWifiPhy::YansWifiPhy ()
5511
d77201fa5ee2 ChannelNumber attribute added to YansWifiPhy. Now it is possible to setup wifi channel using WifiPhyHelper::Set() method.
Pavel Boyko <boyko@iitp.ru>
parents: 5495
diff changeset
   129
  :  m_channelNumber (1),
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   130
     m_endRxEvent (),
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   131
     m_random (0.0, 1.0),
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   132
     m_channelStartingFrequency (0)
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   133
{
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   134
  NS_LOG_FUNCTION (this);
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   135
  m_state = CreateObject<WifiPhyStateHelper> ();
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   136
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   137
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   138
YansWifiPhy::~YansWifiPhy ()
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   139
{
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   140
  NS_LOG_FUNCTION (this);
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   141
}
2530
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   142
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   143
void
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   144
YansWifiPhy::DoDispose (void)
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1920
diff changeset
   145
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   146
  NS_LOG_FUNCTION (this);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   147
  m_channel = 0;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   148
  m_modes.clear ();
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   149
  m_device = 0;
5422
21a4f34518ff bug 711: example mesh/mesh fails valgrind.
Andrey Mazo <mazo@iitp.ru>
parents: 5189
diff changeset
   150
  m_mobility = 0;
21a4f34518ff bug 711: example mesh/mesh fails valgrind.
Andrey Mazo <mazo@iitp.ru>
parents: 5189
diff changeset
   151
  m_state = 0;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   152
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   153
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   154
void
4720
15221757964f bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4715
diff changeset
   155
YansWifiPhy::ConfigureStandard (enum WifiPhyStandard standard)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   156
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   157
  NS_LOG_FUNCTION (this << standard);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   158
  switch (standard) {
2166
00b5eb43dba2 Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents: 2164
diff changeset
   159
  case WIFI_PHY_STANDARD_80211a:
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   160
    Configure80211a ();
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   161
    break;
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   162
  case WIFI_PHY_STANDARD_80211b:
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   163
    Configure80211b ();
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   164
    break;
4680
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   165
  case WIFI_PHY_STANDARD_80211_10Mhz: 
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   166
    Configure80211_10Mhz ();
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   167
    break;
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   168
  case WIFI_PHY_STANDARD_80211_5Mhz:
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   169
    Configure80211_5Mhz ();
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   170
    break; 
2166
00b5eb43dba2 Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents: 2164
diff changeset
   171
  case WIFI_PHY_STANDARD_holland:
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   172
    ConfigureHolland ();
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   173
    break;
5747
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   174
  case WIFI_PHY_STANDARD_80211p_CCH:
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   175
    Configure80211p_CCH ();
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   176
    break;
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   177
  case WIFI_PHY_STANDARD_80211p_SCH:
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   178
    Configure80211p_SCH ();
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   179
    break;
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   180
  default:
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   181
    NS_ASSERT (false);
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   182
    break;
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   183
  }
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1920
diff changeset
   184
}
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   186
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   187
void 
4315
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   188
YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   189
{
4315
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   190
  NS_LOG_FUNCTION (this << noiseFigureDb);
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   191
  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   192
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   193
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   194
YansWifiPhy::SetTxPowerStart (double start)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   196
  NS_LOG_FUNCTION (this << start);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   197
  m_txPowerBaseDbm = start;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   198
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   199
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   200
YansWifiPhy::SetTxPowerEnd (double end)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   201
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   202
  NS_LOG_FUNCTION (this << end);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   203
  m_txPowerEndDbm = end;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   204
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   205
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   206
YansWifiPhy::SetNTxPower (uint32_t n)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   207
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   208
  NS_LOG_FUNCTION (this << n);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   209
  m_nTxPower = n;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   210
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   211
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   212
YansWifiPhy::SetTxGain (double gain)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   213
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   214
  NS_LOG_FUNCTION (this << gain);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   215
  m_txGainDb = gain;
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   217
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   218
YansWifiPhy::SetRxGain (double gain)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   219
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   220
  NS_LOG_FUNCTION (this << gain);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   221
  m_rxGainDb = gain;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   222
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   223
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   224
YansWifiPhy::SetEdThreshold (double threshold)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   225
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   226
  NS_LOG_FUNCTION (this << threshold);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   227
  m_edThresholdW = DbmToW (threshold);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   228
}
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   229
void 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   230
YansWifiPhy::SetCcaMode1Threshold (double threshold)
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   231
{
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   232
  NS_LOG_FUNCTION (this << threshold);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   233
  m_ccaMode1ThresholdW = DbmToW (threshold);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   234
}
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   235
void 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   236
YansWifiPhy::SetErrorRateModel (Ptr<ErrorRateModel> rate)
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   237
{
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   238
  m_interference.SetErrorRateModel (rate);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   239
}
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   240
void 
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   241
YansWifiPhy::SetDevice (Ptr<Object> device)
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   242
{
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   243
  m_device = device;
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   244
}
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   245
void 
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   246
YansWifiPhy::SetMobility (Ptr<Object> mobility)
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   247
{
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   248
  m_mobility = mobility;
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   249
}
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   250
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   251
double 
4315
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   252
YansWifiPhy::GetRxNoiseFigure (void) const
2155
194dd8bdcf56 add WifiPhy::GetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2150
diff changeset
   253
{
4315
56a5bf298339 noiseFloor -> noiseFigure (bug 543)
Nicola Baldo <nbaldo@cttc.es>
parents: 4264
diff changeset
   254
  return RatioToDb (m_interference.GetNoiseFigure ());
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   255
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   256
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   257
YansWifiPhy::GetTxPowerStart (void) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   258
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   259
  return m_txPowerBaseDbm;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   260
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   261
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   262
YansWifiPhy::GetTxPowerEnd (void) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   263
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   264
  return m_txPowerEndDbm;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   265
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   266
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   267
YansWifiPhy::GetTxGain (void) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   268
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   269
  return m_txGainDb;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   270
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   271
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   272
YansWifiPhy::GetRxGain (void) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   273
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   274
  return m_rxGainDb;
2155
194dd8bdcf56 add WifiPhy::GetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2150
diff changeset
   275
}
194dd8bdcf56 add WifiPhy::GetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2150
diff changeset
   276
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   277
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   278
YansWifiPhy::GetEdThreshold (void) const
2055
8899d6ef5d52 phy state logger
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1999
diff changeset
   279
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   280
  return WToDbm (m_edThresholdW);
2055
8899d6ef5d52 phy state logger
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1999
diff changeset
   281
}
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   282
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   283
double 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   284
YansWifiPhy::GetCcaMode1Threshold (void) const
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   285
{
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   286
  return WToDbm (m_ccaMode1ThresholdW);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   287
}
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   288
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   289
Ptr<ErrorRateModel> 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   290
YansWifiPhy::GetErrorRateModel (void) const
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   291
{
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   292
  return m_interference.GetErrorRateModel ();
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   293
}
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   294
Ptr<Object> 
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   295
YansWifiPhy::GetDevice (void) const
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   296
{
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   297
  return m_device;
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   298
}
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   299
Ptr<Object> 
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   300
YansWifiPhy::GetMobility (void)
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   301
{
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   302
  return m_mobility;
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   303
}
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   304
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   305
double 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   306
YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   307
{
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   308
  return m_interference.GetErrorRateModel ()->CalculateSnr (txMode, ber);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   309
}
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   310
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   311
Ptr<WifiChannel> 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   312
YansWifiPhy::GetChannel (void) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   313
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   314
  return m_channel;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   315
}
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   316
void 
3893
94f771c1373a split WifiChannel in WifiChannel + YansWifiChannel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3888
diff changeset
   317
YansWifiPhy::SetChannel (Ptr<YansWifiChannel> channel)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   318
{
1891
add6fb8761f3 use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1890
diff changeset
   319
  m_channel = channel;
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   320
  m_channel->Add (this);
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   321
}
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   322
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   323
void 
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   324
YansWifiPhy::SetChannelNumber (uint16_t nch)
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   325
{
5512
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   326
  if (Simulator::Now () == Seconds (0))
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   327
    {
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   328
      // this is not channel switch, this is initialization 
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   329
      NS_LOG_DEBUG("start at channel " << nch);
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   330
      m_channelNumber = nch;
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   331
      return;
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   332
    }
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   333
28bccc88b34c bugfix in YansWifiPhy::SetChannelNumber()
Pavel Boyko <boyko@iitp.ru>
parents: 5511
diff changeset
   334
  NS_ASSERT (!IsStateSwitching()); 
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   335
  switch (m_state->GetState ()) {
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   336
  case YansWifiPhy::RX:
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   337
    NS_LOG_DEBUG ("drop packet because of channel switching while reception");
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   338
    m_endRxEvent.Cancel();
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   339
    goto switchChannel;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   340
    break;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   341
  case YansWifiPhy::TX:
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   342
      NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   343
      Simulator::Schedule (GetDelayUntilIdle(), &YansWifiPhy::SetChannelNumber, this, nch);
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   344
    break;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   345
  case YansWifiPhy::CCA_BUSY:
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   346
  case YansWifiPhy::IDLE:
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   347
    goto switchChannel;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   348
    break;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   349
  default:
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   350
    NS_ASSERT (false);
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   351
    break;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   352
  }
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   353
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   354
  return;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   355
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   356
  switchChannel: 
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   357
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   358
  NS_LOG_DEBUG("switching channel " << m_channelNumber << " -> " << nch);
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   359
  m_state->SwitchToChannelSwitching(m_channelSwitchDelay); 
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   360
  m_interference.EraseEvents(); 
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   361
  /*
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   362
   * Needed here to be able to correctly sensed the medium for the first
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   363
   * time after the switching. The actual switching is not performed until
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   364
   * after m_channelSwitchDelay. Packets received during the switching
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   365
   * state are added to the event list and are employed later to figure
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   366
   * out the state of the medium after the switching.
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   367
   */
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   368
  m_channelNumber = nch;
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   369
}
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   370
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   371
uint16_t 
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   372
YansWifiPhy::GetChannelNumber() const
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   373
{
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   374
  return m_channelNumber;
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   375
}
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   376
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   377
double
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   378
YansWifiPhy::GetChannelFrequencyMhz() const
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   379
{
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   380
  return m_channelStartingFrequency + 5 * (GetChannelNumber() - 1);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   381
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   382
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   383
void 
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   384
YansWifiPhy::SetReceiveOkCallback (RxOkCallback callback)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   385
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   386
  m_state->SetReceiveOkCallback (callback);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   387
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   388
void 
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   389
YansWifiPhy::SetReceiveErrorCallback (RxErrorCallback callback)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   390
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   391
  m_state->SetReceiveErrorCallback (callback);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   392
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   393
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   394
YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, 
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   395
                                 double rxPowerDbm,
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   396
                                 WifiMode txMode,
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   397
                                 enum WifiPreamble preamble)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   398
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   399
  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txMode << preamble);
2071
122c95ffccdd use dB instead of dbm where appropriate
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2056
diff changeset
   400
  rxPowerDbm += m_rxGainDb;
1988
210701141b08 convert to and from dbms when needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1979
diff changeset
   401
  double rxPowerW = DbmToW (rxPowerDbm);
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2155
diff changeset
   402
  Time rxDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   403
  Time endRx = Simulator::Now () + rxDuration;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   404
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   405
  Ptr<InterferenceHelper::Event> event;
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   406
  event = m_interference.Add (packet->GetSize (), 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   407
                              txMode,
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   408
                              preamble,
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   409
                              rxDuration,
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   410
                              rxPowerW);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   411
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   412
  switch (m_state->GetState ()) {
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   413
  case YansWifiPhy::SWITCHING: 
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   414
    NS_LOG_DEBUG ("drop packet because of channel switching");
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   415
    NotifyRxDrop (packet);
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   416
    /*
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   417
     * Packets received on the upcoming channel are added to the event list
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   418
     * during the switching state. This way the medium can be correctly sensed
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   419
     * when the device listens to the channel for the first time after the
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   420
     * switching e.g. after channel switching, the channel may be sensed as
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   421
     * busy due to other devices' tramissions started before the end of
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   422
     * the switching.
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   423
     */
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   424
    if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) 
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   425
      {
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   426
        // that packet will be noise _after_ the completion of the
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   427
        // channel switching.
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   428
        goto maybeCcaBusy;
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   429
      }
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   430
    break;
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   431
  case YansWifiPhy::RX:
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   432
    NS_LOG_DEBUG ("drop packet because already in Rx (power="<<
1979
d535a38b7fc4 convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1978
diff changeset
   433
                  rxPowerW<<"W)");
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   434
    NotifyRxDrop (packet);
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   435
    if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) 
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   436
      {
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3893
diff changeset
   437
        // that packet will be noise _after_ the reception of the
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3893
diff changeset
   438
        // currently-received packet.
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   439
        goto maybeCcaBusy;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   440
      }
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   441
    break;
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   442
  case YansWifiPhy::TX:
1979
d535a38b7fc4 convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1978
diff changeset
   443
    NS_LOG_DEBUG ("drop packet because already in Tx (power="<<
d535a38b7fc4 convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1978
diff changeset
   444
                  rxPowerW<<"W)");
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   445
    NotifyRxDrop (packet);
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   446
    if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) 
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   447
      {
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3893
diff changeset
   448
        // that packet will be noise _after_ the transmission of the
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3893
diff changeset
   449
        // currently-transmitted packet.
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   450
        goto maybeCcaBusy;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   451
      }
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   452
    break;
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   453
  case YansWifiPhy::CCA_BUSY:
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   454
  case YansWifiPhy::IDLE:
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   455
    if (rxPowerW > m_edThresholdW) 
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   456
      {
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   457
        NS_LOG_DEBUG ("sync to signal (power="<<rxPowerW<<"W)");
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   458
        // sync to signal
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   459
        m_state->SwitchToRx (rxDuration);
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   460
        NS_ASSERT (m_endRxEvent.IsExpired ());
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   461
        NotifyRxBegin (packet);
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   462
        m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, 
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   463
                                            packet,
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   464
                                            event);
2071
122c95ffccdd use dB instead of dbm where appropriate
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2056
diff changeset
   465
      }
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   466
    else 
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   467
      {
1979
d535a38b7fc4 convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1978
diff changeset
   468
        NS_LOG_DEBUG ("drop packet because signal power too Small ("<<
d535a38b7fc4 convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1978
diff changeset
   469
                      rxPowerW<<"<"<<m_edThresholdW<<")");
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   470
        NotifyRxDrop (packet);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   471
        goto maybeCcaBusy;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   472
      }
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
    break;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   474
  }
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   475
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   476
  return;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   477
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
 maybeCcaBusy:
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   479
  // We are here because we have received the first bit of a packet and we are
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   480
  // not going to be able to synchronize on it
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   481
  // In this model, CCA becomes busy when the aggregation of all signals as
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   482
  // tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   484
  Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaMode1ThresholdW);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   485
  if (!delayUntilCcaEnd.IsZero ())
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   486
    {
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   487
      m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   488
    }
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   489
}
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4039
diff changeset
   490
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   491
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   492
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   493
{
3882
05de3d432860 print the tx power, not a random character
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3880
diff changeset
   494
  NS_LOG_FUNCTION (this << packet << txMode << preamble << (uint32_t)txPower);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
  /* Transmission can happen if:
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   496
   *  - we are syncing on a packet. It is the responsability of the
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   497
   *    MAC layer to avoid doing this but the PHY does nothing to 
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   498
   *    prevent it.
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   499
   *  - we are idle
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   500
   */
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   501
  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   502
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2155
diff changeset
   503
  Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble);
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   504
  if (m_state->IsStateRx ())
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3893
diff changeset
   505
    {
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   506
      m_endRxEvent.Cancel ();
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3893
diff changeset
   507
    }
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   508
  NotifyTxBegin (packet);
4492
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   509
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;   
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   510
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
4715
d0041768ff60 bug 644: make sure we set standard and frequency correctly in radiotap output
Nicola Baldo <nbaldo@cttc.es>
parents: 4690
diff changeset
   511
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   512
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   513
  m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   514
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   515
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   516
uint32_t 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   517
YansWifiPhy::GetNModes (void) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   518
{
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   519
  return m_modes.size ();
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   520
}
1891
add6fb8761f3 use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1890
diff changeset
   521
WifiMode 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   522
YansWifiPhy::GetMode (uint32_t mode) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   523
{
1891
add6fb8761f3 use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1890
diff changeset
   524
  return m_modes[mode];
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   525
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   526
uint32_t 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   527
YansWifiPhy::GetNTxPower (void) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   528
{
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   529
  return m_nTxPower;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   530
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   531
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   532
void
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   533
YansWifiPhy::Configure80211a (void)
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   534
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   535
  NS_LOG_FUNCTION (this);
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   536
  m_channelStartingFrequency = 5e3; // 5.000 GHz 
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   537
  m_modes.push_back (WifiPhy::Get6mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   538
  m_modes.push_back (WifiPhy::Get9mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   539
  m_modes.push_back (WifiPhy::Get12mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   540
  m_modes.push_back (WifiPhy::Get18mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   541
  m_modes.push_back (WifiPhy::Get24mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   542
  m_modes.push_back (WifiPhy::Get36mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   543
  m_modes.push_back (WifiPhy::Get48mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   544
  m_modes.push_back (WifiPhy::Get54mba ());
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   545
}
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   546
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   547
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   548
void
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   549
YansWifiPhy::Configure80211b (void)
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   550
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   551
  NS_LOG_FUNCTION (this);
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   552
  m_channelStartingFrequency = 2412; // 2.412 GHz 
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   553
  m_modes.push_back (WifiPhy::Get1mbb ());
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   554
  m_modes.push_back (WifiPhy::Get2mbb ());
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   555
  m_modes.push_back (WifiPhy::Get5_5mbb ());
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   556
  m_modes.push_back (WifiPhy::Get11mbb ());
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   557
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4315
diff changeset
   558
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   559
void
4680
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   560
YansWifiPhy::Configure80211_10Mhz (void)
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   561
{
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   562
  NS_LOG_FUNCTION (this);
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   563
  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a 
4680
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   564
  m_modes.push_back (WifiPhy::Get3mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   565
  m_modes.push_back (WifiPhy::Get4_5mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   566
  m_modes.push_back (WifiPhy::Get6mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   567
  m_modes.push_back (WifiPhy::Get9mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   568
  m_modes.push_back (WifiPhy::Get12mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   569
  m_modes.push_back (WifiPhy::Get18mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   570
  m_modes.push_back (WifiPhy::Get24mb10Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   571
  m_modes.push_back (WifiPhy::Get27mb10Mhz  ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   572
}
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   573
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   574
void
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   575
YansWifiPhy::Configure80211_5Mhz (void)
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   576
{
4681
8558474b6149 made InterferenceHelper::CalculateTxDuration () static
Nicola Baldo <nbaldo@cttc.es>
parents: 4680
diff changeset
   577
  NS_LOG_FUNCTION (this); 
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   578
  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
4680
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   579
  m_modes.push_back (WifiPhy::Get1_5mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   580
  m_modes.push_back (WifiPhy::Get2_25mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   581
  m_modes.push_back (WifiPhy::Get3mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   582
  m_modes.push_back (WifiPhy::Get4_5mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   583
  m_modes.push_back (WifiPhy::Get6mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   584
  m_modes.push_back (WifiPhy::Get9mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   585
  m_modes.push_back (WifiPhy::Get12mb5Mhz ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   586
  m_modes.push_back (WifiPhy::Get13_5mb5Mhz  ());
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   587
}
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   588
a52c39181dd4 Support for 5 and 10Mhz wifi channels
Ramon Bauza <monbauza@gmail.com>
parents: 4492
diff changeset
   589
void
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   590
YansWifiPhy::ConfigureHolland (void)
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   591
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   592
  NS_LOG_FUNCTION (this);
4690
86343f7d6bfd Initial multichannel support in Yans Wifi PHY.
Pavel Boyko <boyko@iitp.ru>
parents: 4681
diff changeset
   593
  m_channelStartingFrequency = 5e3; // 5.000 GHz 
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   594
  m_modes.push_back (WifiPhy::Get6mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   595
  m_modes.push_back (WifiPhy::Get12mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   596
  m_modes.push_back (WifiPhy::Get18mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   597
  m_modes.push_back (WifiPhy::Get36mba ());
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3912
diff changeset
   598
  m_modes.push_back (WifiPhy::Get54mba ());
2083
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   599
}
c7541b84285e add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2077
diff changeset
   600
5747
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   601
void
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   602
YansWifiPhy::Configure80211p_CCH (void)
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   603
{
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   604
  NS_LOG_FUNCTION (this);
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   605
  m_channelStartingFrequency = 5e3; // 802.11p works over the 5Ghz freq range
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   606
  m_modes.push_back (WifiPhy::Get3mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   607
  m_modes.push_back (WifiPhy::Get4_5mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   608
  m_modes.push_back (WifiPhy::Get6mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   609
  m_modes.push_back (WifiPhy::Get9mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   610
  m_modes.push_back (WifiPhy::Get12mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   611
  m_modes.push_back (WifiPhy::Get18mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   612
  m_modes.push_back (WifiPhy::Get24mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   613
  m_modes.push_back (WifiPhy::Get27mb10Mhz  ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   614
}
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   615
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   616
void
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   617
YansWifiPhy::Configure80211p_SCH (void)
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   618
{
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   619
  NS_LOG_FUNCTION (this);
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   620
  m_channelStartingFrequency = 5e3; // 802.11p works over the 5Ghz freq range
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   621
  m_modes.push_back (WifiPhy::Get3mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   622
  m_modes.push_back (WifiPhy::Get4_5mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   623
  m_modes.push_back (WifiPhy::Get6mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   624
  m_modes.push_back (WifiPhy::Get9mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   625
  m_modes.push_back (WifiPhy::Get12mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   626
  m_modes.push_back (WifiPhy::Get18mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   627
  m_modes.push_back (WifiPhy::Get24mb10Mhz ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   628
  m_modes.push_back (WifiPhy::Get27mb10Mhz  ());
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   629
}
a171e73c4dae add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents: 5512
diff changeset
   630
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   631
void 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   632
YansWifiPhy::RegisterListener (WifiPhyListener *listener)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   633
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   634
  m_state->RegisterListener (listener);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   635
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   636
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   637
bool 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   638
YansWifiPhy::IsStateCcaBusy (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   639
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   640
  return m_state->IsStateCcaBusy ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   641
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   642
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   643
bool 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   644
YansWifiPhy::IsStateIdle (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   645
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   646
  return m_state->IsStateIdle ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   647
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   648
bool 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   649
YansWifiPhy::IsStateBusy (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   650
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   651
  return m_state->IsStateBusy ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   652
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   653
bool 
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   654
YansWifiPhy::IsStateRx (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   655
{
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   656
  return m_state->IsStateRx ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   657
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   658
bool 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   659
YansWifiPhy::IsStateTx (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   660
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   661
  return m_state->IsStateTx ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   662
}
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   663
bool 
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   664
YansWifiPhy::IsStateSwitching (void)
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   665
{
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   666
  return m_state->IsStateSwitching ();
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 5152
diff changeset
   667
}
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   668
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   669
Time
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   670
YansWifiPhy::GetStateDuration (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   671
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   672
  return m_state->GetStateDuration ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   673
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   674
Time
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   675
YansWifiPhy::GetDelayUntilIdle (void)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   676
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   677
  return m_state->GetDelayUntilIdle ();
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   678
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   679
2139
a2cf93c741c3 add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2083
diff changeset
   680
Time 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   681
YansWifiPhy::GetLastRxStartTime (void) const
2139
a2cf93c741c3 add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2083
diff changeset
   682
{
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
   683
  return m_state->GetLastRxStartTime ();
2139
a2cf93c741c3 add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2083
diff changeset
   684
}
a2cf93c741c3 add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2083
diff changeset
   685
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   686
Time 
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   687
YansWifiPhy::CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   688
{
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   689
  return m_interference.CalculateTxDuration (size, payloadMode, preamble);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   690
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   691
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   692
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   693
YansWifiPhy::DbToRatio (double dB) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   694
{
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   695
  double ratio = pow(10.0,dB/10.0);
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   696
  return ratio;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   697
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   698
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   699
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   700
YansWifiPhy::DbmToW (double dBm) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   701
{
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   702
  double mW = pow(10.0,dBm/10.0);
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   703
  return mW / 1000.0;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   704
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   705
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   706
double
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   707
YansWifiPhy::WToDbm (double w) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   708
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   709
  return 10.0 * log10(w * 1000.0);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   710
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   711
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   712
double
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   713
YansWifiPhy::RatioToDb (double ratio) const
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   714
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   715
  return 10.0 * log10(ratio);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   716
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   717
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
   718
double
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   719
YansWifiPhy::GetEdThresholdW (void) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   720
{
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   721
  return m_edThresholdW;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   722
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   723
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   724
double 
3888
a15618dcd0eb rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3882
diff changeset
   725
YansWifiPhy::GetPowerDbm (uint8_t power) const
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   726
{
1974
0d6b3bead74a replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   727
  NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm);
0d6b3bead74a replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   728
  NS_ASSERT (m_nTxPower > 0);
2782
4c813b3ea1c3 tx power shoudl reflect the user-selected power level, not be always the power level zero.
Providence SALUMU MUNGA <Providence.Salumu_Munga@it-sudparis.eu>
parents: 2659
diff changeset
   729
  double dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / m_nTxPower;
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   730
  return dbm;
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   731
}
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   732
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   733
void
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   734
YansWifiPhy::EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   735
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2782
diff changeset
   736
  NS_LOG_FUNCTION (this << packet << event);
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   737
  NS_ASSERT (IsStateRx ());
1974
0d6b3bead74a replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   738
  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   739
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   740
  struct InterferenceHelper::SnrPer snrPer;
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   741
  snrPer = m_interference.CalculateSnrPer (event);
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   742
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   743
  NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<<
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   744
                ", snr="<<snrPer.snr<<", per="<<snrPer.per<<", size="<<packet->GetSize ());
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
   745
  if (m_random.GetValue () > snrPer.per) 
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   746
    {
4492
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   747
      NotifyRxEnd (packet); 
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   748
      uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;   
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   749
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());  
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   750
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4470
diff changeset
   751
      double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
4715
d0041768ff60 bug 644: make sure we set standard and frequency correctly in radiotap output
Nicola Baldo <nbaldo@cttc.es>
parents: 4690
diff changeset
   752
      NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   753
      m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   754
    } 
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   755
  else 
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   756
    {
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   757
      /* failure. */
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   758
      NotifyRxDrop (packet);
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5747
diff changeset
   759
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
1889
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   760
    }
41589561e4a7 WifiPhy class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   761
}
1977
4303409f3d8e remove uneeded trailing ';'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1974
diff changeset
   762
} // namespace ns3