From 53f3c0654dfc377652cdb31121a4845b4db2d008 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Mon, 24 Aug 2009 13:09:32 +0200 Subject: [PATCH] new trace sources for WifiRemoteStationManager --- .../wifi/wifi-remote-station-manager.cc | 64 +++++++++++++++-- .../wifi/wifi-remote-station-manager.h | 72 ++++++++++++++++++- 2 files changed, 130 insertions(+), 6 deletions(-) diff --git a/src/devices/wifi/wifi-remote-station-manager.cc b/src/devices/wifi/wifi-remote-station-manager.cc index 01c204b09..1e09f5f62 100644 --- a/src/devices/wifi/wifi-remote-station-manager.cc +++ b/src/devices/wifi/wifi-remote-station-manager.cc @@ -159,6 +159,18 @@ WifiRemoteStationManager::GetTypeId (void) WifiModeValue (), MakeWifiModeAccessor (&WifiRemoteStationManager::m_nonUnicastMode), MakeWifiModeChecker ()) + .AddTraceSource ("MacTxRtsFailed", + "The transmission of a RTS by the MAC layer has failed", + MakeTraceSourceAccessor (&WifiRemoteStationManager::m_macTxRtsFailed)) + .AddTraceSource ("MacTxDataFailed", + "The transmission of a data packet by the MAC layer has failed", + MakeTraceSourceAccessor (&WifiRemoteStationManager::m_macTxDataFailed)) + .AddTraceSource ("MacTxFinalRtsFailed", + "The transmission of a RTS has exceeded the maximum number of attempts", + MakeTraceSourceAccessor (&WifiRemoteStationManager::m_macTxFinalRtsFailed)) + .AddTraceSource ("MacTxFinalDataFailed", + "The transmission of a data packet has exceeded the maximum number of attempts", + MakeTraceSourceAccessor (&WifiRemoteStationManager::m_macTxFinalDataFailed)) ; return tid; } @@ -175,7 +187,7 @@ WifiRemoteStationManager::DoDispose (void) { for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++) { - delete (*i).second; + delete (*i); } m_stations.clear (); delete m_nonUnicast; @@ -237,14 +249,15 @@ WifiRemoteStationManager::Lookup (Mac48Address address) } for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++) { - if ((*i).first == address) + if ((*i)->GetAddress () == address) { - return (*i).second; + return (*i); } } WifiRemoteStation *station = CreateStation (); + station->SetAddress(address); station->Reset (); - m_stations.push_back (std::make_pair (address, station)); + m_stations.push_back (station); return station; } @@ -264,7 +277,7 @@ WifiRemoteStationManager::Reset (void) { for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++) { - delete i->second; + delete (*i); } m_stations.clear (); m_basicModes.clear (); @@ -318,6 +331,33 @@ WifiRemoteStationManager::GetNonUnicastMode (void) const return m_nonUnicastMode; } + +void +WifiRemoteStationManager::NotifyTxRtsFailed (Mac48Address address) +{ + m_macTxRtsFailed (address); +} + +void +WifiRemoteStationManager::NotifyTxDataFailed (Mac48Address address) +{ + m_macTxDataFailed (address); +} + +void +WifiRemoteStationManager::NotifyTxFinalRtsFailed (Mac48Address address) +{ + m_macTxFinalRtsFailed (address); +} + +void +WifiRemoteStationManager::NotifyTxFinalDataFailed (Mac48Address address) +{ + m_macTxFinalDataFailed (address); +} + + + } // namespace ns3 /*************************************************************** @@ -564,6 +604,16 @@ WifiRemoteStation::GetAvgSlrc () const { return m_avgSlrc; } +void +WifiRemoteStation::SetAddress(Mac48Address address) +{ + m_address = address; +} +Mac48Address +WifiRemoteStation::GetAddress() +{ + return m_address; +} uint32_t WifiRemoteStation::GetNSupportedModes (void) const { @@ -698,6 +748,7 @@ void WifiRemoteStation::ReportRtsFailed (void) { m_ssrc++; + GetManager ()->NotifyTxRtsFailed (m_address); DoReportRtsFailed (); } @@ -705,6 +756,7 @@ void WifiRemoteStation::ReportDataFailed (void) { m_slrc++; + GetManager ()->NotifyTxDataFailed (m_address); DoReportDataFailed (); } @@ -727,6 +779,7 @@ void WifiRemoteStation::ReportFinalRtsFailed (void) { m_ssrc = 0; + GetManager ()->NotifyTxFinalRtsFailed (m_address); DoReportFinalRtsFailed (); } @@ -734,6 +787,7 @@ void WifiRemoteStation::ReportFinalDataFailed (void) { m_slrc = 0; + GetManager ()->NotifyTxFinalDataFailed (m_address); DoReportFinalDataFailed (); } diff --git a/src/devices/wifi/wifi-remote-station-manager.h b/src/devices/wifi/wifi-remote-station-manager.h index a7d698a3c..c6531d441 100644 --- a/src/devices/wifi/wifi-remote-station-manager.h +++ b/src/devices/wifi/wifi-remote-station-manager.h @@ -88,7 +88,7 @@ protected: friend class WifiRemoteStation; virtual void DoDispose (void); private: - typedef std::vector > Stations; + typedef std::vector Stations; virtual class WifiRemoteStation *CreateStation (void) = 0; Stations m_stations; WifiMode m_defaultTxMode; @@ -100,6 +100,63 @@ private: uint32_t m_rtsCtsThreshold; uint32_t m_fragmentationThreshold; WifiMode m_nonUnicastMode; + + + /** + * Public method used to fire a MacTxRtsFailed trace. + * Implemented for encapsulation purposes. + */ + void NotifyTxRtsFailed (Mac48Address address); + + /** + * Public method used to fire a MacTxDataFailed trace. + * Implemented for encapsulation purposes. + */ + void NotifyTxDataFailed (Mac48Address address); + + /** + * Public method used to fire a MacTxFinalRtsFailed trace. + * Implemented for encapsulation purposes. + */ + void NotifyTxFinalRtsFailed (Mac48Address address); + + /** + * Public method used to fire a MacTxFinalDataFailed trace. + * Implemented for encapsulation purposes. + */ + void NotifyTxFinalDataFailed (Mac48Address address); + + + /** + * The trace source fired when the transmission of a RTS has failed + * + * \see class CallBackTraceSource + */ + TracedCallback m_macTxRtsFailed; + + /** + * The trace source fired when the transmission of a data packet has failed + * + * \see class CallBackTraceSource + */ + TracedCallback m_macTxDataFailed; + + /** + * The trace source fired when the transmission of a RTS has + * exceeded the maximum number of attempts + * + * \see class CallBackTraceSource + */ + TracedCallback m_macTxFinalRtsFailed; + + /** + * The trace source fired when the transmission of a data packet has + * exceeded the maximum number of attempts + * + * \see class CallBackTraceSource + */ + TracedCallback m_macTxFinalDataFailed; + }; } // namespace ns3 @@ -264,6 +321,18 @@ public: * \return exponentially weighted average SLRC, this is used by Airtime link metric of 802.11s */ double GetAvgSlrc () const; + /** + * set the address of the remote stationt represented by this instance of WifiRemoteStation + * + * @param address the MAC address of the remote station + */ + void SetAddress(Mac48Address address); + /** + * get the address of the remote stationt represented by this instance of WifiRemoteStation + * + * @return the MAC address of the remote station + */ + Mac48Address GetAddress(); private: virtual Ptr GetManager (void) const = 0; virtual WifiMode DoGetDataMode (uint32_t size) = 0; @@ -294,6 +363,7 @@ private: TracedValue m_slrc; double m_avgSlrcCoefficient; double m_avgSlrc; + Mac48Address m_address; }; } // namespace ns3