# HG changeset patch # User Ashwin Narayan # Date 1310836728 14400 # Node ID 07a8e2881ec2bbfc119c7864e387d4e94f50748c # Parent 9da649b6670fd859936919c4d72c5e536cb9665c Added comments and changes for Doxygen compliance diff -r 9da649b6670f -r 07a8e2881ec2 src/wifi/model/mac-low.h --- a/src/wifi/model/mac-low.h Sat Jul 16 10:44:13 2011 -0400 +++ b/src/wifi/model/mac-low.h Sat Jul 16 13:18:48 2011 -0400 @@ -445,6 +445,7 @@ * \param rxSnr snr of packet received * \param txMode transmission mode of packet received * \param preamble type of preamble used for the packet received + * \param radiotaphdr radiotap header created in YansWifiPhy * * This method is typically invoked by the lower PHY layer to notify * the MAC layer that a packet was successfully received. diff -r 9da649b6670f -r 07a8e2881ec2 src/wifi/model/monitor-wifi-mac.cc --- a/src/wifi/model/monitor-wifi-mac.cc Sat Jul 16 10:44:13 2011 -0400 +++ b/src/wifi/model/monitor-wifi-mac.cc Sat Jul 16 13:18:48 2011 -0400 @@ -15,7 +15,8 @@ * 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 , Ashwin Narayan + * Author: Mathieu Lacage , + * Ashwin Narayan */ #include "monitor-wifi-mac.h" @@ -24,6 +25,7 @@ #include "ns3/pointer.h" #include "ns3/uinteger.h" #include "ns3/trace-source-accessor.h" +#include "ns3/abort.h" #include "mac-rx-middle.h" #include "mac-tx-middle.h" @@ -50,6 +52,16 @@ return tid; } +/* + * Please note that WifiNetDevice::SetMonitorMode () must + * be invoked for this to work correctly. + * + * Functions that have been inherited but not used have been + * given empty implementations owing to the fact that they + * are not applicable. + * + */ + MonitorWifiMac::MonitorWifiMac () { NS_LOG_FUNCTION (this); @@ -60,7 +72,7 @@ m_low = CreateObject (); m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); - m_low->SetMonitorMode (); + m_low->SetMonitorMode (); // Enables Monitor Mode functionality m_dcfManager = new DcfManager (); m_dcfManager->SetupLowListener (m_low); @@ -138,7 +150,7 @@ void MonitorWifiMac::SetQosSupported (bool enable) { - NS_FATAL_ERROR ("QoS Functionality not supported in MonitorWifiMac"); + NS_ABORT_MSG ("QoS Functionality not supported in MonitorWifiMac"); } bool @@ -266,40 +278,42 @@ return m_low->GetAddress (); } +/** + * Not applicable in Monitor Mode + */ void MonitorWifiMac::SetSsid (Ssid ssid) { - NS_LOG_FUNCTION (this << ssid); - m_ssid = ssid; } - +/** + * Not applicable in Monitor Mode + */ Ssid MonitorWifiMac::GetSsid (void) const { return m_ssid; } - +/** + * Not applicable in Monitor Mode + */ void MonitorWifiMac::SetBssid (Mac48Address bssid) { - NS_LOG_FUNCTION (this << bssid); - m_low->SetBssid (bssid); } - +/** + * Not applicable in Monitor Mode + */ Mac48Address MonitorWifiMac::GetBssid (void) const { return m_low->GetBssid (); } - +/** + * Not applicable in Monitor Mode + */ void MonitorWifiMac::SetWifiRemoteStationManager (Ptr stationManager) { - NS_LOG_FUNCTION (this << stationManager); - m_stationManager = stationManager; - m_low->SetWifiRemoteStationManager (stationManager); - - m_dca->SetWifiRemoteStationManager (stationManager); } void @@ -317,18 +331,27 @@ m_low->SetPromisc (); } +/** + * Not applicable in Monitor Mode + */ void MonitorWifiMac::Enqueue (Ptr packet, Mac48Address to, Mac48Address from) { + NS_ABORT_MSG ("Not applicable in MonitorMacWifi"); } - +/** + * Not applicable in Monitor Mode + */ void MonitorWifiMac::Enqueue (Ptr packet, Mac48Address to) { + NS_ABORT_MSG ("Not applicable in MonitorMacWifi"); } - +/** + * Not applicable in Monitor Mode + */ bool MonitorWifiMac::SupportsSendFrom (void) const { diff -r 9da649b6670f -r 07a8e2881ec2 src/wifi/model/monitor-wifi-mac.h --- a/src/wifi/model/monitor-wifi-mac.h Sat Jul 16 10:44:13 2011 -0400 +++ b/src/wifi/model/monitor-wifi-mac.h Sat Jul 16 13:18:48 2011 -0400 @@ -15,7 +15,8 @@ * 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 , Ashwin Narayan + * Author: Mathieu Lacage , + * Ashwin Narayan */ #ifndef MONITOR_WIFI_MAC_H #define MONITOR_WIFI_MAC_H @@ -43,7 +44,28 @@ * \brief base class for Monitor Wifi Mac objects. * * This class is essentially a copy of the non-QoS - * functionality of RegularWifiMac + * functionality of RegularWifiMac and serves as an + * abstraction for Monitor mode usage. + * + * This mode is generally used for passive sniffing. + * The interface receives all packets in its listening + * channel, even though it may not be destined for it. + * The 802.11 MAC packet contains extra header radiotap + * which includes physical layer information such as + * received channel, signal quality, signal to noise + * ratio, antenna scheme, etc. + * + * The other purpose of monitor mode is packet injection. + * It is possible to inject random IEEE 802.11 MAC frames + * using the radiotap header and monitor mode WLAN network + * interface. + * + * Please note that WifiNetDevice::SetMonitorMode () must + * be invoked for this to work correctly. + * + * Functions that have been inherited but not used have been + * given empty implementations owing to the fact that they + * are not applicable. * */ @@ -55,34 +77,137 @@ MonitorWifiMac (); virtual ~MonitorWifiMac (); + /** + * \param slotTime the slot duration + */ void SetSlot (Time slotTime); + /** + * \param sifs the sifs duration + */ void SetSifs (Time sifs); + /** + * \param eifsNoDifs the duration of an EIFS minus DIFS. + * + * This value is used to calculate the EIFS depending + * on AIFSN. + */ void SetEifsNoDifs (Time eifsNoDifs); + /** + * \param pifs the pifs duration. + */ void SetPifs (Time pifs); + /** + * \param ctsTimeout the duration of a CTS timeout. + */ void SetCtsTimeout (Time ctsTimeout); + /** + * \param ackTimeout the duration of an ACK timeout. + */ void SetAckTimeout (Time ackTimeout); + /** + * \returns the current PIFS duration. + */ Time GetPifs (void) const; + /** + * \returns the current SIFS duration. + */ Time GetSifs (void) const; + /** + * \returns the current slot duration. + */ Time GetSlot (void) const; + /** + * \returns the current EIFS minus DIFS duration + */ Time GetEifsNoDifs (void) const; + /** + * \returns the current CTS timeout duration. + */ Time GetCtsTimeout (void) const; + /** + * \returns the current ACK timeout duration. + */ Time GetAckTimeout (void) const; + /** + * \returns the MAC address associated to this MAC layer. + */ virtual Mac48Address GetAddress (void) const; + /** + * Not applicable in Monitor Mode node + */ virtual Ssid GetSsid (void) const; + /** + * \param address the current address of this MAC layer. + */ virtual void SetAddress (Mac48Address address); + /** + * Not applicable in Monitor Mode + */ virtual void SetSsid (Ssid ssid); + /** + * Not applicable in Monitor Mode + */ virtual void SetBssid (Mac48Address bssid); + /** + * Not applicable in Monitor Mode + */ virtual Mac48Address GetBssid (void) const; + /** + * \brief Sets the interface in promiscuous mode. + * + * Enables promiscuous mode on the interface. Note that any further + * filtering on the incoming frame path may affect the overall + * behavior. + */ virtual void SetPromisc (void); + + /** + * Not applicable in Monitor Mode + */ virtual void Enqueue (Ptr packet, Mac48Address to, Mac48Address from); + /** + * Not applicable in Monitor Mode + */ virtual bool SupportsSendFrom (void) const; + /** + * Not applicable in Monitor Mode + */ virtual void Enqueue (Ptr packet, Mac48Address to); + /** + * \param phy the physical layer attached to this MAC. + */ virtual void SetWifiPhy (Ptr phy); + /** + * \param stationManager the station manager attached to this MAC. + */ virtual void SetWifiRemoteStationManager (Ptr stationManager); + + /** + * This type defines the callback of a higher layer that a + * WifiMac(-derived) object invokes to pass a packet up the stack. + * + * \param packet the packet that has been received. + * \param from the MAC address of the device that sent the packet. + * \param to the MAC address ot the device that the packet is + * destined for. + */ typedef Callback, Mac48Address, Mac48Address> ForwardUpCallback; + /** + * \param upCallback the callback to invoke when a packet must be + * forwarded up the stack. + */ virtual void SetForwardUpCallback (ForwardUpCallback upCallback); + /** + * \param linkUp the callback to invoke when the link becomes up. + */ virtual void SetLinkUpCallback (Callback linkUp); + /** + * \param linkDown the callback to invoke when the link becomes down. + */ virtual void SetLinkDownCallback (Callback linkDown); + /* Next functions are not pure virtual so non Qos WifiMacs are not + * forced to implement them. + */ virtual void SetBasicBlockAckTimeout (Time blockAckTimeout); virtual Time GetBasicBlockAckTimeout (void) const; virtual void SetCompressedBlockAckTimeout (Time blockAckTimeout); @@ -106,26 +231,70 @@ Ssid m_ssid; + /** This holds a pointer to the DCF instance for this WifiMac - used + for transmission of frames to non-QoS peers. */ Ptr m_dca; + /** + * \param standard the phy standard to be used + * + * This method is called by ns3::WifiMac::ConfigureStandard to + * complete the configuration process for a requested phy standard. + * + * This method may be overriden by a derived class (e.g., in order + * to apply DCF parameters specific to the usage model it is + * dealing with), in which case the reimplementation may choose to + * deal with certain values in the WifiPhyStandard enumeration, and + * chain up to this implementation to deal with the remainder. + */ virtual void FinishConfigureStandard (enum WifiPhyStandard standard); + /** + * This method acts as the MacRxMiddle receive callback and is + * invoked to notify us that a frame has been received. The radiotap + * header is added to the packet here and then sent up the stack after + * extracting the origin and destination addresses from the MAC header. + * + * \param packet the packet that has been received. + * \param hdr a pointer to the MAC header of the received frame. + * \param radiotaphdr a pointer to the Radiotap Header of the packet. + */ virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); virtual void TxOk (const WifiMacHeader &hdr); virtual void TxFailed (const WifiMacHeader &hdr); void ForwardUp (Ptr packet, Mac48Address from, Mac48Address to); + /** + * Not applicable to Monitor Mode + * + */ virtual void DeaggregateAmsduAndForward (Ptr aggregatedPacket, const WifiMacHeader *hdr); - + /** + * Not applicable to Monitor Mode + * + */ virtual void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, Mac48Address originator); + /** + * Not applicable to Monitor Mode + * + */ bool m_qosSupported; + /** + * Not applicable to Monitor Mode + * + */ void SetQosSupported (bool enable); + /** + * Not applicable to Monitor Mode + * + */ bool GetQosSupported () const; private: + /** Accessor for the DCF object */ Ptr GetDcaTxop (void) const; TracedCallback m_txOkCallback; diff -r 9da649b6670f -r 07a8e2881ec2 src/wifi/model/regular-wifi-mac.h --- a/src/wifi/model/regular-wifi-mac.h Sat Jul 16 10:44:13 2011 -0400 +++ b/src/wifi/model/regular-wifi-mac.h Sat Jul 16 13:18:48 2011 -0400 @@ -276,6 +276,7 @@ * * \param packet the packet that has been received. * \param hdr a pointer to the MAC header of the received frame. + * \param radiotaphdr a point to the radiotap header of the packet. */ virtual void Receive (Ptr packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr); virtual void TxOk (const WifiMacHeader &hdr);