support BRAND_NEW station in adhoc code. initialize the supported rates.
--- a/src/devices/wifi/mac-high-adhoc.cc Thu Oct 18 12:20:41 2007 +0200
+++ b/src/devices/wifi/mac-high-adhoc.cc Thu Oct 18 13:37:22 2007 +0200
@@ -21,6 +21,8 @@
#include "mac-high-adhoc.h"
#include "dca-txop.h"
#include "wifi-net-device.h"
+#include "mac-stations.h"
+#include "wifi-phy.h"
#include "ns3/packet.h"
#include "ns3/log.h"
@@ -49,6 +51,16 @@
{
m_dca = dca;
}
+void
+MacHighAdhoc::SetStations (MacStations *stations)
+{
+ m_stations = stations;
+}
+void
+MacHighAdhoc::SetPhy (WifiPhy *phy)
+{
+ m_phy = phy;
+}
Mac48Address
MacHighAdhoc::GetBssid (void) const
@@ -69,6 +81,18 @@
hdr.SetAddr3 (m_device->GetBssid ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
+
+ MacStation *destination = m_stations->Lookup (to);
+ if (destination->IsBrandNew ())
+ {
+ // in adhoc mode, we assume that every destination
+ // supports all the rates we support.
+ for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
+ {
+ destination->AddSupportedMode (m_phy->GetMode (0));
+ }
+ }
+
m_dca->Queue (packet, hdr);
}
--- a/src/devices/wifi/mac-high-adhoc.h Thu Oct 18 12:20:41 2007 +0200
+++ b/src/devices/wifi/mac-high-adhoc.h Thu Oct 18 13:37:22 2007 +0200
@@ -30,6 +30,8 @@
class Packet;
class WifiNetDevice;
class WifiMacHeader;
+class MacStations;
+class WifiPhy;
class MacHighAdhoc {
public:
@@ -41,6 +43,8 @@
void SetDevice (WifiNetDevice *device);
void SetForwardCallback (ForwardCallback callback);
void SetDcaTxop (DcaTxop *dca);
+ void SetStations (MacStations *stations);
+ void SetPhy (WifiPhy *phy);
Mac48Address GetBssid (void) const;
@@ -52,6 +56,8 @@
DcaTxop *m_dca;
WifiNetDevice *m_device;
ForwardCallback m_callback;
+ MacStations *m_stations;
+ WifiPhy *m_phy;
};
} // namespace ns3
--- a/src/devices/wifi/mac-stations.cc Thu Oct 18 12:20:41 2007 +0200
+++ b/src/devices/wifi/mac-stations.cc Thu Oct 18 13:37:22 2007 +0200
@@ -51,7 +51,9 @@
NonUnicastMacStation::NonUnicastMacStation (MacStations *stations)
: m_stations (stations)
-{}
+{
+ RecordDisassociated ();
+}
void
NonUnicastMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
{
@@ -184,11 +186,17 @@
namespace ns3 {
MacStation::MacStation ()
- : m_state (DISASSOC)
+ : m_state (BRAND_NEW)
{}
MacStation::~MacStation ()
{}
+bool
+MacStation::IsBrandNew (void) const
+{
+ return m_state == BRAND_NEW;
+}
+
bool
MacStation::IsAssociated (void) const
{
--- a/src/devices/wifi/mac-stations.h Thu Oct 18 12:20:41 2007 +0200
+++ b/src/devices/wifi/mac-stations.h Thu Oct 18 13:37:22 2007 +0200
@@ -86,6 +86,7 @@
// the BSSBasicRateSet.
void AddSupportedMode (WifiMode mode);
+ bool IsBrandNew (void) const;
bool IsAssociated (void) const;
bool IsWaitAssocTxOk (void) const;
void RecordWaitAssocTxOk (void);
@@ -117,6 +118,7 @@
bool IsIn (WifiMode mode) const;
WifiMode GetControlAnswerMode (WifiMode reqMode);
enum {
+ BRAND_NEW,
DISASSOC,
WAIT_ASSOC_TX_OK,
GOT_ASSOC_TX_OK
--- a/src/devices/wifi/wifi-net-device.cc Thu Oct 18 12:20:41 2007 +0200
+++ b/src/devices/wifi/wifi-net-device.cc Thu Oct 18 13:37:22 2007 +0200
@@ -158,7 +158,6 @@
return dca;
}
-
void
WifiNetDevice::ConnectTo (Ptr<WifiChannel> channel)
{
@@ -246,6 +245,8 @@
high->SetDcaTxop (m_dca);
high->SetForwardCallback (MakeCallback (&AdhocWifiNetDevice::DoForwardUp,
static_cast<WifiNetDevice *> (this)));
+ high->SetPhy (m_phy);
+ high->SetStations (m_stations);
m_rxMiddle->SetForwardCallback (MakeCallback (&MacHighAdhoc::Receive, high));
m_high = high;
}
@@ -390,7 +391,8 @@
SupportedRates rates;
for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
{
- rates.AddSupportedRate (m_phy->GetMode (i).GetPhyRate ());
+ WifiMode mode = m_phy->GetMode (i);
+ rates.AddSupportedRate (mode.GetPhyRate ());
}
MacHighNqap *high = new MacHighNqap ();