OLD | NEW |
(Empty) | |
| 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 JAMMER_H |
| 22 #define JAMMER_H |
| 23 |
| 24 #include "ns3/packet.h" |
| 25 #include "ns3/object.h" |
| 26 #include "ns3/traced-callback.h" |
| 27 #include "ns3/ptr.h" |
| 28 #include "ns3/random-variable.h" |
| 29 #include "ns3/wireless-module-utility.h" |
| 30 #include "ns3/energy-source.h" |
| 31 |
| 32 namespace ns3 { |
| 33 |
| 34 /** |
| 35 * Base class for wireless Jammers. Implements basic methods of jammers. Other |
| 36 * types of jammers can be defined from this class. Note that for the jammer to |
| 37 * work properly, a \ref WirelessModuleUtility must be installed onto the node. |
| 38 * This is automatically done by the \ref JammerHelper. |
| 39 */ |
| 40 class Jammer : public Object |
| 41 { |
| 42 public: |
| 43 static TypeId GetTypeId (void); |
| 44 Jammer (); |
| 45 virtual ~Jammer (); |
| 46 |
| 47 /** |
| 48 * \brief Sets pointer to WirelessModuleUtility installed on node.. |
| 49 * |
| 50 * \param utility Pointer to WirelessModuleUtility. |
| 51 */ |
| 52 virtual void SetUtility (Ptr<WirelessModuleUtility> utility) = 0; |
| 53 |
| 54 /** |
| 55 * \brief Sets pointer to energy source. |
| 56 * |
| 57 * \param energySrcPtr Pointer to EnergySource installed on node. |
| 58 * |
| 59 * This function is called by JammerHelper. |
| 60 */ |
| 61 virtual void SetEnergySource (Ptr<EnergySource> source) = 0; |
| 62 |
| 63 /** |
| 64 * \brief Sets jammer ID. |
| 65 * |
| 66 * \param id Jammer ID. |
| 67 * |
| 68 * Jammer ID is set to be the same as the node's ID on which the jammer is |
| 69 * aggregated. |
| 70 */ |
| 71 void SetId (uint32_t id); |
| 72 |
| 73 /** |
| 74 * \brief Gets jammer ID. |
| 75 * |
| 76 * \returns Jammer ID. |
| 77 */ |
| 78 uint32_t GetId (void) const; |
| 79 |
| 80 /** |
| 81 * Starts the jammer. |
| 82 */ |
| 83 void StartJammer (void); |
| 84 |
| 85 /** |
| 86 * Stops jammer, calls DoStopJammer. |
| 87 */ |
| 88 void StopJammer (void); |
| 89 |
| 90 /** |
| 91 * \param packet Pointer to incoming packet. |
| 92 * \param startRss Start RSS of packet. |
| 93 * \returns True if the incoming packet is to be received; false if the packet |
| 94 * is to be dropped. |
| 95 * |
| 96 * This function is called by WirelessModuleUtility at start of RX. Signature |
| 97 * is WirelessModuleUtility::UtilityRxCallback . |
| 98 */ |
| 99 bool StartRxHandler (Ptr<Packet> packet, double startRss); |
| 100 ·· |
| 101 /** |
| 102 * \param packet Pointer to incoming packet. |
| 103 * \param averageRss Average RSS of packet. |
| 104 * \returns True if packet is received. False otherwise. |
| 105 * |
| 106 * This function is called by WirelessModuleUtility at end of RX. Signature |
| 107 * is WirelessModuleUtility::UtilityRxCallback . |
| 108 */ |
| 109 bool EndRxHandler (Ptr<Packet> packet, double averageRss); |
| 110 |
| 111 /** |
| 112 * \param packet Pointer to sent packet. |
| 113 * |
| 114 * This function is called by WirelessModuleUtility at end of TX. Signature |
| 115 * is WirelessModuleUtility::UtilityTxCallback . |
| 116 */ |
| 117 void EndTxHandler (Ptr<Packet> packet, double txPower); |
| 118 |
| 119 /** |
| 120 * \returns True if jammer is on. |
| 121 */ |
| 122 bool IsJammerOn (void) const; |
| 123 |
| 124 |
| 125 private: |
| 126 /** |
| 127 * \brief Performs jamming. |
| 128 * |
| 129 * Implemented in child classes. |
| 130 */ |
| 131 virtual void DoJamming (void) = 0; |
| 132 |
| 133 /** |
| 134 * \brief Stops jammer. |
| 135 * |
| 136 * Implemented in child classes. |
| 137 */ |
| 138 virtual void DoStopJammer (void) = 0; |
| 139 |
| 140 /** |
| 141 * \brief Handles start RX event. |
| 142 * |
| 143 * \param packet Pointer to incoming packet. |
| 144 * \param startRss RSS at the start of packet. |
| 145 * \returns True if this packet is to be received, false otherwise. |
| 146 * |
| 147 * Implemented in child classes. |
| 148 */ |
| 149 virtual bool DoStartRxHandler (Ptr<Packet> packet, double startRss) = 0; |
| 150 |
| 151 /** |
| 152 * \brief Handles incoming packet (EndRxHandler). |
| 153 * |
| 154 * \param packet Pointer to incoming packet. |
| 155 * \param averageRss Average RSS of packet. |
| 156 * \returns True. |
| 157 * |
| 158 * Implemented in child classes. |
| 159 */ |
| 160 virtual bool DoEndRxHandler (Ptr<Packet> packet, double averageRss) = 0; |
| 161 |
| 162 /** |
| 163 * \brief Handles end TX event. |
| 164 * |
| 165 * \param packet Pointer to outgoing packet. |
| 166 * |
| 167 * Implemented in child classes |
| 168 */ |
| 169 virtual void DoEndTxHandler (Ptr<Packet> packet, double txPower) = 0; |
| 170 |
| 171 private: |
| 172 uint32_t m_id; |
| 173 bool m_jammerOn; |
| 174 |
| 175 }; |
| 176 |
| 177 } // namespace ns3 |
| 178 |
| 179 #endif /* JAMMER_H */ |
OLD | NEW |