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/boolean.h"
27 
28 namespace ns3 {
29 
31 {
32  //By default, we create an AdHoc MAC layer without QoS.
33  SetType ("ns3::AdhocWifiMac",
34  "QosSupported", BooleanValue (false));
35 
36  m_protectionManager.SetTypeId ("ns3::WifiDefaultProtectionManager");
37  m_ackManager.SetTypeId ("ns3::WifiDefaultAckManager");
38 }
39 
41 {
42 }
43 
46 {
48  mac->SetDevice (device);
49  mac->SetAddress (Mac48Address::Allocate ());
50  mac->ConfigureStandard (standard);
51 
52  Ptr<RegularWifiMac> wifiMac = DynamicCast<RegularWifiMac> (mac);
54 
55  if (wifiMac != 0 && (fem = wifiMac->GetFrameExchangeManager ()) != 0)
56  {
58  protectionManager->SetWifiMac (wifiMac);
59  fem->SetProtectionManager (protectionManager);
60 
62  ackManager->SetWifiMac (wifiMac);
63  fem->SetAckManager (ackManager);
64  }
65  return mac;
66 }
67 
68 } //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_ackManager
Factory to create an acknowledgment manager.
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:46
WifiMacHelper()
Create a WifiMacHelper to make life easier for people who want to work with Wifi MAC layers...
mac
Definition: third.py:99
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.
virtual ~WifiMacHelper()
Destroy a WifiMacHelper.
ObjectFactory m_mac
MAC object factory.
ObjectFactory m_protectionManager
Factory to create a protection manager.