flexran_agent_pdcp.c 5.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */ 

/*! \file flexran_agent_pdcp.c
 * \brief FlexRAN agent Control Module PDCP 
24
 * \author Navid Nikaein and shahab SHARIAT BAGHERI
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 * \date 2017
 * \version 0.1
 */

#include "flexran_agent_pdcp.h"


/*Trigger boolean for PDCP measurement*/
bool triggered_pdcp = false;
/*Flags showing if a pdcp agent has already been registered*/
unsigned int pdcp_agent_registered[NUM_MAX_ENB];

/*Array containing the Agent-PDCP interfaces*/
AGENT_PDCP_xface *agent_pdcp_xface[NUM_MAX_ENB];

// NUMBER_OF_UE_MAX

void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id,
					const mid_t ue_id,
					Protocol__FlexPdcpStats *pdcp_aggr_stats){

  int lcid=0;
  /* only calculate the DRBs */ 
  //LOG_I(FLEXRAN_AGENT, "enb %d ue %d \n", mod_id, ue_id);
  
  for (lcid=NUM_MAX_SRB ; lcid < NUM_MAX_SRB + NUM_MAX_DRB; lcid++){
    
    pdcp_aggr_stats->pkt_tx += flexran_get_pdcp_tx(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_tx_bytes += flexran_get_pdcp_tx_bytes(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_tx_rate_s += flexran_get_pdcp_tx_rate_s(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_tx_throughput_s += flexran_get_pdcp_tx_throughput_s(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_tx_aiat += flexran_get_pdcp_tx_aiat(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_tx_aiat_s += flexran_get_pdcp_tx_aiat_s(mod_id,ue_id,lcid);
    
      
    pdcp_aggr_stats->pkt_rx += flexran_get_pdcp_rx(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_rx_bytes += flexran_get_pdcp_rx_bytes(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_rx_rate_s += flexran_get_pdcp_rx_rate_s(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_rx_goodput_s += flexran_get_pdcp_rx_goodput_s(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_rx_aiat += flexran_get_pdcp_rx_aiat(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_rx_aiat_s += flexran_get_pdcp_rx_aiat_s(mod_id,ue_id,lcid);
    pdcp_aggr_stats->pkt_rx_oo += flexran_get_pdcp_rx_oo(mod_id,ue_id,lcid);
    
  }
  
}


int flexran_agent_pdcp_stats_reply(mid_t mod_id,       
				   const report_config_t *report_config,
				   Protocol__FlexUeStatsReport **ue_report,
				   Protocol__FlexCellStatsReport **cell_report) {
  
  
  // Protocol__FlexHeader *header;
shahab's avatar
shahab committed
80
  int i;
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
  // int cc_id = 0;
 
  
  /* Allocate memory for list of UE reports */
  if (report_config->nr_ue > 0) {
    
    for (i = 0; i < report_config->nr_ue; i++) {

      /* Check flag for creation of buffer status report */
      if (report_config->ue_report_type[i].ue_report_flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_PDCP_STATS) {
	
	Protocol__FlexPdcpStats *pdcp_aggr_stats;
	pdcp_aggr_stats = malloc(sizeof(Protocol__FlexPdcpStats));
	if (pdcp_aggr_stats == NULL)
	  goto error;
	protocol__flex_pdcp_stats__init(pdcp_aggr_stats);
	
	flexran_agent_pdcp_aggregate_stats(mod_id, i, pdcp_aggr_stats);

	pdcp_aggr_stats->has_pkt_tx=1;
	pdcp_aggr_stats->has_pkt_tx_bytes =1;
	pdcp_aggr_stats->has_pkt_tx_rate_s=1; 
	pdcp_aggr_stats->has_pkt_tx_throughput_s =1;
	pdcp_aggr_stats->has_pkt_tx_aiat =1; 
	pdcp_aggr_stats->has_pkt_tx_aiat_s =1;

	pdcp_aggr_stats->pkt_tx_sn = flexran_get_pdcp_tx_sn(mod_id, i, DEFAULT_DRB);
	pdcp_aggr_stats->has_pkt_tx_sn =1;
	
	pdcp_aggr_stats->has_pkt_rx =1;
	pdcp_aggr_stats->has_pkt_rx_bytes =1; 
	pdcp_aggr_stats->has_pkt_rx_rate_s =1;
	pdcp_aggr_stats->has_pkt_rx_goodput_s =1;
	pdcp_aggr_stats->has_pkt_rx_aiat =1;
	pdcp_aggr_stats->has_pkt_rx_aiat_s =1;
	pdcp_aggr_stats->has_pkt_rx_oo =1;

	pdcp_aggr_stats->pkt_rx_sn = flexran_get_pdcp_rx_sn(mod_id, i, DEFAULT_DRB);
	pdcp_aggr_stats->has_pkt_rx_sn =1;

121
122
123
	pdcp_aggr_stats->sfn = flexran_get_pdcp_sfn(mod_id);
	pdcp_aggr_stats->has_sfn =1;

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
	ue_report[i]->pdcp_stats = pdcp_aggr_stats;

      }
    }
  }  else {
    LOG_D(FLEXRAN_AGENT, "no UE\n");
  }     
  
  return 0;
  
 error:
  LOG_W(FLEXRAN_AGENT, "Can't allocate PDCP stats\n");
  
  /* if (cell_report != NULL)
        free(cell_report);
  if (ue_report != NULL)
        free(ue_report);
  */
  return -1;
}



int flexran_agent_register_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) {
  if (pdcp_agent_registered[mod_id]) {
    LOG_E(PDCP, "PDCP agent for eNB %d is already registered\n", mod_id);
    return -1;
  }

  //xface->flexran_pdcp_stats_measurement = NULL;

  pdcp_agent_registered[mod_id] = 1;
  agent_pdcp_xface[mod_id] = xface;

  return 0;
}

int flexran_agent_unregister_pdcp_xface(mid_t mod_id, AGENT_PDCP_xface *xface) {

  //xface->agent_ctxt = NULL;
  //xface->flexran_pdcp_stats_measurement = NULL;

  
  pdcp_agent_registered[mod_id] = 0;
  agent_pdcp_xface[mod_id] = NULL;

  return 0;
}