Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ns3/log.h"
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include "ns3/gnuplot.h"
- #include "ns3/command-line.h"
- #include "ns3/config.h"
- #include "ns3/uinteger.h"
- #include "ns3/double.h"
- #include "ns3/log.h"
- #include "ns3/ssid.h"
- #include <iostream>
- #include <string>
- #include <unistd.h>
- #include <fstream>
- using namespace ns3;
- using namespace std;
- ifstream m_rssiERROR;
- ifstream m_rssiERROR1;
- ofstream m_locationERROR;
- ofstream m_locationERROR1;
- struct loc
- {
- double x;
- double y;
- };
- double ErrorLOS (double RSSI)
- {
- double error_bound,arch_lenght,radius,distance3D,lossDb;
- double const gainDb=10;
- double const SSP=23;
- double const freqGHz=30;
- lossDb=SSP+gainDb-RSSI;
- distance3D=pow(10,((lossDb-20*log10(freqGHz)-32.4)/17.3));
- radius=sqrt(distance3D*distance3D-1.5*1.5);
- arch_lenght=(2*M_PI*radius)/16;
- error_bound=arch_lenght/2;
- return error_bound;
- }
- void UELocationLOS(double RSSI,double sectorNum)
- {
- loc UE;
- double radius,distance3D,lossDb,theta;
- double const gainDb=10;
- double const SSP=23;
- double const freqGHz=30;
- lossDb=SSP+gainDb-RSSI;
- double const baseAngle=11.25;
- distance3D=pow(10,((lossDb-20*log10(freqGHz)-32.4)/17.3));
- radius=sqrt((distance3D*distance3D)-(1.5*1.5));
- theta=baseAngle+22.5*sectorNum;
- theta = theta/57.2958;
- theta = theta - 1.5708;
- UE.x=radius*cos(theta);
- UE.y=radius*sin(theta);
- m_locationERROR<<UE.x+10<<" "<<UE.y+15<<std::endl;
- }
- double ErrorNLOS (double RSSI)
- {
- double error_bound,arch_lenght,radius,distance3D,lossDb;
- double const gainDb=10;
- double const SSP=23;
- double const freqGHz=30;
- lossDb=SSP+gainDb-RSSI;
- distance3D=pow(10,((lossDb-24.9*log(freqGHz)-17.3)/38.3));
- radius=sqrt(distance3D*distance3D-1.5*1.5);
- arch_lenght=(2*M_PI*radius)/16;
- error_bound=arch_lenght/2;
- return error_bound;
- }
- void UELocationNLOS(double RSSI,double sectorNum)
- {
- loc UE;
- double radius,distance3D,lossDb,theta;
- double const gainDb=10;
- double const SSP=23;
- double const freqGHz=30;
- lossDb=SSP+gainDb-RSSI;
- double const baseAngle=11.25;
- distance3D=pow(10,((lossDb-24.9*log10(freqGHz)-17.3)/38.3));
- radius=sqrt(distance3D*distance3D-(1.5*1.5));
- theta=baseAngle+22.5*sectorNum;
- theta = theta / 57.2958;
- theta = theta - 1.5708;
- UE.x=radius*cos(theta);
- UE.y=radius*sin(theta);
- m_locationERROR1<<UE.x+10<<" "<<UE.y+15<<std::endl;
- }
- int main(int argc, char *argv[])
- {
- m_rssiERROR.open("LOSrssiwithError.txt");
- m_rssiERROR1.open("NLOSrssiwithError.txt");
- m_locationERROR.open("LOSLocation.txt");
- m_locationERROR1.open("NLOSLocation.txt");
- double *rssiLOS = new double[200];
- double *rssiNLOS = new double[200];
- int l = 0;
- for( std::string line; getline( m_rssiERROR, line ); )
- {
- rssiLOS[l] = atof(line.c_str());
- l++;
- }
- int h = 0;
- for(std::string line1; getline( m_rssiERROR1, line1 );)
- {
- rssiNLOS[h] = atof(line1.c_str());
- h++;
- }
- int k = 0;
- for(int i=0;i<300;i+=5)
- {
- UELocationLOS(rssiLOS[k],4);
- UELocationNLOS(rssiNLOS[k],4);
- usleep(i*1000);
- k++;
- }
- m_rssiERROR.close();
- m_rssiERROR1.close();
- m_locationERROR.close();
- m_locationERROR1.close();
- delete [] rssiLOS;
- delete [] rssiNLOS;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement