Range-based propagation loss model added
This commit is contained in:
@@ -420,6 +420,48 @@ MatrixPropagationLossModelTestCase::DoRun (void)
|
||||
return GetErrorStatus ();
|
||||
}
|
||||
|
||||
class RangePropagationLossModelTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
RangePropagationLossModelTestCase ();
|
||||
virtual ~RangePropagationLossModelTestCase ();
|
||||
|
||||
private:
|
||||
virtual bool DoRun (void);
|
||||
};
|
||||
|
||||
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
|
||||
: TestCase ("Test RangePropagationLossModel")
|
||||
{
|
||||
}
|
||||
|
||||
RangePropagationLossModelTestCase::~RangePropagationLossModelTestCase ()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
RangePropagationLossModelTestCase::DoRun (void)
|
||||
{
|
||||
Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
|
||||
Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector (0,0,0));
|
||||
Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector (127.1,0,0)); // within range
|
||||
|
||||
Ptr<RangePropagationLossModel> lossModel = CreateObject<RangePropagationLossModel> ();
|
||||
|
||||
double txPwrdBm = -80.0;
|
||||
double tolerance = 1e-6;
|
||||
double resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
|
||||
NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, txPwrdBm, tolerance, "Got unexpected rcv power");
|
||||
b->SetPosition (Vector (127.25,0,0)); // beyond range
|
||||
resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
|
||||
NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, -1000.0, tolerance, "Got unexpected rcv power");
|
||||
Simulator::Destroy ();
|
||||
|
||||
return GetErrorStatus ();
|
||||
}
|
||||
|
||||
class PropagationLossModelsTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
@@ -433,6 +475,7 @@ PropagationLossModelsTestSuite::PropagationLossModelsTestSuite ()
|
||||
AddTestCase (new TwoRayGroundPropagationLossModelTestCase);
|
||||
AddTestCase (new LogDistancePropagationLossModelTestCase);
|
||||
AddTestCase (new MatrixPropagationLossModelTestCase);
|
||||
AddTestCase (new RangePropagationLossModelTestCase);
|
||||
}
|
||||
|
||||
PropagationLossModelsTestSuite WifiPropagationLossModelsTestSuite;
|
||||
|
||||
@@ -790,4 +790,43 @@ MatrixPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (RangePropagationLossModel);
|
||||
|
||||
TypeId
|
||||
RangePropagationLossModel::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::RangePropagationLossModel")
|
||||
.SetParent<PropagationLossModel> ()
|
||||
.AddConstructor<RangePropagationLossModel> ()
|
||||
.AddAttribute ("MaxRange",
|
||||
"Maximum Transmission Range (meters)",
|
||||
DoubleValue (250),
|
||||
MakeDoubleAccessor (&RangePropagationLossModel::m_range),
|
||||
MakeDoubleChecker<double> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
RangePropagationLossModel::RangePropagationLossModel ()
|
||||
{
|
||||
}
|
||||
|
||||
double
|
||||
RangePropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
double distance = a->GetDistanceFrom (b);
|
||||
if (distance <= m_range)
|
||||
{
|
||||
return txPowerDbm;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1000;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -503,6 +503,29 @@ private:
|
||||
std::map<MobilityPair, double> m_loss;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief The propagation loss depends only on the distance (range) between transmitter and receiver.
|
||||
*
|
||||
* The single MaxRange attribute (units of meters) determines path loss.
|
||||
* Receivers at or within MaxRange meters receive the transmission at the
|
||||
* transmit power level. Receivers beyond MaxRange receive at power
|
||||
* -1000 dBm (effectively zero).
|
||||
*/
|
||||
class RangePropagationLossModel : public PropagationLossModel
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
RangePropagationLossModel ();
|
||||
private:
|
||||
RangePropagationLossModel (const RangePropagationLossModel& o);
|
||||
RangePropagationLossModel& operator= (const RangePropagationLossModel& o);
|
||||
virtual double DoCalcRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
private:
|
||||
double m_range;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* PROPAGATION_LOSS_MODEL_H */
|
||||
|
||||
Reference in New Issue
Block a user