40 #include <gsl/gsl_math.h>
41 #include <gsl/gsl_integration.h>
42 #include <gsl/gsl_cdf.h>
43 #include <gsl/gsl_sf_bessel.h>
44 #define min(a,b) ((a) < (b) ? (a) : (b))
45 #define max(a,b) ((a) > (b) ? (a) : (b))
46 #define WLAN_SIR_perfect 10.0 // if SIR > 10dB, perfect reception
47 #define WLAN_SIR_impossible 0.1 // if SIR < -10dB, impossible to receive
49 typedef struct fn_parameter_t
57 return 0.5 * erfc (x / sqrt (2.0));
60 double f (
double x,
void * params)
64 double f = pow ( 2 * gsl_cdf_ugaussian_P (x + beta) - 1, n - 1) * exp (-x * x / 2.0) / sqrt (2.0 * M_PI);
73 params.
beta = sqrt (2.0 * e2);
75 gsl_integration_workspace*
w = gsl_integration_workspace_alloc (1000);
79 gsl_integration_qagiu (&F, -params.
beta, 0, 1e-7, 1000, w, &sep, &error);
80 gsl_integration_workspace_free (w);
90 return 1.0 - pow ( 1.0 -
p_e2 (e1 / 2.0), 2.0);
95 return pow (10.0, x / 10.0);
100 return 10.0 * log10 (x);
105 double pi = acos (-1.0);
106 return ( (sqrt (2.0) + 1.0) / sqrt (8.0 * pi * sqrt (2.0))) * (1.0 / sqrt (x)) * exp ( -(2.0 - sqrt (2.0)) *
x);
129 double EbN0 = sinr * 22000000.0 / 1000000.0;
130 double ber = 0.5 * exp (-EbN0);
155 double EbN0 = sinr * 22000000.0 / 1000000.0 / 2.0;
174 pew =
min (pew, 0.99999);
175 ber = 8.0 / 15.0 * pew;
194 pew =
min (pew, 0.99999);
195 ber = 128.0 / 255.0 * pew;
200 int main (
int argc,
char * argv[])
203 double totalPkt = 200.0;
208 double EcNc, EbN01, EbN02, EbN05, EbN011;
209 double ieee1,ieee2,ieee5,ieee11;
210 double numBits = (1024. + 40. + 14.) * 8.;
211 double dbpsk,dqpsk,cck16,cck256,sepcck16,sepcck256;
212 noise =
DbToNoneDb (noise) * 1.3803e-23 * 290.0 * 22000000;
213 for (rss = -102.0; rss <= -80.0; rss += 0.1)
216 EcNc = sinr * 22000000.0 / 11000000.0;
217 EbN01 = sinr * 22000000.0 / 1000000.0;
219 EbN02 = sinr * 22000000.0 / 1000000.0 / 2.0;
220 EbN05 = sinr * 22000000.0 / 1375000.0 / 4.0;
221 EbN011 = sinr * 22000000.0 / 1375000.0 / 8.0;
223 printf (
"%g %g %g %g %g %g ", rss,
NoneDbToDb (EcNc),
231 printf (
" %g %g %g %g ", ieee1, ieee2,ieee5,ieee11);
232 ieee1 = totalPkt * pow (1 - ieee1, numBits);
233 ieee2 = totalPkt * pow (1 - ieee2, numBits);
234 ieee5 = totalPkt * pow (1 - ieee5, numBits);
235 ieee11 = totalPkt * pow (1 - ieee11, numBits);
237 printf (
" %g %g %g %g ", ieee1, ieee2,ieee5,ieee11);
240 cck16 =
max (0, 8.0 / 15.0 *
p_e2 (4.0 * EbN05 / 2.0));
241 cck256 =
max (0, 128.0 / 255.0 *
p_e1 (8.0 * EbN011 / 2.0));
243 printf (
" %g %g %g %g ", dbpsk, dqpsk,cck16,cck256);
244 dbpsk = totalPkt * pow (1 - dbpsk,numBits);
245 dqpsk = totalPkt * pow (1 - dqpsk,numBits);
246 sepcck16 =
p_e2 (4.0 * EbN05 / 2.0);
247 sepcck256 =
p_e1 (8.0 * EbN011 / 2.0);
248 cck16 = totalPkt * pow (1.0 - sepcck16,numBits / 4.0);
249 cck256 = totalPkt * pow (1.0 - sepcck256,numBits / 8.0);
251 printf (
" %g %g %g %g ", dbpsk, dqpsk,cck16,cck256);
Custom version of log2() to deal with Bug 1467.
double Get80211bDsssDbpskBer(double sinr)
double Get80211bDsssDqpskCCK11BerIeee(double EcNc)
double QFunction(double x)
double Get80211bDsssDqpskBer(double sinr)
double NoneDbToDb(double x)
double Get80211bDsssDqpskBerIeee(double EcNc)
double f(double x, void *params)
double Get80211bDsssDqpskCCK5_5BerIeee(double EcNc)
double DbToNoneDb(double x)
double Get80211bDsssDbpskBerIeee(double EcNc)
double DQPSKFunction(double x)
#define WLAN_SIR_impossible