wifi: Get rid of MSDU and MPDU standard aggregator classes
This commit is contained in:
@@ -46,10 +46,10 @@ VhtWifiMacHelper::Default (void)
|
||||
"VhtSupported", BooleanValue (true));
|
||||
|
||||
//MPDU aggregation is always supported
|
||||
helper.SetMpduAggregatorForAc (AC_VO, "ns3::MpduStandardAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_VI, "ns3::MpduStandardAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_BE, "ns3::MpduStandardAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_BK, "ns3::MpduStandardAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_VO, "ns3::MpduAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_VI, "ns3::MpduAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_BE, "ns3::MpduAggregator");
|
||||
helper.SetMpduAggregatorForAc (AC_BK, "ns3::MpduAggregator");
|
||||
|
||||
return helper;
|
||||
}
|
||||
|
||||
@@ -821,9 +821,7 @@ WifiHelper::EnableLogComponents (void)
|
||||
LogComponentEnable ("MinstrelHtWifiManager", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("MinstrelWifiManager", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("MpduAggregator", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("MpduStandardAggregator", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("MsduAggregator", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("MsduStandardAggregator", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("NistErrorRateModel", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("OnoeWifiManager", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("ParfWifiManager", LOG_LEVEL_ALL);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "mpdu-aggregator.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("MpduAggregator");
|
||||
@@ -33,11 +34,139 @@ MpduAggregator::GetTypeId (void)
|
||||
static TypeId tid = TypeId ("ns3::MpduAggregator")
|
||||
.SetParent<Object> ()
|
||||
.SetGroupName ("Wifi")
|
||||
//No AddConstructor because this is an abstract class.
|
||||
.AddConstructor<MpduAggregator> ()
|
||||
.AddAttribute ("MaxAmpduSize", "Max length in bytes of an A-MPDU (Deprecated!)",
|
||||
UintegerValue (65535),
|
||||
MakeUintegerAccessor (&MpduAggregator::m_maxAmpduLength),
|
||||
MakeUintegerChecker<uint16_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
MpduAggregator::MpduAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
MpduAggregator::~MpduAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MpduAggregator::SetMaxAmpduSize (uint16_t maxSize)
|
||||
{
|
||||
m_maxAmpduLength = maxSize;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
MpduAggregator::GetMaxAmpduSize (void) const
|
||||
{
|
||||
return m_maxAmpduLength;
|
||||
}
|
||||
|
||||
bool
|
||||
MpduAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<Packet> currentPacket;
|
||||
AmpduSubframeHeader currentHdr;
|
||||
|
||||
uint8_t padding = CalculatePadding (aggregatedPacket);
|
||||
uint32_t actualSize = aggregatedPacket->GetSize ();
|
||||
|
||||
if ((4 + packet->GetSize () + actualSize + padding) <= m_maxAmpduLength)
|
||||
{
|
||||
if (padding)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
aggregatedPacket->AddAtEnd (pad);
|
||||
}
|
||||
currentHdr.SetCrc (1);
|
||||
currentHdr.SetSig ();
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
currentPacket = packet->Copy ();
|
||||
|
||||
currentPacket->AddHeader (currentHdr);
|
||||
aggregatedPacket->AddAtEnd (currentPacket);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
MpduAggregator::AggregateSingleMpdu (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<Packet> currentPacket;
|
||||
AmpduSubframeHeader currentHdr;
|
||||
|
||||
uint8_t padding = CalculatePadding (aggregatedPacket);
|
||||
if (padding)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
aggregatedPacket->AddAtEnd (pad);
|
||||
}
|
||||
|
||||
currentHdr.SetEof (1);
|
||||
currentHdr.SetCrc (1);
|
||||
currentHdr.SetSig ();
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
currentPacket = packet->Copy ();
|
||||
|
||||
currentPacket->AddHeader (currentHdr);
|
||||
aggregatedPacket->AddAtEnd (currentPacket);
|
||||
}
|
||||
|
||||
void
|
||||
MpduAggregator::AddHeaderAndPad (Ptr<Packet> packet, bool last, bool isSingleMpdu) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
AmpduSubframeHeader currentHdr;
|
||||
|
||||
//This is called to prepare packets from the aggregate queue to be sent so no need to check total size since it has already been
|
||||
//done before when deciding how many packets to add to the queue
|
||||
currentHdr.SetCrc (1);
|
||||
currentHdr.SetSig ();
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
if (isSingleMpdu)
|
||||
{
|
||||
currentHdr.SetEof (1);
|
||||
}
|
||||
|
||||
packet->AddHeader (currentHdr);
|
||||
uint32_t padding = CalculatePadding (packet);
|
||||
|
||||
if (padding && !last)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
packet->AddAtEnd (pad);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MpduAggregator::CanBeAggregated (uint32_t packetSize, Ptr<Packet> aggregatedPacket, uint8_t blockAckSize) const
|
||||
{
|
||||
uint8_t padding = CalculatePadding (aggregatedPacket);
|
||||
uint32_t actualSize = aggregatedPacket->GetSize ();
|
||||
if (blockAckSize > 0)
|
||||
{
|
||||
blockAckSize = blockAckSize + 4 + padding;
|
||||
}
|
||||
if ((4 + packetSize + actualSize + padding + blockAckSize) <= m_maxAmpduLength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t
|
||||
MpduAggregator::CalculatePadding (Ptr<const Packet> packet) const
|
||||
{
|
||||
return (4 - (packet->GetSize () % 4 )) % 4;
|
||||
}
|
||||
|
||||
MpduAggregator::DeaggregatedMpdus
|
||||
MpduAggregator::Deaggregate (Ptr<Packet> aggregatedPacket)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ns3 {
|
||||
class WifiMacHeader;
|
||||
|
||||
/**
|
||||
* \brief Abstract class that concrete mpdu aggregators have to implement
|
||||
* \brief Aggregator used to construct A-MPDUs
|
||||
* \ingroup wifi
|
||||
*/
|
||||
class MpduAggregator : public Object
|
||||
@@ -51,20 +51,24 @@ public:
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
MpduAggregator ();
|
||||
virtual ~MpduAggregator ();
|
||||
|
||||
/**
|
||||
* Sets the maximum A-MPDU size in bytes.
|
||||
* Value 0 means that MPDU aggregation is disabled.
|
||||
*
|
||||
* \param maxSize the maximum A-MPDU size in bytes.
|
||||
*/
|
||||
virtual void SetMaxAmpduSize (uint32_t maxSize) = 0;
|
||||
void SetMaxAmpduSize (uint16_t maxSize);
|
||||
/**
|
||||
* Returns the maximum A-MPDU size in bytes.
|
||||
* Value 0 means that MPDU aggregation is disabled.
|
||||
*
|
||||
* \return the maximum A-MPDU size in bytes.
|
||||
*/
|
||||
virtual uint32_t GetMaxAmpduSize (void) const = 0;
|
||||
uint16_t GetMaxAmpduSize (void) const;
|
||||
|
||||
/**
|
||||
* \param packet Packet we have to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket Packet that will contain <i>packet</i>, if aggregation is possible.
|
||||
@@ -74,14 +78,14 @@ public:
|
||||
* Adds <i>packet</i> to <i>aggregatedPacket</i>. In concrete aggregator's implementation is
|
||||
* specified how and if <i>packet</i> can be added to <i>aggregatedPacket</i>.
|
||||
*/
|
||||
virtual bool Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const = 0;
|
||||
bool Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const;
|
||||
/**
|
||||
* \param packet the packet we want to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket packet that will contain the packet of size <i>packetSize</i>, if aggregation is possible.
|
||||
*
|
||||
* This method performs a VHT/HE single MPDU aggregation.
|
||||
*/
|
||||
virtual void AggregateSingleMpdu (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const = 0;
|
||||
void AggregateSingleMpdu (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const;
|
||||
/**
|
||||
* \param packet the packet we want to insert into <i>aggregatedPacket</i>.
|
||||
* \param last true if it is the last packet.
|
||||
@@ -89,7 +93,7 @@ public:
|
||||
*
|
||||
* Adds A-MPDU subframe header and padding to each MPDU that is part of an A-MPDU before it is sent.
|
||||
*/
|
||||
virtual void AddHeaderAndPad (Ptr<Packet> packet, bool last, bool isSingleMpdu) const = 0;
|
||||
void AddHeaderAndPad (Ptr<Packet> packet, bool last, bool isSingleMpdu) const;
|
||||
/**
|
||||
* \param packetSize size of the packet we want to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket packet that will contain the packet of size <i>packetSize</i>, if aggregation is possible.
|
||||
@@ -99,15 +103,8 @@ public:
|
||||
*
|
||||
* This method is used to determine if a packet could be aggregated to an A-MPDU without exceeding the maximum packet size.
|
||||
*/
|
||||
virtual bool CanBeAggregated (uint32_t packetSize, Ptr<Packet> aggregatedPacket, uint8_t blockAckSize) const = 0;
|
||||
/**
|
||||
* \param packet the Packet
|
||||
* \return padding that must be added to the end of an aggregated packet
|
||||
*
|
||||
* Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added.
|
||||
* Each A-MPDU subframe is padded so that its length is multiple of 4 octets.
|
||||
*/
|
||||
virtual uint32_t CalculatePadding (Ptr<const Packet> packet) const = 0;
|
||||
bool CanBeAggregated (uint32_t packetSize, Ptr<Packet> aggregatedPacket, uint8_t blockAckSize) const;
|
||||
|
||||
/**
|
||||
* Deaggregates an A-MPDU by removing the A-MPDU subframe header and padding.
|
||||
*
|
||||
@@ -115,6 +112,19 @@ public:
|
||||
* \return list of deaggragted packets and their A-MPDU subframe headers
|
||||
*/
|
||||
static DeaggregatedMpdus Deaggregate (Ptr<Packet> aggregatedPacket);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* \param packet the Packet
|
||||
* \return padding that must be added to the end of an aggregated packet
|
||||
*
|
||||
* Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added.
|
||||
* Each A-MPDU subframe is padded so that its length is multiple of 4 octets.
|
||||
*/
|
||||
uint8_t CalculatePadding (Ptr<const Packet> packet) const;
|
||||
|
||||
uint16_t m_maxAmpduLength; //!< Maximum length in bytes of A-MPDUs
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Ghada Badawy <gbadawy@gmail.com>
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "mpdu-standard-aggregator.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("MpduStandardAggregator");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (MpduStandardAggregator);
|
||||
|
||||
TypeId
|
||||
MpduStandardAggregator::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::MpduStandardAggregator")
|
||||
.SetParent<MpduAggregator> ()
|
||||
.SetGroupName ("Wifi")
|
||||
.AddConstructor<MpduStandardAggregator> ()
|
||||
.AddAttribute ("MaxAmpduSize", "Max length in bytes of an A-MPDU (Deprecated!)",
|
||||
UintegerValue (65535),
|
||||
MakeUintegerAccessor (&MpduStandardAggregator::m_maxAmpduLength),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
MpduStandardAggregator::MpduStandardAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
MpduStandardAggregator::~MpduStandardAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MpduStandardAggregator::SetMaxAmpduSize (uint32_t maxSize)
|
||||
{
|
||||
m_maxAmpduLength = maxSize;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MpduStandardAggregator::GetMaxAmpduSize (void) const
|
||||
{
|
||||
return m_maxAmpduLength;
|
||||
}
|
||||
|
||||
bool
|
||||
MpduStandardAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<Packet> currentPacket;
|
||||
AmpduSubframeHeader currentHdr;
|
||||
|
||||
uint32_t padding = CalculatePadding (aggregatedPacket);
|
||||
uint32_t actualSize = aggregatedPacket->GetSize ();
|
||||
|
||||
if ((4 + packet->GetSize () + actualSize + padding) <= m_maxAmpduLength)
|
||||
{
|
||||
if (padding)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
aggregatedPacket->AddAtEnd (pad);
|
||||
}
|
||||
currentHdr.SetCrc (1);
|
||||
currentHdr.SetSig ();
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
currentPacket = packet->Copy ();
|
||||
|
||||
currentPacket->AddHeader (currentHdr);
|
||||
aggregatedPacket->AddAtEnd (currentPacket);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
MpduStandardAggregator::AggregateSingleMpdu (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<Packet> currentPacket;
|
||||
AmpduSubframeHeader currentHdr;
|
||||
|
||||
uint32_t padding = CalculatePadding (aggregatedPacket);
|
||||
if (padding)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
aggregatedPacket->AddAtEnd (pad);
|
||||
}
|
||||
|
||||
currentHdr.SetEof (1);
|
||||
currentHdr.SetCrc (1);
|
||||
currentHdr.SetSig ();
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
currentPacket = packet->Copy ();
|
||||
|
||||
currentPacket->AddHeader (currentHdr);
|
||||
aggregatedPacket->AddAtEnd (currentPacket);
|
||||
}
|
||||
|
||||
void
|
||||
MpduStandardAggregator::AddHeaderAndPad (Ptr<Packet> packet, bool last, bool isSingleMpdu) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
AmpduSubframeHeader currentHdr;
|
||||
|
||||
//This is called to prepare packets from the aggregate queue to be sent so no need to check total size since it has already been
|
||||
//done before when deciding how many packets to add to the queue
|
||||
currentHdr.SetCrc (1);
|
||||
currentHdr.SetSig ();
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
if (isSingleMpdu)
|
||||
{
|
||||
currentHdr.SetEof (1);
|
||||
}
|
||||
|
||||
packet->AddHeader (currentHdr);
|
||||
uint32_t padding = CalculatePadding (packet);
|
||||
|
||||
if (padding && !last)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
packet->AddAtEnd (pad);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MpduStandardAggregator::CanBeAggregated (uint32_t packetSize, Ptr<Packet> aggregatedPacket, uint8_t blockAckSize) const
|
||||
{
|
||||
uint32_t padding = CalculatePadding (aggregatedPacket);
|
||||
uint32_t actualSize = aggregatedPacket->GetSize ();
|
||||
if (blockAckSize > 0)
|
||||
{
|
||||
blockAckSize = blockAckSize + 4 + padding;
|
||||
}
|
||||
if ((4 + packetSize + actualSize + padding + blockAckSize) <= m_maxAmpduLength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MpduStandardAggregator::CalculatePadding (Ptr<const Packet> packet) const
|
||||
{
|
||||
return (4 - (packet->GetSize () % 4 )) % 4;
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
@@ -1,111 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Ghada Badawy <gbadawy@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef MPDU_STANDARD_AGGREGATOR_H
|
||||
#define MPDU_STANDARD_AGGREGATOR_H
|
||||
|
||||
#include "mpdu-aggregator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup wifi
|
||||
* Standard MPDU aggregator
|
||||
*
|
||||
*/
|
||||
class MpduStandardAggregator : public MpduAggregator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Get the type ID.
|
||||
* \return the object TypeId
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
MpduStandardAggregator ();
|
||||
~MpduStandardAggregator ();
|
||||
|
||||
/**
|
||||
* Sets the maximum A-MPDU size in bytes.
|
||||
* Value 0 means that MPDU aggregation is disabled.
|
||||
*
|
||||
* \param maxSize the maximum A-MPDU size in bytes.
|
||||
*/
|
||||
void SetMaxAmpduSize (uint32_t maxSize);
|
||||
/**
|
||||
* Returns the maximum A-MPDU size in bytes.
|
||||
* Value 0 means that MPDU aggregation is disabled.
|
||||
*
|
||||
* \return the maximum A-MPDU size in bytes.
|
||||
*/
|
||||
uint32_t GetMaxAmpduSize (void) const;
|
||||
/**
|
||||
* \param packet packet we have to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket packet that will contain <i>packet</i>, if aggregation is possible.
|
||||
*
|
||||
* \return true if <i>packet</i> can be aggregated to <i>aggregatedPacket</i>,
|
||||
* false otherwise.
|
||||
*
|
||||
* This method performs an MPDU aggregation.
|
||||
* Returns true if <i>packet</i> can be aggregated to <i>aggregatedPacket</i>, false otherwise.
|
||||
*/
|
||||
bool Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const;
|
||||
/**
|
||||
* \param packet the packet we want to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket packet that will contain the packet of size <i>packetSize</i>, if aggregation is possible.
|
||||
*
|
||||
* This method performs a VHT/HE single MPDU aggregation.
|
||||
*/
|
||||
void AggregateSingleMpdu (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket) const;
|
||||
/**
|
||||
* \param packet the packet we want to insert into <i>aggregatedPacket</i>.
|
||||
* \param last true if it is the last packet.
|
||||
* \param isSingleMpdu true if it is a single MPDU
|
||||
*
|
||||
* Adds A-MPDU subframe header and padding to each MPDU that is part of an A-MPDU before it is sent.
|
||||
*/
|
||||
void AddHeaderAndPad (Ptr<Packet> packet, bool last, bool isSingleMpdu) const;
|
||||
/**
|
||||
* \param packetSize size of the packet we want to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket packet that will contain the packet of size <i>packetSize</i>, if aggregation is possible.
|
||||
* \param blockAckSize size of the piggybacked block ack request
|
||||
*
|
||||
* \return true if the packet of size <i>packetSize</i> can be aggregated to <i>aggregatedPacket</i>,
|
||||
* false otherwise.
|
||||
*
|
||||
* This method is used to determine if a packet could be aggregated to an A-MPDU without exceeding the maximum packet size.
|
||||
*/
|
||||
bool CanBeAggregated (uint32_t packetSize, Ptr<Packet> aggregatedPacket, uint8_t blockAckSize) const;
|
||||
/**
|
||||
* \param packet the packet
|
||||
* \return the padding that must be added to the end of an aggregated packet
|
||||
*
|
||||
* Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added.
|
||||
* Each A-MPDU subframe is padded so that its length is multiple of 4 octets.
|
||||
*/
|
||||
uint32_t CalculatePadding (Ptr<const Packet> packet) const;
|
||||
|
||||
|
||||
private:
|
||||
uint32_t m_maxAmpduLength; //!< Maximum length in bytes of A-MPDUs
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* MPDU_STANDARD_AGGREGATOR_H */
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "msdu-aggregator.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -33,10 +34,71 @@ MsduAggregator::GetTypeId (void)
|
||||
static TypeId tid = TypeId ("ns3::MsduAggregator")
|
||||
.SetParent<Object> ()
|
||||
.SetGroupName ("Wifi")
|
||||
.AddConstructor<MsduAggregator> ()
|
||||
.AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU (Deprecated!)",
|
||||
UintegerValue (7935),
|
||||
MakeUintegerAccessor (&MsduAggregator::m_maxAmsduLength),
|
||||
MakeUintegerChecker<uint16_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
MsduAggregator::MsduAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
MsduAggregator::~MsduAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MsduAggregator::SetMaxAmsduSize (uint16_t maxSize)
|
||||
{
|
||||
m_maxAmsduLength = maxSize;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
MsduAggregator::GetMaxAmsduSize (void) const
|
||||
{
|
||||
return m_maxAmsduLength;
|
||||
}
|
||||
|
||||
bool
|
||||
MsduAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket,
|
||||
Mac48Address src, Mac48Address dest) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<Packet> currentPacket;
|
||||
AmsduSubframeHeader currentHdr;
|
||||
|
||||
uint8_t padding = CalculatePadding (aggregatedPacket);
|
||||
uint32_t actualSize = aggregatedPacket->GetSize ();
|
||||
|
||||
if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength)
|
||||
{
|
||||
if (padding)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
aggregatedPacket->AddAtEnd (pad);
|
||||
}
|
||||
currentHdr.SetDestinationAddr (dest);
|
||||
currentHdr.SetSourceAddr (src);
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
currentPacket = packet->Copy ();
|
||||
|
||||
currentPacket->AddHeader (currentHdr);
|
||||
aggregatedPacket->AddAtEnd (currentPacket);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
MsduAggregator::CalculatePadding (Ptr<const Packet> packet) const
|
||||
{
|
||||
return (4 - (packet->GetSize () % 4 )) % 4;
|
||||
}
|
||||
|
||||
MsduAggregator::DeaggregatedMsdus
|
||||
MsduAggregator::Deaggregate (Ptr<Packet> aggregatedPacket)
|
||||
{
|
||||
@@ -47,7 +109,7 @@ MsduAggregator::Deaggregate (Ptr<Packet> aggregatedPacket)
|
||||
Ptr<Packet> extractedMsdu = Create<Packet> ();
|
||||
uint32_t maxSize = aggregatedPacket->GetSize ();
|
||||
uint16_t extractedLength;
|
||||
uint32_t padding;
|
||||
uint8_t padding;
|
||||
uint32_t deserialized = 0;
|
||||
|
||||
while (deserialized < maxSize)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ns3 {
|
||||
class WifiMacHeader;
|
||||
|
||||
/**
|
||||
* \brief Abstract class that concrete msdu aggregators have to implement
|
||||
* \brief Aggregator used to construct A-MSDUs
|
||||
* \ingroup wifi
|
||||
*/
|
||||
class MsduAggregator : public Object
|
||||
@@ -47,20 +47,23 @@ public:
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
MsduAggregator ();
|
||||
virtual ~MsduAggregator ();
|
||||
|
||||
/**
|
||||
* Sets the maximum A-MSDU size in bytes.
|
||||
* Value 0 means that MSDU aggregation is disabled.
|
||||
*
|
||||
* \param maxSize the maximum A-MSDU size in bytes.
|
||||
*/
|
||||
virtual void SetMaxAmsduSize (uint32_t maxSize) = 0;
|
||||
void SetMaxAmsduSize (uint16_t maxSize);
|
||||
/**
|
||||
* Returns the maximum A-MSDU size in bytes.
|
||||
* Value 0 means that MSDU aggregation is disabled.
|
||||
*
|
||||
* \return the maximum A-MSDU size in bytes.
|
||||
*/
|
||||
virtual uint32_t GetMaxAmsduSize (void) const = 0;
|
||||
uint16_t GetMaxAmsduSize (void) const;
|
||||
|
||||
/**
|
||||
* Adds <i>packet</i> to <i>aggregatedPacket</i>. In concrete aggregator's implementation is
|
||||
@@ -73,8 +76,8 @@ public:
|
||||
* \param dest the destination address
|
||||
* \return true if successful.
|
||||
*/
|
||||
virtual bool Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket,
|
||||
Mac48Address src, Mac48Address dest) const = 0;
|
||||
bool Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket,
|
||||
Mac48Address src, Mac48Address dest) const;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -82,6 +85,21 @@ public:
|
||||
* \returns DeaggregatedMsdus.
|
||||
*/
|
||||
static DeaggregatedMsdus Deaggregate (Ptr<Packet> aggregatedPacket);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calculates how much padding must be added to the end of aggregated packet,
|
||||
* after that a new packet is added.
|
||||
* Each A-MSDU subframe is padded so that its length is multiple of 4 octets.
|
||||
*
|
||||
* \param packet
|
||||
*
|
||||
* \return the number of octets required for padding
|
||||
*/
|
||||
uint8_t CalculatePadding (Ptr<const Packet> packet) const;
|
||||
|
||||
uint16_t m_maxAmsduLength; ///< maximum AMSDU length
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 MIRKO BANCHI
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mirko Banchi <mk.banchi@gmail.com>
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "msdu-standard-aggregator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("MsduStandardAggregator");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (MsduStandardAggregator);
|
||||
|
||||
TypeId
|
||||
MsduStandardAggregator::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::MsduStandardAggregator")
|
||||
.SetParent<MsduAggregator> ()
|
||||
.SetGroupName ("Wifi")
|
||||
.AddConstructor<MsduStandardAggregator> ()
|
||||
.AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU (Deprecated!)",
|
||||
UintegerValue (7935),
|
||||
MakeUintegerAccessor (&MsduStandardAggregator::m_maxAmsduLength),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
MsduStandardAggregator::MsduStandardAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
MsduStandardAggregator::~MsduStandardAggregator ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MsduStandardAggregator::SetMaxAmsduSize (uint32_t maxSize)
|
||||
{
|
||||
m_maxAmsduLength = maxSize;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MsduStandardAggregator::GetMaxAmsduSize (void) const
|
||||
{
|
||||
return m_maxAmsduLength;
|
||||
}
|
||||
|
||||
bool
|
||||
MsduStandardAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket,
|
||||
Mac48Address src, Mac48Address dest) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<Packet> currentPacket;
|
||||
AmsduSubframeHeader currentHdr;
|
||||
|
||||
uint32_t padding = CalculatePadding (aggregatedPacket);
|
||||
uint32_t actualSize = aggregatedPacket->GetSize ();
|
||||
|
||||
if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength)
|
||||
{
|
||||
if (padding)
|
||||
{
|
||||
Ptr<Packet> pad = Create<Packet> (padding);
|
||||
aggregatedPacket->AddAtEnd (pad);
|
||||
}
|
||||
currentHdr.SetDestinationAddr (dest);
|
||||
currentHdr.SetSourceAddr (src);
|
||||
currentHdr.SetLength (packet->GetSize ());
|
||||
currentPacket = packet->Copy ();
|
||||
|
||||
currentPacket->AddHeader (currentHdr);
|
||||
aggregatedPacket->AddAtEnd (currentPacket);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MsduStandardAggregator::CalculatePadding (Ptr<const Packet> packet) const
|
||||
{
|
||||
return (4 - (packet->GetSize () % 4 )) % 4;
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
@@ -1,90 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 MIRKO BANCHI
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mirko Banchi <mk.banchi@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef MSDU_STANDARD_AGGREGATOR_H
|
||||
#define MSDU_STANDARD_AGGREGATOR_H
|
||||
|
||||
#include "msdu-aggregator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup wifi
|
||||
* Standard MSDU aggregator
|
||||
*
|
||||
*/
|
||||
class MsduStandardAggregator : public MsduAggregator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Get the type ID.
|
||||
* \return the object TypeId
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
MsduStandardAggregator ();
|
||||
~MsduStandardAggregator ();
|
||||
|
||||
/**
|
||||
* Sets the maximum A-MSDU size in bytes.
|
||||
* Value 0 means that MSDU aggregation is disabled.
|
||||
*
|
||||
* \param maxSize the maximum A-MSDU size in bytes.
|
||||
*/
|
||||
void SetMaxAmsduSize (uint32_t maxSize);
|
||||
/**
|
||||
* Returns the maximum A-MSDU size in bytes.
|
||||
* Value 0 means that MSDU aggregation is disabled.
|
||||
*
|
||||
* \return the maximum A-MSDU size in bytes.
|
||||
*/
|
||||
uint32_t GetMaxAmsduSize (void) const;
|
||||
/**
|
||||
* \param packet Packet we have to insert into <i>aggregatedPacket</i>.
|
||||
* \param aggregatedPacket Packet that will contain <i>packet</i>, if aggregation is possible,
|
||||
* \param src Source address of <i>packet</i>.
|
||||
* \param dest Destination address of <i>packet</i>.
|
||||
*
|
||||
* \return true if the packet can be aggregated,
|
||||
* false otherwise
|
||||
*
|
||||
* This method performs an MSDU aggregation.
|
||||
* Returns true if <i>packet</i> can be aggregated to <i>aggregatedPacket</i>, false otherwise.
|
||||
*/
|
||||
bool Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket, Mac48Address src, Mac48Address dest) const;
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Calculates how much padding must be added to the end of aggregated packet,
|
||||
* after that a new packet is added.
|
||||
* Each A-MSDU subframe is padded so that its length is multiple of 4 octets.
|
||||
*
|
||||
* \param packet
|
||||
*
|
||||
* \return the number of octets required for padding
|
||||
*/
|
||||
uint32_t CalculatePadding (Ptr<const Packet> packet) const;
|
||||
|
||||
uint32_t m_maxAmsduLength; ///< maximum AMSDU length
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* MSDU_STANDARD_AGGREGATOR_H */
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "mac-tx-middle.h"
|
||||
#include "mac-low.h"
|
||||
#include "dcf-manager.h"
|
||||
#include "msdu-standard-aggregator.h"
|
||||
#include "mpdu-standard-aggregator.h"
|
||||
#include "msdu-aggregator.h"
|
||||
#include "mpdu-aggregator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -1367,12 +1367,12 @@ RegularWifiMac::EnableAggregation (void)
|
||||
{
|
||||
if (i->second->GetMsduAggregator () == 0)
|
||||
{
|
||||
Ptr<MsduStandardAggregator> msduAggregator = CreateObject<MsduStandardAggregator> ();
|
||||
Ptr<MsduAggregator> msduAggregator = CreateObject<MsduAggregator> ();
|
||||
i->second->SetMsduAggregator (msduAggregator);
|
||||
}
|
||||
if (i->second->GetMpduAggregator () == 0)
|
||||
{
|
||||
Ptr<MpduStandardAggregator> mpduAggregator = CreateObject<MpduStandardAggregator> ();
|
||||
Ptr<MpduAggregator> mpduAggregator = CreateObject<MpduAggregator> ();
|
||||
i->second->SetMpduAggregator (mpduAggregator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include "ns3/yans-wifi-phy.h"
|
||||
#include "ns3/mac-tx-middle.h"
|
||||
#include "ns3/dcf-manager.h"
|
||||
#include "ns3/msdu-standard-aggregator.h"
|
||||
#include "ns3/mpdu-standard-aggregator.h"
|
||||
#include "ns3/msdu-aggregator.h"
|
||||
#include "ns3/mpdu-aggregator.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -106,7 +106,7 @@ AmpduAggregationTest::DoRun (void)
|
||||
* Configure MPDU aggregation.
|
||||
*/
|
||||
m_factory = ObjectFactory ();
|
||||
m_factory.SetTypeId ("ns3::MpduStandardAggregator");
|
||||
m_factory.SetTypeId ("ns3::MpduAggregator");
|
||||
m_factory.Set ("MaxAmpduSize", UintegerValue (65535));
|
||||
m_mpduAggregator = m_factory.Create<MpduAggregator> ();
|
||||
m_edca->SetMpduAggregator (m_mpduAggregator);
|
||||
@@ -311,8 +311,8 @@ TwoLevelAggregationTest::DoRun (void)
|
||||
/*
|
||||
* Configure aggregation.
|
||||
*/
|
||||
m_msduAggregator = CreateObject<MsduStandardAggregator> ();
|
||||
m_mpduAggregator = CreateObject<MpduStandardAggregator> ();
|
||||
m_msduAggregator = CreateObject<MsduAggregator> ();
|
||||
m_mpduAggregator = CreateObject<MpduAggregator> ();
|
||||
|
||||
m_msduAggregator->SetMaxAmsduSize (4095);
|
||||
m_mpduAggregator->SetMaxAmpduSize (65535);
|
||||
@@ -368,7 +368,7 @@ TwoLevelAggregationTest::DoRun (void)
|
||||
* This test is needed to ensure that no packets are removed from the queue in MacLow::PerformMsduAggregation, since aggregation will no occur in MacLow::AggregateToAmpdu.
|
||||
*/
|
||||
m_factory = ObjectFactory ();
|
||||
m_factory.SetTypeId ("ns3::MpduStandardAggregator");
|
||||
m_factory.SetTypeId ("ns3::MpduAggregator");
|
||||
m_factory.Set ("MaxAmpduSize", UintegerValue (0));
|
||||
m_mpduAggregator = m_factory.Create<MpduAggregator> ();
|
||||
m_edca->SetMpduAggregator (m_mpduAggregator);
|
||||
|
||||
@@ -57,7 +57,6 @@ def build(bld):
|
||||
'model/edca-txop-n.cc',
|
||||
'model/msdu-aggregator.cc',
|
||||
'model/amsdu-subframe-header.cc',
|
||||
'model/msdu-standard-aggregator.cc',
|
||||
'model/originator-block-ack-agreement.cc',
|
||||
'model/ctrl-headers.cc',
|
||||
'model/qos-blocked-destinations.cc',
|
||||
@@ -72,7 +71,6 @@ def build(bld):
|
||||
'model/rrpaa-wifi-manager.cc',
|
||||
'model/ampdu-subframe-header.cc',
|
||||
'model/mpdu-aggregator.cc',
|
||||
'model/mpdu-standard-aggregator.cc',
|
||||
'model/ampdu-tag.cc',
|
||||
'model/wifi-radio-energy-model.cc',
|
||||
'model/wifi-tx-current-model.cc',
|
||||
@@ -160,7 +158,6 @@ def build(bld):
|
||||
'model/edca-txop-n.h',
|
||||
'model/msdu-aggregator.h',
|
||||
'model/amsdu-subframe-header.h',
|
||||
'model/msdu-standard-aggregator.h',
|
||||
'model/mgt-headers.h',
|
||||
'model/status-code.h',
|
||||
'model/capability-information.h',
|
||||
@@ -183,7 +180,6 @@ def build(bld):
|
||||
'model/wifi-tx-vector.h',
|
||||
'model/ampdu-subframe-header.h',
|
||||
'model/mpdu-aggregator.h',
|
||||
'model/mpdu-standard-aggregator.h',
|
||||
'model/ampdu-tag.h',
|
||||
'model/wifi-radio-energy-model.h',
|
||||
'model/wifi-tx-current-model.h',
|
||||
|
||||
Reference in New Issue
Block a user