-
Notifications
You must be signed in to change notification settings - Fork 0
/
WifiConfigurationXml.h
203 lines (162 loc) · 6.02 KB
/
WifiConfigurationXml.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* File: WifiConfigurationXml.h
* Author: bdupont
*
* Created on September 20, 2011, 10:26 AM
*/
#ifndef _WIFICONFIGURATIONXML_H
#define _WIFICONFIGURATIONXML_H
#include "tinyxml.h"
#include "ns3/simulator.h"
#include <string>
using namespace std;
using namespace ns3;
class WifiConfigurationXml {
private:
int m_wifiConfigId;
string m_wifiStandard;
string m_dataMode;
double m_txPowerStart;
double m_txPowerEnd;
int m_txPowerLevels;
double m_txGain;
double m_rxGain;
double m_energyDetectionThreshold;
WifiHelper wifiHelper;
NqosWifiMacHelper wifiMacHelper;
YansWifiPhyHelper wifiPhyHelper;
void CreateFromAttribs() {
wifiHelper = WifiHelper::Default();
if ("WIFI_PHY_STANDARD_80211a" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211a);
} else if ("WIFI_PHY_STANDARD_80211b" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211b);
} else if ("WIFI_PHY_STANDARD_80211_10Mhz" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211_10Mhz);
} else if ("WIFI_PHY_STANDARD_80211_10Mhz" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211_10Mhz);
} else if ("WIFI_PHY_STANDARD_80211_5Mhz" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211_5Mhz);
} else if ("WIFI_PHY_STANDARD_holland" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_holland);
} else if ("WIFI_PHY_STANDARD_80211p_CCH" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211p_CCH);
} else if ("WIFI_PHY_STANDARD_80211p_SCH" == m_wifiStandard) {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211p_SCH);
} else {
wifiHelper.SetStandard(WIFI_PHY_STANDARD_80211a);
}
wifiMacHelper = NqosWifiMacHelper::Default();
wifiPhyHelper = YansWifiPhyHelper::Default();
YansWifiChannelHelper wifiChannelHelper = YansWifiChannelHelper::Default();
wifiMacHelper.SetType("ns3::AdhocWifiMac");
wifiHelper.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode", StringValue(m_dataMode));
//m_wifiChannelHelper.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
Ptr<YansWifiChannel> wifiChannel = wifiChannelHelper.Create();
wifiPhyHelper.SetChannel(wifiChannel);
wifiPhyHelper.Set("TxPowerStart", DoubleValue(m_txPowerStart)); // 250-300 meter transmission range
wifiPhyHelper.Set("TxPowerEnd", DoubleValue(m_txPowerEnd)); // 250-300 meter transmission range
wifiPhyHelper.Set("TxPowerLevels", UintegerValue(m_txPowerLevels));
wifiPhyHelper.Set("TxGain", DoubleValue(m_txGain));
wifiPhyHelper.Set("RxGain", DoubleValue(m_rxGain));
wifiPhyHelper.Set("EnergyDetectionThreshold", DoubleValue(m_energyDetectionThreshold));
}
public:
WifiHelper GetWifiHelper() {
return wifiHelper;
}
NqosWifiMacHelper GetWifiMacHelper() {
return wifiMacHelper;
}
YansWifiPhyHelper GetWifiPhyHelper() {
return wifiPhyHelper;
}
string GetDataMode() {
return m_dataMode;
}
void SetDataMode(string dataMode) {
m_dataMode = dataMode;
}
double GetEnergyDetectionThreshold() {
return m_energyDetectionThreshold;
}
void SetEnergyDetectionThreshold(double energyDetectionThreshold) {
m_energyDetectionThreshold = energyDetectionThreshold;
}
double GetRxGain() {
return m_rxGain;
}
void SetRxGain(double rxGain) {
m_rxGain = rxGain;
}
double GetTxGain() {
return m_txGain;
}
void SetTxGain(double txGain) {
m_txGain = txGain;
}
double GetTxPowerEnd() {
return m_txPowerEnd;
}
void SetTxPowerEnd(double txPowerEnd) {
m_txPowerEnd = txPowerEnd;
}
int GetTxPowerLevels() {
return m_txPowerLevels;
}
void SetTxPowerLevels(int txPowerLevels) {
m_txPowerLevels = txPowerLevels;
}
double GetTxPowerStart() {
return m_txPowerStart;
}
void SetTxPowerStart(double txPowerStart) {
m_txPowerStart = txPowerStart;
}
int GetWifiConfigId() {
return m_wifiConfigId;
}
void SetWifiConfigId(int wifiConfigId) {
m_wifiConfigId = wifiConfigId;
}
string GetWifiStandard() {
return m_wifiStandard;
}
void SetWifiStandard(string wifiStandard) {
m_wifiStandard = wifiStandard;
}
void LoadDefaults() {
m_wifiStandard = "WIFI_PHY_STANDARD_80211a";
m_dataMode = "OfdmRate6MbpsBW10MHz";
m_txPowerStart = 21.5;
m_txPowerEnd = 21.5;
m_txPowerLevels = 1;
m_txGain = 2.0;
m_rxGain = 2.0;
m_energyDetectionThreshold = -101.0;
CreateFromAttribs();
}
void LoadFromXml(TiXmlHandle wifiConfigRoot) {
m_wifiStandard = "WIFI_PHY_STANDARD_80211a";
m_dataMode = "OfdmRate6MbpsBW10MHz";
m_txPowerStart = 21.5;
m_txPowerEnd = 21.5;
m_txPowerLevels = 1;
m_txGain = 2.0;
m_rxGain = 2.0;
m_energyDetectionThreshold = -101.0;
TiXmlElement* wifiConfigRootPtr = wifiConfigRoot.Element();
if(wifiConfigRootPtr) {
m_wifiStandard = string(wifiConfigRootPtr->Attribute("wifiStandard"));
m_dataMode = string(wifiConfigRootPtr->Attribute("dataMode"));
wifiConfigRootPtr->QueryDoubleAttribute("txPowerStart", &m_txPowerStart);
wifiConfigRootPtr->QueryDoubleAttribute("txPowerEnd", &m_txPowerEnd);
wifiConfigRootPtr->QueryIntAttribute("txPowerLevels", &m_txPowerLevels);
wifiConfigRootPtr->QueryDoubleAttribute("txGain", &m_txGain);
wifiConfigRootPtr->QueryDoubleAttribute("rxGain", &m_rxGain);
wifiConfigRootPtr->QueryDoubleAttribute("energyDetectionThreshold", &m_energyDetectionThreshold);
}
CreateFromAttribs();
}
};
#endif /* _WIFICONFIGURATIONXML_H */