diff --git a/src/wifi/helper/vht-wifi-mac-helper.cc b/src/wifi/helper/vht-wifi-mac-helper.cc index 801e7d6df..772d49ea8 100644 --- a/src/wifi/helper/vht-wifi-mac-helper.cc +++ b/src/wifi/helper/vht-wifi-mac-helper.cc @@ -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; } diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 245dabbc1..254f29c3e 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -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); diff --git a/src/wifi/model/mpdu-aggregator.cc b/src/wifi/model/mpdu-aggregator.cc index f2c7e3cb8..ae3f8da3a 100644 --- a/src/wifi/model/mpdu-aggregator.cc +++ b/src/wifi/model/mpdu-aggregator.cc @@ -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 () .SetGroupName ("Wifi") - //No AddConstructor because this is an abstract class. + .AddConstructor () + .AddAttribute ("MaxAmpduSize", "Max length in bytes of an A-MPDU (Deprecated!)", + UintegerValue (65535), + MakeUintegerAccessor (&MpduAggregator::m_maxAmpduLength), + MakeUintegerChecker ()) ; 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 packet, Ptr aggregatedPacket) const +{ + NS_LOG_FUNCTION (this); + Ptr currentPacket; + AmpduSubframeHeader currentHdr; + + uint8_t padding = CalculatePadding (aggregatedPacket); + uint32_t actualSize = aggregatedPacket->GetSize (); + + if ((4 + packet->GetSize () + actualSize + padding) <= m_maxAmpduLength) + { + if (padding) + { + Ptr pad = Create (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 packet, Ptr aggregatedPacket) const +{ + NS_LOG_FUNCTION (this); + Ptr currentPacket; + AmpduSubframeHeader currentHdr; + + uint8_t padding = CalculatePadding (aggregatedPacket); + if (padding) + { + Ptr pad = Create (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, 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 pad = Create (padding); + packet->AddAtEnd (pad); + } +} + +bool +MpduAggregator::CanBeAggregated (uint32_t packetSize, Ptr 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 packet) const +{ + return (4 - (packet->GetSize () % 4 )) % 4; +} + MpduAggregator::DeaggregatedMpdus MpduAggregator::Deaggregate (Ptr aggregatedPacket) { diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index cc0ffea2e..53aff3204 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -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 aggregatedPacket. * \param aggregatedPacket Packet that will contain packet, if aggregation is possible. @@ -74,14 +78,14 @@ public: * Adds packet to aggregatedPacket. In concrete aggregator's implementation is * specified how and if packet can be added to aggregatedPacket. */ - virtual bool Aggregate (Ptr packet, Ptr aggregatedPacket) const = 0; + bool Aggregate (Ptr packet, Ptr aggregatedPacket) const; /** * \param packet the packet we want to insert into aggregatedPacket. * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. * * This method performs a VHT/HE single MPDU aggregation. */ - virtual void AggregateSingleMpdu (Ptr packet, Ptr aggregatedPacket) const = 0; + void AggregateSingleMpdu (Ptr packet, Ptr aggregatedPacket) const; /** * \param packet the packet we want to insert into aggregatedPacket. * \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, bool last, bool isSingleMpdu) const = 0; + void AddHeaderAndPad (Ptr packet, bool last, bool isSingleMpdu) const; /** * \param packetSize size of the packet we want to insert into aggregatedPacket. * \param aggregatedPacket packet that will contain the packet of size packetSize, 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 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 packet) const = 0; + bool CanBeAggregated (uint32_t packetSize, Ptr 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 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 packet) const; + + uint16_t m_maxAmpduLength; //!< Maximum length in bytes of A-MPDUs }; } //namespace ns3 diff --git a/src/wifi/model/mpdu-standard-aggregator.cc b/src/wifi/model/mpdu-standard-aggregator.cc deleted file mode 100644 index 3ccd42add..000000000 --- a/src/wifi/model/mpdu-standard-aggregator.cc +++ /dev/null @@ -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 - */ - -#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 () - .SetGroupName ("Wifi") - .AddConstructor () - .AddAttribute ("MaxAmpduSize", "Max length in bytes of an A-MPDU (Deprecated!)", - UintegerValue (65535), - MakeUintegerAccessor (&MpduStandardAggregator::m_maxAmpduLength), - MakeUintegerChecker ()) - ; - 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 packet, Ptr aggregatedPacket) const -{ - NS_LOG_FUNCTION (this); - Ptr currentPacket; - AmpduSubframeHeader currentHdr; - - uint32_t padding = CalculatePadding (aggregatedPacket); - uint32_t actualSize = aggregatedPacket->GetSize (); - - if ((4 + packet->GetSize () + actualSize + padding) <= m_maxAmpduLength) - { - if (padding) - { - Ptr pad = Create (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 packet, Ptr aggregatedPacket) const -{ - NS_LOG_FUNCTION (this); - Ptr currentPacket; - AmpduSubframeHeader currentHdr; - - uint32_t padding = CalculatePadding (aggregatedPacket); - if (padding) - { - Ptr pad = Create (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, 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 pad = Create (padding); - packet->AddAtEnd (pad); - } -} - -bool -MpduStandardAggregator::CanBeAggregated (uint32_t packetSize, Ptr 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 packet) const -{ - return (4 - (packet->GetSize () % 4 )) % 4; -} - -} //namespace ns3 diff --git a/src/wifi/model/mpdu-standard-aggregator.h b/src/wifi/model/mpdu-standard-aggregator.h deleted file mode 100644 index d49b11c6a..000000000 --- a/src/wifi/model/mpdu-standard-aggregator.h +++ /dev/null @@ -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 - */ - -#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 aggregatedPacket. - * \param aggregatedPacket packet that will contain packet, if aggregation is possible. - * - * \return true if packet can be aggregated to aggregatedPacket, - * false otherwise. - * - * This method performs an MPDU aggregation. - * Returns true if packet can be aggregated to aggregatedPacket, false otherwise. - */ - bool Aggregate (Ptr packet, Ptr aggregatedPacket) const; - /** - * \param packet the packet we want to insert into aggregatedPacket. - * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. - * - * This method performs a VHT/HE single MPDU aggregation. - */ - void AggregateSingleMpdu (Ptr packet, Ptr aggregatedPacket) const; - /** - * \param packet the packet we want to insert into aggregatedPacket. - * \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, bool last, bool isSingleMpdu) const; - /** - * \param packetSize size of the packet we want to insert into aggregatedPacket. - * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. - * \param blockAckSize size of the piggybacked block ack request - * - * \return true if the packet of size packetSize can be aggregated to aggregatedPacket, - * 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 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 packet) const; - - -private: - uint32_t m_maxAmpduLength; //!< Maximum length in bytes of A-MPDUs -}; - -} //namespace ns3 - -#endif /* MPDU_STANDARD_AGGREGATOR_H */ diff --git a/src/wifi/model/msdu-aggregator.cc b/src/wifi/model/msdu-aggregator.cc index b6375f7ce..6dfdefa2c 100644 --- a/src/wifi/model/msdu-aggregator.cc +++ b/src/wifi/model/msdu-aggregator.cc @@ -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 () .SetGroupName ("Wifi") + .AddConstructor () + .AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU (Deprecated!)", + UintegerValue (7935), + MakeUintegerAccessor (&MsduAggregator::m_maxAmsduLength), + MakeUintegerChecker ()) ; 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 packet, Ptr aggregatedPacket, + Mac48Address src, Mac48Address dest) const +{ + NS_LOG_FUNCTION (this); + Ptr currentPacket; + AmsduSubframeHeader currentHdr; + + uint8_t padding = CalculatePadding (aggregatedPacket); + uint32_t actualSize = aggregatedPacket->GetSize (); + + if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength) + { + if (padding) + { + Ptr pad = Create (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 packet) const +{ + return (4 - (packet->GetSize () % 4 )) % 4; +} + MsduAggregator::DeaggregatedMsdus MsduAggregator::Deaggregate (Ptr aggregatedPacket) { @@ -47,7 +109,7 @@ MsduAggregator::Deaggregate (Ptr aggregatedPacket) Ptr extractedMsdu = Create (); uint32_t maxSize = aggregatedPacket->GetSize (); uint16_t extractedLength; - uint32_t padding; + uint8_t padding; uint32_t deserialized = 0; while (deserialized < maxSize) diff --git a/src/wifi/model/msdu-aggregator.h b/src/wifi/model/msdu-aggregator.h index 78b9cb46d..cc1888669 100644 --- a/src/wifi/model/msdu-aggregator.h +++ b/src/wifi/model/msdu-aggregator.h @@ -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 packet to aggregatedPacket. In concrete aggregator's implementation is @@ -73,8 +76,8 @@ public: * \param dest the destination address * \return true if successful. */ - virtual bool Aggregate (Ptr packet, Ptr aggregatedPacket, - Mac48Address src, Mac48Address dest) const = 0; + bool Aggregate (Ptr packet, Ptr aggregatedPacket, + Mac48Address src, Mac48Address dest) const; /** * @@ -82,6 +85,21 @@ public: * \returns DeaggregatedMsdus. */ static DeaggregatedMsdus Deaggregate (Ptr 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 packet) const; + + uint16_t m_maxAmsduLength; ///< maximum AMSDU length }; } //namespace ns3 diff --git a/src/wifi/model/msdu-standard-aggregator.cc b/src/wifi/model/msdu-standard-aggregator.cc deleted file mode 100644 index 0e88f8e37..000000000 --- a/src/wifi/model/msdu-standard-aggregator.cc +++ /dev/null @@ -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 - */ - -#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 () - .SetGroupName ("Wifi") - .AddConstructor () - .AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU (Deprecated!)", - UintegerValue (7935), - MakeUintegerAccessor (&MsduStandardAggregator::m_maxAmsduLength), - MakeUintegerChecker ()) - ; - 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 packet, Ptr aggregatedPacket, - Mac48Address src, Mac48Address dest) const -{ - NS_LOG_FUNCTION (this); - Ptr currentPacket; - AmsduSubframeHeader currentHdr; - - uint32_t padding = CalculatePadding (aggregatedPacket); - uint32_t actualSize = aggregatedPacket->GetSize (); - - if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength) - { - if (padding) - { - Ptr pad = Create (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 packet) const -{ - return (4 - (packet->GetSize () % 4 )) % 4; -} - -} //namespace ns3 diff --git a/src/wifi/model/msdu-standard-aggregator.h b/src/wifi/model/msdu-standard-aggregator.h deleted file mode 100644 index 53849ba09..000000000 --- a/src/wifi/model/msdu-standard-aggregator.h +++ /dev/null @@ -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 - */ - -#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 aggregatedPacket. - * \param aggregatedPacket Packet that will contain packet, if aggregation is possible, - * \param src Source address of packet. - * \param dest Destination address of packet. - * - * \return true if the packet can be aggregated, - * false otherwise - * - * This method performs an MSDU aggregation. - * Returns true if packet can be aggregated to aggregatedPacket, false otherwise. - */ - bool Aggregate (Ptr packet, Ptr 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 packet) const; - - uint32_t m_maxAmsduLength; ///< maximum AMSDU length -}; - -} //namespace ns3 - -#endif /* MSDU_STANDARD_AGGREGATOR_H */ diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index fe758a9a6..767332ce7 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -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 msduAggregator = CreateObject (); + Ptr msduAggregator = CreateObject (); i->second->SetMsduAggregator (msduAggregator); } if (i->second->GetMpduAggregator () == 0) { - Ptr mpduAggregator = CreateObject (); + Ptr mpduAggregator = CreateObject (); i->second->SetMpduAggregator (mpduAggregator); } } diff --git a/src/wifi/test/wifi-aggregation-test.cc b/src/wifi/test/wifi-aggregation-test.cc index 701834ecb..3c0ce4b24 100644 --- a/src/wifi/test/wifi-aggregation-test.cc +++ b/src/wifi/test/wifi-aggregation-test.cc @@ -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 (); m_edca->SetMpduAggregator (m_mpduAggregator); @@ -311,8 +311,8 @@ TwoLevelAggregationTest::DoRun (void) /* * Configure aggregation. */ - m_msduAggregator = CreateObject (); - m_mpduAggregator = CreateObject (); + m_msduAggregator = CreateObject (); + m_mpduAggregator = CreateObject (); 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 (); m_edca->SetMpduAggregator (m_mpduAggregator); diff --git a/src/wifi/wscript b/src/wifi/wscript index eb5436d11..465ba3d8c 100644 --- a/src/wifi/wscript +++ b/src/wifi/wscript @@ -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',