A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
spectrum-decision.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License version 2 as
4  * published by the Free Software Foundation;
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * Author: Abdulla K. Al-Ali <abdulla.alali@qu.edu.qa>
16  */
17 
18 // Decision policy, when a PU is detected on the current channel
19 // Policy 0: Switch to a new channel as soon as a PU is detected
20 #define DECISION_POLICY_ALWAYS_SWITCH 0
21 // Policy 1: Switch to a new channel, with probability THRESHOLD_SWITCH
22 #define DECISION_POLICY_PROBABILISTIC_SWITCH 1
23 // Policy 2: Never switch!
24 #define DECISION_POLICY_NEVER_SWITCH 2
25 
26 // Switching threshold, for policy 1
27 #define THRESHOLD_SWITCH 0.8
28 
29 // Next Spectrum Selection
30 // Policy 1: next channel -> ( next_channel + 1 ) % MAX_CHANNELS
31 #define ROUND_ROBIN_SWITCH 0
32 // Policy 2: next_channel -> random(1..MAX_CHANNELS)
33 #define RANDOM_SWITCH 1
34 
35 #ifndef SPECTRUM_DECISION_H
36 #define SPECTRUM_DECISION_H
37 
38 #include "spectrum-manager.h"
39 
40 namespace ns3 {
41 class SpectrumManager;
42 
43 // Spectrum Decision module: decide the next channel when a PU is detected on the current one
44 class SpectrumDecision : public Object {
45 
46  public:
47 
48  // Spectrum Decision Initializer
50 
51  // Decide wheter to stay on the current channel or switch to a new channel
52  bool DecideSwitch();
53 
54  // Get the next channel to be used, based on the allocation policy
55  int DecideSpectrum(int current_channel);
56 
57  private:
58 
59  // Decision policy: stay or leave the current channel
60  int m_decisionPolicy;
61 
62  // Switching policy: decide the next channel to be used
63  int m_spectrumPolicy;
64 
65  // Spectrum Manager reference
66  SpectrumManager *m_specManager;
67 };
68 
69 }
70 #endif
APIs for Cognitive Radio extension.
a base class which provides memory management and object aggregation
Definition: object.h:63