src/devices/wifi/nqap-wifi-mac.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 08 Jul 2008 10:02:46 -0700
changeset 3389 d02d0233f14b
parent 3197 362f1a144828
child 3517 5ba130a7f519
permissions -rw-r--r--
add missing implementations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "ns3/assert.h"
2012
54dd9789c670 enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2010
diff changeset
    21
#include "ns3/log.h"
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/simulator.h"
2156
754a843db672 improve log output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2154
diff changeset
    23
#include "ns3/node.h"
2012
54dd9789c670 enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2010
diff changeset
    24
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    25
#include "nqap-wifi-mac.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    26
#include "dca-txop.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    27
#include "wifi-mac-header.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    28
#include "mgt-headers.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    29
#include "wifi-phy.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    30
#include "dcf-manager.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    31
#include "mac-rx-middle.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    32
#include "mac-low.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    33
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    34
NS_LOG_COMPONENT_DEFINE ("NqapWifiMac");
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
namespace ns3 {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    38
NS_OBJECT_ENSURE_REGISTERED (NqapWifiMac);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    39
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    40
TypeId 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    41
NqapWifiMac::GetTypeId (void)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    42
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    43
  static TypeId tid = TypeId ("ns3::NqapWifiMac")
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    44
    .SetParent<WifiMac> ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    45
    .AddConstructor<NqapWifiMac> ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    46
    .AddAttribute ("BeaconInterval", "Delay between two beacons",
3197
362f1a144828 Change the default beacon interval to a more realistic value (100 ms); closes bug #177.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2989
diff changeset
    47
                   TimeValue (Seconds (0.1)),
3389
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
    48
                   MakeTimeAccessor (&NqapWifiMac::GetBeaconInterval,
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
    49
                                     &NqapWifiMac::SetBeaconInterval),
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    50
                   MakeTimeChecker ())
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    51
    .AddAttribute ("BeaconGeneration", "Whether or not beacons are generated.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
    52
                   BooleanValue (false),
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    53
                   MakeBooleanAccessor (&NqapWifiMac::SetBeaconGeneration,
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    54
                                        &NqapWifiMac::GetBeaconGeneration),
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    55
                   MakeBooleanChecker ())
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    56
    ;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    57
  return tid;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    58
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    59
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    60
NqapWifiMac::NqapWifiMac ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    61
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
    62
  NS_LOG_FUNCTION (this);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    63
  m_rxMiddle = new MacRxMiddle ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    64
  m_rxMiddle->SetForwardCallback (MakeCallback (&NqapWifiMac::Receive, this));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    65
2617
0ecb3a9422e4 avoid double-frees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    66
  m_low = CreateObject<MacLow> ();
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    67
  m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle));
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    68
  m_low->SetMac (this);
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    69
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    70
  m_dcfManager = new DcfManager ();
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    71
  m_dcfManager->SetupLowListener (m_low);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    72
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    73
  m_dca = CreateObject<DcaTxop> ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    74
  m_dca->SetLow (m_low);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    75
  m_dca->SetManager (m_dcfManager);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    76
  m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    77
  m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    78
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    79
  m_beaconDca = CreateObject<DcaTxop> ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    80
  m_beaconDca->SetLow (m_low);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    81
  m_beaconDca->SetManager (m_dcfManager);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    82
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    83
NqapWifiMac::~NqapWifiMac ()
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
    84
{
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
    85
  NS_LOG_FUNCTION (this);
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
    86
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    87
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    88
void
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    89
NqapWifiMac::DoDispose (void)
2054
ba8e810bae4c derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2028
diff changeset
    90
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
    91
  NS_LOG_FUNCTION (this);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    92
  delete m_rxMiddle;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    93
  delete m_dcfManager;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    94
  m_rxMiddle = 0;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    95
  m_low = 0;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
    96
  m_dcfManager = 0;
2054
ba8e810bae4c derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2028
diff changeset
    97
  m_phy = 0;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    98
  m_dca = 0;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
    99
  m_beaconDca = 0;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   100
  m_beaconEvent.Cancel ();
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   101
  WifiMac::DoDispose ();
2054
ba8e810bae4c derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2028
diff changeset
   102
}
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   104
void
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   105
NqapWifiMac::SetBeaconGeneration (bool enable)
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   106
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   107
  NS_LOG_FUNCTION (this << enable);
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   108
  if (enable)
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   109
    {
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   110
      m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this);
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   111
    }
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   112
  else
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   113
    {
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   114
      m_beaconEvent.Cancel ();
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   115
    }
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   116
}
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   117
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   118
bool
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   119
NqapWifiMac::GetBeaconGeneration (void) const
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   120
{
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   121
  return m_beaconEvent.IsRunning ();
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   122
}
3389
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
   123
Time 
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
   124
NqapWifiMac::GetBeaconInterval (void) const
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
   125
{
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
   126
  return m_beaconInterval;
d02d0233f14b add missing implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3197
diff changeset
   127
}
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   128
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   129
void 
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   130
NqapWifiMac::SetSlot (Time slotTime)
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   131
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   132
  NS_LOG_FUNCTION (this << slotTime);
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   133
  m_dcfManager->SetSlot (slotTime);
2686
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   134
  m_slot = slotTime;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   135
}
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   136
void 
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   137
NqapWifiMac::SetSifs (Time sifs)
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   138
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   139
  NS_LOG_FUNCTION (this << sifs);
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   140
  m_dcfManager->SetSifs (sifs);
2686
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   141
  m_sifs = sifs;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   142
}
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   143
void 
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   144
NqapWifiMac::SetEifsNoDifs (Time eifsNoDifs)
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   145
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   146
  NS_LOG_FUNCTION (this << eifsNoDifs);
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   147
  m_dcfManager->SetEifsNoDifs (eifsNoDifs);
2686
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   148
  m_eifsNoDifs = eifsNoDifs;
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   149
}
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   150
Time 
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   151
NqapWifiMac::GetSlot (void) const
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   152
{
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   153
  return m_slot;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   154
}
2686
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   155
Time 
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   156
NqapWifiMac::GetSifs (void) const
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   157
{
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   158
  return m_sifs;
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   159
}
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   160
Time 
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   161
NqapWifiMac::GetEifsNoDifs (void) const
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   162
{
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   163
  return m_eifsNoDifs;
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   164
}
e8cdac3c936f fix build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2617
diff changeset
   165
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   166
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   168
NqapWifiMac::SetWifiPhy (Ptr<WifiPhy> phy)
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   169
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   170
  NS_LOG_FUNCTION (this << phy);
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   171
  m_phy = phy;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   172
  m_dcfManager->SetupPhyListener (phy);
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   173
  m_low->SetPhy (phy);
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   174
}
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   176
NqapWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   177
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   178
  NS_LOG_FUNCTION (this << stationManager);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   179
  m_stationManager = stationManager;
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   180
  m_dca->SetWifiRemoteStationManager (stationManager);
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   181
  m_beaconDca->SetWifiRemoteStationManager (stationManager);
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   182
  m_low->SetWifiRemoteStationManager (stationManager);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   183
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   184
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   185
NqapWifiMac::SetForwardUpCallback (Callback<void,Ptr<Packet>, const Mac48Address &> upCallback)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   187
  NS_LOG_FUNCTION (this);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   188
  m_upCallback = upCallback;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   189
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   190
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   191
NqapWifiMac::SetLinkUpCallback (Callback<void> linkUp)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   192
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   193
  NS_LOG_FUNCTION (this);
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   194
  if (!linkUp.IsNull ())
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   195
    {
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   196
      linkUp ();
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   197
    }
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
}
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   200
NqapWifiMac::SetLinkDownCallback (Callback<void> linkDown)
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   201
{
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   202
  NS_LOG_FUNCTION (this);
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   203
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   204
Mac48Address 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   205
NqapWifiMac::GetAddress (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   206
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   207
  return m_address;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   208
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   209
Ssid 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   210
NqapWifiMac::GetSsid (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   211
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   212
  return m_ssid;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   213
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   214
Mac48Address 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   215
NqapWifiMac::GetBssid (void) const
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   216
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   217
  return m_address;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   218
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   219
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   220
NqapWifiMac::SetAddress (Mac48Address address)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   221
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   222
  NS_LOG_FUNCTION (address);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   223
  m_address = address;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   224
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   225
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   226
NqapWifiMac::SetSsid (Ssid ssid)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   227
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   228
  NS_LOG_FUNCTION (ssid);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   229
  m_ssid = ssid;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   230
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   231
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   232
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   233
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   234
NqapWifiMac::SetBeaconInterval (Time interval)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   236
  NS_LOG_FUNCTION (this << interval);
2058
1444e6708451 use Time for the beacon interval.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2054
diff changeset
   237
  m_beaconInterval = interval;
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
}
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   239
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   240
NqapWifiMac::StartBeaconing (void)
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   241
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   242
  NS_LOG_FUNCTION (this);
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   243
  SendOneBeacon ();
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   244
}
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   246
NqapWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   247
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   248
  NS_LOG_FUNCTION (this << packet << from);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   249
  m_upCallback (packet, from);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   250
}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   251
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   252
NqapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   254
  NS_LOG_FUNCTION (this << packet << from << to);
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
  WifiMacHeader hdr;
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
  hdr.SetTypeData ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
  hdr.SetAddr1 (to);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   258
  hdr.SetAddr2 (GetAddress ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
  hdr.SetAddr3 (from);
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
  hdr.SetDsFrom ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
  hdr.SetDsNotTo ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
  m_dca->Queue (packet, hdr);  
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
}
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   265
NqapWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   267
  NS_LOG_FUNCTION (this << packet << to);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   268
  ForwardDown (packet, GetAddress (), to);
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
}
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   270
SupportedRates
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   271
NqapWifiMac::GetSupportedRates (void) const
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   272
{
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   273
  // send the set of supported rates and make sure that we indicate
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   274
  // the Basic Rate set in this set of supported rates.
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   275
  SupportedRates rates;
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   276
  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   277
    {
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   278
      WifiMode mode = m_phy->GetMode (i);
2164
6e347fdbfa4a avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
   279
      rates.AddSupportedRate (mode.GetDataRate ());
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   280
    }
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   281
  // set the basic rates
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   282
  for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   283
    {
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   284
      WifiMode mode = m_stationManager->GetBasicMode (j);
2164
6e347fdbfa4a avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
   285
      rates.SetBasicRate (mode.GetDataRate ());
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   286
    }
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   287
  return rates;
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   288
}
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   289
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   290
NqapWifiMac::SendProbeResp (Mac48Address to)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   291
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   292
  NS_LOG_FUNCTION (this << to);
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   293
  WifiMacHeader hdr;
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
  hdr.SetProbeResp ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   295
  hdr.SetAddr1 (to);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   296
  hdr.SetAddr2 (GetAddress ());
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   297
  hdr.SetAddr3 (GetAddress ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
  hdr.SetDsNotFrom ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   299
  hdr.SetDsNotTo ();
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   300
  Ptr<Packet> packet = Create<Packet> ();
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   301
  MgtProbeResponseHeader probe;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   302
  probe.SetSsid (GetSsid ());
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   303
  probe.SetSupportedRates (GetSupportedRates ());
2058
1444e6708451 use Time for the beacon interval.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2054
diff changeset
   304
  probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   305
  packet->AddHeader (probe);
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   306
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   307
  m_dca->Queue (packet, hdr);
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   308
}
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   309
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   310
NqapWifiMac::SendAssocResp (Mac48Address to, bool success)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   311
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   312
  NS_LOG_FUNCTION (this << to << success);
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   313
  WifiMacHeader hdr;
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   314
  hdr.SetAssocResp ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   315
  hdr.SetAddr1 (to);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   316
  hdr.SetAddr2 (GetAddress ());
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   317
  hdr.SetAddr3 (GetAddress ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   318
  hdr.SetDsNotFrom ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   319
  hdr.SetDsNotTo ();
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   320
  Ptr<Packet> packet = Create<Packet> ();
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   321
  MgtAssocResponseHeader assoc;
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   322
  StatusCode code;
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   323
  if (success)
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   324
    {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   325
      code.SetSuccess ();
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   326
    }
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   327
  else
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   328
    {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   329
      code.SetFailure ();
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   330
    }
2028
20e87f08a04b set the supported rates in assoc resp frames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2012
diff changeset
   331
  assoc.SetSupportedRates (GetSupportedRates ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   332
  assoc.SetStatusCode (code);
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   333
  packet->AddHeader (assoc);
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   334
  
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   335
  m_dca->Queue (packet, hdr);
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   336
}
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   337
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   338
NqapWifiMac::SendOneBeacon (void)
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   339
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   340
  NS_LOG_FUNCTION (this);
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   341
  WifiMacHeader hdr;
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   342
  hdr.SetBeacon ();
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   343
  hdr.SetAddr1 (Mac48Address::GetBroadcast ());
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   344
  hdr.SetAddr2 (GetAddress ());
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   345
  hdr.SetAddr3 (GetAddress ());
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   346
  hdr.SetDsNotFrom ();
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   347
  hdr.SetDsNotTo ();
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   348
  Ptr<Packet> packet = Create<Packet> ();
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   349
  MgtBeaconHeader beacon;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   350
  beacon.SetSsid (GetSsid ());
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   351
  beacon.SetSupportedRates (GetSupportedRates ());
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   352
  beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   353
  packet->AddHeader (beacon);
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   354
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   355
  m_beaconDca->Queue (packet, hdr);
2528
a527ec47b756 avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2524
diff changeset
   356
  m_beaconEvent = Simulator::Schedule (m_beaconInterval, &NqapWifiMac::SendOneBeacon, this);
2089
f6d8dea92b39 implement AP beaconing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2058
diff changeset
   357
}
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   359
NqapWifiMac::TxOk (WifiMacHeader const &hdr)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   360
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   361
  NS_LOG_FUNCTION (this);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   362
  WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   363
  if (hdr.IsAssocResp () && 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   364
      station->IsWaitAssocTxOk ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   365
    {
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   366
      NS_LOG_DEBUG ("associated with sta="<<hdr.GetAddr1 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   367
      station->RecordGotAssocTxOk ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   368
    }
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   369
}
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   370
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   371
NqapWifiMac::TxFailed (WifiMacHeader const &hdr)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   372
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   373
  NS_LOG_FUNCTION (this);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   374
  WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   375
  if (hdr.IsAssocResp () && 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   376
      station->IsWaitAssocTxOk ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   377
    {
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   378
      NS_LOG_DEBUG ("assoc failed with sta="<<hdr.GetAddr1 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   379
      station->RecordGotAssocTxFailed ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   380
    }
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   381
}
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   382
void 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   383
NqapWifiMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   384
{
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   385
  NS_LOG_FUNCTION (this << packet << hdr);
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   386
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   387
  WifiRemoteStation *station = m_stationManager->Lookup (hdr->GetAddr2 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   388
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   389
  if (hdr->IsData ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   390
    {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   391
      if (!hdr->IsFromDs () && 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   392
          hdr->IsToDs () &&
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   393
          hdr->GetAddr1 () == GetAddress () &&
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   394
          station->IsAssociated ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   395
        {
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   396
          if (hdr->GetAddr3 () == GetAddress ()) 
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   397
            {
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   398
              NS_LOG_DEBUG ("frame for me from="<<hdr->GetAddr2 ());
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   399
              ForwardUp (packet, hdr->GetAddr2 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   400
            } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   401
          else 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   402
            {
2985
fa0747c4ad5e use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2686
diff changeset
   403
              NS_LOG_DEBUG ("forwarding frame from="<<hdr->GetAddr2 ()<<", to="<<hdr->GetAddr3 ());
2208
48ed970f6120 copy the packet before sending it down or up
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2164
diff changeset
   404
              Ptr<Packet> copy = packet->Copy ();
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   405
              ForwardDown (packet,
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   406
                           hdr->GetAddr2 (), 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   407
                           hdr->GetAddr3 ());
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   408
              ForwardUp (copy, hdr->GetAddr2 ());
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   409
            }
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   410
        } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   411
      else if (hdr->IsFromDs () &&
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   412
               hdr->IsToDs ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   413
        {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   414
          // this is an AP-to-AP frame
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   415
          // we ignore for now.
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   416
        } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   417
      else 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   418
        {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   419
          // we can ignore these frames since 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   420
          // they are not targeted at the AP
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   421
        }
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   422
    } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   423
  else if (hdr->IsMgt ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   424
    {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   425
      if (hdr->IsProbeReq ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   426
        {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   427
          NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   428
          SendProbeResp (hdr->GetAddr2 ());
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   429
        } 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   430
      else if (hdr->GetAddr1 () == GetAddress ()) 
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   431
        {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   432
          if (hdr->IsAssocReq ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   433
            {
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   434
              // first, verify that the the station's supported
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   435
              // rate set is compatible with our Basic Rate set
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   436
              MgtAssocRequestHeader assocReq;
2159
20f882e85b4a port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2156
diff changeset
   437
              packet->RemoveHeader (assocReq);
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   438
              SupportedRates rates = assocReq.GetSupportedRates ();
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   439
              bool problem = false;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   440
              for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   441
                {
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   442
                  WifiMode mode = m_stationManager->GetBasicMode (i);
2164
6e347fdbfa4a avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
   443
                  if (!rates.IsSupportedRate (mode.GetDataRate ()))
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   444
                    {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   445
                      problem = true;
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   446
                      break;
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   447
                    }
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   448
                }
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   449
              if (problem)
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   450
                {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   451
                  // one of the Basic Rate set mode is not
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   452
                  // supported by the station. So, we return an assoc
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   453
                  // response with an error status.
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   454
                  SendAssocResp (hdr->GetAddr2 (), false);
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   455
                }
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   456
              else
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   457
                {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   458
                  // station supports all rates in Basic Rate Set.
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2350
diff changeset
   459
                  // record all its supported modes in its associated WifiRemoteStation
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   460
                  for (uint32_t j = 0; j < m_phy->GetNModes (); j++)
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   461
                    {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   462
                      WifiMode mode = m_phy->GetMode (j);
2164
6e347fdbfa4a avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2159
diff changeset
   463
                      if (rates.IsSupportedRate (mode.GetDataRate ()))
2010
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   464
                        {
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   465
                          station->AddSupportedMode (mode);
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   466
                        }
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   467
                    }
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   468
                  station->RecordWaitAssocTxOk ();
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   469
                  // send assoc response with success status.
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   470
                  SendAssocResp (hdr->GetAddr2 (), true);
e2e16c1712c8 handle the BasicRateSet in the AP
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   471
                }
1940
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   472
            } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
          else if (hdr->IsDisassociation ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   474
            {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   475
              station->RecordDisassociated ();
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   476
            } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   477
          else if (hdr->IsReassocReq ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
            {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   479
              /* we don't support reassoc frames for now */
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   480
            } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   481
          else if (hdr->IsAuthentication () ||
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   482
                   hdr->IsDeauthentication ()) 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
            {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   484
              /*
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   485
               */
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   486
            } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   487
          else 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   488
            {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   489
              /* unknown mgt frame
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   490
               */
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   491
            }
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   492
        }
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   493
    } 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   494
  else 
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
    {
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   496
    /* damn, what could this be ? a control frame ?
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   497
     * control frames should never reach the MacHigh so,
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   498
     * this is likely to be a bug. assert.
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   499
     */
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   500
      NS_ASSERT (false);
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   501
    }  
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   502
}
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   503
6c62be5cf73a add NQap to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   504
} // namespace ns3