wifi: Avoid copying packets unnecessarily
Ensures that the packets forwarded up at the receiver side are the same as those received from the upper layer at the transmitter side.
This commit is contained in:
@@ -88,13 +88,13 @@ MeshWifiInterfaceMac::~MeshWifiInterfaceMac ()
|
||||
// WifiMac inherited
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MeshWifiInterfaceMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from)
|
||||
MeshWifiInterfaceMac::Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to << from);
|
||||
ForwardDown (packet, from, to);
|
||||
}
|
||||
void
|
||||
MeshWifiInterfaceMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
|
||||
MeshWifiInterfaceMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to);
|
||||
ForwardDown (packet, m_low->GetAddress (), to);
|
||||
@@ -212,10 +212,8 @@ MeshWifiInterfaceMac::SwitchFrequencyChannel (uint16_t new_id)
|
||||
// Forward frame down
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address from, Mac48Address to)
|
||||
MeshWifiInterfaceMac::ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
|
||||
{
|
||||
// copy packet to allow modifications
|
||||
Ptr<Packet> packet = const_packet->Copy ();
|
||||
WifiMacHeader hdr;
|
||||
hdr.SetType (WIFI_MAC_QOSDATA);
|
||||
hdr.SetAddr2 (GetAddress ());
|
||||
|
||||
@@ -61,8 +61,8 @@ public:
|
||||
virtual ~MeshWifiInterfaceMac ();
|
||||
|
||||
// Inherited from WifiMac
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to);
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from);
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to);
|
||||
virtual bool SupportsSendFrom () const;
|
||||
virtual void SetLinkUpCallback (Callback<void> linkUp);
|
||||
///\name Each mesh point interface must know the mesh point address
|
||||
@@ -190,7 +190,7 @@ private:
|
||||
* \param from the from address
|
||||
* \param to the to address
|
||||
*/
|
||||
void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
|
||||
void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
|
||||
/// Send beacon
|
||||
void SendBeacon ();
|
||||
/// Schedule next beacon
|
||||
|
||||
@@ -156,7 +156,7 @@ OcbWifiMac::SetLinkDownCallback (Callback<void> linkDown)
|
||||
}
|
||||
|
||||
void
|
||||
OcbWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
|
||||
OcbWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to);
|
||||
if (m_stationManager->IsBrandNew (to))
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
* dequeued as soon as the channel access function determines that
|
||||
* access is granted to this MAC.
|
||||
*/
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to);
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to);
|
||||
/**
|
||||
* \param cwmin the min contention window
|
||||
* \param cwmax the max contention window
|
||||
|
||||
@@ -676,11 +676,12 @@ WaveNetDevice::IsAvailableChannel (uint32_t channelNumber) const
|
||||
}
|
||||
|
||||
void
|
||||
WaveNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
|
||||
WaveNetDevice::ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << from << to);
|
||||
Ptr<Packet> copy = packet->Copy ();
|
||||
LlcSnapHeader llc;
|
||||
packet->RemoveHeader (llc);
|
||||
copy->RemoveHeader (llc);
|
||||
enum NetDevice::PacketType type;
|
||||
if (to.IsBroadcast ())
|
||||
{
|
||||
@@ -704,8 +705,8 @@ WaveNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to
|
||||
// currently we cannot know from which MAC entity the packet is received,
|
||||
// so we use the MAC entity for CCH as it receives this packet.
|
||||
Ptr<OcbWifiMac> mac = GetMac (CCH);
|
||||
mac->NotifyRx (packet);
|
||||
m_forwardUp (this, packet, llc.GetType (), from);
|
||||
mac->NotifyRx (copy);
|
||||
m_forwardUp (this, copy, llc.GetType (), from);
|
||||
}
|
||||
|
||||
if (!m_promiscRx.IsNull ())
|
||||
@@ -713,8 +714,8 @@ WaveNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to
|
||||
// currently we cannot know from which MAC entity the packet is received,
|
||||
// so we use the MAC entity for CCH as it receives this packet.
|
||||
Ptr<OcbWifiMac> mac = GetMac (CCH);
|
||||
mac->NotifyPromiscRx (packet);
|
||||
m_promiscRx (this, packet, llc.GetType (), from, to, type);
|
||||
mac->NotifyPromiscRx (copy);
|
||||
m_promiscRx (this, copy, llc.GetType (), from, to, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ private:
|
||||
* \param from
|
||||
* \param to
|
||||
*/
|
||||
void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
|
||||
void ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
|
||||
|
||||
/// MacEntities typedef
|
||||
typedef std::map<uint32_t, Ptr<OcbWifiMac> > MacEntities;
|
||||
|
||||
@@ -72,7 +72,7 @@ AdhocWifiMac::SetAddress (Mac48Address address)
|
||||
}
|
||||
|
||||
void
|
||||
AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
|
||||
AdhocWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to);
|
||||
if (m_stationManager->IsBrandNew (to))
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
* dequeued as soon as the channel access function determines that
|
||||
* access is granted to this MAC.
|
||||
*/
|
||||
void Enqueue (Ptr<const Packet> packet, Mac48Address to);
|
||||
void Enqueue (Ptr<Packet> packet, Mac48Address to);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -299,7 +299,7 @@ ApWifiMac::GetVhtOperationalChannelWidth (void) const
|
||||
}
|
||||
|
||||
void
|
||||
ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
|
||||
ApWifiMac::ForwardDown (Ptr<Packet> packet, Mac48Address from,
|
||||
Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << from << to);
|
||||
@@ -325,7 +325,7 @@ ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
|
||||
}
|
||||
|
||||
void
|
||||
ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
|
||||
ApWifiMac::ForwardDown (Ptr<Packet> packet, Mac48Address from,
|
||||
Mac48Address to, uint8_t tid)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << from << to << +tid);
|
||||
@@ -375,7 +375,7 @@ ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
|
||||
}
|
||||
|
||||
void
|
||||
ApWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from)
|
||||
ApWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to << from);
|
||||
if (to.IsBroadcast () || m_stationManager->IsAssociated (to))
|
||||
@@ -389,7 +389,7 @@ ApWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from
|
||||
}
|
||||
|
||||
void
|
||||
ApWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
|
||||
ApWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to);
|
||||
//We're sending this packet with a from address that is our own. We
|
||||
@@ -1022,9 +1022,7 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << *mpdu);
|
||||
const WifiMacHeader* hdr = &mpdu->GetHeader ();
|
||||
// Create a copy of the MPDU payload because non-const operations like RemovePacketTag
|
||||
// and RemoveHeader may need to be performed.
|
||||
Ptr<Packet> packet = mpdu->GetPacket ()->Copy ();
|
||||
Ptr<const Packet> packet = mpdu->GetPacket ();
|
||||
Mac48Address from = hdr->GetAddr2 ();
|
||||
if (hdr->IsData ())
|
||||
{
|
||||
@@ -1067,13 +1065,13 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
//header...
|
||||
if (hdr->IsQosData ())
|
||||
{
|
||||
ForwardDown (packet, from, to, hdr->GetQosTid ());
|
||||
ForwardDown (copy, from, to, hdr->GetQosTid ());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForwardDown (packet, from, to);
|
||||
ForwardDown (copy, from, to);
|
||||
}
|
||||
ForwardUp (copy, from, to);
|
||||
ForwardUp (packet, from, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1101,7 +1099,7 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
{
|
||||
NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ());
|
||||
MgtProbeRequestHeader probeRequestHeader;
|
||||
packet->RemoveHeader (probeRequestHeader);
|
||||
packet->PeekHeader (probeRequestHeader);
|
||||
Ssid ssid = probeRequestHeader.GetSsid ();
|
||||
if (ssid == GetSsid () || ssid.IsBroadcast ())
|
||||
{
|
||||
@@ -1118,7 +1116,7 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
//first, verify that the the station's supported
|
||||
//rate set is compatible with our Basic Rate set
|
||||
MgtAssocRequestHeader assocReq;
|
||||
packet->RemoveHeader (assocReq);
|
||||
packet->PeekHeader (assocReq);
|
||||
CapabilityInformation capabilities = assocReq.GetCapabilities ();
|
||||
m_stationManager->AddSupportedPlcpPreamble (from, capabilities.IsShortPreamble ());
|
||||
SupportedRates rates = assocReq.GetSupportedRates ();
|
||||
@@ -1314,7 +1312,7 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
//first, verify that the the station's supported
|
||||
//rate set is compatible with our Basic Rate set
|
||||
MgtReassocRequestHeader reassocReq;
|
||||
packet->RemoveHeader (reassocReq);
|
||||
packet->PeekHeader (reassocReq);
|
||||
CapabilityInformation capabilities = reassocReq.GetCapabilities ();
|
||||
m_stationManager->AddSupportedPlcpPreamble (from, capabilities.IsShortPreamble ());
|
||||
SupportedRates rates = reassocReq.GetSupportedRates ();
|
||||
@@ -1559,7 +1557,7 @@ ApWifiMac::DeaggregateAmsduAndForward (Ptr<WifiMacQueueItem> mpdu)
|
||||
Mac48Address from = i.second.GetSourceAddr ();
|
||||
Mac48Address to = i.second.GetDestinationAddr ();
|
||||
NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to);
|
||||
ForwardDown (i.first, from, to, mpdu->GetHeader ().GetQosTid ());
|
||||
ForwardDown (i.first->Copy (), from, to, mpdu->GetHeader ().GetQosTid ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
* dequeued as soon as the channel access function determines that
|
||||
* access is granted to this MAC.
|
||||
*/
|
||||
void Enqueue (Ptr<const Packet> packet, Mac48Address to);
|
||||
void Enqueue (Ptr<Packet> packet, Mac48Address to);
|
||||
|
||||
/**
|
||||
* \param packet the packet to send.
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
* this device to operate in a bridged mode, forwarding received
|
||||
* frames without altering the source address.
|
||||
*/
|
||||
void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
|
||||
void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from);
|
||||
|
||||
bool SupportsSendFrom (void) const;
|
||||
|
||||
@@ -191,7 +191,7 @@ private:
|
||||
* \param from the address to be used for Address 3 field in the header
|
||||
* \param to the address to be used for Address 1 field in the header
|
||||
*/
|
||||
void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
|
||||
void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
|
||||
/**
|
||||
* Forward the packet down to DCF/EDCAF (enqueue the packet).
|
||||
*
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
* \param to the address to be used for Address 1 field in the header
|
||||
* \param tid the traffic id for the packet
|
||||
*/
|
||||
void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
|
||||
void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
|
||||
/**
|
||||
* Forward a probe response packet to the DCF. The standard is not clear on the correct
|
||||
* queue for management frames if QoS is supported. We always use the DCF.
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
* dequeued as soon as the channel access function determines that
|
||||
* access is granted to this MAC.
|
||||
*/
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0;
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to) = 0;
|
||||
/**
|
||||
* Enable or disable QoS support for the device.
|
||||
*
|
||||
|
||||
@@ -300,7 +300,7 @@ MsduAggregator::Deaggregate (Ptr<Packet> aggregatedPacket)
|
||||
deserialized += padding;
|
||||
}
|
||||
|
||||
std::pair<Ptr<Packet>, AmsduSubframeHeader> packetHdr (extractedMsdu, hdr);
|
||||
std::pair<Ptr<const Packet>, AmsduSubframeHeader> packetHdr (extractedMsdu, hdr);
|
||||
set.push_back (packetHdr);
|
||||
}
|
||||
NS_LOG_INFO ("Deaggreated A-MSDU: extracted " << set.size () << " MSDUs");
|
||||
|
||||
@@ -43,9 +43,9 @@ class MsduAggregator : public Object
|
||||
{
|
||||
public:
|
||||
/// DeaggregatedMsdus typedef
|
||||
typedef std::list<std::pair<Ptr<Packet>, AmsduSubframeHeader> > DeaggregatedMsdus;
|
||||
typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader> > DeaggregatedMsdus;
|
||||
/// DeaggregatedMsdusCI typedef
|
||||
typedef std::list<std::pair<Ptr<Packet>, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI;
|
||||
typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI;
|
||||
/// EDCA queues typedef
|
||||
typedef std::map<AcIndex, Ptr<QosTxop> > EdcaQueues;
|
||||
|
||||
|
||||
@@ -832,7 +832,7 @@ RegularWifiMac::GetRifsSupported (void) const
|
||||
}
|
||||
|
||||
void
|
||||
RegularWifiMac::Enqueue (Ptr<const Packet> packet,
|
||||
RegularWifiMac::Enqueue (Ptr<Packet> packet,
|
||||
Mac48Address to, Mac48Address from)
|
||||
{
|
||||
//We expect RegularWifiMac subclasses which do support forwarding (e.g.,
|
||||
@@ -850,7 +850,7 @@ RegularWifiMac::SupportsSendFrom (void) const
|
||||
}
|
||||
|
||||
void
|
||||
RegularWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
|
||||
RegularWifiMac::ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << from << to);
|
||||
m_forwardUp (packet, from, to);
|
||||
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
* this device to operate in a bridged mode, forwarding received
|
||||
* frames without altering the source address.
|
||||
*/
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from);
|
||||
|
||||
virtual bool SupportsSendFrom (void) const;
|
||||
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
* dequeued as soon as the channel access function determines that
|
||||
* access is granted to this MAC.
|
||||
*/
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0;
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to) = 0;
|
||||
/**
|
||||
* \param phy the physical layer attached to this MAC.
|
||||
*/
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
* \param from the MAC address of the device that sent the packet.
|
||||
* \param to the MAC address of the device that the packet is destined for.
|
||||
*/
|
||||
typedef Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> ForwardUpCallback;
|
||||
typedef Callback<void, Ptr<const Packet>, Mac48Address, Mac48Address> ForwardUpCallback;
|
||||
/**
|
||||
* \param upCallback the callback to invoke when a packet must be
|
||||
* forwarded up the stack.
|
||||
@@ -414,7 +414,7 @@ protected:
|
||||
* \param from the address of the source
|
||||
* \param to the address of the destination
|
||||
*/
|
||||
void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
|
||||
void ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
|
||||
|
||||
/**
|
||||
* This method can be called to de-aggregate an A-MSDU and forward
|
||||
|
||||
@@ -432,7 +432,7 @@ StaWifiMac::IsWaitAssocResp (void) const
|
||||
}
|
||||
|
||||
void
|
||||
StaWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
|
||||
StaWifiMac::Enqueue (Ptr<Packet> packet, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << to);
|
||||
if (!IsAssociated ())
|
||||
@@ -506,9 +506,7 @@ StaWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << *mpdu);
|
||||
const WifiMacHeader* hdr = &mpdu->GetHeader ();
|
||||
// Create a copy of the MPDU payload because non-const operations like RemovePacketTag
|
||||
// and RemoveHeader may need to be performed.
|
||||
Ptr<Packet> packet = mpdu->GetPacket ()->Copy ();
|
||||
Ptr<const Packet> packet = mpdu->GetPacket ();
|
||||
NS_ASSERT (!hdr->IsCtl ());
|
||||
if (hdr->GetAddr3 () == GetAddress ())
|
||||
{
|
||||
@@ -577,7 +575,8 @@ StaWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
{
|
||||
NS_LOG_DEBUG ("Beacon received");
|
||||
MgtBeaconHeader beacon;
|
||||
packet->RemoveHeader (beacon);
|
||||
Ptr<Packet> copy = packet->Copy ();
|
||||
copy->RemoveHeader (beacon);
|
||||
CapabilityInformation capabilities = beacon.GetCapabilities ();
|
||||
NS_ASSERT (capabilities.IsEss ());
|
||||
bool goodBeacon = false;
|
||||
@@ -632,7 +631,7 @@ StaWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
{
|
||||
NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
|
||||
SnrTag snrTag;
|
||||
bool removed = packet->RemovePacketTag (snrTag);
|
||||
bool removed = copy->RemovePacketTag (snrTag);
|
||||
NS_ASSERT (removed);
|
||||
ApInfo apInfo;
|
||||
apInfo.m_apAddr = hdr->GetAddr2 ();
|
||||
@@ -650,14 +649,15 @@ StaWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
{
|
||||
NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
|
||||
MgtProbeResponseHeader probeResp;
|
||||
packet->RemoveHeader (probeResp);
|
||||
Ptr<Packet> copy = packet->Copy ();
|
||||
copy->RemoveHeader (probeResp);
|
||||
if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
|
||||
{
|
||||
NS_LOG_DEBUG ("Probe response is not for our SSID");
|
||||
return;
|
||||
}
|
||||
SnrTag snrTag;
|
||||
bool removed = packet->RemovePacketTag (snrTag);
|
||||
bool removed = copy->RemovePacketTag (snrTag);
|
||||
NS_ASSERT (removed);
|
||||
ApInfo apInfo;
|
||||
apInfo.m_apAddr = hdr->GetAddr2 ();
|
||||
@@ -674,7 +674,7 @@ StaWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
|
||||
if (m_state == WAIT_ASSOC_RESP)
|
||||
{
|
||||
MgtAssocResponseHeader assocResp;
|
||||
packet->RemoveHeader (assocResp);
|
||||
packet->PeekHeader (assocResp);
|
||||
if (m_assocRequestEvent.IsRunning ())
|
||||
{
|
||||
m_assocRequestEvent.Cancel ();
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
* dequeued as soon as the channel access function determines that
|
||||
* access is granted to this MAC.
|
||||
*/
|
||||
void Enqueue (Ptr<const Packet> packet, Mac48Address to);
|
||||
void Enqueue (Ptr<Packet> packet, Mac48Address to);
|
||||
|
||||
/**
|
||||
* \param phy the physical layer attached to this MAC.
|
||||
|
||||
@@ -313,19 +313,18 @@ Txop::HasFramesToTransmit (void)
|
||||
}
|
||||
|
||||
void
|
||||
Txop::Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr)
|
||||
Txop::Queue (Ptr<Packet> packet, const WifiMacHeader &hdr)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << &hdr);
|
||||
Ptr<Packet> packetCopy = packet->Copy ();
|
||||
// remove the priority tag attached, if any
|
||||
SocketPriorityTag priorityTag;
|
||||
packetCopy->RemovePacketTag (priorityTag);
|
||||
m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr, packetCopy);
|
||||
packet->RemovePacketTag (priorityTag);
|
||||
m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr, packet);
|
||||
if (m_channelAccessManager->NeedBackoffUponAccess (this))
|
||||
{
|
||||
GenerateBackoff ();
|
||||
}
|
||||
m_queue->Enqueue (Create<WifiMacQueueItem> (packetCopy, hdr));
|
||||
m_queue->Enqueue (Create<WifiMacQueueItem> (packet, hdr));
|
||||
StartAccessIfNeeded ();
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ public:
|
||||
* Store the packet in the internal queue until it
|
||||
* can be sent safely.
|
||||
*/
|
||||
virtual void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
|
||||
virtual void Queue (Ptr<Packet> packet, const WifiMacHeader &hdr);
|
||||
|
||||
/**
|
||||
* Sends CF frame to sta with address <i>addr</i>.
|
||||
|
||||
@@ -155,7 +155,7 @@ WifiMacQueueItem::DoAggregate (Ptr<const WifiMacQueueItem> msdu)
|
||||
: msdu->GetHeader ().GetAddr4 ()));
|
||||
hdr.SetLength (static_cast<uint16_t> (msdu->GetPacket ()->GetSize ()));
|
||||
|
||||
m_msduList.push_back ({msdu->GetPacket ()->Copy (), hdr});
|
||||
m_msduList.push_back ({msdu->GetPacket (), hdr});
|
||||
|
||||
// build the A-MSDU
|
||||
NS_ASSERT (m_packet);
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
* this device to operate in a bridged mode, forwarding received
|
||||
* frames without altering the source address.
|
||||
*/
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from) = 0;
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from) = 0;
|
||||
/**
|
||||
* \param packet the packet to send.
|
||||
* \param to the address to which the packet should be sent.
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
* dequeued as soon as the DCF function determines that
|
||||
* access it granted to this MAC.
|
||||
*/
|
||||
virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0;
|
||||
virtual void Enqueue (Ptr<Packet> packet, Mac48Address to) = 0;
|
||||
/**
|
||||
* \return if this MAC supports sending from arbitrary address.
|
||||
*
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
/**
|
||||
* \param upCallback the callback to invoke when a packet must be forwarded up the stack.
|
||||
*/
|
||||
virtual void SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback) = 0;
|
||||
virtual void SetForwardUpCallback (Callback<void,Ptr<const Packet>, Mac48Address, Mac48Address> upCallback) = 0;
|
||||
/**
|
||||
* \param linkUp the callback to invoke when the link becomes up.
|
||||
*/
|
||||
|
||||
@@ -358,7 +358,7 @@ WifiNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
|
||||
}
|
||||
|
||||
void
|
||||
WifiNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
|
||||
WifiNetDevice::ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet << from << to);
|
||||
LlcSnapHeader llc;
|
||||
@@ -380,21 +380,22 @@ WifiNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to
|
||||
type = NetDevice::PACKET_OTHERHOST;
|
||||
}
|
||||
|
||||
Ptr<Packet> copy = packet->Copy ();
|
||||
if (type != NetDevice::PACKET_OTHERHOST)
|
||||
{
|
||||
m_mac->NotifyRx (packet);
|
||||
packet->RemoveHeader (llc);
|
||||
m_forwardUp (this, packet, llc.GetType (), from);
|
||||
copy->RemoveHeader (llc);
|
||||
m_forwardUp (this, copy, llc.GetType (), from);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet->RemoveHeader (llc);
|
||||
copy->RemoveHeader (llc);
|
||||
}
|
||||
|
||||
if (!m_promiscRx.IsNull ())
|
||||
{
|
||||
m_mac->NotifyPromiscRx (packet);
|
||||
m_promiscRx (this, packet, llc.GetType (), from, to, type);
|
||||
m_mac->NotifyPromiscRx (copy);
|
||||
m_promiscRx (this, copy, llc.GetType (), from, to, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ protected:
|
||||
* \param from
|
||||
* \param to
|
||||
*/
|
||||
void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
|
||||
void ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -33,6 +33,14 @@
|
||||
#include "ns3/ht-configuration.h"
|
||||
#include "ns3/vht-configuration.h"
|
||||
#include "ns3/he-configuration.h"
|
||||
#include "ns3/node-container.h"
|
||||
#include "ns3/yans-wifi-helper.h"
|
||||
#include "ns3/mobility-helper.h"
|
||||
#include "ns3/pointer.h"
|
||||
#include "ns3/packet-socket-server.h"
|
||||
#include "ns3/packet-socket-client.h"
|
||||
#include "ns3/packet-socket-helper.h"
|
||||
#include <iterator>
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -606,6 +614,207 @@ HeAggregationTest::DoRun ()
|
||||
DoRunSubTest (256);
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
*
|
||||
* \brief Test for A-MSDU and A-MPDU aggregation
|
||||
*
|
||||
* This test aims to check that the packets passed to the MAC layer (on the sender
|
||||
* side) are forwarded up to the upper layer (on the receiver side) when A-MSDU and
|
||||
* A-MPDU aggregation are used. This test checks that no packet copies are performed,
|
||||
* hence packets can be tracked by means of a pointer.
|
||||
*
|
||||
* In this test, an HT STA sends 8 packets (each of 1000 bytes) to an HT AP.
|
||||
* The block ack threshold is set to 2, hence the first packet is sent as an MPDU
|
||||
* containing a single MSDU because the establishment of a Block Ack agreement is
|
||||
* not triggered yet. The maximum A-MSDU size is set to 4500 bytes and the
|
||||
* maximum A-MPDU size is set to 7500 bytes, hence the remaining packets are sent
|
||||
* in an A-MPDU containing two MPDUs, the first one including 4 MSDUs and the second
|
||||
* one including 3 MPDUs.
|
||||
*/
|
||||
class PreservePacketsInAmpdus : public TestCase
|
||||
{
|
||||
public:
|
||||
PreservePacketsInAmpdus ();
|
||||
virtual ~PreservePacketsInAmpdus ();
|
||||
|
||||
virtual void DoRun (void);
|
||||
|
||||
|
||||
private:
|
||||
std::list<Ptr<const Packet>> m_packetList; ///< List of packets passed to the MAC
|
||||
std::vector<std::size_t> m_nMpdus; ///< Number of MPDUs in PSDUs passed to the PHY
|
||||
std::vector<std::size_t> m_nMsdus; ///< Number of MSDUs in MPDUs passed to the PHY
|
||||
|
||||
/**
|
||||
* Callback invoked when an MSDU is passed to the MAC
|
||||
* \param packet the MSDU to transmit
|
||||
*/
|
||||
void NotifyMacTransmit (Ptr<const Packet> packet);
|
||||
/**
|
||||
* Callback invoked when the sender MAC passes a PSDU(s) to the PHY
|
||||
* \param psdu the PSDU
|
||||
* \param txVector the TX vector
|
||||
* \param txPowerW the transmit power in Watts
|
||||
*/
|
||||
void NotifyPsduForwardedDown (Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW);
|
||||
/**
|
||||
* Callback invoked when the receiver MAC forwards a packet up to the upper layer
|
||||
* \param p the packet
|
||||
*/
|
||||
void NotifyMacForwardUp (Ptr<const Packet> p);
|
||||
};
|
||||
|
||||
PreservePacketsInAmpdus::PreservePacketsInAmpdus ()
|
||||
: TestCase ("Test case to check that the Wifi Mac forwards up the same packets received at sender side.")
|
||||
{
|
||||
}
|
||||
|
||||
PreservePacketsInAmpdus::~PreservePacketsInAmpdus ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PreservePacketsInAmpdus::NotifyMacTransmit (Ptr<const Packet> packet)
|
||||
{
|
||||
m_packetList.push_back (packet);
|
||||
}
|
||||
|
||||
void
|
||||
PreservePacketsInAmpdus::NotifyPsduForwardedDown (Ptr<const WifiPsdu> psdu, WifiTxVector txVector, double txPowerW)
|
||||
{
|
||||
if (!psdu->GetHeader (0).IsQosData ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_nMpdus.push_back (psdu->GetNMpdus ());
|
||||
|
||||
for (auto& mpdu : *PeekPointer (psdu))
|
||||
{
|
||||
std::size_t dist = std::distance (mpdu->begin (), mpdu->end ());
|
||||
// the list of aggregated MSDUs is empty if the MPDU includes a non-aggregated MSDU
|
||||
m_nMsdus.push_back (dist > 0 ? dist : 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PreservePacketsInAmpdus::NotifyMacForwardUp (Ptr<const Packet> p)
|
||||
{
|
||||
auto it = std::find (m_packetList.begin (), m_packetList.end (), p);
|
||||
NS_TEST_EXPECT_MSG_EQ ((it != m_packetList.end ()), true, "Packet being forwarded up not found");
|
||||
m_packetList.erase (it);
|
||||
}
|
||||
|
||||
void
|
||||
PreservePacketsInAmpdus::DoRun (void)
|
||||
{
|
||||
NodeContainer wifiStaNode;
|
||||
wifiStaNode.Create (1);
|
||||
|
||||
NodeContainer wifiApNode;
|
||||
wifiApNode.Create (1);
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
|
||||
phy.SetChannel (channel.Create ());
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
|
||||
|
||||
WifiMacHelper mac;
|
||||
Ssid ssid = Ssid ("ns-3-ssid");
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"BE_MaxAmsduSize", UintegerValue (4500),
|
||||
"BE_MaxAmpduSize", UintegerValue (7500),
|
||||
"Ssid", SsidValue (ssid),
|
||||
/* setting blockack threshold for sta's BE queue */
|
||||
"BE_BlockAckThreshold", UintegerValue (2),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
|
||||
NetDeviceContainer staDevices;
|
||||
staDevices = wifi.Install (phy, mac, wifiStaNode);
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true));
|
||||
|
||||
NetDeviceContainer apDevices;
|
||||
apDevices = wifi.Install (phy, mac, wifiApNode);
|
||||
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (1.0, 0.0, 0.0));
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.Install (wifiStaNode);
|
||||
|
||||
Ptr<WifiNetDevice> ap_device = DynamicCast<WifiNetDevice> (apDevices.Get (0));
|
||||
Ptr<WifiNetDevice> sta_device = DynamicCast<WifiNetDevice> (staDevices.Get (0));
|
||||
|
||||
PacketSocketAddress socket;
|
||||
socket.SetSingleDevice (sta_device->GetIfIndex ());
|
||||
socket.SetPhysicalAddress (ap_device->GetAddress ());
|
||||
socket.SetProtocol (1);
|
||||
|
||||
// install packet sockets on nodes.
|
||||
PacketSocketHelper packetSocket;
|
||||
packetSocket.Install (wifiStaNode);
|
||||
packetSocket.Install (wifiApNode);
|
||||
|
||||
Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
|
||||
client->SetAttribute ("PacketSize", UintegerValue (1000));
|
||||
client->SetAttribute ("MaxPackets", UintegerValue (8));
|
||||
client->SetAttribute ("Interval", TimeValue (Seconds (1)));
|
||||
client->SetRemote (socket);
|
||||
wifiStaNode.Get (0)->AddApplication (client);
|
||||
client->SetStartTime (Seconds (1));
|
||||
client->SetStopTime (Seconds (3.0));
|
||||
Simulator::Schedule (Seconds (1.5), &PacketSocketClient::SetAttribute, client,
|
||||
"Interval", TimeValue (MicroSeconds (0)));
|
||||
|
||||
Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
|
||||
server->SetLocal (socket);
|
||||
wifiApNode.Get (0)->AddApplication (server);
|
||||
server->SetStartTime (Seconds (0.0));
|
||||
server->SetStopTime (Seconds (4.0));
|
||||
|
||||
PointerValue ptr;
|
||||
sta_device->GetMac ()->GetAttribute ("BE_Txop", ptr);
|
||||
Ptr<QosTxop> qosTxop = ptr.Get<QosTxop> ();
|
||||
|
||||
sta_device->GetMac ()->TraceConnectWithoutContext ("MacTx",
|
||||
MakeCallback (&PreservePacketsInAmpdus::NotifyMacTransmit, this));
|
||||
qosTxop->GetLow ()->GetPhy ()->TraceConnectWithoutContext ("PhyTxPsduBegin",
|
||||
MakeCallback (&PreservePacketsInAmpdus::NotifyPsduForwardedDown, this));
|
||||
ap_device->GetMac ()->TraceConnectWithoutContext ("MacRx",
|
||||
MakeCallback (&PreservePacketsInAmpdus::NotifyMacForwardUp, this));
|
||||
|
||||
Simulator::Stop (Seconds (5));
|
||||
Simulator::Run ();
|
||||
|
||||
Simulator::Destroy ();
|
||||
|
||||
// Two packets are transmitted. The first one is an MPDU containing a single MSDU.
|
||||
// The second one is an A-MPDU containing two MPDUs: the first MPDU contains 4 MSDUs
|
||||
// and the second MPDU contains 3 MSDUs
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMpdus.size (), 2, "Unexpected number of transmitted packets");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMsdus.size (), 3, "Unexpected number of transmitted MPDUs");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMpdus[0], 1, "Unexpected number of MPDUs in the first A-MPDU");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMsdus[0], 1, "Unexpected number of MSDUs in the first MPDU");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMpdus[1], 2, "Unexpected number of MPDUs in the second A-MPDU");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMsdus[1], 4, "Unexpected number of MSDUs in the second MPDU");
|
||||
NS_TEST_EXPECT_MSG_EQ (m_nMsdus[2], 3, "Unexpected number of MSDUs in the third MPDU");
|
||||
// All the packets must have been forwarded up at the receiver
|
||||
NS_TEST_EXPECT_MSG_EQ (m_packetList.empty (), true, "Some packets have not been forwarded up");
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup wifi-test
|
||||
* \ingroup tests
|
||||
@@ -624,6 +833,7 @@ WifiAggregationTestSuite::WifiAggregationTestSuite ()
|
||||
AddTestCase (new AmpduAggregationTest, TestCase::QUICK);
|
||||
AddTestCase (new TwoLevelAggregationTest, TestCase::QUICK);
|
||||
AddTestCase (new HeAggregationTest, TestCase::QUICK);
|
||||
AddTestCase (new PreservePacketsInAmpdus, TestCase::QUICK);
|
||||
}
|
||||
|
||||
static WifiAggregationTestSuite g_wifiAggregationTestSuite; ///< the test suite
|
||||
|
||||
Reference in New Issue
Block a user