diff options
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/include/openbsc/gsm_data.h | 8 | ||||
-rw-r--r-- | openbsc/src/libbsc/net_init.c | 1 | ||||
-rw-r--r-- | openbsc/src/libmsc/gsm_04_08.c | 34 |
3 files changed, 42 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 5829c8d11..70c08c326 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -215,6 +215,9 @@ enum { MSC_CTR_CALL_MO_CONNECT_ACK, MSC_CTR_CALL_MT_SETUP, MSC_CTR_CALL_MT_CONNECT, + MSC_CTR_CALL_ACTIVE, + MSC_CTR_CALL_COMPLETE, + MSC_CTR_CALL_INCOMPLETE, }; static const struct rate_ctr_desc msc_ctr_description[] = { @@ -235,6 +238,9 @@ static const struct rate_ctr_desc msc_ctr_description[] = { [MSC_CTR_CALL_MO_CONNECT_ACK] = {"call.mo_connect_ack", "Received a connect ack from MS of a MO call. Call is now succesful connected up."}, [MSC_CTR_CALL_MT_SETUP] = {"call.mt_setup", "Sent setup requests to the MS (MT)."}, [MSC_CTR_CALL_MT_CONNECT] = {"call.mt_connect", "Sent a connect to the MS (MT)."}, + [MSC_CTR_CALL_ACTIVE] = {"call.active", "Count total amount of calls that ever reached active state."}, + [MSC_CTR_CALL_COMPLETE] = {"call.complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."}, + [MSC_CTR_CALL_INCOMPLETE] = {"call.incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."}, }; @@ -298,7 +304,7 @@ struct gsm_network { struct rate_ctr_group *bsc_ctrs; struct rate_ctr_group *msc_ctrs; - + struct osmo_counter *active_calls; /* layer 4 */ struct mncc_sock_state *mncc_state; diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c index e53b4662f..57e359909 100644 --- a/openbsc/src/libbsc/net_init.c +++ b/openbsc/src/libbsc/net_init.c @@ -86,6 +86,7 @@ struct gsm_network *gsm_network_init(void *ctx, /* init statistics */ net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0); net->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, 0); + net->active_calls = osmo_counter_alloc("msc.active_calls"); net->mncc_recv = mncc_recv; net->ext_min = GSM_MIN_EXTEN; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index aa3d78a9b..be1b26045 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1299,6 +1299,39 @@ int gsm48_send_rr_app_info(struct gsm_subscriber_connection *conn, uint8_t apdu_ return gsm48_conn_sendmsg(msg, conn, NULL); } +/* FIXME: this count_statistics is a state machine behaviour. we should convert + * the complete call control into a state machine. Afterwards we can move this + * code into state transitions. + */ +static void count_statistics(struct gsm_trans *trans, int new_state) +{ + int old_state = trans->cc.state; + struct rate_ctr_group *msc = trans->net->msc_ctrs; + + if (old_state == new_state) + return; + + /* state incoming */ + switch (new_state) { + case GSM_CSTATE_ACTIVE: + osmo_counter_inc(trans->net->active_calls); + rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_ACTIVE]); + break; + } + + /* state outgoing */ + switch (old_state) { + case GSM_CSTATE_ACTIVE: + osmo_counter_dec(trans->net->active_calls); + if (new_state == GSM_CSTATE_DISCONNECT_REQ || + new_state == GSM_CSTATE_DISCONNECT_IND) + rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_COMPLETE]); + else + rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_INCOMPLETE]); + break; + } +} + /* Call Control */ /* The entire call control code is written in accordance with Figure 7.10c @@ -1315,6 +1348,7 @@ static void new_cc_state(struct gsm_trans *trans, int state) gsm48_cc_state_name(trans->cc.state), gsm48_cc_state_name(state)); + count_statistics(trans, state); trans->cc.state = state; } |