A Discrete-Event Network Simulator
API
wifi-mac-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "ns3/net-device.h"
22 #include "wifi-mac-helper.h"
23 #include "ns3/frame-exchange-manager.h"
24 #include "ns3/wifi-protection-manager.h"
25 #include "ns3/wifi-ack-manager.h"
26 #include "ns3/multi-user-scheduler.h"
27 #include "ns3/boolean.h"
28 
29 namespace ns3 {
30 
32 {
33  //By default, we create an AdHoc MAC layer without QoS.
34  SetType ("ns3::AdhocWifiMac",
35  "QosSupported", BooleanValue (false));
36 
37  m_protectionManager.SetTypeId ("ns3::WifiDefaultProtectionManager");
38  m_ackManager.SetTypeId ("ns3::WifiDefaultAckManager");
39 }
40 
42 {
43 }
44 
47 {
48  auto standardIt = wifiStandards.find (standard);
49  NS_ABORT_MSG_IF (standardIt == wifiStandards.end (), "Selected standard is not defined!");
50 
52  mac->SetDevice (device);
53  mac->SetAddress (Mac48Address::Allocate ());
54  mac->ConfigureStandard (standard);
55 
56  Ptr<RegularWifiMac> wifiMac = DynamicCast<RegularWifiMac> (mac);
58 
59  if (wifiMac != 0 && (fem = wifiMac->GetFrameExchangeManager ()) != 0)
60  {
62  protectionManager->SetWifiMac (wifiMac);
63  fem->SetProtectionManager (protectionManager);
64 
66  ackManager->SetWifiMac (wifiMac);
67  fem->SetAckManager (ackManager);
68 
69  // create and install the Multi User Scheduler if this is an HE AP
70  Ptr<ApWifiMac> apMac = DynamicCast<ApWifiMac> (mac);
71  if (apMac != nullptr && standardIt->second.macStandard >= WIFI_MAC_STANDARD_80211ax
73  {
75  apMac->AggregateObject (muScheduler);
76  }
77  }
78  return mac;
79 }
80 
81 } //namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void SetType(std::string type, Args &&... args)
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
ObjectFactory m_muScheduler
Multi-user Scheduler object factory.
ObjectFactory m_ackManager
Factory to create an acknowledgment manager.
const std::map< WifiStandard, WifiStandardInfo > wifiStandards
map a given standard configured by the user to the corresponding WifiStandardInfo ...
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
virtual Ptr< WifiMac > Create(Ptr< NetDevice > device, WifiStandard standard) const
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:70
WifiMacHelper()
Create a WifiMacHelper to make life easier for people who want to work with Wifi MAC layers...
mac
Definition: third.py:99
MultiUserScheduler is an abstract base class defining the API that APs supporting at least VHT can us...
WifiAckManager is an abstract base class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiStandard
Identifies the allowed configurations that a Wifi device is configured to use.
WifiProtectionManager is an abstract base class.
bool IsTypeIdSet(void) const
Check if the ObjectFactory has been configured with a TypeId.
virtual ~WifiMacHelper()
Destroy a WifiMacHelper.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ObjectFactory m_mac
MAC object factory.
ObjectFactory m_protectionManager
Factory to create a protection manager.