Hey,
Even I am working woth the mmwave module, I have done the calculation for SINR check this out:
the SINR in mmwave modules is given as array of power values so you need to make few changes to mmwave-ue-phy.cc, which are:
void
MmWaveUePhy::GenerateDlCqiReport (const SpectrumValue& sinr)
{
NS_LOG_FUNCTION (this);
// Not totally sure what this is about. We have to check.
if (m_ulConfigured && (m_rnti > 0) && m_receptionEnabled)
{
if (Simulator::Now () > m_wbCqiLast + m_wbCqiPeriod)
{
SpectrumValue newSinr = sinr;
Ptr<MmWaveDlCqiMessage> msg = CreateDlCqiFeedbackMessage (newSinr);
double avSinr= ComputeAvgSinr(newSinr);
if (msg)
{
DoSendControlMessage (msg);
}
Ptr<MmWaveUeNetDevice> UeRx = DynamicCast<MmWaveUeNetDevice> (GetDevice ());
m_reportCurrentCellRsrpSinrTrace (UeRx->GetImsi (), avSinr, newSinr);
}
}
}
double
MmWaveUePhy::ComputeAvgSinr (const SpectrumValue& sinr)
{
NS_LOG_FUNCTION (this);
// averaged SINR among RBs
double sum = 0.0;
uint8_t rbNum = 0;
Values::const_iterator it;
for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
{
sum += (*it);
rbNum++;
}
double avrgSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
return avrgSinr;
}
Now in your program file add the following trace and funtions:
-First you add these lines in the main file to connect the trace:
AsciiTraceHelper asciiTraceHelper;
Ptr<OutputStreamWrapper> stream = asciiTraceHelper.CreateFileStream ("ueTest.txt");
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::MmWaveUeNetDevice/ComponentCarrierMapUe/*/MmWaveUePhy/ReportCurrentCellRsrpSinr",
MakeBoundCallback (&ReportUeMeasurementsCallbackDetail,stream));
-Next this is the function:
void
ReportUeMeasurementsCallbackDetail (Ptr<OutputStreamWrapper> stream,std::string context,
uint64_t imsi, double sinr, SpectrumValue& power)
{
std::cout << "UE"<<imsi<<"SINR"<<10*log(sinr) / log(10)<<"RSRP"<< power<<std::endl;
std::cout<<"Printed"<<std::endl;
int nth=3; //looking for the second ocurrence of "/"
int cnt=0;
size_t pos=0;
while( cnt != nth )
{
pos = context.find("/", pos);
if ( pos == std::string::npos )
std::cout << nth << "th ocurrence not found!"<< std::endl;
pos+=1;
cnt++;
}
// std::cout << "test" <<context<< std::endl;
//manipulate the string to get the node ID
std::string str1;
str1 = context.substr(10,pos-11);
int ue= atoi(str1.c_str());
//Get the UE position from the NodeList
Ptr<MobilityModel> m1 = ns3::NodeList::GetNode(ue)->GetObject<MobilityModel>();
// Get the eNB position from the eNB
Ptr<MobilityModel> m2 = ns3::NodeList::GetNode(0)->GetObject<MobilityModel>();
// //print UE and eNB location
Vector v1 = m1->GetPosition();
Vector v2 = Vector (25, 25 , 7);
std::cout << Simulator::Now().GetSeconds()<<std::endl;
// <<"\tUE:" << imsi << " - (" << v1.x <<
", " << v1.y << "," <<v1.z
<<")"<<std::endl;
// std::cout << " \teNB:"
<< 1<< " - (" << v2.x << ", " << v2.y
<<"," <<v2.z << ")"<<std::endl;
//Print the distante between UE and eNB
Vector distance = v2-v1;
std::cout << " Distance : " << distance << std::endl;
*stream->GetStream() << Simulator::Now().GetSeconds() <<
"\t" <<imsi<<"\t"<< 10*log(sinr) / log(10)
<<"\t"<<v1 <<"\t"<<distance<< std::endl;
}