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 * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu> |
| 19 */ |
| 20 |
| 21 #ifndef RANDOM_JAMMER_H |
| 22 #define RANDOM_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 * Random Jammer. |
| 32 */ |
| 33 class RandomJammer : public Jammer |
| 34 { |
| 35 public: |
| 36 static TypeId GetTypeId (void); |
| 37 RandomJammer (); |
| 38 virtual ~RandomJammer (); |
| 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 SetTxPower (double power); |
| 58 double GetTxPower (void) const; |
| 59 void SetJammingDuration (Time duration); |
| 60 Time GetJammingDuration (void) const; |
| 61 void SetRandomVariable (RandomVariable random); |
| 62 void SetRxTimeout (Time rxTimeout); |
| 63 Time GetRxTimeout (void) const; |
| 64 void SetReactToMitigation (const bool flag); |
| 65 bool GetReactToMitigation (void) const; |
| 66 |
| 67 private: |
| 68 void DoDispose (void); |
| 69 |
| 70 /** |
| 71 * Stops jammer. |
| 72 */ |
| 73 virtual void DoStopJammer (void); |
| 74 |
| 75 /** |
| 76 * Sends out jamming burst at random interval. |
| 77 */ |
| 78 virtual void DoJamming (void); |
| 79 |
| 80 /** |
| 81 * \brief Handles start RX event. |
| 82 * |
| 83 * \param packet Pointer to incoming packet. |
| 84 * \param startRss Start RSS of packet. |
| 85 * \return False. Constant jammer will *always* ignore incoming packets. |
| 86 */ |
| 87 virtual bool DoStartRxHandler (Ptr<Packet> packet, double startRss); |
| 88 |
| 89 /** |
| 90 * \brief Handles incoming packet. |
| 91 * |
| 92 * \param packet Pointer to incoming packet. |
| 93 * \param averageRss Average RSS of packet |
| 94 * \return False. Constant jammer will *always* ignore incoming packets. |
| 95 */ |
| 96 virtual bool DoEndRxHandler (Ptr<Packet> packet, double averageRss); |
| 97 |
| 98 /** |
| 99 * \brief Notifies jammer of end of sending jamming signal. |
| 100 * |
| 101 * \param packet Pointer to dummy packet that was sent. |
| 102 * \param txPower Transmit power of packet. |
| 103 * |
| 104 * For random jammer, it schedules the next jamming burst in this function. |
| 105 */ |
| 106 virtual void DoEndTxHandler (Ptr<Packet> packet, double txPower); |
| 107 |
| 108 /** |
| 109 * Handles RX timeout event by hopping onto next channel. |
| 110 */ |
| 111 void RxTimeoutHandler (void); |
| 112 |
| 113 private: |
| 114 Ptr<WirelessModuleUtility> m_utility; |
| 115 Ptr<EnergySource> m_source; |
| 116 RandomVariable m_randomJammingInterval; // random variable to use |
| 117 double m_txPower; // TX power |
| 118 Time m_jammingDuration; // jamming duration |
| 119 EventId m_jammingEvent; // jamming event |
| 120 Time m_rxTimeout; // RX timeout interval |
| 121 EventId m_rxTimeoutEvent; // RX timeout event |
| 122 bool m_reactToMitigation; // true if jammer is reacting to mitigation |
| 123 bool m_reacting; // flag indicating jammer is reacting to mitigation |
| 124 |
| 125 }; // class RandomJammer |
| 126 |
| 127 } // namespace ns3 |
| 128 |
| 129 #endif /* RANDOM_JAMMER_H */ |
LEFT | RIGHT |