Clean up coding style.
authorGary Pei <guangyu.pei@boeing.com>
Fri, 22 May 2009 10:51:23 -0700
changeset 4463 0ee5121445c2
parent 4462 b55586078d9f
child 4464 40997b37ee4d
Clean up coding style.
src/devices/wifi/interference-helper.cc
src/devices/wifi/yans-error-rate-model.cc
--- a/src/devices/wifi/interference-helper.cc	Fri May 22 10:25:43 2009 -0700
+++ b/src/devices/wifi/interference-helper.cc	Fri May 22 10:51:23 2009 -0700
@@ -228,21 +228,22 @@
 InterferenceHelper::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble) const
 {
   uint64_t delay = 0;
-  switch (m_80211_standard) {
-  case WIFI_PHY_STANDARD_80211a:
-  case WIFI_PHY_STANDARD_holland:
-    delay += m_plcpLongPreambleDelayUs;
-    // symbol duration is 4us
-    delay += 4;
-    delay += lrint (ceil ((size * 8.0 + 16.0 + 6.0) / payloadMode.GetDataRate () / 4e-6) * 4);
-    break;
-  case WIFI_PHY_STANDARD_80211b:
-    delay += m_plcpLongPreambleDelayUs;
-    delay += lrint (ceil ((size * 8.0 + 48.0) / payloadMode.GetDataRate () / 4e-6) * 4);
-    break;
-  default:
-   NS_ASSERT (false);
-   break;
+  switch (m_80211_standard) 
+  {
+    case WIFI_PHY_STANDARD_80211a:
+    case WIFI_PHY_STANDARD_holland:
+      delay += m_plcpLongPreambleDelayUs;
+      // symbol duration is 4us
+      delay += 4;
+      delay += lrint (ceil ((size * 8.0 + 16.0 + 6.0) / payloadMode.GetDataRate () / 4e-6) * 4);
+      break;
+    case WIFI_PHY_STANDARD_80211b:
+      delay += m_plcpLongPreambleDelayUs;
+      delay += lrint (ceil ((size * 8.0 + 48.0) / payloadMode.GetDataRate () / 4e-6) * 4);
+      break;
+    default:
+     NS_ASSERT (false);
+     break;
   }
 
   return MicroSeconds (delay);
--- a/src/devices/wifi/yans-error-rate-model.cc	Fri May 22 10:25:43 2009 -0700
+++ b/src/devices/wifi/yans-error-rate-model.cc	Fri May 22 10:51:23 2009 -0700
@@ -287,53 +287,57 @@
 double 
 YansErrorRateModel::DqpskFunction (double x) const
 {
- return ( (sqrt (2.0) + 1.0) / sqrt (8.0*3.1415926*sqrt (2.0)))
-        *(1.0/sqrt (x))
-        *exp ( - (2.0 - sqrt (2.0)) * x) ;
+  return ( (sqrt (2.0) + 1.0) / sqrt (8.0*3.1415926*sqrt (2.0)))
+         *(1.0/sqrt (x))
+         *exp ( - (2.0 - sqrt (2.0)) * x) ;
 }
 
 double 
 YansErrorRateModel::Get80211bDsssDbpskSuccessRate (double sinr, uint32_t nbits) const
 {
- double EbN0 = sinr * 22000000.0 / 1000000.0; // 1 bit per symbol with 1 MSPS
- double ber = 0.5 * exp (-EbN0);
- NS_LOG_DEBUG ("DSSS Dbpsk snr="<<sinr<<" ber="<<ber<<" psr"<<pow((1.0 - ber), nbits)<<" nbits"<<nbits);
- return pow ((1.0 - ber), nbits);
+  double EbN0 = sinr * 22000000.0 / 1000000.0; // 1 bit per symbol with 1 MSPS
+  double ber = 0.5 * exp (-EbN0);
+  NS_LOG_DEBUG ("DSSS Dbpsk snr="<<sinr<<" ber="<<ber<<" psr"<<pow((1.0 - ber), nbits)<<" nbits"<<nbits);
+  return pow ((1.0 - ber), nbits);
 }
 
 double 
 YansErrorRateModel::Get80211bDsssDqpskSuccessRate (double sinr,uint32_t nbits) const
 {
- double EbN0 = sinr * 22000000.0 / 1000000.0 / 2.0; // 2 bits per symbol, 1 MSPS
- double ber = DqpskFunction (EbN0);
- return pow ((1.0 - ber), nbits);
+  double EbN0 = sinr * 22000000.0 / 1000000.0 / 2.0; // 2 bits per symbol, 1 MSPS
+  double ber = DqpskFunction (EbN0);
+  return pow ((1.0 - ber), nbits);
 }
 
 double 
 YansErrorRateModel::Get80211bDsssDqpskCck5_5SuccessRate (double sinr,uint32_t nbits) const
 {
 #ifdef ENABLE_GSL
- // symbol error probability
- double EbN0 = sinr * 22000000.0 / 1375000.0 / 4.0;
- double sep = SymbolErrorProb16Cck (4.0*EbN0/2.0);
- return pow (1.0-sep,nbits/4.0);
+  // symbol error probability
+  double EbN0 = sinr * 22000000.0 / 1375000.0 / 4.0;
+  double sep = SymbolErrorProb16Cck (4.0*EbN0/2.0);
+  return pow (1.0-sep,nbits/4.0);
 #else
- NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model"); 
- // The matlab model
- double ber; 
- if(sinr > WLAN_SIR_PERFECT)
-  ber = 0.0 ;
- else if(sinr < WLAN_SIR_IMPOSSIBLE)
-  ber = 0.5;
- else
- { // fitprops.coeff from matlab berfit
-  double a1 =  5.3681634344056195e-001;
-  double a2 =  3.3092430025608586e-003;
-  double a3 =  4.1654372361004000e-001;
-  double a4 =  1.0288981434358866e+000;
-  ber = a1 * exp (-(pow ((sinr-a2)/a3,a4)));
- }
- return pow ((1.0 - ber), nbits);
+  NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model"); 
+  // The matlab model
+  double ber; 
+  if(sinr > WLAN_SIR_PERFECT)
+    {
+       ber = 0.0 ;
+    }
+  else if(sinr < WLAN_SIR_IMPOSSIBLE)
+    {
+       ber = 0.5;
+    }
+  else
+    { // fitprops.coeff from matlab berfit
+       double a1 =  5.3681634344056195e-001;
+       double a2 =  3.3092430025608586e-003;
+       double a3 =  4.1654372361004000e-001;
+       double a4 =  1.0288981434358866e+000;
+       ber = a1 * exp (-(pow ((sinr-a2)/a3,a4)));
+     }
+  return pow ((1.0 - ber), nbits);
 #endif
 }
 
@@ -342,28 +346,32 @@
 {
 #ifdef ENABLE_GSL
  // symbol error probability
- double EbN0 = sinr * 22000000.0 / 1375000.0 / 8.0;
- double sep = SymbolErrorProb256Cck (8.0*EbN0/2.0);
- return pow (1.0-sep,nbits/8.0);
+  double EbN0 = sinr * 22000000.0 / 1375000.0 / 8.0;
+  double sep = SymbolErrorProb256Cck (8.0*EbN0/2.0);
+  return pow (1.0-sep,nbits/8.0);
 #else
- NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model"); 
- // The matlab model
- double ber; 
- if(sinr > WLAN_SIR_PERFECT)
-  ber = 0.0 ;
- else if(sinr < WLAN_SIR_IMPOSSIBLE)
-  ber = 0.5;
- else
- { // fitprops.coeff from matlab berfit
-  double a1 =  7.9056742265333456e-003;
-  double a2 = -1.8397449399176360e-001;
-  double a3 =  1.0740689468707241e+000;
-  double a4 =  1.0523316904502553e+000;
-  double a5 =  3.0552298746496687e-001;
-  double a6 =  2.2032715128698435e+000;
-  ber =  (a1*sinr*sinr+a2*sinr+a3)/(sinr*sinr*sinr+a4*sinr*sinr+a5*sinr+a6);
- }
- return pow ((1.0 - ber), nbits);
+  NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model"); 
+  // The matlab model
+  double ber; 
+  if (sinr > WLAN_SIR_PERFECT)
+    {
+       ber = 0.0 ;
+    }
+  else if (sinr < WLAN_SIR_IMPOSSIBLE)
+    {
+       ber = 0.5;
+    }
+  else
+    { // fitprops.coeff from matlab berfit
+       double a1 =  7.9056742265333456e-003;
+       double a2 = -1.8397449399176360e-001;
+       double a3 =  1.0740689468707241e+000;
+       double a4 =  1.0523316904502553e+000;
+       double a5 =  3.0552298746496687e-001;
+       double a6 =  2.2032715128698435e+000;
+       ber =  (a1*sinr*sinr+a2*sinr+a3)/(sinr*sinr*sinr+a4*sinr*sinr+a5*sinr+a6);
+     }
+  return pow ((1.0 - ber), nbits);
 #endif
 }
 
@@ -371,38 +379,42 @@
 double 
 IntegralFunction (double x, void *params)
 {
- double beta = ((FunctionParameters *) params)->beta;
- double n = ((FunctionParameters *) params)->n;
- double IntegralFunction = pow ( 2*gsl_cdf_ugaussian_P (x+ beta) - 1, n-1) * exp (-x*x/2.0) / sqrt (2.0 * M_PI);
- return IntegralFunction;
+  double beta = ((FunctionParameters *) params)->beta;
+  double n = ((FunctionParameters *) params)->n;
+  double IntegralFunction = pow ( 2*gsl_cdf_ugaussian_P (x+ beta) - 1, n-1) 
+                            * exp (-x*x/2.0) / sqrt (2.0 * M_PI);
+  return IntegralFunction;
 }
 
 double 
 YansErrorRateModel::SymbolErrorProb16Cck (double e2) const
 {
- double sep;
- double error;
+  double sep;
+  double error;
  
- FunctionParameters params;
- params.beta = sqrt (2.0*e2);
- params.n = 8.0;
+  FunctionParameters params;
+  params.beta = sqrt (2.0*e2);
+  params.n = 8.0;
 
- gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000); 
+  gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000); 
  
- gsl_function F;
- F.function = &IntegralFunction;
- F.params = &params;
+  gsl_function F;
+  F.function = &IntegralFunction;
+  F.params = &params;
 
- gsl_integration_qagiu(&F,-params.beta, 0, 1e-7, 1000, w, &sep, &error);
- gsl_integration_workspace_free (w);
- if (error == 0.0) sep = 1.0;
+  gsl_integration_qagiu(&F,-params.beta, 0, 1e-7, 1000, w, &sep, &error);
+  gsl_integration_workspace_free (w);
+  if (error == 0.0) 
+    {
+       sep = 1.0;
+    }
 
- return 1.0 - sep;
+  return 1.0 - sep;
 }
 
 double YansErrorRateModel::SymbolErrorProb256Cck (double e1) const
 {
- return 1.0 - pow( 1.0 - SymbolErrorProb16Cck (e1/2.0), 2.0);
+  return 1.0 - pow( 1.0 - SymbolErrorProb16Cck (e1/2.0), 2.0);
 }
 
 #endif