# HG changeset patch # User Ashwin Narayan # Date 1310820840 14400 # Node ID 141f8d6ccb0307f9b942e02cd6fe0f16c6ba9145 # Parent ccddb981db2ad7522848e3e594e47d3d11ba96e3 Cleaning up code for review diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/adhoc-wifi-mac.cc --- a/src/wifi/model/adhoc-wifi-mac.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/adhoc-wifi-mac.cc Sat Jul 16 08:54:00 2011 -0400 @@ -162,7 +162,7 @@ } void -AdhocWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr) +AdhocWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr) { NS_LOG_FUNCTION (this << packet << hdr); NS_ASSERT (!hdr->IsCtl ()); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/adhoc-wifi-mac.h --- a/src/wifi/model/adhoc-wifi-mac.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/adhoc-wifi-mac.h Sat Jul 16 08:54:00 2011 -0400 @@ -62,7 +62,7 @@ virtual void Enqueue (Ptr packet, Mac48Address to); private: - virtual void Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr); + virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); }; } // namespace ns3 diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/ap-wifi-mac.cc --- a/src/wifi/model/ap-wifi-mac.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/ap-wifi-mac.cc Sat Jul 16 08:54:00 2011 -0400 @@ -397,7 +397,7 @@ } void -ApWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr) +ApWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr) { NS_LOG_FUNCTION (this << packet << hdr); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/ap-wifi-mac.h --- a/src/wifi/model/ap-wifi-mac.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/ap-wifi-mac.h Sat Jul 16 08:54:00 2011 -0400 @@ -96,7 +96,7 @@ void StartBeaconing (void); private: - virtual void Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr); + virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); virtual void TxOk (const WifiMacHeader &hdr); virtual void TxFailed (const WifiMacHeader &hdr); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/mac-low.cc --- a/src/wifi/model/mac-low.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/mac-low.cc Sat Jul 16 08:54:00 2011 -0400 @@ -581,7 +581,7 @@ } void -MacLow::SetRxCallback (Callback,const WifiMacHeader *,RadiotapHeader> callback) +MacLow::SetRxCallback (Callback,const WifiMacHeader *,const RadiotapHeader *> callback) { m_rxCallback = callback; } @@ -678,7 +678,7 @@ */ WifiMacHeader hdr; packet->RemoveHeader (hdr); - m_currentRadiotapHdr = radiotaphdr; + m_currentRadiotapHdr = &radiotaphdr; bool isPrevNavZero = IsNavZero (); NS_LOG_DEBUG ("duration/id=" << hdr.GetDuration ()); @@ -929,7 +929,7 @@ rxPacket: WifiMacTrailer fcs; packet->RemoveTrailer (fcs); - m_rxCallback (packet, &hdr, radiotaphdr); + m_rxCallback (packet, &hdr, &radiotaphdr); return; } diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/mac-low.h --- a/src/wifi/model/mac-low.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/mac-low.h Sat Jul 16 08:54:00 2011 -0400 @@ -372,7 +372,7 @@ class MacLow : public Object { public: - typedef Callback, const WifiMacHeader*, RadiotapHeader> MacLowRxCallback; + typedef Callback, const WifiMacHeader*, const RadiotapHeader*> MacLowRxCallback; MacLow (); virtual ~MacLow (); @@ -407,7 +407,7 @@ * This callback typically forwards incoming packets to * an instance of ns3::MacRxMiddle. */ - void SetRxCallback (Callback,const WifiMacHeader *, RadiotapHeader> callback); + void SetRxCallback (Callback,const WifiMacHeader *,const RadiotapHeader*> callback); /** * \param listener listen to NAV events for every incoming * and outgoing packet. @@ -620,7 +620,7 @@ Ptr m_currentPacket; WifiMacHeader m_currentHdr; - RadiotapHeader m_currentRadiotapHdr; + RadiotapHeader *m_currentRadiotapHdr; MacLowTransmissionParameters m_txParams; MacLowTransmissionListener *m_listener; Mac48Address m_self; diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/mac-rx-middle.cc --- a/src/wifi/model/mac-rx-middle.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/mac-rx-middle.cc Sat Jul 16 08:54:00 2011 -0400 @@ -243,7 +243,7 @@ } void -MacRxMiddle::Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr) +MacRxMiddle::Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr) { NS_LOG_FUNCTION (packet << hdr); NS_ASSERT (hdr->IsData () || hdr->IsMgt ()); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/mac-rx-middle.h --- a/src/wifi/model/mac-rx-middle.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/mac-rx-middle.h Sat Jul 16 08:54:00 2011 -0400 @@ -41,14 +41,14 @@ class MacRxMiddle { public: - typedef Callback, const WifiMacHeader*, RadiotapHeader> ForwardUpCallback; + typedef Callback, const WifiMacHeader*, const RadiotapHeader *> ForwardUpCallback; MacRxMiddle (); ~MacRxMiddle (); void SetForwardCallback (ForwardUpCallback callback); - void Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr); + void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); private: friend class MacRxMiddleTest; OriginatorRxStatus* Lookup (const WifiMacHeader* hdr); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/monitor-mac-high.cc --- a/src/wifi/model/monitor-mac-high.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/monitor-mac-high.cc Sat Jul 16 08:54:00 2011 -0400 @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Mathieu Lacage + * Author: Mathieu Lacage , Ashwin Narayan */ #include "monitor-mac-high.h" @@ -138,14 +138,13 @@ void MonitorMacHigh::SetQosSupported (bool enable) { - NS_LOG_FUNCTION (this); - m_qosSupported = enable; + NS_FATAL_ERROR ("QoS Functionality not supported in MonitorMacHigh"); } bool MonitorMacHigh::GetQosSupported () const { - return m_qosSupported; + return false; } void @@ -322,12 +321,6 @@ MonitorMacHigh::Enqueue (Ptr packet, Mac48Address to, Mac48Address from) { - // We expect RegularWifiMac subclasses which do support forwarding (e.g., - // AP) to override this method. Therefore, we throw a fatal error if - // someone tries to invoke this method on a class which has not done - // this. - NS_FATAL_ERROR ("This MAC entity (" << this << ", " << GetAddress () - << ") does not support Enqueue() with from address"); } void @@ -350,13 +343,13 @@ } void -MonitorMacHigh::Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr) +MonitorMacHigh::Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr) { Mac48Address to = hdr->GetAddr1 (); Mac48Address from = hdr->GetAddr2 (); NS_LOG_DEBUG ("Received packet to: " << to << " from: " << from << " at:" << m_low->GetAddress ()); - packet->AddHeader (radiotaphdr); + packet->AddHeader (*radiotaphdr); ForwardUp (packet, from, to); } @@ -364,69 +357,12 @@ MonitorMacHigh::DeaggregateAmsduAndForward (Ptr aggregatedPacket, const WifiMacHeader *hdr) { - MsduAggregator::DeaggregatedMsdus packets = - MsduAggregator::Deaggregate (aggregatedPacket); - - for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin (); - i != packets.end (); ++i) - { - ForwardUp ((*i).first, (*i).second.GetSourceAddr (), - (*i).second.GetDestinationAddr ()); - } } void MonitorMacHigh::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, Mac48Address originator) { - NS_LOG_FUNCTION (this); - WifiMacHeader hdr; - hdr.SetAction (); - hdr.SetAddr1 (originator); - hdr.SetAddr2 (GetAddress ()); - hdr.SetAddr3 (GetAddress ()); - hdr.SetDsNotFrom (); - hdr.SetDsNotTo (); - - MgtAddBaResponseHeader respHdr; - StatusCode code; - code.SetSuccess (); - respHdr.SetStatusCode (code); - //Here a control about queues type? - respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); - - if (reqHdr->IsImmediateBlockAck ()) - { - respHdr.SetImmediateBlockAck (); - } - else - { - respHdr.SetDelayedBlockAck (); - } - respHdr.SetTid (reqHdr->GetTid ()); - // For now there's not no control about limit of reception. We - // assume that receiver has no limit on reception. However we assume - // that a receiver sets a bufferSize in order to satisfy next - // equation: (bufferSize + 1) % 16 = 0 So if a recipient is able to - // buffer a packet, it should be also able to buffer all possible - // packet's fragments. See section 7.3.1.14 in IEEE802.11e for more - // details. - respHdr.SetBufferSize (1023); - respHdr.SetTimeout (reqHdr->GetTimeout ()); - - WifiActionHeader actionHdr; - WifiActionHeader::ActionValue action; - action.blockAck = WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE; - actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action); - - Ptr packet = Create (); - packet->AddHeader (respHdr); - packet->AddHeader (actionHdr); - - // We need to notify our MacLow object as it will have to buffer all - // correctly received packets for this Block Ack session - m_low->CreateBlockAckAgreement (&respHdr, originator, - reqHdr->GetStartingSequence ()); } void diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/monitor-mac-high.h --- a/src/wifi/model/monitor-mac-high.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/monitor-mac-high.h Sat Jul 16 08:54:00 2011 -0400 @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Mathieu Lacage + * Author: Mathieu Lacage , Ashwin Narayan */ #ifndef MONITOR_MAC_HIGH_H #define MONITOR_MAC_HIGH_H @@ -39,6 +39,14 @@ class MacTxMiddle; class DcfManager; +/** + * \brief base class for Monitor Wifi Mac objects. + * + * This class is essentially a copy of the non-QoS + * functionality of RegularWifiMac + * + */ + class MonitorMacHigh : public WifiMac { public: @@ -102,7 +110,7 @@ virtual void FinishConfigureStandard (enum WifiPhyStandard standard); - virtual void Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr); + virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); virtual void TxOk (const WifiMacHeader &hdr); virtual void TxFailed (const WifiMacHeader &hdr); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/regular-wifi-mac.cc --- a/src/wifi/model/regular-wifi-mac.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/regular-wifi-mac.cc Sat Jul 16 08:54:00 2011 -0400 @@ -153,7 +153,7 @@ edca->SetTxFailedCallback (MakeCallback (&RegularWifiMac::TxFailed, this)); edca->SetAccessCategory (ac); edca->CompleteConfig (); - m_edca.insert (std::make_pair(ac, edca)); + m_edca.insert (std::make_pair (ac, edca)); } void @@ -422,14 +422,25 @@ } void -RegularWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr) +RegularWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr) { NS_LOG_FUNCTION (this << packet << hdr); Mac48Address to = hdr->GetAddr1 (); Mac48Address from = hdr->GetAddr2 (); - if (hdr->IsMgt () && hdr->IsAction () && to == GetAddress ()) + // We don't know how to deal with any frame that is not addressed to + // us (and odds are there is nothing sensible we could do anyway), + // so we ignore such frames. + // + // The derived class may also do some such filtering, but it doesn't + // hurt to have it here too as a backstop. + if (to != GetAddress ()) + { + return; + } + + if (hdr->IsMgt () && hdr->IsAction ()) { // There is currently only any reason for Management Action // frames to be flying about if we are a QoS STA. diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/regular-wifi-mac.h --- a/src/wifi/model/regular-wifi-mac.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/regular-wifi-mac.h Sat Jul 16 08:54:00 2011 -0400 @@ -277,7 +277,7 @@ * \param packet the packet that has been received. * \param hdr a pointer to the MAC header of the received frame. */ - virtual void Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr); + virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); virtual void TxOk (const WifiMacHeader &hdr); virtual void TxFailed (const WifiMacHeader &hdr); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/sta-wifi-mac.cc --- a/src/wifi/model/sta-wifi-mac.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/sta-wifi-mac.cc Sat Jul 16 08:54:00 2011 -0400 @@ -371,7 +371,7 @@ } void -StaWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr) +StaWifiMac::Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr) { NS_LOG_FUNCTION (this << packet << hdr); NS_ASSERT (!hdr->IsCtl ()); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/sta-wifi-mac.h --- a/src/wifi/model/sta-wifi-mac.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/sta-wifi-mac.h Sat Jul 16 08:54:00 2011 -0400 @@ -95,7 +95,7 @@ void SetActiveProbing (bool enable); bool GetActiveProbing (void) const; - virtual void Receive (Ptr packet, const WifiMacHeader *hdr, RadiotapHeader radiotaphdr); + virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); void SendProbeRequest (void); void SendAssociationRequest (void); void TryToEnsureAssociated (void); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/wifi-net-device.cc --- a/src/wifi/model/wifi-net-device.cc Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/wifi-net-device.cc Sat Jul 16 08:54:00 2011 -0400 @@ -367,7 +367,7 @@ void WifiNetDevice::SetMonitorMode () { - m_monitor = true; + m_monitor = true; // Must be set only if WifiNetDevice has a MonitorMacHigh underneath } bool diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/wifi-net-device.h --- a/src/wifi/model/wifi-net-device.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/wifi-net-device.h Sat Jul 16 08:54:00 2011 -0400 @@ -81,7 +81,8 @@ */ Ptr GetRemoteStationManager (void) const; /** - * \param monitor sets mode as monitor mode + * Sets device in Monitor Mode. Must be done only if WifiNetDevice + * has a MonitorMacHigh underneath */ void SetMonitorMode (void); diff -r ccddb981db2a -r 141f8d6ccb03 src/wifi/model/wifi-phy.h --- a/src/wifi/model/wifi-phy.h Sun Jul 10 08:55:21 2011 -0400 +++ b/src/wifi/model/wifi-phy.h Sat Jul 16 08:54:00 2011 -0400 @@ -150,6 +150,7 @@ * arg2: snr of packet * arg3: mode of packet * arg4: type of preamble used for packet. + * arg5: RadiotapHeader of packet */ typedef Callback, double, WifiMode, enum WifiPreamble, RadiotapHeader> RxOkCallback; /**