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
29namespace 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 NS_ABORT_MSG_IF (standard == WIFI_STANDARD_UNSPECIFIED, "No standard specified!");
48
49 // this is a const method, but we need to force the correct QoS setting
50 ObjectFactory macObjectFactory = m_mac;
51 if (standard >= WIFI_STANDARD_80211n)
52 {
53 macObjectFactory.Set ("QosSupported", BooleanValue (true));
54 }
55
56 Ptr<WifiMac> mac = macObjectFactory.Create<WifiMac> ();
57 mac->SetDevice (device);
58 mac->SetAddress (Mac48Address::Allocate ());
59 mac->ConfigureStandard (standard);
60
61 Ptr<FrameExchangeManager> fem = mac->GetFrameExchangeManager ();
62
63 if (fem != nullptr)
64 {
66 protectionManager->SetWifiMac (mac);
67 fem->SetProtectionManager (protectionManager);
68
70 ackManager->SetWifiMac (mac);
71 fem->SetAckManager (ackManager);
72
73 // create and install the Multi User Scheduler if this is an HE AP
74 Ptr<ApWifiMac> apMac = DynamicCast<ApWifiMac> (mac);
75 if (apMac != nullptr && standard >= WIFI_STANDARD_80211ax
77 {
79 apMac->AggregateObject (muScheduler);
80 }
81 }
82 return mac;
83}
84
85} //namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:37
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
MultiUserScheduler is an abstract base class defining the API that APs supporting at least VHT can us...
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
bool IsTypeIdSet(void) const
Check if the ObjectFactory has been configured with a TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
WifiAckManager is an abstract base class.
ObjectFactory m_mac
MAC object factory.
virtual ~WifiMacHelper()
Destroy a WifiMacHelper.
virtual Ptr< WifiMac > Create(Ptr< WifiNetDevice > device, WifiStandard standard) const
ObjectFactory m_protectionManager
Factory to create a protection manager.
ObjectFactory m_muScheduler
Multi-user Scheduler object factory.
WifiMacHelper()
Create a WifiMacHelper to make life easier for people who want to work with Wifi MAC layers.
ObjectFactory m_ackManager
Factory to create an acknowledgment manager.
void SetType(std::string type, Args &&... args)
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:86
WifiProtectionManager is an abstract base class.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_UNSPECIFIED
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:96