Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1.  
  2. #include "ns3/log.h"
  3. #include <iostream>
  4. #include <cmath>
  5. #include <ctime>
  6. #include "ns3/gnuplot.h"
  7. #include "ns3/command-line.h"
  8. #include "ns3/config.h"
  9. #include "ns3/uinteger.h"
  10. #include "ns3/double.h"
  11. #include "ns3/log.h"
  12. #include "ns3/ssid.h"
  13. #include <iostream>
  14. #include <string>
  15. #include <unistd.h>
  16. #include <fstream>
  17.  
  18. using namespace ns3;
  19. using namespace std;
  20. ifstream m_rssiERROR;
  21. ifstream m_rssiERROR1;
  22. ofstream m_locationERROR;
  23. ofstream m_locationERROR1;
  24.  
  25. struct loc
  26. {
  27. double x;
  28. double y;
  29. };
  30.  
  31. double ErrorLOS (double RSSI)
  32. {
  33. double error_bound,arch_lenght,radius,distance3D,lossDb;
  34. double const gainDb=10;
  35. double const SSP=23;
  36. double const freqGHz=30;
  37. lossDb=SSP+gainDb-RSSI;
  38. distance3D=pow(10,((lossDb-20*log10(freqGHz)-32.4)/17.3));
  39. radius=sqrt(distance3D*distance3D-1.5*1.5);
  40. arch_lenght=(2*M_PI*radius)/16;
  41. error_bound=arch_lenght/2;
  42. return error_bound;
  43. }
  44.  
  45. void UELocationLOS(double RSSI,double sectorNum)
  46. {
  47. loc UE;
  48. double radius,distance3D,lossDb,theta;
  49. double const gainDb=10;
  50. double const SSP=23;
  51. double const freqGHz=30;
  52. lossDb=SSP+gainDb-RSSI;
  53. double const baseAngle=11.25;
  54. distance3D=pow(10,((lossDb-20*log10(freqGHz)-32.4)/17.3));
  55. radius=sqrt((distance3D*distance3D)-(1.5*1.5));
  56. theta=baseAngle+22.5*sectorNum;
  57. theta = theta/57.2958;
  58. theta = theta - 1.5708;
  59. UE.x=radius*cos(theta);
  60. UE.y=radius*sin(theta);
  61. m_locationERROR<<UE.x+10<<" "<<UE.y+15<<std::endl;
  62. }
  63.  
  64. double ErrorNLOS (double RSSI)
  65. {
  66. double error_bound,arch_lenght,radius,distance3D,lossDb;
  67. double const gainDb=10;
  68. double const SSP=23;
  69. double const freqGHz=30;
  70. lossDb=SSP+gainDb-RSSI;
  71. distance3D=pow(10,((lossDb-24.9*log(freqGHz)-17.3)/38.3));
  72. radius=sqrt(distance3D*distance3D-1.5*1.5);
  73. arch_lenght=(2*M_PI*radius)/16;
  74. error_bound=arch_lenght/2;
  75. return error_bound;
  76. }
  77.  
  78. void UELocationNLOS(double RSSI,double sectorNum)
  79. {
  80. loc UE;
  81. double radius,distance3D,lossDb,theta;
  82. double const gainDb=10;
  83. double const SSP=23;
  84. double const freqGHz=30;
  85. lossDb=SSP+gainDb-RSSI;
  86. double const baseAngle=11.25;
  87. distance3D=pow(10,((lossDb-24.9*log10(freqGHz)-17.3)/38.3));
  88. radius=sqrt(distance3D*distance3D-(1.5*1.5));
  89. theta=baseAngle+22.5*sectorNum;
  90. theta = theta / 57.2958;
  91. theta = theta - 1.5708;
  92. UE.x=radius*cos(theta);
  93. UE.y=radius*sin(theta);
  94. m_locationERROR1<<UE.x+10<<" "<<UE.y+15<<std::endl;
  95. }
  96.  
  97. int main(int argc, char *argv[])
  98. {
  99.  
  100. m_rssiERROR.open("LOSrssiwithError.txt");
  101. m_rssiERROR1.open("NLOSrssiwithError.txt");
  102. m_locationERROR.open("LOSLocation.txt");
  103. m_locationERROR1.open("NLOSLocation.txt");
  104. double *rssiLOS = new double[200];
  105. double *rssiNLOS = new double[200];
  106.  
  107.  
  108. int l = 0;
  109. for( std::string line; getline( m_rssiERROR, line ); )
  110. {
  111. rssiLOS[l] = atof(line.c_str());
  112. l++;
  113. }
  114. int h = 0;
  115.  
  116.  
  117. for(std::string line1; getline( m_rssiERROR1, line1 );)
  118. {
  119. rssiNLOS[h] = atof(line1.c_str());
  120. h++;
  121. }
  122.  
  123.  
  124. int k = 0;
  125. for(int i=0;i<300;i+=5)
  126. {
  127. UELocationLOS(rssiLOS[k],4);
  128. UELocationNLOS(rssiNLOS[k],4);
  129. usleep(i*1000);
  130. k++;
  131. }
  132.  
  133. m_rssiERROR.close();
  134. m_rssiERROR1.close();
  135. m_locationERROR.close();
  136. m_locationERROR1.close();
  137. delete [] rssiLOS;
  138. delete [] rssiNLOS;
  139.  
  140. return 0;
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement