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