allow rate control algorithms to control more per-packet parameters.
This commit is contained in:
@@ -177,6 +177,12 @@ DcaTxop::Queue (Ptr<const Packet> packet, WifiMacHeader const &hdr)
|
||||
StartAccessIfNeeded ();
|
||||
}
|
||||
|
||||
MacStation *
|
||||
DcaTxop::GetStation (Mac48Address ad) const
|
||||
{
|
||||
return m_stations->Lookup (ad);
|
||||
}
|
||||
|
||||
void
|
||||
DcaTxop::RestartAccessIfNeeded (void)
|
||||
{
|
||||
@@ -216,34 +222,22 @@ DcaTxop::Parameters (void)
|
||||
bool
|
||||
DcaTxop::NeedRts (void)
|
||||
{
|
||||
if (m_currentPacket->GetSize () > Parameters ()->GetRtsCtsThreshold ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->NeedRts (m_currentPacket);
|
||||
}
|
||||
|
||||
bool
|
||||
DcaTxop::NeedFragmentation (void)
|
||||
{
|
||||
if (m_currentPacket->GetSize () > Parameters ()->GetFragmentationThreshold ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->NeedFragmentation (m_currentPacket);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DcaTxop::GetNFragments (void)
|
||||
{
|
||||
uint32_t nFragments = m_currentPacket->GetSize () / Parameters ()->GetFragmentationThreshold () + 1;
|
||||
return nFragments;
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->GetNFragments (m_currentPacket);
|
||||
}
|
||||
void
|
||||
DcaTxop::NextFragment (void)
|
||||
@@ -251,49 +245,24 @@ DcaTxop::NextFragment (void)
|
||||
m_fragmentNumber++;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DcaTxop::GetLastFragmentSize (void)
|
||||
{
|
||||
uint32_t lastFragmentSize = m_currentPacket->GetSize () %
|
||||
Parameters ()->GetFragmentationThreshold ();
|
||||
return lastFragmentSize;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DcaTxop::GetFragmentSize (void)
|
||||
{
|
||||
return Parameters ()->GetFragmentationThreshold ();
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->GetFragmentSize (m_currentPacket, m_fragmentNumber);
|
||||
}
|
||||
bool
|
||||
DcaTxop::IsLastFragment (void)
|
||||
{
|
||||
if (m_fragmentNumber == (GetNFragments () - 1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->IsLastFragment (m_currentPacket, m_fragmentNumber);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DcaTxop::GetNextFragmentSize (void)
|
||||
{
|
||||
if (IsLastFragment ())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t nextFragmentNumber = m_fragmentNumber + 1;
|
||||
if (nextFragmentNumber == (GetNFragments () - 1))
|
||||
{
|
||||
return GetLastFragmentSize ();
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetFragmentSize ();
|
||||
}
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->GetFragmentSize (m_currentPacket, m_fragmentNumber + 1);
|
||||
}
|
||||
|
||||
Ptr<Packet>
|
||||
@@ -306,18 +275,29 @@ DcaTxop::GetFragmentPacket (WifiMacHeader *hdr)
|
||||
if (IsLastFragment ())
|
||||
{
|
||||
hdr->SetNoMoreFragments ();
|
||||
fragment = m_currentPacket->CreateFragment (startOffset,
|
||||
GetLastFragmentSize ());
|
||||
}
|
||||
else
|
||||
{
|
||||
hdr->SetMoreFragments ();
|
||||
fragment = m_currentPacket->CreateFragment (startOffset,
|
||||
GetFragmentSize ());
|
||||
}
|
||||
fragment = m_currentPacket->CreateFragment (startOffset,
|
||||
GetFragmentSize ());
|
||||
return fragment;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DcaTxop::GetMaxSsrc (void) const
|
||||
{
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->GetMaxSsrc (m_currentPacket);
|
||||
}
|
||||
uint32_t
|
||||
DcaTxop::GetMaxSlrc (void) const
|
||||
{
|
||||
MacStation *station = GetStation (m_currentHdr.GetAddr1 ());
|
||||
return station->GetMaxSlrc (m_currentPacket);
|
||||
}
|
||||
|
||||
bool
|
||||
DcaTxop::NeedsAccess (void) const
|
||||
{
|
||||
@@ -429,7 +409,7 @@ DcaTxop::MissedCts (void)
|
||||
MY_DEBUG ("missed cts");
|
||||
m_ssrc++;
|
||||
m_ctstimeoutTrace (m_ssrc);
|
||||
if (m_ssrc > Parameters ()->GetMaxSsrc ())
|
||||
if (m_ssrc > GetMaxSsrc ())
|
||||
{
|
||||
MacStation *station = m_stations->Lookup (m_currentHdr.GetAddr1 ());
|
||||
station->ReportFinalRtsFailed ();
|
||||
@@ -476,7 +456,7 @@ DcaTxop::MissedAck (void)
|
||||
MY_DEBUG ("missed ack");
|
||||
m_slrc++;
|
||||
m_acktimeoutTrace (m_slrc);
|
||||
if (m_slrc > Parameters ()->GetMaxSlrc ())
|
||||
if (m_slrc > GetMaxSlrc ())
|
||||
{
|
||||
MacStation *station = m_stations->Lookup (m_currentHdr.GetAddr1 ());
|
||||
station->ReportFinalDataFailed ();
|
||||
|
||||
@@ -38,6 +38,7 @@ class MacLow;
|
||||
class MacParameters;
|
||||
class MacTxMiddle;
|
||||
class RandomStream;
|
||||
class MacStation;
|
||||
class MacStations;
|
||||
|
||||
/**
|
||||
@@ -135,9 +136,11 @@ private:
|
||||
bool NeedRts (void);
|
||||
bool NeedFragmentation (void);
|
||||
uint32_t GetNFragments (void);
|
||||
uint32_t GetLastFragmentSize (void);
|
||||
uint32_t GetNextFragmentSize (void);
|
||||
uint32_t GetFragmentSize (void);
|
||||
MacStation *GetStation (Mac48Address to) const;
|
||||
uint32_t GetMaxSsrc (void) const;
|
||||
uint32_t GetMaxSlrc (void) const;
|
||||
bool IsLastFragment (void);
|
||||
void NextFragment (void);
|
||||
Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "mac-stations.h"
|
||||
#include "wifi-default-parameters.h"
|
||||
#include "mac-parameters.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/tag.h"
|
||||
@@ -151,6 +152,7 @@ MacStations::Lookup (Mac48Address address)
|
||||
}
|
||||
MacStation *station = CreateStation ();
|
||||
station->Reset ();
|
||||
station->SetParameters (m_parameters);
|
||||
m_stations.push_back (std::make_pair (address, station));
|
||||
return station;
|
||||
}
|
||||
@@ -216,6 +218,11 @@ MacStations::IsLowLatency (void) const
|
||||
{
|
||||
return m_isLowLatency;
|
||||
}
|
||||
void
|
||||
MacStations::SetParameters (MacParameters *parameters)
|
||||
{
|
||||
m_parameters = parameters;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
@@ -301,6 +308,12 @@ MacStation::MacStation ()
|
||||
MacStation::~MacStation ()
|
||||
{}
|
||||
|
||||
void
|
||||
MacStation::SetParameters (MacParameters *parameters)
|
||||
{
|
||||
m_parameters = parameters;
|
||||
}
|
||||
|
||||
bool
|
||||
MacStation::IsBrandNew (void) const
|
||||
{
|
||||
@@ -469,6 +482,80 @@ MacStation::GetRtsMode (Ptr<const Packet> packet)
|
||||
return tag.GetRtsMode ();
|
||||
}
|
||||
|
||||
bool
|
||||
MacStation::NeedRts (Ptr<const Packet> packet)
|
||||
{
|
||||
if (packet->GetSize () > m_parameters->GetRtsCtsThreshold ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
uint32_t
|
||||
MacStation::GetMaxSsrc (Ptr<const Packet> packet)
|
||||
{
|
||||
return m_parameters->GetMaxSsrc ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacStation::GetMaxSlrc (Ptr<const Packet> packet)
|
||||
{
|
||||
return m_parameters->GetMaxSlrc ();
|
||||
}
|
||||
|
||||
bool
|
||||
MacStation::NeedFragmentation (Ptr<const Packet> packet)
|
||||
{
|
||||
if (packet->GetSize () > m_parameters->GetFragmentationThreshold ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
uint32_t
|
||||
MacStation::GetNFragments (Ptr<const Packet> packet)
|
||||
{
|
||||
uint32_t nFragments = packet->GetSize () / m_parameters->GetFragmentationThreshold () + 1;
|
||||
return nFragments;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacStation::GetFragmentSize (Ptr<const Packet> packet, uint32_t fragmentNumber)
|
||||
{
|
||||
uint32_t nFragment = GetNFragments (packet);
|
||||
if (fragmentNumber >= nFragment)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (fragmentNumber == nFragment - 1)
|
||||
{
|
||||
uint32_t lastFragmentSize = packet->GetSize () % m_parameters->GetFragmentationThreshold ();
|
||||
return lastFragmentSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_parameters->GetFragmentationThreshold ();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MacStation::IsLastFragment (Ptr<const Packet> packet, uint32_t fragmentNumber)
|
||||
{
|
||||
if (fragmentNumber == (GetNFragments (packet) - 1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace ns3 {
|
||||
|
||||
class MacStation;
|
||||
class NonUnicastMacStation;
|
||||
class MacParameters;
|
||||
|
||||
class MacStations
|
||||
{
|
||||
@@ -40,6 +41,7 @@ public:
|
||||
|
||||
MacStations (WifiMode defaultTxMode);
|
||||
virtual ~MacStations ();
|
||||
void SetParameters (MacParameters *parameters);
|
||||
|
||||
// Invoked in a STA upon dis-association
|
||||
// or in an AP upon reboot
|
||||
@@ -69,6 +71,7 @@ private:
|
||||
NonUnicastMacStation *m_nonUnicast;
|
||||
BasicModes m_basicModes;
|
||||
bool m_isLowLatency;
|
||||
MacParameters *m_parameters;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
@@ -89,6 +92,7 @@ public:
|
||||
// The set of supported modes includes
|
||||
// the BSSBasicRateSet.
|
||||
void AddSupportedMode (WifiMode mode);
|
||||
void SetParameters (MacParameters *parameters);
|
||||
|
||||
bool IsBrandNew (void) const;
|
||||
bool IsAssociated (void) const;
|
||||
@@ -112,6 +116,13 @@ public:
|
||||
virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) = 0;
|
||||
virtual void ReportFinalRtsFailed (void) = 0;
|
||||
virtual void ReportFinalDataFailed (void) = 0;
|
||||
virtual bool NeedRts (Ptr<const Packet> packet);
|
||||
virtual uint32_t GetMaxSsrc (Ptr<const Packet> packet);
|
||||
virtual uint32_t GetMaxSlrc (Ptr<const Packet> packet);
|
||||
virtual bool NeedFragmentation (Ptr<const Packet> packet);
|
||||
virtual uint32_t GetNFragments (Ptr<const Packet> packet);
|
||||
virtual uint32_t GetFragmentSize (Ptr<const Packet> packet, uint32_t fragmentNumber);
|
||||
virtual bool IsLastFragment (Ptr<const Packet> packet, uint32_t fragmentNumber);
|
||||
|
||||
WifiMode GetCtsMode (WifiMode rtsMode);
|
||||
WifiMode GetAckMode (WifiMode dataMode);
|
||||
@@ -134,6 +145,7 @@ private:
|
||||
GOT_ASSOC_TX_OK
|
||||
} m_state;
|
||||
SupportedModes m_modes;
|
||||
MacParameters *m_parameters;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -234,6 +234,7 @@ WifiNetDevice::Construct (void)
|
||||
Time ackDelay = m_phy->CalculateTxDuration (hdr.GetSize () + 4, m_phy->GetMode (0), WIFI_PREAMBLE_LONG);
|
||||
parameters->Initialize (ctsDelay, ackDelay);
|
||||
m_parameters = parameters;
|
||||
m_stations->SetParameters (m_parameters);
|
||||
|
||||
// the MacLow
|
||||
MacLow *low = new MacLow ();
|
||||
|
||||
Reference in New Issue
Block a user