LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2008 INRIA |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,· |
| 19 * Ashwin Narayan <ashwin.narayan89@gmail.com> |
| 20 */ |
| 21 #ifndef MONITOR_WIFI_MAC_H |
| 22 #define MONITOR_WIFI_MAC_H |
| 23 |
| 24 #include "ns3/wifi-mac.h" |
| 25 #include "ns3/radiotap-header.h" |
| 26 |
| 27 #include "dca-txop.h" |
| 28 #include "edca-txop-n.h" |
| 29 #include "wifi-remote-station-manager.h" |
| 30 #include "ssid.h" |
| 31 #include "qos-utils.h" |
| 32 |
| 33 #include <map> |
| 34 |
| 35 namespace ns3 { |
| 36 |
| 37 class Dcf; |
| 38 class MacLow; |
| 39 class MacRxMiddle; |
| 40 class MacTxMiddle; |
| 41 class DcfManager; |
| 42 |
| 43 /** |
| 44 * \brief base class for Monitor Wifi Mac objects. |
| 45 * |
| 46 * This class is essentially a copy of the non-QoS |
| 47 * functionality of RegularWifiMac and serves as an |
| 48 * abstraction for Monitor mode usage. |
| 49 * |
| 50 * This mode is generally used for passive sniffing.· |
| 51 * The interface receives all packets in its listening· |
| 52 * channel, even though it may not be destined for it. |
| 53 * The 802.11 MAC packet contains extra header radiotap· |
| 54 * which includes physical layer information such as |
| 55 * received channel, signal quality, signal to noise· |
| 56 * ratio, antenna scheme, etc.· |
| 57 * |
| 58 * The other purpose of monitor mode is packet injection.· |
| 59 * It is possible to inject raw IEEE 802.11 MAC frames· |
| 60 * using the radiotap header and monitor mode WLAN network· |
| 61 * interface. |
| 62 * |
| 63 * Please note that WifiNetDevice::SetMonitorMode () must· |
| 64 * be invoked for this to work correctly. |
| 65 * |
| 66 * Functions that have been inherited but not used have been |
| 67 * given empty implementations owing to the fact that they· |
| 68 * are not applicable. |
| 69 * |
| 70 */ |
| 71 |
| 72 class MonitorWifiMac : public WifiMac |
| 73 { |
| 74 public: |
| 75 static TypeId GetTypeId (void); |
| 76 |
| 77 MonitorWifiMac (); |
| 78 virtual ~MonitorWifiMac (); |
| 79 |
| 80 /** |
| 81 * The following functions have been inherited from WifiMac. |
| 82 * |
| 83 */ |
| 84 |
| 85 void SetSlot (Time slotTime); |
| 86 void SetSifs (Time sifs); |
| 87 void SetEifsNoDifs (Time eifsNoDifs); |
| 88 void SetPifs (Time pifs); |
| 89 void SetCtsTimeout (Time ctsTimeout); |
| 90 void SetAckTimeout (Time ackTimeout); |
| 91 Time GetPifs (void) const; |
| 92 Time GetSifs (void) const; |
| 93 Time GetSlot (void) const; |
| 94 Time GetEifsNoDifs (void) const; |
| 95 Time GetCtsTimeout (void) const; |
| 96 Time GetAckTimeout (void) const; |
| 97 virtual Mac48Address GetAddress (void) const; |
| 98 virtual void SetAddress (Mac48Address address); |
| 99 virtual void SetPromisc (void); |
| 100 ·· |
| 101 /** |
| 102 * The following functions have been inherited from WifiMac |
| 103 * but are not applicable in Monitor Mode. |
| 104 */ |
| 105 virtual Ssid GetSsid (void) const; |
| 106 virtual void SetSsid (Ssid ssid); |
| 107 virtual void SetBssid (Mac48Address bssid); |
| 108 virtual Mac48Address GetBssid (void) const; |
| 109 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address
from); |
| 110 virtual bool SupportsSendFrom (void) const; |
| 111 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to); |
| 112 virtual void DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, |
| 113 const WifiMacHeader *hdr); |
| 114 virtual void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, |
| 115 Mac48Address originator); |
| 116 bool m_qosSupported; |
| 117 void SetQosSupported (bool enable); |
| 118 bool GetQosSupported () const; |
| 119 |
| 120 virtual void SetWifiPhy (Ptr<WifiPhy> phy); |
| 121 virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> statio
nManager); |
| 122 |
| 123 typedef Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> ForwardUpCallb
ack; |
| 124 virtual void SetForwardUpCallback (ForwardUpCallback upCallback); |
| 125 virtual void SetLinkUpCallback (Callback<void> linkUp); |
| 126 virtual void SetLinkDownCallback (Callback<void> linkDown); |
| 127 virtual void SetBasicBlockAckTimeout (Time blockAckTimeout); |
| 128 virtual Time GetBasicBlockAckTimeout (void) const; |
| 129 virtual void SetCompressedBlockAckTimeout (Time blockAckTimeout); |
| 130 virtual Time GetCompressedBlockAckTimeout (void) const; |
| 131 |
| 132 protected: |
| 133 virtual void DoStart (); |
| 134 virtual void DoDispose (); |
| 135 |
| 136 MacRxMiddle *m_rxMiddle; |
| 137 MacTxMiddle *m_txMiddle; |
| 138 Ptr<MacLow> m_low; |
| 139 DcfManager *m_dcfManager; |
| 140 Ptr<WifiPhy> m_phy; |
| 141 |
| 142 Ptr<WifiRemoteStationManager> m_stationManager; |
| 143 |
| 144 ForwardUpCallback m_forwardUp; |
| 145 Callback<void> m_linkUp; |
| 146 Callback<void> m_linkDown; |
| 147 |
| 148 Ssid m_ssid; |
| 149 |
| 150 Ptr<DcaTxop> m_dca; |
| 151 |
| 152 virtual void FinishConfigureStandard (enum WifiPhyStandard standard); |
| 153 |
| 154 /** |
| 155 * This method acts as the MacRxMiddle receive callback and is |
| 156 * invoked to notify us that a frame has been received. The radiotap |
| 157 * header is added to the packet here and then sent up the stack after |
| 158 * extracting the origin and destination addresses from the MAC header. |
| 159 * |
| 160 * \param packet the packet that has been received. |
| 161 * \param hdr a pointer to the MAC header of the received frame. |
| 162 * \param radiotaphdr a pointer to the Radiotap Header of the packet. |
| 163 */ |
| 164 virtual void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr, const Radi
otapHeader *radiotaphdr); |
| 165 virtual void TxOk (const WifiMacHeader &hdr); |
| 166 virtual void TxFailed (const WifiMacHeader &hdr); |
| 167 |
| 168 void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to); |
| 169 private: |
| 170 /** Accessor for the DCF object */ |
| 171 Ptr<DcaTxop> GetDcaTxop (void) const; |
| 172 |
| 173 TracedCallback<const WifiMacHeader &> m_txOkCallback; |
| 174 TracedCallback<const WifiMacHeader &> m_txErrCallback; |
| 175 }; |
| 176 |
| 177 } // namespace ns3 |
| 178 |
| 179 #endif /* MONITOR_WIFI_MAC_H */ |
LEFT | RIGHT |