REM helper deactivates PHYs instead of removing, and exit when done by default
This commit is contained in:
@@ -215,17 +215,19 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
Simulator::Stop (Seconds (simTime));
|
||||
lteHelper->EnableTraces ();
|
||||
|
||||
// better to leave traces disabled
|
||||
//lteHelper->EnableTraces ();
|
||||
|
||||
Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> ();
|
||||
remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0"));
|
||||
remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
|
||||
remHelper->SetAttribute ("XMin", DoubleValue (-200.0));
|
||||
remHelper->SetAttribute ("XMax", DoubleValue (1200.0));
|
||||
remHelper->SetAttribute ("XRes", UintegerValue (100));
|
||||
remHelper->SetAttribute ("XRes", UintegerValue (400));
|
||||
remHelper->SetAttribute ("YMin", DoubleValue (-300.0));
|
||||
remHelper->SetAttribute ("YMax", DoubleValue (+3500.0));
|
||||
remHelper->SetAttribute ("YRes", UintegerValue (100));
|
||||
remHelper->SetAttribute ("YRes", UintegerValue (300));
|
||||
remHelper->SetAttribute ("Z", DoubleValue (1.5));
|
||||
remHelper->Install ();
|
||||
// Recall the buildings helper to place the REM nodes in its position
|
||||
|
||||
@@ -90,10 +90,10 @@ int main (int argc, char *argv[])
|
||||
remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
|
||||
remHelper->SetAttribute ("XMin", DoubleValue (-400.0));
|
||||
remHelper->SetAttribute ("XMax", DoubleValue (400.0));
|
||||
remHelper->SetAttribute ("XRes", UintegerValue (100));
|
||||
remHelper->SetAttribute ("XRes", UintegerValue (40));
|
||||
remHelper->SetAttribute ("YMin", DoubleValue (-300.0));
|
||||
remHelper->SetAttribute ("YMax", DoubleValue (300.0));
|
||||
remHelper->SetAttribute ("YRes", UintegerValue (75));
|
||||
remHelper->SetAttribute ("YRes", UintegerValue (30));
|
||||
remHelper->SetAttribute ("Z", DoubleValue (0.0));
|
||||
remHelper->Install ();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ns3/double.h>
|
||||
#include <ns3/uinteger.h>
|
||||
#include <ns3/string.h>
|
||||
#include <ns3/boolean.h>
|
||||
#include <ns3/spectrum-channel.h>
|
||||
#include <ns3/config.h>
|
||||
#include <ns3/rem-spectrum-phy.h>
|
||||
@@ -104,6 +105,10 @@ RadioEnvironmentMapHelper::GetTypeId (void)
|
||||
DoubleValue (0.0),
|
||||
MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_z),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("ExitWhenDone", "If true, Simulator::Stop () will be called as soon as the REM has been generated",
|
||||
BooleanValue (true),
|
||||
MakeBooleanAccessor (&RadioEnvironmentMapHelper::m_exitWhenDone),
|
||||
MakeBooleanChecker ())
|
||||
|
||||
;
|
||||
return tid;
|
||||
@@ -147,7 +152,7 @@ RadioEnvironmentMapHelper::Install ()
|
||||
}
|
||||
}
|
||||
Simulator::Schedule (Seconds (0.0055), &RadioEnvironmentMapHelper::Connect, this);
|
||||
Simulator::Schedule (Seconds (0.0065), &RadioEnvironmentMapHelper::PrintAndDisconnect, this);
|
||||
Simulator::Schedule (Seconds (0.0065), &RadioEnvironmentMapHelper::PrintAndDeactivate, this);
|
||||
|
||||
}
|
||||
|
||||
@@ -170,7 +175,7 @@ RadioEnvironmentMapHelper::Connect ()
|
||||
}
|
||||
|
||||
void
|
||||
RadioEnvironmentMapHelper::PrintAndDisconnect ()
|
||||
RadioEnvironmentMapHelper::PrintAndDeactivate ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
std::ofstream outFile;
|
||||
@@ -195,10 +200,16 @@ RadioEnvironmentMapHelper::PrintAndDisconnect ()
|
||||
<< pos.z << "\t"
|
||||
<< it2->phy->GetSinr ()
|
||||
<< std::endl;
|
||||
m_channel->RemoveRx (it2->phy);
|
||||
it2->phy->Deactivate ();
|
||||
}
|
||||
}
|
||||
outFile.close ();
|
||||
if (m_exitWhenDone)
|
||||
{
|
||||
Simulator::Stop ();
|
||||
Simulator::Destroy ();
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
private:
|
||||
|
||||
void Connect ();
|
||||
void PrintAndDisconnect ();
|
||||
void PrintAndDeactivate ();
|
||||
|
||||
|
||||
struct RemPoint
|
||||
@@ -81,6 +81,8 @@ private:
|
||||
|
||||
std::string m_channelPath;
|
||||
std::string m_outputFile;
|
||||
|
||||
bool m_exitWhenDone;
|
||||
|
||||
Ptr<SpectrumChannel> m_channel;
|
||||
};
|
||||
|
||||
@@ -39,7 +39,8 @@ RemSpectrumPhy::RemSpectrumPhy ()
|
||||
m_netDevice (0),
|
||||
m_channel (0),
|
||||
m_referenceSignalPower (0),
|
||||
m_sumPower (0)
|
||||
m_sumPower (0),
|
||||
m_active (true)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
@@ -139,13 +140,16 @@ void
|
||||
RemSpectrumPhy::StartRx (Ptr<SpectrumSignalParameters> params)
|
||||
{
|
||||
NS_LOG_FUNCTION ( this << params);
|
||||
double power = Integral (*(params->psd));
|
||||
NS_ASSERT_MSG (params->duration.GetMilliSeconds () == 1,
|
||||
"RemSpectrumPhy works only for LTE signals with duration of 1 ms");
|
||||
m_sumPower += power;
|
||||
if (power > m_referenceSignalPower)
|
||||
{
|
||||
m_referenceSignalPower = power;
|
||||
if (m_active)
|
||||
{
|
||||
double power = Integral (*(params->psd));
|
||||
NS_ASSERT_MSG (params->duration.GetMilliSeconds () == 1,
|
||||
"RemSpectrumPhy works only for LTE signals with duration of 1 ms");
|
||||
m_sumPower += power;
|
||||
if (power > m_referenceSignalPower)
|
||||
{
|
||||
m_referenceSignalPower = power;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,5 +159,11 @@ RemSpectrumPhy::GetSinr ()
|
||||
return m_referenceSignalPower / (m_sumPower + m_noisePower);
|
||||
}
|
||||
|
||||
void
|
||||
RemSpectrumPhy::Deactivate ()
|
||||
{
|
||||
m_active = false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -67,6 +67,11 @@ public:
|
||||
Ptr<AntennaModel> GetRxAntenna ();
|
||||
void StartRx (Ptr<SpectrumSignalParameters> params);
|
||||
|
||||
|
||||
/**
|
||||
* set the SpectrumModel to be used for reception
|
||||
*
|
||||
*/
|
||||
void SetRxSpectrumModel (Ptr<SpectrumModel>);
|
||||
|
||||
/**
|
||||
@@ -76,6 +81,12 @@ public:
|
||||
*/
|
||||
double GetSinr ();
|
||||
|
||||
/**
|
||||
* make StartRx a no-op from now on
|
||||
*
|
||||
*/
|
||||
void Deactivate ();
|
||||
|
||||
protected:
|
||||
void DoDispose ();
|
||||
|
||||
@@ -89,6 +100,8 @@ private:
|
||||
double m_sumPower;
|
||||
double m_noisePower;
|
||||
|
||||
bool m_active;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user