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/wifi-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 
36  m_protectionManager.SetTypeId ("ns3::WifiDefaultProtectionManager");
37  m_ackManager.SetTypeId ("ns3::WifiDefaultAckManager");
38 }
39 
41 {
42 }
43 
46 {
47  auto standardIt = wifiStandards.find (standard);
48  NS_ABORT_MSG_IF (standardIt == wifiStandards.end (), "Selected standard is not defined!");
49 
50  // this is a const method, but we need to force the correct QoS setting
51  ObjectFactory macObjectFactory = m_mac;
52  if (standard >= WIFI_STANDARD_80211n_2_4GHZ)
53  {
54  macObjectFactory.Set ("QosSupported", BooleanValue (true));
55  }
56 
57  Ptr<WifiMac> mac = macObjectFactory.Create<WifiMac> ();
58  mac->SetDevice (device);
59  mac->SetAddress (Mac48Address::Allocate ());
60  mac->ConfigureStandard (standard);
61 
62  Ptr<RegularWifiMac> wifiMac = DynamicCast<RegularWifiMac> (mac);
64 
65  if (wifiMac != 0 && (fem = wifiMac->GetFrameExchangeManager ()) != 0)
66  {
68  protectionManager->SetWifiMac (wifiMac);
69  fem->SetProtectionManager (protectionManager);
70 
72  ackManager->SetWifiMac (wifiMac);
73  fem->SetAckManager (ackManager);
74 
75  // create and install the Multi User Scheduler if this is an HE AP
76  Ptr<ApWifiMac> apMac = DynamicCast<ApWifiMac> (mac);
77  if (apMac != nullptr && standardIt->second.macStandard >= WIFI_MAC_STANDARD_80211ax
79  {
81  apMac->AggregateObject (muScheduler);
82  }
83  }
84  return mac;
85 }
86 
87 } //namespace ns3
wifi-mac-helper.h
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
ns3::MultiUserScheduler
MultiUserScheduler is an abstract base class defining the API that APs supporting at least VHT can us...
Definition: multi-user-scheduler.h:51
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WIFI_MAC_STANDARD_80211ax
@ WIFI_MAC_STANDARD_80211ax
Definition: wifi-standards.h:94
ns3::ObjectFactory::IsTypeIdSet
bool IsTypeIdSet(void) const
Check if the ObjectFactory has been configured with a TypeId.
Definition: object-factory.cc:58
third.mac
mac
Definition: third.py:99
ns3::WifiMacHelper::m_protectionManager
ObjectFactory m_protectionManager
Factory to create a protection manager.
Definition: wifi-mac-helper.h:114
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::Mac48Address::Allocate
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
Definition: mac48-address.cc:135
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition: object-factory.h:48
ns3::WifiMac
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:72
ns3::WifiMacHelper::m_muScheduler
ObjectFactory m_muScheduler
Multi-user Scheduler object factory.
Definition: wifi-mac-helper.h:116
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ns3::WifiAckManager
WifiAckManager is an abstract base class.
Definition: wifi-ack-manager.h:43
ns3::WifiMacHelper::WifiMacHelper
WifiMacHelper()
Create a WifiMacHelper to make life easier for people who want to work with Wifi MAC layers.
Definition: wifi-mac-helper.cc:31
ns3::WifiMacHelper::m_mac
ObjectFactory m_mac
MAC object factory.
Definition: wifi-mac-helper.h:113
ns3::WifiMacHelper::m_ackManager
ObjectFactory m_ackManager
Factory to create an acknowledgment manager.
Definition: wifi-mac-helper.h:115
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition: object-factory.h:223
ns3::WifiMacHelper::SetType
void SetType(std::string type, Args &&... args)
Definition: wifi-mac-helper.h:130
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition: object-factory.cc:40
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Definition: object-factory.cc:98
ns3::wifiStandards
const std::map< WifiStandard, WifiStandardInfo > wifiStandards
map a given standard configured by the user to the corresponding WifiStandardInfo
Definition: wifi-standards.h:188
ns3::WIFI_STANDARD_80211n_2_4GHZ
@ WIFI_STANDARD_80211n_2_4GHZ
Definition: wifi-standards.h:131
ns3::WifiMacHelper::Create
virtual Ptr< WifiMac > Create(Ptr< WifiNetDevice > device, WifiStandard standard) const
Definition: wifi-mac-helper.cc:45
ns3::WifiStandard
WifiStandard
Identifies the allowed configurations that a Wifi device is configured to use.
Definition: wifi-standards.h:126
ns3::WifiMacHelper::~WifiMacHelper
virtual ~WifiMacHelper()
Destroy a WifiMacHelper.
Definition: wifi-mac-helper.cc:40
ns3::WifiProtectionManager
WifiProtectionManager is an abstract base class.
Definition: wifi-protection-manager.h:42