support BRAND_NEW station in adhoc code. initialize the supported rates.
This commit is contained in:
@@ -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 @@ MacHighAdhoc::SetDcaTxop (DcaTxop *dca)
|
||||
{
|
||||
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 @@ MacHighAdhoc::Enqueue (Packet packet, Mac48Address to)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ class DcaTxop;
|
||||
class Packet;
|
||||
class WifiNetDevice;
|
||||
class WifiMacHeader;
|
||||
class MacStations;
|
||||
class WifiPhy;
|
||||
|
||||
class MacHighAdhoc {
|
||||
public:
|
||||
@@ -41,6 +43,8 @@ public:
|
||||
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 @@ private:
|
||||
DcaTxop *m_dca;
|
||||
WifiNetDevice *m_device;
|
||||
ForwardCallback m_callback;
|
||||
MacStations *m_stations;
|
||||
WifiPhy *m_phy;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -51,7 +51,9 @@ private:
|
||||
|
||||
NonUnicastMacStation::NonUnicastMacStation (MacStations *stations)
|
||||
: m_stations (stations)
|
||||
{}
|
||||
{
|
||||
RecordDisassociated ();
|
||||
}
|
||||
void
|
||||
NonUnicastMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
|
||||
{
|
||||
@@ -184,11 +186,17 @@ MacStations::EndBasicModes (void) const
|
||||
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
|
||||
{
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
// 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 @@ private:
|
||||
bool IsIn (WifiMode mode) const;
|
||||
WifiMode GetControlAnswerMode (WifiMode reqMode);
|
||||
enum {
|
||||
BRAND_NEW,
|
||||
DISASSOC,
|
||||
WAIT_ASSOC_TX_OK,
|
||||
GOT_ASSOC_TX_OK
|
||||
|
||||
@@ -158,7 +158,6 @@ WifiNetDevice::CreateDca (uint32_t minCw, uint32_t maxCw) const
|
||||
return dca;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WifiNetDevice::ConnectTo (Ptr<WifiChannel> channel)
|
||||
{
|
||||
@@ -246,6 +245,8 @@ AdhocWifiNetDevice::AdhocWifiNetDevice (Ptr<Node> node)
|
||||
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 @@ NqapWifiNetDevice::NqapWifiNetDevice (Ptr<Node> node)
|
||||
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 ();
|
||||
|
||||
Reference in New Issue
Block a user