34#ifndef DOXYGEN_SHOULD_SKIP_THIS
36#include <gsl/gsl_cdf.h>
37#include <gsl/gsl_integration.h>
38#include <gsl/gsl_math.h>
39#include <gsl/gsl_sf_bessel.h>
41#define min(a, b) ((a) < (b) ? (a) : (b))
42#define max(a, b) ((a) > (b) ? (a) : (b))
43#define WLAN_SIR_perfect 10.0
44#define WLAN_SIR_impossible 0.1
46typedef struct fn_parameter_t
55 return 0.5 * erfc(x / sqrt(2.0));
59f(
double x,
void* params)
61 double beta = ((fn_parameters*)params)->beta;
62 double n = ((fn_parameters*)params)->n;
64 pow(2 * gsl_cdf_ugaussian_P(x + beta) - 1, n - 1) * exp(-x * x / 2.0) / sqrt(2.0 * M_PI);
74 params.beta = sqrt(2.0 * e2);
76 gsl_integration_workspace* w = gsl_integration_workspace_alloc(1000);
80 gsl_integration_qagiu(&F, -
params.beta, 0, 1e-7, 1000, w, &sep, &error);
81 gsl_integration_workspace_free(w);
92 return 1.0 - pow(1.0 - p_e2(e1 / 2.0), 2.0);
98 return pow(10.0, x / 10.0);
104 return 10.0 * log10(x);
108DQPSKFunction(
double x)
110 double pi = acos(-1.0);
111 return ((sqrt(2.0) + 1.0) / sqrt(8.0 * pi * sqrt(2.0))) * (1.0 / sqrt(x)) *
112 exp(-(2.0 - sqrt(2.0)) *
x);
116Get80211bDsssDbpskBerIeee(
double EcNc)
119 if (EcNc > WLAN_SIR_perfect)
123 else if (EcNc < WLAN_SIR_impossible)
129 ber = min(QFunction(sqrt(11.0 * EcNc)), 0.5);
135Get80211bDsssDbpskBer(
double sinr)
137 double EbN0 = sinr * 22000000.0 / 1000000.0;
138 double ber = 0.5 * exp(-EbN0);
143Get80211bDsssDqpskBerIeee(
double EcNc)
146 if (EcNc > WLAN_SIR_perfect)
150 else if (EcNc < WLAN_SIR_impossible)
156 ber = min(QFunction(sqrt(5.5 * EcNc)), 0.5);
162Get80211bDsssDqpskBer(
double sinr)
165 double EbN0 = sinr * 22000000.0 / 1000000.0 / 2.0;
166 double ber = DQPSKFunction(EbN0);
171Get80211bDsssDqpskCCK5_5BerIeee(
double EcNc)
174 if (EcNc > WLAN_SIR_perfect)
178 else if (EcNc < WLAN_SIR_impossible)
184 double pew = 14.0 * QFunction(sqrt(EcNc * 8.0)) + QFunction(sqrt(EcNc * 16.0));
185 pew = min(pew, 0.99999);
186 ber = 8.0 / 15.0 * pew;
192Get80211bDsssDqpskCCK11BerIeee(
double EcNc)
195 if (EcNc > WLAN_SIR_perfect)
199 else if (EcNc < WLAN_SIR_impossible)
205 double pew = 24.0 * QFunction(sqrt(EcNc * 4.0)) + 16.0 * QFunction(sqrt(EcNc * 6.0)) +
206 174.0 * QFunction(sqrt(EcNc * 8.0)) + 16.0 * QFunction(sqrt(EcNc * 10.0)) +
207 24.0 * QFunction(sqrt(EcNc * 12.0)) + QFunction(sqrt(EcNc * 16.0));
208 pew = min(pew, 0.99999);
209 ber = 128.0 / 255.0 * pew;
215main(
int argc,
char* argv[])
218 double totalPkt = 200.0;
223 double EcNc, EbN01, EbN02, EbN05, EbN011;
224 double ieee1, ieee2, ieee5, ieee11;
225 double numBits = (1024. + 40. + 14.) * 8.;
226 double dbpsk, dqpsk, cck16, cck256, sepcck16, sepcck256;
227 noise = DbToNoneDb(noise) * 1.3803e-23 * 290.0 * 22000000;
228 for (rss = -102.0; rss <= -80.0; rss += 0.1)
230 sinr = DbToNoneDb(rss) / 1000.0 / noise;
231 EcNc = sinr * 22000000.0 / 11000000.0;
232 EbN01 = sinr * 22000000.0 / 1000000.0;
234 EbN02 = sinr * 22000000.0 / 1000000.0 / 2.0;
235 EbN05 = sinr * 22000000.0 / 1375000.0 / 4.0;
236 EbN011 = sinr * 22000000.0 / 1375000.0 / 8.0;
238 printf(
"%g %g %g %g %g %g ",
245 ieee1 = Get80211bDsssDbpskBerIeee(EcNc);
246 ieee2 = Get80211bDsssDqpskBerIeee(EcNc);
247 ieee5 = Get80211bDsssDqpskCCK5_5BerIeee(EcNc);
248 ieee11 = Get80211bDsssDqpskCCK11BerIeee(EcNc);
250 printf(
" %g %g %g %g ", ieee1, ieee2, ieee5, ieee11);
251 ieee1 = totalPkt * pow(1 - ieee1, numBits);
252 ieee2 = totalPkt * pow(1 - ieee2, numBits);
253 ieee5 = totalPkt * pow(1 - ieee5, numBits);
254 ieee11 = totalPkt * pow(1 - ieee11, numBits);
256 printf(
" %g %g %g %g ", ieee1, ieee2, ieee5, ieee11);
257 dbpsk = Get80211bDsssDbpskBer(sinr);
258 dqpsk = Get80211bDsssDqpskBer(sinr);
259 cck16 = max(0, 8.0 / 15.0 * p_e2(4.0 * EbN05 / 2.0));
260 cck256 = max(0, 128.0 / 255.0 * p_e1(8.0 * EbN011 / 2.0));
262 printf(
" %g %g %g %g ", dbpsk, dqpsk, cck16, cck256);
263 dbpsk = totalPkt * pow(1 - dbpsk, numBits);
264 dqpsk = totalPkt * pow(1 - dqpsk, numBits);
265 sepcck16 = p_e2(4.0 * EbN05 / 2.0);
266 sepcck256 = p_e1(8.0 * EbN011 / 2.0);
267 cck16 = totalPkt * pow(1.0 - sepcck16, numBits / 4.0);
268 cck256 = totalPkt * pow(1.0 - sepcck256, numBits / 8.0);
270 printf(
" %g %g %g %g ", dbpsk, dqpsk, cck16, cck256);
272 printf(
" %g \n", NoneDbToDb(sinr));
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.