|
145 |
return GetErrorStatus (); |
145 |
return GetErrorStatus (); |
146 |
} |
146 |
} |
147 |
|
147 |
|
|
|
148 |
// Added for Two-Ray Ground Model - tomhewer@mac.com |
149 |
|
150 |
class TwoRayGroundPropagationLossModelTestCase : public TestCase |
151 |
{ |
152 |
public: |
153 |
TwoRayGroundPropagationLossModelTestCase (); |
154 |
virtual ~TwoRayGroundPropagationLossModelTestCase (); |
155 |
|
156 |
private: |
157 |
virtual bool DoRun (void); |
158 |
|
159 |
typedef struct { |
160 |
Vector m_position; |
161 |
double m_pt; // dBm |
162 |
double m_pr; // W |
163 |
double m_tolerance; |
164 |
} TestVector; |
165 |
|
166 |
TestVectors<TestVector> m_testVectors; |
167 |
}; |
168 |
|
169 |
TwoRayGroundPropagationLossModelTestCase::TwoRayGroundPropagationLossModelTestCase () |
170 |
: TestCase ("Check to see that the ns-3 TwoRayGround propagation loss model provides correct received power"), m_testVectors () |
171 |
{ |
172 |
} |
173 |
|
174 |
TwoRayGroundPropagationLossModelTestCase::~TwoRayGroundPropagationLossModelTestCase () |
175 |
{ |
176 |
} |
177 |
|
178 |
bool |
179 |
TwoRayGroundPropagationLossModelTestCase::DoRun (void) |
180 |
{ |
181 |
// wavelength at 2.4 GHz is 0.125m |
182 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125)); |
183 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0)); |
184 |
|
185 |
// set antenna height to 1.5m above z coordinate |
186 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5)); |
187 |
|
188 |
// Select a reference transmit power of 17.0206 dBm |
189 |
// Pt = 10^(17.0206/10)/10^3 = .05035702 W |
190 |
double txPowerW = 0.05035702; |
191 |
double txPowerdBm = 10 * log10 (txPowerW) + 30; |
192 |
|
193 |
// |
194 |
// As with the Friis tests above, we want to test the propagation loss |
195 |
// model calculations at a few chosen distances and compare the results |
196 |
// to those we can manually calculate. Let us test the ns-3 calculated |
197 |
// value for agreement to be within 5e-16, as above. |
198 |
// |
199 |
TestVector testVector; |
200 |
|
201 |
// Below the Crossover distance use Friis so this test should be the same as that above |
202 |
// Crossover = (4 * PI * TxAntennaHeight * RxAntennaHeight) / Lamdba |
203 |
// Crossover = (4 * PI * 1.5 * 1.5) / 0.125 = 226.1946m |
204 |
|
205 |
testVector.m_position = Vector (100, 0, 0); |
206 |
testVector.m_pt = txPowerdBm; |
207 |
testVector.m_pr = 4.98265e-10; |
208 |
testVector.m_tolerance = 5e-16; |
209 |
m_testVectors.Add (testVector); |
210 |
|
211 |
// These values are above the crossover distance and therefore use the Two Ray calculation |
212 |
|
213 |
testVector.m_position = Vector (500, 0, 0); |
214 |
testVector.m_pt = txPowerdBm; |
215 |
testVector.m_pr = 4.07891862e-12; |
216 |
testVector.m_tolerance = 5e-16; |
217 |
m_testVectors.Add (testVector); |
218 |
|
219 |
testVector.m_position = Vector (1000, 0, 0); |
220 |
testVector.m_pt = txPowerdBm; |
221 |
testVector.m_pr = 2.5493241375e-13; |
222 |
testVector.m_tolerance = 5e-16; |
223 |
m_testVectors.Add (testVector); |
224 |
|
225 |
testVector.m_position = Vector (2000, 0, 0); |
226 |
testVector.m_pt = txPowerdBm; |
227 |
testVector.m_pr = 1.593327585938e-14; |
228 |
testVector.m_tolerance = 5e-16; |
229 |
m_testVectors.Add (testVector); |
230 |
|
231 |
// Repeat the tests for non-zero z coordinates |
232 |
|
233 |
// Pr = (0.05035702 * (1.5*1.5) * (2.5*2.5)) / (500*500*500*500) = 1.13303295e-11 |
234 |
// dCross = (4 * pi * 1.5 * 2.5) / 0.125 = 376.99m |
235 |
testVector.m_position = Vector (500, 0, 1); |
236 |
testVector.m_pt = txPowerdBm; |
237 |
testVector.m_pr = 1.13303295e-11; |
238 |
testVector.m_tolerance = 5e-16; |
239 |
m_testVectors.Add (testVector); |
240 |
|
241 |
// Pr = (0.05035702 * (1.5*1.5) * (5.5*5.5)) / (1000*1000*1000*1000) = 3.42742467375e-12 |
242 |
// dCross = (4 * pi * 1.5 * 5.5) / 0.125 = 829.38m |
243 |
testVector.m_position = Vector (1000, 0, 4); |
244 |
testVector.m_pt = txPowerdBm; |
245 |
testVector.m_pr = 3.42742467375e-12; |
246 |
testVector.m_tolerance = 5e-16; |
247 |
m_testVectors.Add (testVector); |
248 |
|
249 |
// Pr = (0.05035702 * (1.5*1.5) * (11.5*11.5)) / (2000*2000*2000*2000) = 9.36522547734e-13 |
250 |
// dCross = (4 * pi * 1.5 * 11.5) / 0.125 = 1734.15m |
251 |
testVector.m_position = Vector (2000, 0, 10); |
252 |
testVector.m_pt = txPowerdBm; |
253 |
testVector.m_pr = 9.36522547734e-13; |
254 |
testVector.m_tolerance = 5e-16; |
255 |
m_testVectors.Add (testVector); |
256 |
|
257 |
|
258 |
// Now, check that the received power values are expected |
259 |
|
260 |
Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); |
261 |
a->SetPosition (Vector (0,0,0)); |
262 |
Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); |
263 |
|
264 |
Ptr<TwoRayGroundPropagationLossModel> lossModel = CreateObject<TwoRayGroundPropagationLossModel> (); |
265 |
for (uint32_t i = 0; i < m_testVectors.GetN (); ++i) |
266 |
{ |
267 |
testVector = m_testVectors.Get (i); |
268 |
b->SetPosition (testVector.m_position); |
269 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b); |
270 |
double resultW = pow (10.0, resultdBm/10.0)/1000; |
271 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
272 |
} |
273 |
|
274 |
return GetErrorStatus (); |
275 |
} |
276 |
|
148 |
class LogDistancePropagationLossModelTestCase : public TestCase |
277 |
class LogDistancePropagationLossModelTestCase : public TestCase |
149 |
{ |
278 |
{ |
150 |
public: |
279 |
public: |
|
244 |
: TestSuite ("propagation-loss-model", UNIT) |
373 |
: TestSuite ("propagation-loss-model", UNIT) |
245 |
{ |
374 |
{ |
246 |
AddTestCase (new FriisPropagationLossModelTestCase); |
375 |
AddTestCase (new FriisPropagationLossModelTestCase); |
|
|
376 |
AddTestCase (new TwoRayGroundPropagationLossModelTestCase); |
247 |
AddTestCase (new LogDistancePropagationLossModelTestCase); |
377 |
AddTestCase (new LogDistancePropagationLossModelTestCase); |
248 |
} |
378 |
} |
249 |
|
379 |
|