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 CONSTANTJAMMER_H |
| 22 #define CONSTANTJAMMER_H |
| 23 |
| 24 #include "jammer.h" |
| 25 #include "ns3/nstime.h" |
| 26 #include "ns3/event-id.h" |
| 27 |
| 28 namespace ns3 { |
| 29 |
| 30 /** |
| 31 * Constant Jammer. |
| 32 */ |
| 33 class ConstantJammer : public Jammer |
| 34 { |
| 35 public: |
| 36 static TypeId GetTypeId (void); |
| 37 ConstantJammer (); |
| 38 virtual ~ConstantJammer (); |
| 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 /** |
| 62 * \brief Sets the constant interval between jamming bursts. |
| 63 * |
| 64 * \param interval Interval between jamming bursts. |
| 65 */ |
| 66 void SetConstantJammingInterval (Time interval); |
| 67 Time GetConstantJammingInterval (void) const; |
| 68 void SetRxTimeout (Time rxTimeout); |
| 69 Time GetRxTimeout (void) const; |
| 70 void SetReactToMitigation (const bool flag); |
| 71 bool GetReactToMitigation (void) const; |
| 72 ·· |
| 73 |
| 74 private: |
| 75 void DoDispose (void); |
| 76 |
| 77 /** |
| 78 * Stops jammer. |
| 79 */ |
| 80 virtual void DoStopJammer (void); |
| 81 |
| 82 /** |
| 83 * Sends out jamming burst at random interval. |
| 84 */ |
| 85 virtual void DoJamming (void); |
| 86 |
| 87 /** |
| 88 * \brief Handles start RX event. |
| 89 * |
| 90 * \param packet Pointer to incoming packet. |
| 91 * \param startRss Start RSS of packet. |
| 92 * \return False. Constant jammer will *always* ignore incoming packets. |
| 93 */ |
| 94 virtual bool DoStartRxHandler (Ptr<Packet> packet, double startRss); |
| 95 |
| 96 /** |
| 97 * \brief Handles end RX event (incoming packet). |
| 98 * |
| 99 * \param packet Pointer to incoming packet. |
| 100 * \param averageRss Average RSS of packet. |
| 101 * \returns False. Constant jammer will *always* ignore incoming packets. |
| 102 */ |
| 103 virtual bool DoEndRxHandler (Ptr<Packet> packet, double averageRss); |
| 104 |
| 105 /** |
| 106 * \brief Notifies jammer of end of sending jamming signal |
| 107 * |
| 108 * \param packet Pointer to dummy packet that was sent. |
| 109 * \param txPower Transmit power of packet. |
| 110 * |
| 111 * For constant jammer, it will schedule the next jamming burst at the end of |
| 112 * previous jamming burst. |
| 113 */ |
| 114 virtual void DoEndTxHandler (Ptr<Packet> packet, double txPower); |
| 115 |
| 116 /** |
| 117 * Handles RX timeout event by hopping onto next channel. |
| 118 */ |
| 119 void RxTimeoutHandler (void); |
| 120 |
| 121 private: |
| 122 Ptr<WirelessModuleUtility> m_utility; // pointer to utility |
| 123 Ptr<EnergySource> m_source; // pointer to energy source |
| 124 Time m_constantJammingInterval; // jamming interval |
| 125 double m_txPower; // TX power |
| 126 Time m_jammingDuration; // jamming duration |
| 127 EventId m_jammingEvent; // jamming event |
| 128 Time m_rxTimeout; // RX timeout interval |
| 129 EventId m_rxTimeoutEvent; // RX timeout event |
| 130 bool m_reactToMitigation; // true if jammer is reacting to mitigation |
| 131 bool m_reacting; // flag indicating jammer is reacting to mitigation |
| 132 |
| 133 }; |
| 134 |
| 135 } // namespace ns3 |
| 136 |
| 137 |
| 138 #endif /* CONSTANTJAMMER_H */ |
LEFT | RIGHT |