A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
pu-model.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
// A model for PU activity and CR channel sensing
19
20
#ifndef NS_PU_MODEL_H
21
#define NS_PU_MODEL_H
22
23
#include <stdio.h>
24
#include <stdlib.h>
25
#include <string.h>
26
#include <math.h>
27
#include "common-cognitive-header.h"
28
#include "ns3/object.h"
29
#include "ns3/nstime.h"
30
#include "ns3/log.h"
31
32
33
// Constant value for the PU Mapping file
34
// Max number of PUs
35
#define MAX_PU_USERS 60
36
// Max number of PU-data entry
37
#define MAX_PU_DATA_ENTRY 700
38
// Debug variable: enable verbose mode
39
#define IO_DEBUG 1
40
41
namespace
ns3 {
42
43
//PU information
44
struct
PuActivity
{
45
// channel used for tx
46
int
main_channel;
47
// number of arrival/departure entries
48
int
number_data;
49
// current location
50
double
x_loc;
51
double
y_loc;
52
// arrival/departure time
53
Time
arrival_time[MAX_PU_DATA_ENTRY];
54
Time
departure_time[MAX_PU_DATA_ENTRY];
55
bool
detected[MAX_PU_DATA_ENTRY];
56
// PU receiver location
57
double
x_loc_receiver;
58
double
y_loc_receiver;
59
// PU <alpha-beta> activity description
60
double
alpha;
61
double
beta;
62
// PU transmitting range
63
double
radius;
64
// Avg. interference caused by CR on the PU receiver
65
double
interference;
66
};
67
68
class
PUModel
:
public
Object
{
69
70
public
:
71
static
TypeId
GetTypeId (
void
);
72
// PUmodel creator
73
PUModel
();
74
// Return true if a PU is transmitting in the same spectrum of the CR
75
bool
IsPuActive(
Time
timeNow,
Time
ts,
double
x,
double
y,
int
channel);
76
//Check if PU is active at that time
77
bool
CheckActive(
Time
timeNow,
Time
ts);
78
//Get next PU off time
79
Time
GetNextOffTime(
Time
timeNow);
80
//Set PU map file
81
void
SetPuMapFile(
char
* file);
82
83
private
:
84
85
// Number of PUs in the current scenario
86
int
m_numberPus_;
87
// Data structures with information of PUs
88
PuActivity
m_puData[MAX_PU_USERS];
89
// Method to read data from PU file and save them in the pu_activity data structure
90
void
ReadData(
char
* dir);
91
// Method to get the distance from the PU transmitter
92
double
Distance(
double
x,
double
y,
int
channel);
93
// Method to get the distance from the PU receiver
94
double
DistanceFromReceiver
(
double
x,
double
y,
int
channel);
95
// Method tc check if a PU is transmitting on a given spectrum at a given time
96
bool
CheckActive(
Time
timeNow,
Time
ts,
int
channel);
97
98
};
99
}
100
#endif
ns3::Time
keep track of time unit.
Definition:
nstime.h:149
ns3::PUModel
Definition:
pu-model.h:68
ns3::PUModel::DistanceFromReceiver
double DistanceFromReceiver(double x, double y, int channel)
distance_receiver: Return the current distance from the PU receiver on a given channel ...
Definition:
pu-model.cc:305
ns3::PuActivity
Definition:
pu-model.h:44
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:44
src
cognitive
model
pu-model.h
Generated on Sun Mar 16 2014 11:25:01 for ns-3 by
1.8.6