--- a/examples/mixed-wireless.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/mixed-wireless.cc Fri Apr 24 10:01:41 2009 +0200
@@ -144,13 +144,14 @@
// our container
//
WifiHelper wifi;
- wifi.SetMac ("ns3::AdhocWifiMac");
+ NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
+ mac.SetType ("ns3::AdhocWifiMac");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-54mbs"));
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
- NetDeviceContainer backboneDevices = wifi.Install (wifiPhy, backbone);
+ NetDeviceContainer backboneDevices = wifi.Install (wifiPhy, mac, backbone);
//
// Add the IPv4 protocol stack to the nodes in our container
//
@@ -258,6 +259,7 @@
// Create an infrastructure network
//
WifiHelper wifiInfra = WifiHelper::Default ();
+ NqosWifiMacHelper macInfra = NqosWifiMacHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
// Create unique ssids for these networks
std::string ssidString("wifi-infra");
@@ -267,15 +269,15 @@
Ssid ssid = Ssid (ssidString);
wifiInfra.SetRemoteStationManager ("ns3::ArfWifiManager");
// setup stas
- wifiInfra.SetMac ("ns3::NqstaWifiMac",
+ macInfra.SetType ("ns3::NqstaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
- NetDeviceContainer staDevices = wifiInfra.Install (wifiPhy, stas);
+ NetDeviceContainer staDevices = wifiInfra.Install (wifiPhy, macInfra, stas);
// setup ap.
- wifiInfra.SetMac ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
+ macInfra.SetType ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));
- NetDeviceContainer apDevices = wifiInfra.Install (wifiPhy, backbone.Get (i));
+ NetDeviceContainer apDevices = wifiInfra.Install (wifiPhy, macInfra, backbone.Get (i));
// Collect all of these new devices
NetDeviceContainer infraDevices (apDevices, staDevices);
--- a/examples/stats/wifi-example-sim.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/stats/wifi-example-sim.cc Fri Apr 24 10:01:41 2009 +0200
@@ -128,11 +128,12 @@
NS_LOG_INFO("Installing WiFi and Internet stack.");
WifiHelper wifi = WifiHelper::Default ();
- wifi.SetMac("ns3::AdhocWifiMac");
+ NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
+ wifiMac.SetType ("ns3::AdhocWifiMac");
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
- NetDeviceContainer nodeDevices = wifi.Install(wifiPhy, nodes);
+ NetDeviceContainer nodeDevices = wifi.Install(wifiPhy, wifiMac, nodes);
InternetStackHelper internet;
internet.Install(nodes);
--- a/examples/tap-wifi-dumbbell.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/tap-wifi-dumbbell.cc Fri Apr 24 10:01:41 2009 +0200
@@ -151,19 +151,20 @@
Ssid ssid = Ssid ("left");
WifiHelper wifi = WifiHelper::Default ();
+ NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
- wifi.SetMac ("ns3::NqapWifiMac",
- "Ssid", SsidValue (ssid),
- "BeaconGeneration", BooleanValue (true),
- "BeaconInterval", TimeValue (Seconds (2.5)));
- NetDeviceContainer devicesLeft = wifi.Install (wifiPhy, nodesLeft.Get (0));
+ wifiMac.SetType ("ns3::NqapWifiMac",
+ "Ssid", SsidValue (ssid),
+ "BeaconGeneration", BooleanValue (true),
+ "BeaconInterval", TimeValue (Seconds (2.5)));
+ NetDeviceContainer devicesLeft = wifi.Install (wifiPhy, wifiMac, nodesLeft.Get (0));
- wifi.SetMac ("ns3::NqstaWifiMac",
- "Ssid", SsidValue (ssid),
- "ActiveProbing", BooleanValue (false));
- devicesLeft.Add (wifi.Install (wifiPhy, NodeContainer (nodesLeft.Get (1), nodesLeft.Get (2), nodesLeft.Get (3))));
+ wifiMac.SetType ("ns3::NqstaWifiMac",
+ "Ssid", SsidValue (ssid),
+ "ActiveProbing", BooleanValue (false));
+ devicesLeft.Add (wifi.Install (wifiPhy, wifiMac, NodeContainer (nodesLeft.Get (1), nodesLeft.Get (2), nodesLeft.Get (3))));
MobilityHelper mobility;
mobility.Install (nodesLeft);
--- a/examples/third.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/third.cc Fri Apr 24 10:01:41 2009 +0200
@@ -89,21 +89,23 @@
WifiHelper wifi = WifiHelper::Default ();
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
+ NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
+
Ssid ssid = Ssid ("ns-3-ssid");
- wifi.SetMac ("ns3::NqstaWifiMac",
+ mac.SetType ("ns3::NqstaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevices;
- staDevices = wifi.Install (phy, wifiStaNodes);
+ staDevices = wifi.Install (phy, mac, wifiStaNodes);
- wifi.SetMac ("ns3::NqapWifiMac",
+ mac.SetType ("ns3::NqapWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));
NetDeviceContainer apDevices;
- apDevices = wifi.Install (phy, wifiApNode);
+ apDevices = wifi.Install (phy, mac, wifiApNode);
MobilityHelper mobility;
--- a/examples/wifi-adhoc.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/wifi-adhoc.cc Fri Apr 24 10:01:41 2009 +0200
@@ -36,7 +36,8 @@
public:
Experiment ();
Experiment (std::string name);
- Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const YansWifiChannelHelper &wifiChannel);
+ Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
+ const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel);
private:
void ReceivePacket (Ptr<Socket> socket);
void SetPosition (Ptr<Node> node, Vector position);
@@ -109,7 +110,8 @@
}
Gnuplot2dDataset
-Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const YansWifiChannelHelper &wifiChannel)
+Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
+ const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
{
m_bytesTotal = 0;
@@ -121,7 +123,9 @@
YansWifiPhyHelper phy = wifiPhy;
phy.SetChannel (wifiChannel.Create ());
- NetDeviceContainer devices = wifi.Install (phy, c);
+
+ NqosWifiMacHelper mac = wifiMac;
+ NetDeviceContainer devices = wifi.Install (phy, mac, c);
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
@@ -170,66 +174,67 @@
Experiment experiment;
WifiHelper wifi = WifiHelper::Default ();
+ NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
Gnuplot2dDataset dataset;
- wifi.SetMac ("ns3::AdhocWifiMac");
+ wifiMac.SetType ("ns3::AdhocWifiMac");
NS_LOG_DEBUG ("54");
experiment = Experiment ("54mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-54mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("48");
experiment = Experiment ("48mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-48mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("36");
experiment = Experiment ("36mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-36mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("24");
experiment = Experiment ("24mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-24mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("18");
experiment = Experiment ("18mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-18mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("12");
experiment = Experiment ("12mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-12mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("9");
experiment = Experiment ("9mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-9mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("6");
experiment = Experiment ("6mb");
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-6mbs"));
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
gnuplot.GenerateOutput (std::cout);
@@ -242,37 +247,37 @@
NS_LOG_DEBUG ("arf");
experiment = Experiment ("arf");
wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("aarf");
experiment = Experiment ("aarf");
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("aarf-cd");
experiment = Experiment ("aarf-cd");
wifi.SetRemoteStationManager ("ns3::AarfcdWifiManager");
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("cara");
experiment = Experiment ("cara");
wifi.SetRemoteStationManager ("ns3::CaraWifiManager");
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("rraa");
experiment = Experiment ("rraa");
wifi.SetRemoteStationManager ("ns3::RraaWifiManager");
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
NS_LOG_DEBUG ("ideal");
experiment = Experiment ("ideal");
wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
- dataset = experiment.Run (wifi, wifiPhy, wifiChannel);
+ dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel);
gnuplot.AddDataset (dataset);
gnuplot.GenerateOutput (std::cout);
--- a/examples/wifi-ap.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/wifi-ap.cc Fri Apr 24 10:01:41 2009 +0200
@@ -131,21 +131,22 @@
packetSocket.Install (stas);
packetSocket.Install (ap);
+ NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
Ssid ssid = Ssid ("wifi-default");
wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
// setup stas.
- wifi.SetMac ("ns3::NqstaWifiMac",
+ wifiMac.SetType ("ns3::NqstaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
- staDevs = wifi.Install (wifiPhy, stas);
+ staDevs = wifi.Install (wifiPhy, wifiMac, stas);
// setup ap.
- wifi.SetMac ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
+ wifiMac.SetType ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));
- wifi.Install (wifiPhy, ap);
+ wifi.Install (wifiPhy, wifiMac, ap);
// mobility.
mobility.Install (stas);
--- a/examples/wifi-wired-bridging.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/examples/wifi-wired-bridging.cc Fri Apr 24 10:01:41 2009 +0200
@@ -104,6 +104,7 @@
MobilityHelper mobility;
BridgeHelper bridge;
WifiHelper wifi = WifiHelper::Default ();
+ NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
@@ -121,11 +122,11 @@
// setup the AP.
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (backboneNodes.Get (i));
- wifi.SetMac ("ns3::NqapWifiMac",
+ wifiMac.SetType ("ns3::NqapWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));
- apDev = wifi.Install (wifiPhy, backboneNodes.Get (i));
+ apDev = wifi.Install (wifiPhy, wifiMac, backboneNodes.Get (i));
NetDeviceContainer bridgeDev;
bridgeDev = bridge.Install (backboneNodes.Get (i), NetDeviceContainer (apDev, backboneDevices.Get (i)));
@@ -141,10 +142,10 @@
"Speed", StringValue ("Constant:1.0"),
"Bounds", RectangleValue (Rectangle (wifiX, wifiX+5.0,0.0, (nStas+1)*5.0)));
mobility.Install (sta);
- wifi.SetMac ("ns3::NqstaWifiMac",
+ wifiMac.SetType ("ns3::NqstaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
- staDev = wifi.Install (wifiPhy, sta);
+ staDev = wifi.Install (wifiPhy, wifiMac, sta);
staInterface = ip.Assign (staDev);
// save everything in containers.
--- a/src/devices/wifi/adhoc-wifi-mac.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/adhoc-wifi-mac.cc Fri Apr 24 10:01:41 2009 +0200
@@ -46,7 +46,8 @@
.AddConstructor<AdhocWifiMac> ()
.AddAttribute ("DcaTxop", "The DcaTxop object",
PointerValue (),
- MakePointerAccessor (&AdhocWifiMac::DoGetDcaTxop),
+ MakePointerAccessor (&AdhocWifiMac::GetDcaTxop,
+ &AdhocWifiMac::SetDcaTxop),
MakePointerChecker<DcaTxop> ())
;
return tid;
@@ -63,10 +64,6 @@
m_dcfManager = new DcfManager ();
m_dcfManager->SetupLowListener (m_low);
-
- m_dca = CreateObject<DcaTxop> ();
- m_dca->SetLow (m_low);
- m_dca->SetManager (m_dcfManager);
}
AdhocWifiMac::~AdhocWifiMac ()
{}
@@ -250,9 +247,18 @@
m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ());
}
Ptr<DcaTxop>
-AdhocWifiMac::DoGetDcaTxop(void) const
+AdhocWifiMac::GetDcaTxop(void) const
{
return m_dca;
}
+void
+AdhocWifiMac::SetDcaTxop (Ptr<DcaTxop> dcaTxop)
+{
+ m_dca = dcaTxop;
+ m_dca->SetLow (m_low);
+ m_dca->SetManager (m_dcfManager);
+}
+
+
} // namespace ns3
--- a/src/devices/wifi/adhoc-wifi-mac.h Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/adhoc-wifi-mac.h Fri Apr 24 10:01:41 2009 +0200
@@ -86,7 +86,8 @@
void ForwardUp (Ptr<Packet> packet, WifiMacHeader const*hdr);
AdhocWifiMac (const AdhocWifiMac & ctor_arg);
AdhocWifiMac &operator = (const AdhocWifiMac &o);
- Ptr<DcaTxop> DoGetDcaTxop(void) const;
+ Ptr<DcaTxop> GetDcaTxop(void) const;
+ void SetDcaTxop (Ptr<DcaTxop> dcaTxop);
Ptr<DcaTxop> m_dca;
Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> m_upCallback;
--- a/src/devices/wifi/nqap-wifi-mac.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/nqap-wifi-mac.cc Fri Apr 24 10:01:41 2009 +0200
@@ -60,7 +60,8 @@
MakeBooleanChecker ())
.AddAttribute ("DcaTxop", "The DcaTxop object",
PointerValue (),
- MakePointerAccessor (&NqapWifiMac::DoGetDcaTxop),
+ MakePointerAccessor (&NqapWifiMac::GetDcaTxop,
+ &NqapWifiMac::SetDcaTxop),
MakePointerChecker<DcaTxop> ())
;
return tid;
@@ -78,12 +79,6 @@
m_dcfManager = new DcfManager ();
m_dcfManager->SetupLowListener (m_low);
- m_dca = CreateObject<DcaTxop> ();
- m_dca->SetLow (m_low);
- m_dca->SetManager (m_dcfManager);
- m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this));
- m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this));
-
m_beaconDca = CreateObject<DcaTxop> ();
m_beaconDca->SetAifsn(1);
m_beaconDca->SetMinCw(0);
@@ -108,6 +103,7 @@
m_phy = 0;
m_dca = 0;
m_beaconDca = 0;
+ m_stationManager = 0;
m_beaconEvent.Cancel ();
WifiMac::DoDispose ();
}
@@ -300,8 +296,7 @@
hdr.SetAddr3 (from);
hdr.SetDsFrom ();
hdr.SetDsNotTo ();
-
- m_dca->Queue (packet, hdr);
+ m_dca->Queue (packet, hdr);
}
void
NqapWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from)
@@ -565,9 +560,19 @@
}
}
Ptr<DcaTxop>
-NqapWifiMac::DoGetDcaTxop(void) const
+NqapWifiMac::GetDcaTxop(void) const
{
return m_dca;
}
+void
+NqapWifiMac::SetDcaTxop (Ptr<DcaTxop> dcaTxop)
+{
+ m_dca = dcaTxop;
+ m_dca->SetLow (m_low);
+ m_dca->SetManager (m_dcfManager);
+ m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this));
+ m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this));
+}
+
} // namespace ns3
--- a/src/devices/wifi/nqap-wifi-mac.h Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/nqap-wifi-mac.h Fri Apr 24 10:01:41 2009 +0200
@@ -21,6 +21,7 @@
#define MAC_HIGH_NQAP_H
#include <stdint.h>
+
#include "ns3/mac48-address.h"
#include "ns3/callback.h"
#include "ns3/packet.h"
@@ -113,7 +114,8 @@
virtual void DoDispose (void);
NqapWifiMac (const NqapWifiMac & ctor_arg);
NqapWifiMac &operator = (const NqapWifiMac &o);
- Ptr<DcaTxop> DoGetDcaTxop(void) const;
+ Ptr<DcaTxop> GetDcaTxop (void) const;
+ void SetDcaTxop (Ptr<DcaTxop> dcaTxop);
Ptr<DcaTxop> m_dca;
Ptr<DcaTxop> m_beaconDca;
--- a/src/devices/wifi/nqsta-wifi-mac.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/nqsta-wifi-mac.cc Fri Apr 24 10:01:41 2009 +0200
@@ -89,7 +89,8 @@
MakeBooleanChecker ())
.AddAttribute ("DcaTxop", "The DcaTxop object",
PointerValue (),
- MakePointerAccessor (&NqstaWifiMac::DoGetDcaTxop),
+ MakePointerAccessor (&NqstaWifiMac::GetDcaTxop,
+ &NqstaWifiMac::SetDcaTxop),
MakePointerChecker<DcaTxop> ())
.AddTraceSource ("Assoc", "Associated with an access point.",
MakeTraceSourceAccessor (&NqstaWifiMac::m_assocLogger))
@@ -99,7 +100,6 @@
return tid;
}
-
NqstaWifiMac::NqstaWifiMac ()
: m_state (BEACON_MISSED),
m_probeRequestEvent (),
@@ -115,10 +115,6 @@
m_dcfManager = new DcfManager ();
m_dcfManager->SetupLowListener (m_low);
-
- m_dca = CreateObject<DcaTxop> ();
- m_dca->SetLow (m_low);
- m_dca->SetManager (m_dcfManager);
}
NqstaWifiMac::~NqstaWifiMac ()
@@ -137,6 +133,7 @@
m_dcfManager = 0;
m_phy = 0;
m_dca = 0;
+ m_stationManager = 0;
WifiMac::DoDispose ();
}
@@ -207,10 +204,17 @@
return m_low->GetPifs ();
}
Ptr<DcaTxop>
-NqstaWifiMac::DoGetDcaTxop(void) const
+NqstaWifiMac::GetDcaTxop(void) const
{
return m_dca;
}
+void
+NqstaWifiMac::SetDcaTxop (Ptr<DcaTxop> dcaTxop)
+{
+ m_dca = dcaTxop;
+ m_dca->SetLow (m_low);
+ m_dca->SetManager (m_dcfManager);
+}
void
NqstaWifiMac::SetWifiPhy (Ptr<WifiPhy> phy)
{
@@ -565,7 +569,7 @@
SetState (WAIT_ASSOC_RESP);
SendAssociationRequest ();
}
- }
+ }
else if (hdr->IsProbeResp ())
{
if (m_state == WAIT_PROBE_RESP)
--- a/src/devices/wifi/nqsta-wifi-mac.h Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/nqsta-wifi-mac.h Fri Apr 24 10:01:41 2009 +0200
@@ -137,7 +137,8 @@
virtual void DoDispose (void);
NqstaWifiMac (const NqstaWifiMac & ctor_arg);
NqstaWifiMac &operator = (const NqstaWifiMac & ctor_arg);
- Ptr<DcaTxop> DoGetDcaTxop(void) const;
+ Ptr<DcaTxop> GetDcaTxop(void) const;
+ void SetDcaTxop (Ptr<DcaTxop> dcaTxop);
void SetState (enum MacState value);
enum MacState m_state;
--- a/src/devices/wifi/wifi-test.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/wifi-test.cc Fri Apr 24 10:01:41 2009 +0200
@@ -33,6 +33,8 @@
#include "ns3/simulator.h"
#include "ns3/test.h"
#include "ns3/object-factory.h"
+#include "dca-txop.h"
+#include "ns3/pointer.h"
namespace ns3 {
@@ -69,7 +71,9 @@
Ptr<Node> node = CreateObject<Node> ();
Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
+ Ptr<DcaTxop> queue = CreateObject<DcaTxop> ();
Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
+ mac->SetAttribute("DcaTxop", PointerValue (queue));
Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
--- a/src/devices/wifi/wscript Fri Apr 24 09:57:16 2009 +0200
+++ b/src/devices/wifi/wscript Fri Apr 24 10:01:41 2009 +0200
@@ -81,6 +81,8 @@
'supported-rates.h',
'error-rate-model.h',
'yans-error-rate-model.h',
+ 'dca-txop.h',
+ 'wifi-mac-header.h'
]
obj = bld.create_ns3_program('wifi-phy-test',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/helper/nqos-wifi-mac-helper.cc Fri Apr 24 10:01:41 2009 +0200
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 MIRKO BANCHI
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Mirko Banchi <mk.banchi@gmail.com>
+ */
+#include "nqos-wifi-mac-helper.h"
+#include "ns3/wifi-mac.h"
+#include "ns3/pointer.h"
+#include "ns3/dca-txop.h"
+
+namespace ns3 {
+
+NqosWifiMacHelper::NqosWifiMacHelper ()
+{
+ m_queue.SetTypeId ("ns3::DcaTxop");
+}
+
+NqosWifiMacHelper::~NqosWifiMacHelper ()
+{}
+
+NqosWifiMacHelper
+NqosWifiMacHelper::Default (void)
+{
+ NqosWifiMacHelper helper;
+ helper.SetType ("ns3::AdhocWifiMac");
+ return helper;
+}
+
+void
+NqosWifiMacHelper::SetType (std::string type,
+ std::string n0, const AttributeValue &v0,
+ std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3,
+ std::string n4, const AttributeValue &v4,
+ std::string n5, const AttributeValue &v5,
+ std::string n6, const AttributeValue &v6,
+ std::string n7, const AttributeValue &v7)
+{
+ m_mac.SetTypeId (type);
+ m_mac.Set (n0, v0);
+ m_mac.Set (n1, v1);
+ m_mac.Set (n2, v2);
+ m_mac.Set (n3, v3);
+ m_mac.Set (n4, v4);
+ m_mac.Set (n5, v5);
+ m_mac.Set (n6, v6);
+ m_mac.Set (n7, v7);
+}
+
+void
+NqosWifiMacHelper::SetDcaParameters (std::string n0, const AttributeValue &v0,
+ std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3)
+{
+ m_queue.Set (n0, v0);
+ m_queue.Set (n1, v1);
+ m_queue.Set (n2, v2);
+ m_queue.Set (n3, v3);
+}
+
+Ptr<WifiMac>
+NqosWifiMacHelper::Create (void) const
+{
+ Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
+ Ptr<DcaTxop> queue = m_queue.Create<DcaTxop> ();
+ mac->SetAttribute ("DcaTxop", PointerValue (queue));
+ return mac;
+}
+
+} //namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/helper/nqos-wifi-mac-helper.h Fri Apr 24 10:01:41 2009 +0200
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 MIRKO BANCHI
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Mirko Banchi <mk.banchi@gmail.com>
+ */
+#ifndef NQOS_WIFI_MAC_HELPER_H
+#define NQOS_WIFI_MAC_HELPER_H
+
+#include "wifi-helper.h"
+
+namespace ns3 {
+
+class NqosWifiMacHelper : public WifiMacHelper
+{
+public:
+ NqosWifiMacHelper ();
+ virtual ~NqosWifiMacHelper ();
+ /**
+ * Create a mac helper in a default working state.
+ */
+ static NqosWifiMacHelper Default (void);
+ /**
+ * \param type the type of ns3::WifiMac to create.
+ * \param n0 the name of the attribute to set
+ * \param v0 the value of the attribute to set
+ * \param n1 the name of the attribute to set
+ * \param v1 the value of the attribute to set
+ * \param n2 the name of the attribute to set
+ * \param v2 the value of the attribute to set
+ * \param n3 the name of the attribute to set
+ * \param v3 the value of the attribute to set
+ * \param n4 the name of the attribute to set
+ * \param v4 the value of the attribute to set
+ * \param n5 the name of the attribute to set
+ * \param v5 the value of the attribute to set
+ * \param n6 the name of the attribute to set
+ * \param v6 the value of the attribute to set
+ * \param n7 the name of the attribute to set
+ * \param v7 the value of the attribute to set
+ *
+ * All the attributes specified in this method should exist
+ * in the requested mac.
+ */
+ void SetType (std::string type,
+ std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+ std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+ std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+ std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+ std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+ std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+ std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
+ /**
+ * \param type the type of ns3::WifiMac to create.
+ * \param n0 the name of the attribute to set
+ * \param v0 the value of the attribute to set
+ * \param n1 the name of the attribute to set
+ * \param v1 the value of the attribute to set
+ * \param n2 the name of the attribute to set
+ * \param v2 the value of the attribute to set
+ * \param n3 the name of the attribute to set
+ */
+ void SetDcaParameters (std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+ std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+ std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ());
+private:
+ /**
+ * \returns a newly-created MAC object.
+ *
+ * This method implements the pure virtual method defined in \ref ns3::WifiMacHelper.
+ */
+ virtual Ptr<WifiMac> Create (void) const;
+
+ ObjectFactory m_mac;
+ ObjectFactory m_queue;
+};
+
+} //namespace ns3
+
+#endif /* NQOS_WIFI_MAC_HELPER_H */
--- a/src/helper/wifi-helper.cc Fri Apr 24 09:57:16 2009 +0200
+++ b/src/helper/wifi-helper.cc Fri Apr 24 10:01:41 2009 +0200
@@ -1,6 +1,7 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008 INRIA
+ * Copyright (c) 2009 MIRKO BANCHI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -16,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Author: Mirko Banchi <mk.banchi@gmail.com>
*/
#include "wifi-helper.h"
#include "ns3/wifi-net-device.h"
@@ -40,6 +42,8 @@
WifiPhyHelper::~WifiPhyHelper ()
{}
+WifiMacHelper::~WifiMacHelper ()
+{}
WifiHelper::WifiHelper ()
{}
@@ -49,7 +53,6 @@
{
WifiHelper helper;
helper.SetRemoteStationManager ("ns3::ArfWifiManager");
- helper.SetMac ("ns3::AdhocWifiMac");
return helper;
}
@@ -76,31 +79,9 @@
m_stationManager.Set (n7, v7);
}
-void
-WifiHelper::SetMac (std::string type,
- std::string n0, const AttributeValue &v0,
- std::string n1, const AttributeValue &v1,
- std::string n2, const AttributeValue &v2,
- std::string n3, const AttributeValue &v3,
- std::string n4, const AttributeValue &v4,
- std::string n5, const AttributeValue &v5,
- std::string n6, const AttributeValue &v6,
- std::string n7, const AttributeValue &v7)
-{
- m_mac = ObjectFactory ();
- m_mac.SetTypeId (type);
- m_mac.Set (n0, v0);
- m_mac.Set (n1, v1);
- m_mac.Set (n2, v2);
- m_mac.Set (n3, v3);
- m_mac.Set (n4, v4);
- m_mac.Set (n5, v5);
- m_mac.Set (n6, v6);
- m_mac.Set (n7, v7);
-}
-
NetDeviceContainer
-WifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
+WifiHelper::Install (const WifiPhyHelper &phyHelper,
+ const WifiMacHelper &macHelper, NodeContainer c) const
{
NetDeviceContainer devices;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
@@ -108,7 +89,7 @@
Ptr<Node> node = *i;
Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
- Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
+ Ptr<WifiMac> mac = macHelper.Create ();
Ptr<WifiPhy> phy = phyHelper.Create (node, device);
mac->SetAddress (Mac48Address::Allocate ());
device->SetMac (mac);
@@ -120,16 +101,20 @@
}
return devices;
}
+
NetDeviceContainer
-WifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node) const
+WifiHelper::Install (const WifiPhyHelper &phy,
+ const WifiMacHelper &mac, Ptr<Node> node) const
{
- return Install (phy, NodeContainer (node));
+ return Install (phy, mac, NodeContainer (node));
}
+
NetDeviceContainer
-WifiHelper::Install (const WifiPhyHelper &phy, std::string nodeName) const
+WifiHelper::Install (const WifiPhyHelper &phy,
+ const WifiMacHelper &mac, std::string nodeName) const
{
Ptr<Node> node = Names::Find<Node> (nodeName);
- return Install (phy, NodeContainer (node));
+ return Install (phy, mac, NodeContainer (node));
}
} // namespace ns3
--- a/src/helper/wifi-helper.h Fri Apr 24 09:57:16 2009 +0200
+++ b/src/helper/wifi-helper.h Fri Apr 24 10:01:41 2009 +0200
@@ -1,6 +1,7 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008 INRIA
+ * Copyright (c) 2009 MIRKO BANCHI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -16,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Author: Mirko Banchi <mk.banchi@gmail.com>
*/
#ifndef WIFI_HELPER_H
#define WIFI_HELPER_H
@@ -29,6 +31,7 @@
namespace ns3 {
class WifiPhy;
+class WifiMac;
class WifiNetDevice;
class Node;
@@ -54,6 +57,25 @@
};
/**
+ * \brief create MAC objects
+ *
+ * This base class must be implemented by new MAC implementation which wish to integrate
+ * with the \ref ns3::WifiHelper class.
+ */
+class WifiMacHelper
+{
+public:
+ virtual ~WifiMacHelper ();
+ /**
+ * \returns a new MAC object.
+ *
+ * Subclasses must implement this method to allow the ns3::WifiHelper class
+ * to create MAC objects from ns3::WifiHelper::Install.
+ */
+ virtual Ptr<WifiMac> Create (void) const = 0;
+};
+
+/**
* \brief helps to create WifiNetDevice objects
*
* This class can help to create a large set of similar
@@ -108,61 +130,33 @@
std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
-
- /**
- * \param type the type of ns3::WifiMac to create.
- * \param n0 the name of the attribute to set
- * \param v0 the value of the attribute to set
- * \param n1 the name of the attribute to set
- * \param v1 the value of the attribute to set
- * \param n2 the name of the attribute to set
- * \param v2 the value of the attribute to set
- * \param n3 the name of the attribute to set
- * \param v3 the value of the attribute to set
- * \param n4 the name of the attribute to set
- * \param v4 the value of the attribute to set
- * \param n5 the name of the attribute to set
- * \param v5 the value of the attribute to set
- * \param n6 the name of the attribute to set
- * \param v6 the value of the attribute to set
- * \param n7 the name of the attribute to set
- * \param v7 the value of the attribute to set
- *
- * All the attributes specified in this method should exist
- * in the requested mac.
- */
- void SetMac (std::string type,
- std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
-
/**
* \param phy the PHY helper to create PHY objects
+ * \param mac the MAC helper to create MAC objects
* \param c the set of nodes on which a wifi device must be created
* \returns a device container which contains all the devices created by this method.
*/
- NetDeviceContainer Install (const WifiPhyHelper &phy, NodeContainer c) const;
+ NetDeviceContainer Install (const WifiPhyHelper &phy,
+ const WifiMacHelper &mac, NodeContainer c) const;
/**
* \param phy the PHY helper to create PHY objects
+ * \param mac the MAC helper to create MAC objects
* \param node the node on which a wifi device must be created
* \returns a device container which contains all the devices created by this method.
*/
- NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr<Node> node) const;
+ NetDeviceContainer Install (const WifiPhyHelper &phy,
+ const WifiMacHelper &mac, Ptr<Node> node) const;
/**
* \param phy the PHY helper to create PHY objects
+ * \param mac the MAC helper to create MAC objects
* \param nodeName the name of node on which a wifi device must be created
* \returns a device container which contains all the devices created by this method.
*/
- NetDeviceContainer Install (const WifiPhyHelper &phy, std::string nodeName) const;
+ NetDeviceContainer Install (const WifiPhyHelper &phy,
+ const WifiMacHelper &mac, std::string nodeName) const;
private:
ObjectFactory m_stationManager;
- ObjectFactory m_mac;
};
} // namespace ns3
--- a/src/helper/wscript Fri Apr 24 09:57:16 2009 +0200
+++ b/src/helper/wscript Fri Apr 24 10:01:41 2009 +0200
@@ -23,6 +23,7 @@
'bridge-helper.cc',
'yans-wifi-helper.cc',
'v4ping-helper.cc',
+ 'nqos-wifi-mac-helper.cc',
]
headers = bld.new_task_gen('ns3header')
@@ -48,6 +49,7 @@
'bridge-helper.h',
'yans-wifi-helper.h',
'v4ping-helper.h',
+ 'nqos-wifi-mac-helper.h',
]
env = bld.env_of_name('default')