LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. |
| 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: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu> |
| 19 */ |
| 20 |
| 21 #ifndef EAVESDROPPER_JAMMER_H |
| 22 #define EAVESDROPPER_JAMMER_H |
| 23 |
| 24 #include "jammer.h" |
| 25 #include "ns3/nstime.h" |
| 26 #include "ns3/event-id.h" |
| 27 |
| 28 namespace ns3 { |
| 29 |
| 30 /** |
| 31 * Eavesdropper Jammer. |
| 32 */ |
| 33 class EavesdropperJammer : public Jammer |
| 34 { |
| 35 public: |
| 36 static TypeId GetTypeId (void); |
| 37 EavesdropperJammer (); |
| 38 virtual ~EavesdropperJammer (); |
| 39 |
| 40 /** |
| 41 * \brief Sets pointer to WirelessModuleUtility installed on node.. |
| 42 * |
| 43 * \param utility Pointer to WirelessModuleUtility. |
| 44 */ |
| 45 virtual void SetUtility (Ptr<WirelessModuleUtility> utility); |
| 46 |
| 47 /** |
| 48 * \brief Sets pointer to energy source. |
| 49 * |
| 50 * \param energySrcPtr Pointer to EnergySource installed on node. |
| 51 * |
| 52 * This function is called by JammerHelper. |
| 53 */ |
| 54 virtual void SetEnergySource (Ptr<EnergySource> source); |
| 55 |
| 56 // setter & getters of attributes |
| 57 void SetRxTimeout (Time timeout); |
| 58 Time GetRxTimeout (void) const; |
| 59 void SetScanMode (bool mode); |
| 60 bool GetScanMode (void) const; |
| 61 void SetScanCycles (uint32_t cycles); |
| 62 uint32_t GetScanCycles (void) const; |
| 63 |
| 64 /** |
| 65 * Resets the packet count list for Eavesdropper scan mode. |
| 66 */ |
| 67 void ClearPacketCountList (void); |
| 68 |
| 69 private: |
| 70 void DoDispose (void); |
| 71 |
| 72 /** |
| 73 * Stops jammer. |
| 74 */ |
| 75 void DoStopJammer (void); |
| 76 |
| 77 /** |
| 78 * Sends out jamming burst at random interval. |
| 79 */ |
| 80 void DoJamming (void); |
| 81 |
| 82 /** |
| 83 * \brief Handles start RX event. |
| 84 * |
| 85 * \param packet Pointer to incoming packet. |
| 86 * \param startRss Start RSS of packet. |
| 87 * \returns True. Eavesdropper jammer will *always* accept incoming packets. |
| 88 */ |
| 89 virtual bool DoStartRxHandler (Ptr<Packet> packet, double startRss); |
| 90 ·· |
| 91 /** |
| 92 * \brief Handles end RX event (incoming packet). |
| 93 * |
| 94 * \param packet Pointer to incoming packet. |
| 95 * |
| 96 * Eavesdropper jammer will record the packet and traffic condition in the |
| 97 * current channel. |
| 98 */ |
| 99 virtual bool DoEndRxHandler (Ptr<Packet> packet, double averageRss); |
| 100 |
| 101 /** |
| 102 * \brief Notifies jammer of end of sending jamming signal |
| 103 * |
| 104 * \param packet Pointer to dummy packet that was sent |
| 105 */ |
| 106 virtual void DoEndTxHandler (Ptr<Packet> packet, double txPower); |
| 107 |
| 108 /** |
| 109 * This function is fired periodically. The period is defined to be how long |
| 110 * we want to scan each channel. When the function is fired, we will hop to |
| 111 * the next channel and start recording traffic condition. |
| 112 */ |
| 113 void RxTimeoutHandler (void); |
| 114 |
| 115 private: |
| 116 Ptr<WirelessModuleUtility> m_utility; |
| 117 Ptr<EnergySource> m_source; |
| 118 Time m_rxTimeout; // interval between timeout events |
| 119 uint8_t m_numOfChannels; // number of available channels |
| 120 EventId m_rxTimeoutEvent; // rx timeout event |
| 121 uint32_t m_totalScanCycles; // # of cycles to scan through all channels |
| 122 uint32_t m_scanCount; // # of channels scanned |
| 123 bool m_scanComplete; // flag set to indicate scanning is complete |
| 124 bool m_isScan; // set to run in scan mode |
| 125 /** |
| 126 * This list keeps a record of number of packets received in each channel. |
| 127 * Total number of channels depends on the PHY layer. The list is updated by |
| 128 * the eavesdropper jammer in scanning mode. It is used to determine which |
| 129 * channel has the most traffic. |
| 130 */ |
| 131 std::vector<int> m_numOfPktsReceived; |
| 132 |
| 133 }; |
| 134 |
| 135 } // namespace ns3 |
| 136 |
| 137 #endif /* EAVESDROPPER_JAMMER_H */ |
LEFT | RIGHT |