--- a/samples/main-adhoc-wifi.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/samples/main-adhoc-wifi.cc Mon Oct 15 16:47:53 2007 +0200
@@ -19,7 +19,6 @@
*/
#include "ns3/wifi-net-device.h"
-#include "ns3/wifi-net-device-factory.h"
#include "ns3/wifi-channel.h"
#include "ns3/simulator.h"
#include "ns3/callback.h"
@@ -38,11 +37,11 @@
using namespace ns3;
static Ptr<Node>
-CreateAdhocNode (Ptr<WifiNetDeviceFactory> factory, Ptr<WifiChannel> channel,
+CreateAdhocNode (Ptr<WifiChannel> channel,
Position position, const char *address)
{
Ptr<Node> node = Create<InternetNode> ();
- Ptr<AdhocWifiNetDevice> device = factory->CreateAdhoc (node);
+ Ptr<AdhocWifiNetDevice> device = Create<AdhocWifiNetDevice> (node);
device->ConnectTo (channel);
Ptr<MobilityModel> mobility = Create<StaticMobilityModel> ();
mobility->Set (position);
@@ -91,22 +90,21 @@
//Simulator::EnableLogTo ("80211.log");
- Ptr<WifiNetDeviceFactory> factory = Create<WifiNetDeviceFactory> ();
- // force rts/cts on all the time.
- factory->SetMacRtsCtsThreshold (2200);
- factory->SetMacFragmentationThreshold (2200);
- //factory->SetCr (5, 5);
- //factory->SetIdeal (1e-5);
- factory->SetAarf ();
- //factory->SetArf ();
+ // enable rts cts all the time.
+ DefaultValue::Bind ("WifiRtsCtsThreshold", "0");
+ // disable fragmentation
+ DefaultValue::Bind ("WifiFragmentationThreshold", "2200");
+ DefaultValue::Bind ("WifiRateControlAlgorithm", "Aarf");
+ //DefaultValue::Bind ("WifiRateControlAlgorithm", "Arf");
+
Ptr<WifiChannel> channel = Create<WifiChannel> ();
- Ptr<Node> a = CreateAdhocNode (factory, channel,
+ Ptr<Node> a = CreateAdhocNode (channel,
Position (5.0,0.0,0.0),
"192.168.0.1");
Simulator::Schedule (Seconds (1.0), &AdvancePosition, a);
- Ptr<Node> b = CreateAdhocNode (factory, channel,
+ Ptr<Node> b = CreateAdhocNode (channel,
Position (0.0, 0.0, 0.0),
"192.168.0.2");
@@ -117,13 +115,6 @@
app->Start (Seconds (0.5));
app->Stop (Seconds (43.0));
-#if 0
- TraceContainer container = TraceContainer ();
- wifiServer->RegisterTraces (&container);
- container.SetCallback ("80211-packet-rx",
- MakeCallback (&ThroughputPrinter::Receive, printer));
-#endif
-
Simulator::Run ();
Simulator::Destroy ();
--- a/src/devices/wifi/ideal-mac-stations.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/ideal-mac-stations.cc Mon Oct 15 16:47:53 2007 +0200
@@ -18,7 +18,7 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "ideal-mac-stations.h"
-#include "wifi-phy.h"
+#include "ns3/assert.h"
#include <math.h>
#define noIDEAL_DEBUG 1
@@ -61,15 +61,9 @@
}
void
-IdealMacStations::InitializeThresholds (const WifiPhy *phy, double ber)
+IdealMacStations::AddModeSnrThreshold (WifiMode mode, double snr)
{
- uint8_t nModes = phy->GetNModes ();
- for (uint8_t i = 0; i < nModes; i++)
- {
- WifiMode mode = phy->GetMode (i);
- double snr = phy->CalculateSnr (mode, ber);
- m_thresholds.push_back (std::make_pair (snr,mode));
- }
+ m_thresholds.push_back (std::make_pair (snr,mode));
}
IdealMacStation::IdealMacStation (IdealMacStations *stations)
--- a/src/devices/wifi/ideal-mac-stations.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/ideal-mac-stations.h Mon Oct 15 16:47:53 2007 +0200
@@ -27,8 +27,6 @@
namespace ns3 {
-class WifiPhy;
-
class IdealMacStations : public MacStations {
public:
IdealMacStations (WifiMode defaultTxMode);
@@ -37,7 +35,7 @@
// return the min snr needed to successfully transmit
// data with this mode at the specified ber.
double GetSnrThreshold (WifiMode mode) const;
- void InitializeThresholds (const WifiPhy *phy, double ber);
+ void AddModeSnrThreshold (WifiMode mode, double ber);
private:
virtual class MacStation *CreateStation (void);
--- a/src/devices/wifi/mac-high-adhoc.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-high-adhoc.cc Mon Oct 15 16:47:53 2007 +0200
@@ -41,9 +41,9 @@
{}
void
-MacHighAdhoc::SetInterface (WifiNetDevice *interface)
+MacHighAdhoc::SetDevice (WifiNetDevice *device)
{
- m_interface = interface;
+ m_device = device;
}
void
@@ -73,8 +73,8 @@
WifiMacHeader hdr;
hdr.SetType (WIFI_MAC_DATA);
hdr.SetAddr1 (to);
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
- hdr.SetAddr3 (m_interface->GetBssid ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
+ hdr.SetAddr3 (m_device->GetBssid ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
m_dca->Queue (packet, hdr);
@@ -84,7 +84,7 @@
MacHighAdhoc::Receive (Packet packet, WifiMacHeader const *hdr)
{
TRACE ("received size="<<packet.GetSize ()<<", from="<<hdr->GetAddr2 ());
- m_callback (packet);
+ m_callback (packet, hdr->GetAddr2 ());
}
} // namespace ns3
--- a/src/devices/wifi/mac-high-adhoc.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-high-adhoc.h Mon Oct 15 16:47:53 2007 +0200
@@ -33,12 +33,12 @@
class MacHighAdhoc {
public:
- typedef Callback<void, Packet > ForwardCallback;
+ typedef Callback<void, Packet, const Mac48Address &> ForwardCallback;
MacHighAdhoc ();
~MacHighAdhoc ();
- void SetInterface (WifiNetDevice *interface);
+ void SetDevice (WifiNetDevice *device);
void SetForwardCallback (ForwardCallback callback);
void SetDcaTxop (DcaTxop *dca);
@@ -50,7 +50,7 @@
void Receive (Packet packet, WifiMacHeader const*hdr);
private:
DcaTxop *m_dca;
- WifiNetDevice *m_interface;
+ WifiNetDevice *m_device;
ForwardCallback m_callback;
};
--- a/src/devices/wifi/mac-high-nqap.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-high-nqap.cc Mon Oct 15 16:47:53 2007 +0200
@@ -53,9 +53,9 @@
m_dca->SetTxFailedCallback (MakeCallback (&MacHighNqap::TxFailed, this));
}
void
-MacHighNqap::SetInterface (WifiNetDevice *interface)
+MacHighNqap::SetDevice (WifiNetDevice *device)
{
- m_interface = interface;
+ m_device = device;
}
void
MacHighNqap::SetStations (MacStations *stations)
@@ -83,7 +83,7 @@
WifiMacHeader hdr;
hdr.SetTypeData ();
hdr.SetAddr1 (to);
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
hdr.SetAddr3 (from);
hdr.SetDsFrom ();
hdr.SetDsNotTo ();
@@ -92,7 +92,7 @@
void
MacHighNqap::Queue (Packet packet, Mac48Address to)
{
- ForwardDown (packet, m_interface->GetSelfAddress (), to);
+ ForwardDown (packet, m_device->GetSelfAddress (), to);
}
SupportedRates
MacHighNqap::GetSupportedRates (void)
@@ -106,13 +106,13 @@
WifiMacHeader hdr;
hdr.SetProbeResp ();
hdr.SetAddr1 (to);
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
- hdr.SetAddr3 (m_interface->GetSelfAddress ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
+ hdr.SetAddr3 (m_device->GetSelfAddress ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
Packet packet;
MgtProbeResponseHeader probe;
- probe.SetSsid (m_interface->GetSsid ());
+ probe.SetSsid (m_device->GetSsid ());
SupportedRates rates = GetSupportedRates ();
probe.SetSupportedRates (rates);
probe.SetBeaconIntervalUs (m_beaconIntervalUs);
@@ -127,8 +127,8 @@
WifiMacHeader hdr;
hdr.SetAssocResp ();
hdr.SetAddr1 (to);
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
- hdr.SetAddr3 (m_interface->GetSelfAddress ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
+ hdr.SetAddr3 (m_device->GetSelfAddress ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
Packet packet;
@@ -171,19 +171,19 @@
{
if (!hdr->IsFromDs () &&
hdr->IsToDs () &&
- hdr->GetAddr1 () == m_interface->GetSelfAddress () &&
+ hdr->GetAddr1 () == m_device->GetSelfAddress () &&
station->IsAssociated ())
{
- if (hdr->GetAddr3 () == m_interface->GetSelfAddress ())
+ if (hdr->GetAddr3 () == m_device->GetSelfAddress ())
{
- m_forwardUp (packet);
+ m_forwardUp (packet, hdr->GetAddr2 ());
}
else
{
ForwardDown (packet,
hdr->GetAddr2 (),
hdr->GetAddr3 ());
- m_forwardUp (packet);
+ m_forwardUp (packet, hdr->GetAddr2 ());
}
}
else if (hdr->IsFromDs () &&
@@ -205,7 +205,7 @@
NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
SendProbeResp (hdr->GetAddr2 ());
}
- else if (hdr->GetAddr1 () == m_interface->GetSelfAddress ())
+ else if (hdr->GetAddr1 () == m_device->GetSelfAddress ())
{
if (hdr->IsAssocReq ())
{
--- a/src/devices/wifi/mac-high-nqap.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-high-nqap.h Mon Oct 15 16:47:53 2007 +0200
@@ -35,13 +35,13 @@
class MacHighNqap {
public:
- typedef Callback<void, Packet > ForwardCallback;
+ typedef Callback<void, Packet, const Mac48Address &> ForwardCallback;
MacHighNqap ();
~MacHighNqap ();
void SetDcaTxop (DcaTxop *dca);
- void SetInterface (WifiNetDevice *interface);
+ void SetDevice (WifiNetDevice *device);
void SetStations (MacStations *stations);
void SetForwardCallback (ForwardCallback callback);
void SetSupportedRates (SupportedRates rates);
@@ -59,7 +59,7 @@
SupportedRates GetSupportedRates (void);
DcaTxop *m_dca;
- WifiNetDevice *m_interface;
+ WifiNetDevice *m_device;
MacStations *m_stations;
ForwardCallback m_forwardUp;
SupportedRates m_rates;
--- a/src/devices/wifi/mac-high-nqsta.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-high-nqsta.cc Mon Oct 15 16:47:53 2007 +0200
@@ -85,9 +85,9 @@
m_dca = dca;
}
void
-MacHighNqsta::SetInterface (WifiNetDevice *interface)
+MacHighNqsta::SetDevice (WifiNetDevice *device)
{
- m_interface = interface;
+ m_device = device;
}
void
MacHighNqsta::SetForwardCallback (ForwardCallback callback)
@@ -155,13 +155,13 @@
WifiMacHeader hdr;
hdr.SetProbeReq ();
hdr.SetAddr1 (GetBroadcastBssid ());
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
hdr.SetAddr3 (GetBroadcastBssid ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
Packet packet;
MgtProbeRequestHeader probe;
- probe.SetSsid (m_interface->GetSsid ());
+ probe.SetSsid (m_device->GetSsid ());
SupportedRates rates = GetSupportedRates ();
probe.SetSupportedRates (rates);
packet.AddHeader (probe);
@@ -179,13 +179,13 @@
WifiMacHeader hdr;
hdr.SetAssocReq ();
hdr.SetAddr1 (GetBssid ());
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
hdr.SetAddr3 (GetBssid ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
Packet packet;
MgtAssocRequestHeader assoc;
- assoc.SetSsid (m_interface->GetSsid ());
+ assoc.SetSsid (m_device->GetSsid ());
SupportedRates rates = GetSupportedRates ();
assoc.SetSupportedRates (rates);
packet.AddHeader (assoc);
@@ -287,7 +287,7 @@
WifiMacHeader hdr;
hdr.SetTypeData ();
hdr.SetAddr1 (GetBssid ());
- hdr.SetAddr2 (m_interface->GetSelfAddress ());
+ hdr.SetAddr2 (m_device->GetSelfAddress ());
hdr.SetAddr3 (to);
hdr.SetDsNotFrom ();
hdr.SetDsTo ();
@@ -298,14 +298,14 @@
MacHighNqsta::Receive (Packet packet, WifiMacHeader const *hdr)
{
NS_ASSERT (!hdr->IsCtl ());
- if (hdr->GetAddr1 () != m_interface->GetSelfAddress () &&
+ if (hdr->GetAddr1 () != m_device->GetSelfAddress () &&
!hdr->GetAddr1 ().IsBroadcast ())
{
// packet is not for us
}
else if (hdr->IsData ())
{
- m_forward (packet);
+ m_forward (packet, hdr->GetAddr2 ());
}
else if (hdr->IsProbeReq () ||
hdr->IsAssocReq ())
@@ -319,7 +319,7 @@
MgtBeaconHeader beacon;
packet.RemoveHeader (beacon);
bool goodBeacon = false;
- if (m_interface->GetSsid ().IsBroadcast ())
+ if (m_device->GetSsid ().IsBroadcast ())
{
// we do not have any special ssid so this
// beacon is as good as another.
@@ -327,7 +327,7 @@
RestartBeaconWatchdog (delay);
goodBeacon = true;
}
- else if (beacon.GetSsid ().IsEqual (m_interface->GetSsid ()))
+ else if (beacon.GetSsid ().IsEqual (m_device->GetSsid ()))
{
//beacon for our ssid.
Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons);
@@ -350,7 +350,7 @@
{
MgtProbeResponseHeader probeResp;
packet.RemoveHeader (probeResp);
- if (!probeResp.GetSsid ().IsEqual (m_interface->GetSsid ()))
+ if (!probeResp.GetSsid ().IsEqual (m_device->GetSsid ()))
{
//not a probe resp for our ssid.
return;
--- a/src/devices/wifi/mac-high-nqsta.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-high-nqsta.h Mon Oct 15 16:47:53 2007 +0200
@@ -39,7 +39,7 @@
class MacHighNqsta {
public:
- typedef Callback<void, Packet > ForwardCallback;
+ typedef Callback<void, Packet, const Mac48Address &> ForwardCallback;
typedef Callback<void> AssociatedCallback;
typedef Callback<void> DisAssociatedCallback;
@@ -47,7 +47,7 @@
~MacHighNqsta ();
void SetDcaTxop (DcaTxop *dca);
- void SetInterface (WifiNetDevice *interface);
+ void SetDevice (WifiNetDevice *device);
void SetForwardCallback (ForwardCallback callback);
void SetAssociatedCallback (AssociatedCallback callback);
void SetDisAssociatedCallback (DisAssociatedCallback callback);
@@ -87,7 +87,7 @@
Time m_assocRequestTimeout;
EventId m_probeRequestEvent;
EventId m_assocRequestEvent;
- WifiNetDevice *m_interface;
+ WifiNetDevice *m_device;
ForwardCallback m_forward;
AssociatedCallback m_associatedCallback;
DisAssociatedCallback m_disAssociatedCallback;
--- a/src/devices/wifi/mac-low.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-low.cc Mon Oct 15 16:47:53 2007 +0200
@@ -305,9 +305,9 @@
****************************************************************************/
void
-MacLow::SetInterface (Ptr<WifiNetDevice> interface)
+MacLow::SetDevice (Ptr<WifiNetDevice> device)
{
- m_interface = interface;
+ m_device = device;
}
void
MacLow::SetPhy (WifiPhy *phy)
@@ -384,7 +384,7 @@
}
void
-MacLow::ReceiveError (Packet const packet, double rxSnr)
+MacLow::ReceiveError (Packet packet, double rxSnr)
{
TRACE ("rx failed ");
m_dropError (packet);
@@ -398,7 +398,7 @@
}
void
-MacLow::ReceiveOk (Packet const packet, double rxSnr, WifiMode txMode, WifiMode headerMode)
+MacLow::ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble preamble)
{
/* A packet is received from the PHY.
* When we have handled this packet,
@@ -406,8 +406,7 @@
* packet queue.
*/
WifiMacHeader hdr;
- Packet p = packet;
- p.RemoveHeader (hdr);
+ packet.RemoveHeader (hdr);
bool isPrevNavZero = IsNavZero (Simulator::Now ());
TRACE ("duration/id=" << hdr.GetDuration ());
@@ -416,7 +415,7 @@
{
/* XXX see section 9.9.2.2.1 802.11e/D12.1 */
if (isPrevNavZero &&
- hdr.GetAddr1 () == m_interface->GetSelfAddress ())
+ hdr.GetAddr1 () == m_device->GetSelfAddress ())
{
TRACE ("rx RTS from=" << hdr.GetAddr2 () << ", schedule CTS");
assert (m_sendCtsEvent.IsExpired ());
@@ -437,7 +436,7 @@
}
}
else if (hdr.IsCts () &&
- hdr.GetAddr1 () == m_interface->GetSelfAddress () &&
+ hdr.GetAddr1 () == m_device->GetSelfAddress () &&
m_ctsTimeoutEvent.IsRunning () &&
m_hasCurrent)
{
@@ -458,7 +457,7 @@
txMode);
}
else if (hdr.IsAck () &&
- hdr.GetAddr1 () == m_interface->GetSelfAddress () &&
+ hdr.GetAddr1 () == m_device->GetSelfAddress () &&
(m_normalAckTimeoutEvent.IsRunning () ||
m_fastAckTimeoutEvent.IsRunning () ||
m_superFastAckTimeoutEvent.IsRunning ()) &&
@@ -497,7 +496,7 @@
{
TRACE ("rx drop " << hdr.GetTypeString ());
}
- else if (hdr.GetAddr1 () == m_interface->GetSelfAddress ())
+ else if (hdr.GetAddr1 () == m_device->GetSelfAddress ())
{
MacStation *station = GetStation (hdr.GetAddr2 ());
station->ReportRxOk (rxSnr, txMode);
@@ -538,8 +537,8 @@
return;
rxPacket:
WifiMacTrailer fcs;
- p.RemoveTrailer (fcs);
- m_rxCallback (p, &hdr);
+ packet.RemoveTrailer (fcs);
+ m_rxCallback (packet, &hdr);
return;
}
@@ -669,7 +668,7 @@
Time duration = MicroSeconds (hdr->GetDurationUs ());
if (hdr->IsCfpoll () &&
- hdr->GetAddr2 () == m_interface->GetBssid ())
+ hdr->GetAddr2 () == m_device->GetBssid ())
{
m_lastNavStart = newNavStart;
m_lastNavDuration = duration;
@@ -772,7 +771,7 @@
rts.SetDsNotFrom ();
rts.SetDsNotTo ();
rts.SetAddr1 (m_currentHdr.GetAddr1 ());
- rts.SetAddr2 (m_interface->GetSelfAddress ());
+ rts.SetAddr2 (m_device->GetSelfAddress ());
WifiMode rtsTxMode = GetRtsTxMode (m_currentHdr.GetAddr1 ());
Time duration = Seconds (0);
if (m_txParams.HasDurationId ())
--- a/src/devices/wifi/mac-low.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-low.h Mon Oct 15 16:47:53 2007 +0200
@@ -26,6 +26,7 @@
#include "wifi-mac-header.h"
#include "wifi-mode.h"
+#include "wifi-preamble.h"
#include "ns3/mac48-address.h"
#include "ns3/callback.h"
#include "ns3/callback-trace-source.h"
@@ -151,7 +152,7 @@
MacLow ();
~MacLow ();
- void SetInterface (Ptr<WifiNetDevice> interface);
+ void SetDevice (Ptr<WifiNetDevice> device);
void SetPhy (WifiPhy *phy);
void SetStations (MacStations *stations);
void SetParameters (MacParameters *parameters);
@@ -171,8 +172,8 @@
MacLowTransmissionParameters parameters,
MacLowTransmissionListener *listener);
- void ReceiveOk (Packet const packet, double rxSnr, WifiMode txMode, WifiMode headerMode);
- void ReceiveError (Packet const packet, double rxSnr);
+ void ReceiveOk (Packet packet, double rxSnr, WifiMode txMode, WifiPreamble preamble);
+ void ReceiveError (Packet packet, double rxSnr);
private:
void CancelAllEvents (void);
uint32_t GetAckSize (void) const;
@@ -213,7 +214,7 @@
void SendCurrentTxPacket (void);
void StartDataTxTimers (void);
- Ptr<WifiNetDevice> m_interface;
+ Ptr<WifiNetDevice> m_device;
WifiPhy *m_phy;
MacStations *m_stations;
MacParameters *m_parameters;
--- a/src/devices/wifi/mac-parameters.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-parameters.cc Mon Oct 15 16:47:53 2007 +0200
@@ -20,26 +20,36 @@
*/
#include <cassert>
-
#include "mac-parameters.h"
-#include "wifi-phy.h"
-#include "wifi-mac-header.h"
-#include "wifi-preamble.h"
+#include "wifi-default-parameters.h"
namespace ns3 {
MacParameters::MacParameters ()
{
- m_rtsCtsThreshold = 1000;
- m_fragmentationThreshold = 2000;
- m_maxSsrc = 7;
- m_maxSlrc = 7;
+ m_rtsCtsThreshold = WifiDefaultParameters::GetRtsCtsThreshold ();
+ m_fragmentationThreshold = WifiDefaultParameters::GetFragmentationThreshold ();
+ m_maxSsrc = WifiDefaultParameters::GetMaxSsrc ();
+ m_maxSlrc = WifiDefaultParameters::GetMaxSlrc ();
+
+ // ensure something not too stupid is set by default.
+ NS_ASSERT (WifiDefaultParameters::GetPhyStandard () == WifiDefaultParameters::PHY_STANDARD_80211a);
+ uint32_t ctsAckSize = (2 + 2 + 6) * 8; // bits
+ double dataRate = (6e6 / 2); // mb/s
+ Time delay = Seconds (ctsAckSize / dataRate);
+
+ Initialize (delay, delay);
}
void
-MacParameters::Initialize80211a (WifiPhy const*phy)
+MacParameters::Initialize (Time ctsDelay, Time ackDelay)
{
+ NS_ASSERT (WifiDefaultParameters::GetPhyStandard () == WifiDefaultParameters::PHY_STANDARD_80211a);
+
+ // these values are really 802.11a specific
m_sifs = MicroSeconds (16);
m_slot = MicroSeconds (9);
+
+
/* see section 9.2.10 ieee 802.11-1999 */
m_pifs = m_sifs + m_slot;
// 1000m
@@ -48,16 +58,13 @@
(Formal description of MAC operation, see details on the
Trsp timer setting at page 346)
*/
- WifiMacHeader hdr;
- hdr.SetType (WIFI_MAC_CTL_CTS);
m_ctsTimeout = m_sifs;
- m_ctsTimeout += phy->CalculateTxDuration (hdr.GetSize (), phy->GetMode (0), WIFI_PREAMBLE_LONG);
+ m_ctsTimeout += ctsDelay;
m_ctsTimeout += m_maxPropagationDelay * Scalar (2);
m_ctsTimeout += m_slot;
- hdr.SetType (WIFI_MAC_CTL_ACK);
m_ackTimeout = m_sifs;
- m_ackTimeout += phy->CalculateTxDuration (hdr.GetSize (), phy->GetMode (0), WIFI_PREAMBLE_LONG);
+ m_ackTimeout += ackDelay;
m_ackTimeout += m_maxPropagationDelay * Scalar (2);
m_ackTimeout += m_slot;
}
@@ -68,26 +75,6 @@
m_slot = slotTime;
}
-void
-MacParameters::SetMaxSsrc (uint32_t ssrc)
-{
- m_maxSsrc = ssrc;
-}
-void
-MacParameters::SetMaxSlrc (uint32_t slrc)
-{
- m_maxSlrc = slrc;
-}
-void
-MacParameters::SetRtsCtsThreshold (uint32_t threshold)
-{
- m_rtsCtsThreshold = threshold;
-}
-void
-MacParameters::SetFragmentationThreshold (uint32_t threshold)
-{
- m_fragmentationThreshold = threshold;
-}
Time
MacParameters::GetPifs (void) const
@@ -146,11 +133,6 @@
{
return Seconds (10);
}
-uint32_t
-MacParameters::GetMaxQueueSize (void) const
-{
- return 400;
-}
Time
MacParameters::GetMaxPropagationDelay (void) const
{
--- a/src/devices/wifi/mac-parameters.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/mac-parameters.h Mon Oct 15 16:47:53 2007 +0200
@@ -26,18 +26,13 @@
namespace ns3 {
-class WifiPhy;
-
-class MacParameters {
+class MacParameters
+{
public:
MacParameters ();
-
- void Initialize80211a (WifiPhy const*phy);
+
+ void Initialize (Time ctsDelay, Time ackDelay);
void SetSlotTime (Time slotTime);
- void SetMaxSsrc (uint32_t ssrc);
- void SetMaxSlrc (uint32_t ssrc);
- void SetRtsCtsThreshold (uint32_t threshold);
- void SetFragmentationThreshold (uint32_t threshold);
// XXX AP-specific
Time GetBeaconInterval (void) const;
@@ -53,13 +48,13 @@
Time GetCtsTimeout (void) const;
Time GetAckTimeout (void) const;
Time GetMsduLifetime (void) const;
- uint32_t GetMaxQueueSize (void) const;
Time GetMaxPropagationDelay (void) const;
uint32_t GetMaxMsduSize (void) const;
double GetCapLimit (void) const;
double GetMinEdcaTrafficProportion (void) const;
private:
+ void Initialize80211a (void);
Time m_ctsTimeout;
Time m_ackTimeout;
Time m_sifs;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/wifi-default-parameters.cc Mon Oct 15 16:47:53 2007 +0200
@@ -0,0 +1,204 @@
+#include "wifi-default-parameters.h"
+#include "ns3/default-value.h"
+#include "ns3/time-default-value.h"
+
+namespace ns3 {
+
+namespace WifiDefaultParameters {
+
+static NumericDefaultValue<uint32_t> g_maxSsrc
+("WifiMaxSsrc",
+ "The MAC maximum number of short retransmission retries (rts retransmissions).",
+ 7);
+
+static NumericDefaultValue<uint32_t> g_maxSlrc
+("WifiMaxSlrc",
+ "The MAC maximum number of long retransmission retries (data retransmissions).",
+ 7);
+
+static NumericDefaultValue<uint32_t> g_rtsCtsThreshold
+("WifiRtsCtsThreshold",
+ "The threshold (in bytes) over which rts/cts is used prior to data transmissions.",
+ 2000);
+
+static NumericDefaultValue<uint32_t> g_fragmentationThreshold
+("WifiFragmentationThreshold",
+ "The threshold (in bytes) over which data packets are fragmented",
+ 2000);
+
+static TimeDefaultValue g_apBeaconInterval
+("WifiApBeaconInterval",
+ "The interval between two consecutive beacons",
+ Seconds (1.0));
+
+static EnumDefaultValue<enum RateControlAlgorithm> g_rateControlAlgorithm
+("WifiRateControlAlgorithm",
+ "The rate control algorithm to use",
+ ARF, "Arf",
+ CONSTANT_RATE, "ConstantRate",
+ AARF, "Aarf",
+ IDEAL, "Ideal",
+ 0, (void *)0);
+
+static NumericDefaultValue<double> g_phyEdThreshold
+("WifiPhyEnergyDetectionThreshold",
+ "The energy of a received signal should be higher than this threshold (dbm) to allow the PHY layer to detect the signal.",
+ -140.0);
+
+static NumericDefaultValue<double> g_phyRxNoise
+("WifiPhyRxNoise",
+ "Ratio of energy lost by receiver (dB).",
+ 7);
+
+static NumericDefaultValue<double> g_phyTxPowerBase
+("WifiPhyTxPowerBase",
+ "Minimum available transmission level (dbm).",
+ 16.0206);
+static NumericDefaultValue<double> g_phyTxPowerEnd
+("WifiPhyTxPowerEnd",
+ "Maximum available transmission level (dbm).",
+ 16.0206);
+static NumericDefaultValue<uint32_t> g_phyNTxPower
+("WifiPhyTxPowerLevels",
+ "Number of transmission power levels available between WifiPhyTxPowerBase and WifiPhyTxPowerEnd included.",
+ 1);
+static NumericDefaultValue<double> g_phyTxGain
+("WifiPhyTxGain",
+ "Transmission gain (dbm).",
+ 1.0);
+static NumericDefaultValue<double> g_phyRxGain
+("WifiPhyRxGain",
+ "Reception gain (dbm).",
+ 1.0);
+static StringDefaultValue g_ssid
+("WifiSsid",
+ "The ssid to use. \"\" is the broadcast ssid.",
+ "");
+static EnumDefaultValue<enum PhyModeParameter> g_dataMode
+("WifiConstantDataRate",
+ "The rate to use for data transmissions if using the ConstantRate rate control algorithm.",
+ MODE_6MB, "6mb",
+ MODE_9MB, "9mb",
+ MODE_12MB, "12mb",
+ MODE_18MB, "18mb",
+ MODE_24MB, "24mb",
+ MODE_36MB, "36mb",
+ MODE_48MB, "48mb",
+ MODE_54MB, "54mb");
+static EnumDefaultValue<enum PhyModeParameter> g_ctlMode
+("WifiConstantCtlRate",
+ "The rate to use for control transmissions if using the ConstantRate rate control algorithm.",
+ MODE_6MB, "6mb",
+ MODE_9MB, "9mb",
+ MODE_12MB, "12mb",
+ MODE_18MB, "18mb",
+ MODE_24MB, "24mb",
+ MODE_36MB, "36mb",
+ MODE_48MB, "48mb",
+ MODE_54MB, "54mb");
+static NumericDefaultValue<double> g_idealBer
+("WifiIdealRateControlBerThreshold",
+ "The maximum Bit Error Rate acceptable at any transmission mode",
+ 10e-6);
+
+
+
+uint32_t
+GetMaxSsrc (void)
+{
+ return g_maxSsrc.GetValue ();
+}
+uint32_t
+GetMaxSlrc (void)
+{
+ return g_maxSlrc.GetValue ();
+}
+uint32_t
+GetRtsCtsThreshold (void)
+{
+ return g_rtsCtsThreshold.GetValue ();
+}
+uint32_t
+GetFragmentationThreshold (void)
+{
+ return g_fragmentationThreshold.GetValue ();
+}
+Time
+GetApBeaconInterval (void)
+{
+ return g_apBeaconInterval.GetValue ();
+}
+enum PhyStandard
+GetPhyStandard (void)
+{
+ return PHY_STANDARD_80211a;
+}
+enum RateControlAlgorithm
+GetRateControlAlgorithm (void)
+{
+ return g_rateControlAlgorithm.GetValue ();
+}
+enum PhyModeParameter
+GetConstantDataRate (void)
+{
+ return g_dataMode.GetValue ();
+}
+enum PhyModeParameter
+GetConstantCtlRate (void)
+{
+ return g_ctlMode.GetValue ();
+}
+double
+GetIdealRateControlBer (void)
+{
+ return g_idealBer.GetValue ();
+}
+double
+GetPhyEnergyDetectionThresholdDbm (void)
+{
+ return g_phyEdThreshold.GetValue ();
+}
+double
+GetPhyRxNoiseDb (void)
+{
+ return g_phyRxNoise.GetValue ();
+}
+
+double
+GetPhyTxPowerBaseDbm (void)
+{
+ return g_phyTxPowerBase.GetValue ();
+}
+
+double
+GetPhyTxPowerEndDbm (void)
+{
+ return g_phyTxPowerEnd.GetValue ();
+}
+
+uint32_t
+GetPhyTxPowerLevels (void)
+{
+ return g_phyNTxPower.GetValue ();
+}
+
+double
+GetPhyTxGainDbm (void)
+{
+ return g_phyTxGain.GetValue ();
+}
+double
+GetPhyRxGainDbm (void)
+{
+ return g_phyRxGain.GetValue ();
+}
+Ssid
+GetSsid (void)
+{
+ return Ssid (g_ssid.GetValue ().c_str ());
+}
+
+
+} // namespace WifiDefaultParameters
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/wifi-default-parameters.h Mon Oct 15 16:47:53 2007 +0200
@@ -0,0 +1,57 @@
+#ifndef WIFI_DEFAULT_PARAMETERS_H
+#define WIFI_DEFAULT_PARAMETERS_H
+
+#include <stdint.h>
+#include "ns3/nstime.h"
+#include "ssid.h"
+
+namespace ns3 {
+
+namespace WifiDefaultParameters {
+
+enum PhyStandard {
+ PHY_STANDARD_80211a,
+};
+enum RateControlAlgorithm {
+ CONSTANT_RATE,
+ ARF,
+ AARF,
+ IDEAL
+};
+enum PhyModeParameter {
+ MODE_6MB = 6000000,
+ MODE_9MB = 9000000,
+ MODE_12MB = 12000000,
+ MODE_18MB = 18000000,
+ MODE_24MB = 24000000,
+ MODE_36MB = 36000000,
+ MODE_48MB = 48000000,
+ MODE_54MB = 54000000
+};
+
+uint32_t GetMaxSsrc (void);
+uint32_t GetMaxSlrc (void);
+uint32_t GetRtsCtsThreshold (void);
+uint32_t GetFragmentationThreshold (void);
+Time GetApBeaconInterval (void);
+enum PhyStandard GetPhyStandard (void);
+enum RateControlAlgorithm GetRateControlAlgorithm (void);
+enum PhyModeParameter GetConstantDataRate (void);
+enum PhyModeParameter GetConstantCtlRate (void);
+double GetIdealRateControlBer (void);
+
+double GetPhyEnergyDetectionThresholdDbm (void);
+double GetPhyRxNoiseDb (void);
+double GetPhyTxPowerBaseDbm (void);
+double GetPhyTxPowerEndDbm (void);
+uint32_t GetPhyTxPowerLevels (void);
+double GetPhyTxGainDbm (void);
+double GetPhyRxGainDbm (void);
+
+Ssid GetSsid (void);
+
+} // namespace WifiDefaultParameters
+
+} // namespace ns3
+
+#endif /* WIFI_DEFAULT_PARAMETERS_H */
--- a/src/devices/wifi/wifi-net-device-factory.h Mon Oct 15 16:17:15 2007 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 INRIA
- * All rights reserved.
- *
- * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#ifndef NETWORK_INTERFACE_Wifi_FACTORY_H
-#define NETWORK_INTERFACE_Wifi_FACTORY_H
-
-#include <stdint.h>
-#include "ssid.h"
-#include "ns3/object.h"
-
-namespace ns3 {
-
-class WifiNetDevice;
-class AdhocWifiNetDevice;
-class NqstaWifiNetDevice;
-class NqapWifiNetDevice;
-class DcaTxop;
-class Position;
-
-class WifiNetDeviceFactory : public Object
-{
-public:
- WifiNetDeviceFactory ();
- virtual ~WifiNetDeviceFactory ();
-
- void SetArf (void);
- void SetAarf (void);
- void SetCr (uint8_t dataMode, uint8_t ctlMode);
- void SetIdeal (double ber);
-
- /* absolute reception threshold. dBm. */
- void SetPhyEdThresholdDbm (double dbm);
- /* Ratio of energy lost by receiver. dB. */
- void SetPhyRxNoiseDb (double rxNoise);
- /* absolute transmission energy. dBm. */
- void SetPhyTxPowerDbm (double txPowerBase,
- double txPowerEnd,
- uint8_t nTxPower);
-
- /* no unit. */
- void SetPropSystemLoss (double systemLoss);
- void SetPropTxGainDbm (double txGain);
- void SetPropRxGainDbm (double rxGain);
- void SetPropFrequencyHz (double frequency);
-
- void SetMacRtsCtsThreshold (uint32_t size);
- void SetMacFragmentationThreshold (uint32_t size);
- void SetMacMaxSsrc (uint32_t ssrc);
- void SetMacMaxSlrc (uint32_t slrc);
-
- void SetSsid (Ssid ssid);
-
- Ptr<AdhocWifiNetDevice> CreateAdhoc (Ptr<Node> node);
- Ptr<NqstaWifiNetDevice> CreateNqsta (Ptr<Node> node);
- Ptr<NqapWifiNetDevice> CreateNqap (Ptr<Node> node);
-private:
- void InitializeInterface (Ptr<WifiNetDevice> interface, Position *position) const;
- DcaTxop *CreateDca (Ptr<const WifiNetDevice> interface) const;
- enum {
- RATE_ARF,
- RATE_AARF,
- RATE_CR,
- RATE_IDEAL
- } m_rateControlMode;
-
- uint8_t m_crDataMode;
- uint8_t m_crCtlMode;
-
- double m_idealBer;
-
- double m_phyEdThresholdDbm;
- double m_phyRxNoiseDb;
- double m_phyTxPowerBaseDbm;
- double m_phyTxPowerEndDbm;
- uint8_t m_phyNTxPower;
-
- double m_propSystemLoss;
- double m_propTxGainDbm;
- double m_propRxGainDbm;
- double m_propFrequencyHz;
-
- uint32_t m_macRtsCtsThreshold;
- uint32_t m_macFragmentationThreshold;
- uint32_t m_macMaxSsrc;
- uint32_t m_macMaxSlrc;
-
- Ssid m_ssid;
-};
-
-}; // namespace ns3
-
-#endif /* NETWORK_INTERFACE_Wifi_FACTORY_H */
--- a/src/devices/wifi/wifi-net-device.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/wifi-net-device.cc Mon Oct 15 16:47:53 2007 +0200
@@ -33,14 +33,37 @@
#include "mac-high-nqsta.h"
#include "mac-high-nqap.h"
#include "dca-txop.h"
+#include "wifi-default-parameters.h"
+#include "arf-mac-stations.h"
+#include "aarf-mac-stations.h"
+#include "ideal-mac-stations.h"
+#include "cr-mac-stations.h"
namespace ns3 {
+static WifiMode
+GetWifiModeForPhyMode (WifiPhy *phy, enum WifiDefaultParameters::PhyModeParameter mode)
+{
+ uint32_t phyRate = (uint32_t)mode;
+ for (uint32_t i= 0; i < phy->GetNModes (); i++)
+ {
+ WifiMode mode = phy->GetMode (i);
+ if (mode.GetPhyRate () == phyRate)
+ {
+ return mode;
+ }
+ }
+ NS_ASSERT (false);
+ return WifiMode ();
+}
+
+
WifiNetDevice::WifiNetDevice (Ptr<Node> node)
: NetDevice (node, Mac48Address::Allocate ())
{
SetMtu (2300);
EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
+ Construct ();
}
WifiNetDevice::~WifiNetDevice ()
@@ -53,9 +76,100 @@
delete m_rxMiddle;
}
+void
+WifiNetDevice::Construct (void)
+{
+ // the physical layer.
+ m_phy = new WifiPhy (this);
+
+ // the rate control algorithm
+ switch (WifiDefaultParameters::GetRateControlAlgorithm ()) {
+ case WifiDefaultParameters::ARF:
+ m_stations = new ArfMacStations (m_phy->GetMode (0));
+ break;
+ case WifiDefaultParameters::AARF:
+ m_stations = new AarfMacStations (m_phy->GetMode (0));
+ break;
+ case WifiDefaultParameters::CONSTANT_RATE: {
+ WifiMode dataRate = GetWifiModeForPhyMode (m_phy, WifiDefaultParameters::GetConstantDataRate ());
+ WifiMode ctlRate = GetWifiModeForPhyMode (m_phy, WifiDefaultParameters::GetConstantCtlRate ());
+ m_stations = new CrMacStations (dataRate, ctlRate);
+ } break;
+ case WifiDefaultParameters::IDEAL: {
+ double ber = WifiDefaultParameters::GetIdealRateControlBer ();
+ IdealMacStations *ideal = new IdealMacStations (m_phy->GetMode (0));
+ uint32_t nModes = m_phy->GetNModes ();
+ for (uint32_t i = 0; i < nModes; i++)
+ {
+ WifiMode mode = m_phy->GetMode (i);
+ ideal->AddModeSnrThreshold (mode, m_phy->CalculateSnr (mode, ber));
+ }
+ m_stations = ideal;
+ } break;
+ default:
+ // NOTREACHED
+ NS_ASSERT (false);
+ break;
+ }
+
+ // MacParameters
+ MacParameters *parameters = new MacParameters ();
+ WifiMacHeader hdr;
+ hdr.SetType (WIFI_MAC_CTL_CTS);
+ Time ctsDelay = m_phy->CalculateTxDuration (hdr.GetSize (), m_phy->GetMode (0), WIFI_PREAMBLE_LONG);
+ hdr.SetType (WIFI_MAC_CTL_ACK);
+ Time ackDelay = m_phy->CalculateTxDuration (hdr.GetSize (), m_phy->GetMode (0), WIFI_PREAMBLE_LONG);
+ parameters->Initialize (ctsDelay, ackDelay);
+ m_parameters = parameters;
+
+ // the MacLow
+ MacLow *low = new MacLow ();
+ low->SetDevice (this);
+ low->SetPhy (m_phy);
+ low->SetStations (m_stations);
+ low->SetParameters (m_parameters);
+ m_phy->SetReceiveOkCallback (MakeCallback (&MacLow::ReceiveOk, low));
+ m_phy->SetReceiveErrorCallback (MakeCallback (&MacLow::ReceiveError, low));
+ m_low = low;
+
+ // the 'middle' rx
+ MacRxMiddle *rxMiddle = new MacRxMiddle ();
+ low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, rxMiddle));
+ m_rxMiddle = rxMiddle;
+
+ // the 'middle' tx
+ MacTxMiddle *txMiddle = new MacTxMiddle ();
+ m_txMiddle = txMiddle;
+
+}
+
+DcaTxop *
+WifiNetDevice::CreateDca (void) const
+{
+ DcaTxop *dca = new DcaTxop ();
+ dca->SetParameters (m_parameters);
+ dca->SetTxMiddle (m_txMiddle);
+ dca->SetLow (m_low);
+ dca->SetPhy (m_phy);
+ // 802.11a
+ Time difs = m_parameters->GetSifs () +
+ m_parameters->GetSlotTime () +
+ m_parameters->GetSlotTime ();
+ Time eifs = difs + m_parameters->GetSifs () +
+ m_phy->CalculateTxDuration (2+2+6+4, m_phy->GetMode (0), WIFI_PREAMBLE_LONG);
+ dca->SetDifs (difs);
+ dca->SetEifs (eifs);
+ dca->SetCwBounds (15, 1023);
+ dca->SetMaxQueueSize (400);
+ dca->SetMaxQueueDelay (Seconds (10));
+ return dca;
+}
+
+
void
WifiNetDevice::ConnectTo (Ptr<WifiChannel> channel)
{
+ m_channel = channel;
m_phy->SetChannel (channel);
NotifyConnected ();
}
@@ -92,6 +206,17 @@
Mac48Address self = Mac48Address::ConvertFrom (GetAddress ());
return self;
}
+bool
+WifiNetDevice::DoNeedsArp (void) const
+{
+ return true;
+}
+Ptr<Channel>
+WifiNetDevice::DoGetChannel (void) const
+{
+ return m_channel;
+}
+
/*****************************************************
* Adhoc code
@@ -99,7 +224,18 @@
AdhocWifiNetDevice::AdhocWifiNetDevice (Ptr<Node> node)
: WifiNetDevice (node)
-{}
+{
+ m_ssid = WifiDefaultParameters::GetSsid ();
+ m_dca = CreateDca ();
+
+ MacHighAdhoc *high = new MacHighAdhoc ();
+ high->SetDevice (this);
+ high->SetDcaTxop (m_dca);
+ high->SetForwardCallback (MakeCallback (&AdhocWifiNetDevice::DoForwardUp,
+ static_cast<WifiNetDevice *> (this)));
+ m_rxMiddle->SetForwardCallback (MakeCallback (&MacHighAdhoc::Receive, high));
+ m_high = high;
+}
AdhocWifiNetDevice::~AdhocWifiNetDevice ()
{
delete m_dca;
@@ -139,7 +275,30 @@
NqstaWifiNetDevice::NqstaWifiNetDevice (Ptr<Node> node)
: WifiNetDevice (node)
-{}
+{
+ m_ssid = WifiDefaultParameters::GetSsid ();
+ m_dca = CreateDca ();
+
+ SupportedRates rates;
+ for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
+ {
+ WifiMode mode = m_phy->GetMode (i);
+ rates.AddSupportedRate (mode.GetPhyRate ());
+ }
+
+ MacHighNqsta *high = new MacHighNqsta ();
+ high->SetDevice (this);
+ high->SetDcaTxop (m_dca);
+ high->SetForwardCallback (MakeCallback (&NqstaWifiNetDevice::DoForwardUp,
+ this));
+ high->SetAssociatedCallback (MakeCallback (&NqstaWifiNetDevice::Associated,
+ this));
+ high->SetDisAssociatedCallback (MakeCallback (&NqstaWifiNetDevice::DisAssociated,
+ this));
+ high->SetSupportedRates (rates);
+ m_rxMiddle->SetForwardCallback (MakeCallback (&MacHighNqsta::Receive, high));
+ m_high = high;
+}
NqstaWifiNetDevice::~NqstaWifiNetDevice ()
{
delete m_dca;
@@ -193,7 +352,27 @@
NqapWifiNetDevice::NqapWifiNetDevice (Ptr<Node> node)
: WifiNetDevice (node)
-{}
+{
+ m_ssid = WifiDefaultParameters::GetSsid ();
+
+ m_dca = CreateDca ();
+
+ SupportedRates rates;
+ for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
+ {
+ rates.AddSupportedRate (m_phy->GetMode (i).GetPhyRate ());
+ }
+
+ MacHighNqap *high = new MacHighNqap ();
+ high->SetDevice (this);
+ high->SetDcaTxop (m_dca);
+ high->SetStations (m_stations);
+ high->SetForwardCallback (MakeCallback (&NqapWifiNetDevice::DoForwardUp,
+ this));
+ high->SetSupportedRates (rates);
+ m_rxMiddle->SetForwardCallback (MakeCallback (&MacHighNqap::Receive, high));
+ m_high = high;
+}
NqapWifiNetDevice::~NqapWifiNetDevice ()
{
delete m_dca;
--- a/src/devices/wifi/wifi-net-device.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/wifi-net-device.h Mon Oct 15 16:47:53 2007 +0200
@@ -53,26 +53,33 @@
virtual Mac48Address GetBssid (void) const = 0;
virtual Ssid GetSsid (void) const = 0;
+private:
+ // inherited from parent.
+ virtual bool DoNeedsArp (void) const;
+ virtual Ptr<Channel> DoGetChannel (void) const;
+ virtual bool SendTo (const Packet &packet, const Address &to, uint16_t protocolNumber);
+ // defined for children
+ virtual void NotifyConnected (void) = 0;
+ virtual bool DoSendTo (const Packet &packet, const Mac48Address &to) = 0;
+ // private helper
+ void Construct (void);
+ friend class WifiNetDeviceFactory;
+
+ CallbackTraceSource<Packet, Mac48Address> m_rxLogger;
+ CallbackTraceSource<Packet, Mac48Address> m_txLogger;
protected:
WifiNetDevice (Ptr<Node> node);
void DoForwardUp (Packet packet, const Mac48Address &from);
-private:
- virtual bool SendTo (const Packet &packet, const Address &to, uint16_t protocolNumber);
- virtual void NotifyConnected (void) = 0;
- virtual bool DoSendTo (const Packet &packet, const Mac48Address &to) = 0;
- void Associated (void);
+ DcaTxop *CreateDca (void) const;
- friend class WifiNetDeviceFactory;
-
+ Ptr<WifiChannel> m_channel;
WifiPhy *m_phy;
MacStations *m_stations;
MacLow *m_low;
MacRxMiddle *m_rxMiddle;
MacTxMiddle *m_txMiddle;
MacParameters *m_parameters;
- CallbackTraceSource<Packet, Mac48Address> m_rxLogger;
- CallbackTraceSource<Packet, Mac48Address> m_txLogger;
};
class AdhocWifiNetDevice : public WifiNetDevice {
@@ -85,9 +92,10 @@
void SetSsid (Ssid ssid);
private:
+ void ForwardUp (void);
virtual bool DoSendTo (const Packet &packet, Mac48Address const & to);
virtual void NotifyConnected (void);
- friend class WifiNetDeviceFactory;
+
Ssid m_ssid;
DcaTxop *m_dca;
MacHighAdhoc *m_high;
--- a/src/devices/wifi/wifi-phy.cc Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/wifi-phy.cc Mon Oct 15 16:47:53 2007 +0200
@@ -24,6 +24,7 @@
#include "wifi-channel.h"
#include "wifi-net-device.h"
#include "wifi-preamble.h"
+#include "wifi-default-parameters.h"
#include "ns3/simulator.h"
#include "ns3/packet.h"
#include "ns3/random-variable.h"
@@ -198,13 +199,13 @@
****************************************************************/
WifiPhy::WifiPhy (Ptr<WifiNetDevice> device)
- : m_edThresholdW (DbmToW (-140)),
- m_txGainDbm (1.0),
- m_rxGainDbm (1.0),
- m_rxNoiseRatio (DbToRatio (7)),
- m_txPowerBaseDbm (16.0206),
- m_txPowerEndDbm (16.0206),
- m_nTxPower (1),
+ : m_edThresholdW (DbmToW (WifiDefaultParameters::GetPhyEnergyDetectionThresholdDbm ())),
+ m_txGainDbm (WifiDefaultParameters::GetPhyTxGainDbm ()),
+ m_rxGainDbm (WifiDefaultParameters::GetPhyRxGainDbm ()),
+ m_rxNoiseRatio (DbToRatio (WifiDefaultParameters::GetPhyRxNoiseDb ())),
+ m_txPowerBaseDbm (WifiDefaultParameters::GetPhyTxPowerBaseDbm ()),
+ m_txPowerEndDbm (WifiDefaultParameters::GetPhyTxPowerEndDbm ()),
+ m_nTxPower (WifiDefaultParameters::GetPhyTxPowerLevels ()),
m_syncing (false),
m_endTx (Seconds (0)),
m_endSync (Seconds (0)),
@@ -216,7 +217,10 @@
m_device (device),
m_endSyncEvent (),
m_random (0.0, 1.0)
-{}
+{
+ NS_ASSERT (WifiDefaultParameters::GetPhyStandard () == WifiDefaultParameters::PHY_STANDARD_80211a);
+ Configure80211a ();
+}
WifiPhy::~WifiPhy ()
{
@@ -357,31 +361,6 @@
m_channel->Send (m_device, packet, GetPowerDbm (txPower) + m_txGainDbm, txMode, preamble);
}
-void
-WifiPhy::SetEdThresholdDbm (double edThreshold)
-{
- m_edThresholdW = DbmToW (edThreshold);
-}
-void
-WifiPhy::SetRxNoiseDb (double rxNoise)
-{
- m_rxNoiseRatio = DbToRatio (rxNoise);
-}
-void
-WifiPhy::SetTxPowerIncrementsDbm (double txPowerBase,
- double txPowerEnd,
- int nTxPower)
-{
- m_txPowerBaseDbm = txPowerBase;
- m_txPowerEndDbm = txPowerEnd;
- m_nTxPower = nTxPower;
-}
-void
-WifiPhy::SetRxTxGainDbm (double rxGainDbm, double txGainDbm)
-{
- m_rxGainDbm = rxGainDbm;
- m_txGainDbm = txGainDbm;
-}
uint32_t
WifiPhy::GetNModes (void) const
{
--- a/src/devices/wifi/wifi-phy.h Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/wifi-phy.h Mon Oct 15 16:47:53 2007 +0200
@@ -72,8 +72,8 @@
class WifiPhy
{
public:
- typedef Callback<void,Packet const , double, WifiMode, enum WifiPreamble> SyncOkCallback;
- typedef Callback<void,Packet const , double> SyncErrorCallback;
+ typedef Callback<void,Packet, double, WifiMode, enum WifiPreamble> SyncOkCallback;
+ typedef Callback<void,Packet, double> SyncErrorCallback;
WifiPhy (Ptr<WifiNetDevice> device);
virtual ~WifiPhy ();
@@ -97,13 +97,6 @@
Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble) const;
- void Configure80211a (void);
- void SetEdThresholdDbm (double rxThreshold);
- void SetRxNoiseDb (double rxNoise);
- void SetTxPowerIncrementsDbm (double txPowerBase,
- double txPowerEnd,
- int nTxPower);
- void SetRxTxGainDbm (double rxGainDbm, double txGainDbm);
uint32_t GetNModes (void) const;
WifiMode GetMode (uint32_t mode) const;
uint32_t GetModeBitRate (uint8_t mode) const;
@@ -134,6 +127,7 @@
typedef std::vector <NiChange> NiChanges;
private:
+ void Configure80211a (void);
char const *StateToString (enum WifiPhyState state);
enum WifiPhyState GetState (void);
double GetEdThresholdW (void) const;
--- a/src/devices/wifi/wscript Mon Oct 15 16:17:15 2007 +0200
+++ b/src/devices/wifi/wscript Mon Oct 15 16:47:53 2007 +0200
@@ -31,11 +31,11 @@
'mac-high-nqap.cc',
'mac-high-nqsta.cc',
'wifi-net-device.cc',
+ 'wifi-default-parameters.cc'
]
headers = bld.create_obj('ns3header')
headers.source = [
'wifi-net-device.h',
- 'wifi-net-device-factory.h',
'wifi-channel.h',
'wifi-mode.h',
'ssid.h',