wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_roam_metrics.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class for storing roaming metrics.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 6 %
       
    20 */
       
    21 
       
    22 #include "core_roam_metrics.h"
       
    23 #include "core_am_tools.h"
       
    24 #include "core_tools.h"
       
    25 #include "am_debug.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 core_roam_metrics_c::core_roam_metrics_c() :
       
    33     roam_ts_userdata_disabled_m( 0 ),
       
    34     roam_ts_userdata_enabled_m( 0 ),
       
    35     roam_ts_connect_start_m( 0 ),
       
    36     roam_ts_connect_completed_m( 0 ),
       
    37     roam_success_count_m( 0 )
       
    38     {
       
    39     clear_metrics(); 
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 core_roam_metrics_c::~core_roam_metrics_c()
       
    46     {    
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void core_roam_metrics_c::clear_metrics()
       
    53     {
       
    54     roam_ts_userdata_disabled_m = 0;
       
    55     roam_ts_userdata_enabled_m = 0;
       
    56     roam_ts_connect_start_m = 0;
       
    57     roam_ts_connect_completed_m = 0;
       
    58     roam_success_count_m = 0;
       
    59 
       
    60     core_tools_c::fillz(
       
    61         &roam_attempt_count_m[0],
       
    62         sizeof ( roam_attempt_count_m ) );
       
    63     core_tools_c::fillz(
       
    64         &roam_attempt_failed_count_m[0],
       
    65         sizeof ( roam_attempt_failed_count_m ) );
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 u64_t core_roam_metrics_c::roam_ts_userdata_disabled() const
       
    72     {
       
    73     return roam_ts_userdata_disabled_m;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // ---------------------------------------------------------------------------
       
    78 //  
       
    79 void core_roam_metrics_c::set_roam_ts_userdata_disabled()
       
    80     {
       
    81     roam_ts_userdata_disabled_m = core_am_tools_c::timestamp();  
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 u64_t core_roam_metrics_c::roam_ts_userdata_enabled() const
       
    88     {
       
    89     return roam_ts_userdata_enabled_m;
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // ---------------------------------------------------------------------------
       
    94 //    
       
    95 void core_roam_metrics_c::set_roam_ts_userdata_enabled()
       
    96     {
       
    97     roam_ts_userdata_enabled_m = core_am_tools_c::timestamp();
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 u64_t core_roam_metrics_c::roam_ts_connect_started() const
       
   104     {
       
   105     return roam_ts_connect_start_m;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // ---------------------------------------------------------------------------
       
   110 //  
       
   111 void core_roam_metrics_c::set_roam_ts_connect_started()
       
   112     {
       
   113     roam_ts_connect_start_m = core_am_tools_c::timestamp();
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 u64_t core_roam_metrics_c::roam_ts_connect_completed() const
       
   120     {
       
   121     return roam_ts_connect_completed_m;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // ---------------------------------------------------------------------------
       
   126 // 
       
   127 void core_roam_metrics_c::set_roam_ts_connect_completed()
       
   128     {
       
   129     roam_ts_connect_completed_m = core_am_tools_c::timestamp();
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 u32_t core_roam_metrics_c::roam_total_delay() const
       
   136     {
       
   137     return static_cast<u64_t>( roam_ts_userdata_enabled_m - roam_ts_userdata_disabled_m );
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 u32_t core_roam_metrics_c::roam_connect_delay() const
       
   144     {
       
   145     return static_cast<u64_t>( roam_ts_connect_completed_m - roam_ts_connect_start_m );
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 u16_t core_roam_metrics_c::roam_success_count() const
       
   152     {
       
   153     return roam_success_count_m;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 void core_roam_metrics_c::inc_roam_success_count()
       
   160     {
       
   161     ++roam_success_count_m;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 u16_t core_roam_metrics_c::roam_attempt_count(
       
   168     core_roam_reason_e reason ) const
       
   169     {
       
   170     return roam_attempt_count_m[reason];
       
   171     }
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 void core_roam_metrics_c::inc_roam_attempt_count(
       
   177     core_roam_reason_e reason )
       
   178     {
       
   179     ++roam_attempt_count_m[reason];
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 u16_t core_roam_metrics_c::roam_attempt_failed_count(
       
   186     core_roam_failed_reason_e reason ) const
       
   187     {
       
   188     return roam_attempt_failed_count_m[reason];
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // ---------------------------------------------------------------------------
       
   193 //       
       
   194 void core_roam_metrics_c::inc_roam_attempt_failed_count(
       
   195     core_roam_failed_reason_e reason )
       
   196     {
       
   197     ++roam_attempt_failed_count_m[reason];
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 void core_roam_metrics_c::trace_current_roam_metrics() const
       
   204     {
       
   205 #ifdef _DEBUG
       
   206     DEBUG( "core_roam_metrics_c::next_state() - current roam metrics:" );
       
   207     DEBUG1( "core_roam_metrics_c::next_state() - last roam total delay in ms:                  %u",
       
   208     roam_total_delay() / MILLISECONDS_FROM_MICROSECONDS );
       
   209     DEBUG1( "core_roam_metrics_c::next_state() - last roam connect delay in ms:                %u",
       
   210         roam_connect_delay() / MILLISECONDS_FROM_MICROSECONDS );
       
   211     DEBUG1( "core_roam_metrics_c::next_state() - roam success count:                           %u",
       
   212         roam_success_count() );
       
   213 
       
   214     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to initial connect:         %u",
       
   215         roam_attempt_count( core_roam_reason_initial_connect ) );
       
   216     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to BSS lost:                %u",
       
   217         roam_attempt_count( core_roam_reason_bss_lost ) );
       
   218     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to media disconnect:        %u",
       
   219         roam_attempt_count( core_roam_reason_media_disconnect ) );
       
   220     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to signal strength:         %u",
       
   221         roam_attempt_count( core_roam_reason_signal_strength ) );
       
   222     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to signal prediction:       %u",
       
   223         roam_attempt_count( core_roam_reason_signal_loss_prediction ) );
       
   224     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to failed reauth:           %u",
       
   225         roam_attempt_count( core_roam_reason_failed_reauthentication ) );
       
   226     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts due to directed roam request:   %u",
       
   227         roam_attempt_count( core_roam_reason_directed_roam ) );
       
   228     
       
   229     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts failed due to timeout:          %u",
       
   230         roam_attempt_failed_count( core_roam_failed_reason_timeout ) );
       
   231     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts failed due to no suitable ap:   %u",
       
   232         roam_attempt_failed_count( core_roam_failed_reason_no_suitable_ap ) );
       
   233     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts failed due to AP's status code: %u",
       
   234         roam_attempt_failed_count( core_roam_failed_reason_ap_status_code ) );
       
   235     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts failed due to EAPOL failure:    %u",
       
   236         roam_attempt_failed_count( core_roam_failed_reason_eapol_failure ) );
       
   237     DEBUG1( "core_roam_metrics_c::next_state() - roam attempts failed due to other failure:    %u",
       
   238         roam_attempt_failed_count( core_roam_failed_reason_other_failure ) );
       
   239 #endif // _DEBUG    
       
   240     }