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 JAMMING_MITIGATION_H |
| 22 #define JAMMING_MITIGATION_H |
| 23 |
| 24 #include "ns3/object.h" |
| 25 #include "ns3/ptr.h" |
| 26 #include "ns3/wireless-module-utility.h" |
| 27 #include "ns3/energy-source.h" |
| 28 |
| 29 namespace ns3 { |
| 30 |
| 31 /** |
| 32 * Base class for jamming detection/mitigation methods. Other types of jamming |
| 33 * detection/mitigation methods can be defined from this class. Note that this |
| 34 * class requires a \ref WirelessModuleUtility object to operate, which is done |
| 35 * by \ref JammingMitigationHelper. |
| 36 */ |
| 37 class JammingMitigation : public Object |
| 38 { |
| 39 public: |
| 40 static TypeId GetTypeId (void); |
| 41 JammingMitigation (); |
| 42 virtual ~JammingMitigation (); |
| 43 |
| 44 /** |
| 45 * \brief Sets pointer to WirelessModuleUtility installed on node.. |
| 46 * |
| 47 * \param utility Pointer to WirelessModuleUtility. |
| 48 */ |
| 49 virtual void SetUtility (Ptr<WirelessModuleUtility> utility) = 0; |
| 50 |
| 51 /** |
| 52 * \brief Sets pointer to energy source. |
| 53 * |
| 54 * \param energySrcPtr Pointer to EnergySource installed on node. |
| 55 * |
| 56 * This function is called by JammerHelper. |
| 57 */ |
| 58 virtual void SetEnergySource (Ptr<EnergySource> source) = 0; |
| 59 |
| 60 /** |
| 61 * \brief Sets jamming mitigation object ID. |
| 62 * |
| 63 * \param id Jamming mitigation object ID. |
| 64 * |
| 65 * Jamming mitigation object ID is set to be the same as the node's ID on |
| 66 * which the jamming mitigation object is aggregated. |
| 67 */ |
| 68 void SetId (uint32_t id); |
| 69 |
| 70 /** |
| 71 * \brief Gets jamming mitigation ID. |
| 72 * |
| 73 * \returns jamming mitigation ID. |
| 74 */ |
| 75 uint32_t GetId (void) const; |
| 76 |
| 77 /** |
| 78 * Engages mitigation of jamming. |
| 79 */ |
| 80 void StartMitigation (void); |
| 81 |
| 82 /** |
| 83 * Stops mitigation of jamming. |
| 84 */ |
| 85 void StopMitigation (void); |
| 86 |
| 87 /** |
| 88 * \param packet Pointer to incoming packet. |
| 89 * \param startRss Start RSS of packet. |
| 90 * \returns True. Honest nodes will always accept the packet. |
| 91 * |
| 92 * This function is called by WirelessModuleUtility at start of RX. Signature |
| 93 * is WirelessModuleUtility::UtilityRxCallback . |
| 94 */ |
| 95 bool StartRxHandler (Ptr<Packet> packet, double startRss); |
| 96 |
| 97 /** |
| 98 * \param packet Pointer to incoming packet. |
| 99 * \param Average RSS of packet. |
| 100 * \returns True. Honest nodes will always accept the packet. |
| 101 * |
| 102 * Handles incoming packet at end of RX from utility module, calls |
| 103 * DoHandleIncomingPacket. |
| 104 */ |
| 105 bool EndRxHandler (Ptr<Packet> packet, double averageRss); |
| 106 |
| 107 /** |
| 108 * \brief Handles end TX event. |
| 109 * |
| 110 * \param packet Pointer to packet sent. |
| 111 * \param txPower Transmit power of packet. |
| 112 */ |
| 113 void EndTxHandler (Ptr<Packet> packet, double txPower); |
| 114 |
| 115 private: |
| 116 /** |
| 117 * \brief Engages mitigation of jamming. |
| 118 * |
| 119 * Implemented in child classes. |
| 120 */ |
| 121 virtual void DoMitigation (void) = 0; |
| 122 |
| 123 /** |
| 124 * \brief Stops mitigation of jamming. |
| 125 * |
| 126 * Implemented in child classes. |
| 127 */ |
| 128 virtual void DoStopMitigation (void) = 0; |
| 129 |
| 130 /** |
| 131 * \param packet Pointer to incoming packet. |
| 132 * \param startRss Start RSS of packet. |
| 133 * |
| 134 * Implemented in child classes. |
| 135 */ |
| 136 virtual void DoStartRxHandler (Ptr<Packet> packet, double startRss) = 0; |
| 137 |
| 138 /** |
| 139 * \brief Handles incoming packet. |
| 140 * |
| 141 * \param packet Pointer to incoming packet. |
| 142 * \param Average RSS of packet. |
| 143 * |
| 144 * Implemented in child classes. |
| 145 */ |
| 146 virtual void DoEndRxHandler (Ptr<Packet> packet, double averageRss) = 0; |
| 147 |
| 148 /** |
| 149 * \brief Handles end TX event. |
| 150 * |
| 151 * \param packet Pointer to packet sent. |
| 152 * |
| 153 * Implemented in child classes. |
| 154 */ |
| 155 virtual void DoEndTxHandler (Ptr<Packet> packet, double txPower) = 0; |
| 156 |
| 157 private: |
| 158 bool m_mitigationOn; |
| 159 uint32_t m_id; |
| 160 |
| 161 |
| 162 protected: |
| 163 bool IsMitigationOn (void) const; |
| 164 |
| 165 }; |
| 166 |
| 167 } // namespace ns3 |
| 168 |
| 169 #endif /* JAMMING_MITIGATION_H */ |
LEFT | RIGHT |