wifi: QosTxop skips frames that cannot be forwarded to the destination

This commit is contained in:
Stefano Avallone
2021-12-15 19:11:32 +01:00
parent 961f9ab025
commit 5d7acdcf19
13 changed files with 53 additions and 2 deletions

View File

@@ -89,6 +89,11 @@ MeshWifiInterfaceMac::~MeshWifiInterfaceMac ()
//-----------------------------------------------------------------------------
// WifiMac inherited
//-----------------------------------------------------------------------------
bool
MeshWifiInterfaceMac::CanForwardPacketsTo (Mac48Address to) const
{
return true;
}
void
MeshWifiInterfaceMac::Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from)
{

View File

@@ -65,6 +65,7 @@ public:
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to);
virtual bool SupportsSendFrom () const;
virtual void SetLinkUpCallback (Callback<void> linkUp);
virtual bool CanForwardPacketsTo (Mac48Address to) const;
/// \name Each mesh point interface must know the mesh point address
///@{

View File

@@ -156,6 +156,12 @@ OcbWifiMac::SetLinkDownCallback (Callback<void> linkDown)
NS_LOG_WARN ("in OCB mode the like will never down, so linkDown will never be called");
}
bool
OcbWifiMac::CanForwardPacketsTo (Mac48Address to) const
{
return true;
}
void
OcbWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
{

View File

@@ -126,6 +126,7 @@ public:
* access is granted to this MAC.
*/
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to);
virtual bool CanForwardPacketsTo (Mac48Address to) const;
/**
* \param cwmin the min contention window
* \param cwmax the max contention window

View File

@@ -70,6 +70,12 @@ AdhocWifiMac::SetAddress (Mac48Address address)
RegularWifiMac::SetBssid (address);
}
bool
AdhocWifiMac::CanForwardPacketsTo (Mac48Address to) const
{
return true;
}
void
AdhocWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
{

View File

@@ -47,6 +47,7 @@ public:
void SetAddress (Mac48Address address) override;
void SetLinkUpCallback (Callback<void> linkUp) override;
void Enqueue (Ptr<Packet> packet, Mac48Address to) override;
bool CanForwardPacketsTo (Mac48Address to) const override;
private:
void Receive (Ptr<WifiMacQueueItem> mpdu) override;

View File

@@ -348,11 +348,17 @@ ApWifiMac::ForwardDown (Ptr<Packet> packet, Mac48Address from,
}
}
bool
ApWifiMac::CanForwardPacketsTo (Mac48Address to) const
{
return (to.IsGroup () || m_stationManager->IsAssociated (to));
}
void
ApWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from)
{
NS_LOG_FUNCTION (this << packet << to << from);
if (to.IsGroup () || m_stationManager->IsAssociated (to))
if (CanForwardPacketsTo (to))
{
ForwardDown (packet, from, to);
}

View File

@@ -59,6 +59,7 @@ public:
virtual ~ApWifiMac ();
void SetLinkUpCallback (Callback<void> linkUp) override;
bool CanForwardPacketsTo (Mac48Address to) const override;
void Enqueue (Ptr<Packet> packet, Mac48Address to) override;
void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
bool SupportsSendFrom (void) const override;

View File

@@ -394,6 +394,12 @@ QosTxop::PeekNextMpdu (uint8_t tid, Mac48Address recipient, Ptr<const WifiMacQue
NS_LOG_DEBUG ("Skipping in flight MPDU: " << *item);
item = peek ();
}
else if (item->GetHeader ().HasData ()
&& !m_mac->CanForwardPacketsTo (item->GetHeader ().GetAddr1 ()))
{
NS_LOG_DEBUG ("Skipping frame that cannot be forwarded: " << *item);
item = peek ();
}
else
{
break;

View File

@@ -454,11 +454,17 @@ StaWifiMac::IsWaitAssocResp (void) const
return m_state == WAIT_ASSOC_RESP;
}
bool
StaWifiMac::CanForwardPacketsTo (Mac48Address to) const
{
return (IsAssociated ());
}
void
StaWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
{
NS_LOG_FUNCTION (this << packet << to);
if (!IsAssociated ())
if (!CanForwardPacketsTo (to))
{
NotifyTxDrop (packet);
TryToEnsureAssociated ();

View File

@@ -130,6 +130,7 @@ public:
* access is granted to this MAC.
*/
void Enqueue (Ptr<Packet> packet, Mac48Address to) override;
bool CanForwardPacketsTo (Mac48Address to) const override;
/**
* \param phy the physical layer attached to this MAC.

View File

@@ -148,6 +148,14 @@ public:
*/
virtual bool GetShortSlotTimeSupported (void) const = 0;
/**
* Return true if packets can be forwarded to the given destination,
* false otherwise.
*
* \param to the address to which the packet should be sent
* \return whether packets can be forwarded to the given destination
*/
virtual bool CanForwardPacketsTo (Mac48Address to) const = 0;
/**
* \param packet the packet to send.
* \param to the address to which the packet should be sent.

View File

@@ -133,6 +133,7 @@ AmpduAggregationTest::DoRun (void)
fem->SetAckManager (ackManager);
m_mac->SetWifiPhy (m_phy);
m_device->SetMac (m_mac);
m_mac->SetState (StaWifiMac::ASSOCIATED);
/*
* Configure MPDU aggregation.
@@ -381,6 +382,7 @@ TwoLevelAggregationTest::DoRun (void)
fem->SetAckManager (ackManager);
m_mac->SetWifiPhy (m_phy);
m_device->SetMac (m_mac);
m_mac->SetState (StaWifiMac::ASSOCIATED);
/*
* Configure aggregation.
@@ -614,6 +616,7 @@ HeAggregationTest::DoRunSubTest (uint16_t bufferSize)
fem->SetAckManager (ackManager);
m_mac->SetWifiPhy (m_phy);
m_device->SetMac (m_mac);
m_mac->SetState (StaWifiMac::ASSOCIATED);
/*
* Configure aggregation.