mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 12:40:28 +00:00
Compare commits
49 Commits
F1C_extens
...
pdcp-bench
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc9d7f1fdb | ||
|
|
d6fbe89101 | ||
|
|
c183c94277 | ||
|
|
371aa83fa9 | ||
|
|
822a8287fc | ||
|
|
975d6baf2c | ||
|
|
4dfe112549 | ||
|
|
8dca360b08 | ||
|
|
dd2189e5bc | ||
|
|
bdb258ce0b | ||
|
|
1f2aa635b7 | ||
|
|
66cb36521e | ||
|
|
c6247372a4 | ||
|
|
3ca43e5b4e | ||
|
|
386bc3388a | ||
|
|
3ac94d80f0 | ||
|
|
fa15d39152 | ||
|
|
ae1a5f3601 | ||
|
|
c9d75e47b0 | ||
|
|
02332b71a6 | ||
|
|
e46347d6b0 | ||
|
|
02ea5a6409 | ||
|
|
4ea07bd51e | ||
|
|
b023a39cc2 | ||
|
|
9e621d261d | ||
|
|
0c1865c16f | ||
|
|
824731acde | ||
|
|
8117747bc2 | ||
|
|
8ebb915814 | ||
|
|
bc8bc92317 | ||
|
|
2d44e7f54f | ||
|
|
cabbdb8e94 | ||
|
|
ee67fa18cd | ||
|
|
5592fa6aca | ||
|
|
339e0ab90e | ||
|
|
65aa1fc7ca | ||
|
|
0d76d77022 | ||
|
|
3cdf41ac2d | ||
|
|
f1453f9960 | ||
|
|
a6cf6c4a38 | ||
|
|
47da419f4e | ||
|
|
6bf88d883f | ||
|
|
3c522a8ec8 | ||
|
|
7cbcd373b7 | ||
|
|
d0f2d8bc84 | ||
|
|
cec898a640 | ||
|
|
e0eae4ad5f | ||
|
|
2bacc9134f | ||
|
|
30391362aa |
@@ -1697,8 +1697,7 @@ set(NR_RLC_SRC
|
||||
${OPENAIR2_DIR}/LAYER2/nr_rlc/nr_rlc_ue_manager.c
|
||||
)
|
||||
|
||||
set(L2_SRC
|
||||
${OPENAIR2_DIR}/LAYER2/openair2_proc.c
|
||||
set(PDCP_SRC
|
||||
${PDCP_DIR}/pdcp.c
|
||||
${PDCP_DIR}/pdcp_fifo.c
|
||||
${PDCP_DIR}/pdcp_sequence_manager.c
|
||||
@@ -1706,6 +1705,11 @@ set(L2_SRC
|
||||
${PDCP_DIR}/pdcp_util.c
|
||||
${PDCP_DIR}/pdcp_security.c
|
||||
${PDCP_DIR}/pdcp_netlink.c
|
||||
)
|
||||
|
||||
set(L2_SRC
|
||||
${OPENAIR2_DIR}/LAYER2/openair2_proc.c
|
||||
${PDCP_SRC}
|
||||
# ${RRC_DIR}/rrc_UE.c
|
||||
${RRC_DIR}/rrc_eNB.c
|
||||
${RRC_DIR}/rrc_eNB_endc.c
|
||||
@@ -2597,6 +2601,34 @@ target_link_libraries(du_test
|
||||
${PROTO_AGENT_LIB} pthread UTIL ${T_LIB} dl ${ITTI_LIB}
|
||||
)
|
||||
|
||||
add_executable(pdcp_benchmark
|
||||
${PDCP_DIR}/BENCHMARK/pdcp_benchmark.c
|
||||
${PDCP_SRC}
|
||||
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
|
||||
${OPENAIR2_DIR}/RRC/NAS/rb_config.c
|
||||
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
|
||||
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c
|
||||
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c
|
||||
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
|
||||
${OPENAIR_DIR}/common/utils/utils.c
|
||||
${OPENAIR_DIR}/common/utils/system.c
|
||||
${CONFIG_SOURCES}
|
||||
${T_SOURCE}
|
||||
)
|
||||
|
||||
target_link_libraries (pdcp_benchmark
|
||||
-Wl,--start-group
|
||||
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP
|
||||
LFDS LFDS7
|
||||
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
|
||||
-Wl,--end-group z dl)
|
||||
target_link_libraries (pdcp_benchmark ${LIBXML2_LIBRARIES})
|
||||
target_link_libraries (pdcp_benchmark pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
|
||||
target_link_libraries (pdcp_benchmark ${LIB_LMS_LIBRARIES})
|
||||
target_link_libraries (pdcp_benchmark ${T_LIB})
|
||||
|
||||
|
||||
|
||||
# lte-uesoftmodem is UE implementation
|
||||
#######################################
|
||||
|
||||
|
||||
@@ -697,7 +697,7 @@ function main() {
|
||||
if [ "$SIMUS_PHY" = "1" ] ; then
|
||||
echo_info "Compiling physical unitary tests simulators"
|
||||
# TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
|
||||
simlist="dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim"
|
||||
simlist="pdcp_benchmark dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim"
|
||||
for f in $simlist ; do
|
||||
compilations \
|
||||
phy_simulators $f \
|
||||
|
||||
10
cmake_targets/phy_simulators/build/run100times.sh
Executable file
10
cmake_targets/phy_simulators/build/run100times.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
res=0
|
||||
for i in {1..100}; do
|
||||
|
||||
restmp=$(./pdcp_benchmark | tail -1)
|
||||
res=$(($res+$restmp))
|
||||
echo $i
|
||||
done
|
||||
res=$(($res/100))
|
||||
echo "mean time:"
|
||||
echo $res
|
||||
221
openair2/LAYER2/PDCP_v10.1.0/BENCHMARK/pdcp_benchmark.c
Normal file
221
openair2/LAYER2/PDCP_v10.1.0/BENCHMARK/pdcp_benchmark.c
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* * 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.1 (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 pdcp_security.c
|
||||
* * \brief PDCP Performance Benchmark
|
||||
* * \author
|
||||
* * \email
|
||||
* * \date 2020
|
||||
* */
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "openair2/COMMON/platform_types.h"
|
||||
#include "common/config/config_load_configmodule.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
#include "openair2/UTIL/MEM/mem_block.h"
|
||||
#include "openair2/LAYER2/RLC/rlc.h"
|
||||
#include "openair2/LAYER2/PDCP_v10.1.0/pdcp.h"
|
||||
#include "openair2/LAYER2/PDCP_v10.1.0/pdcp_sequence_manager.h"
|
||||
#include "openair2/UTIL/OSA/osa_defs.h"
|
||||
|
||||
#include "common/config/config_load_configmodule.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "SIMULATION/TOOLS/sim.h"
|
||||
#include "UTIL/LISTS/list.h"
|
||||
#include "OCG_vars.h"
|
||||
|
||||
#include "common/config/config_userapi.h"
|
||||
|
||||
#include "LTE_RLC-Config.h"
|
||||
#include "LTE_DRB-ToAddMod.h"
|
||||
#include "LTE_DRB-ToAddModList.h"
|
||||
#include "LTE_SRB-ToAddMod.h"
|
||||
#include "LTE_SRB-ToAddModList.h"
|
||||
#include "LTE_DL-UM-RLC.h"
|
||||
#include "LTE_PMCH-InfoList-r9.h"
|
||||
|
||||
#include <time.h>
|
||||
//#include "time_meas.h"
|
||||
|
||||
//BUFFER 10
|
||||
/*
|
||||
#define DUMMY_BUFFER ((unsigned char*)"123456789")
|
||||
#define DUMMY_BUFFER_SIZE 10*/
|
||||
//BUFFER 50
|
||||
/*
|
||||
#define DUMMY_BUFFER ((unsigned char*)"1234567890123456789012345678901234567890123456789")
|
||||
#define DUMMY_BUFFER_SIZE 50*/
|
||||
//BUFFER 100
|
||||
|
||||
/*#define DUMMY_BUFFER ((unsigned char*)"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")
|
||||
#define DUMMY_BUFFER_SIZE 100
|
||||
*/
|
||||
|
||||
//BUFFER 1000
|
||||
|
||||
#define DUMMY_BUFFER ((unsigned char*)"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")
|
||||
#define DUMMY_BUFFER_SIZE 1000
|
||||
|
||||
|
||||
|
||||
#define NB_REPEAT 1
|
||||
|
||||
uint64_t get_softmodem_optmask(void) {return 0;}
|
||||
nfapi_mode_t nfapi_getmode(void) {return 0;}
|
||||
softmodem_params_t *get_softmodem_params(void) {return NULL;}
|
||||
|
||||
rlc_op_status_t rrc_rlc_config_req (
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t mbms_flagP,
|
||||
const config_action_t actionP,
|
||||
const rb_id_t rb_idP,
|
||||
const rlc_info_t rlc_infoP) {return 0;}
|
||||
|
||||
rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t *const ctxt_pP,
|
||||
const LTE_SRB_ToAddModList_t *const srb2add_listP,
|
||||
const LTE_DRB_ToAddModList_t *const drb2add_listP,
|
||||
const LTE_DRB_ToReleaseList_t *const drb2release_listP,
|
||||
const LTE_PMCH_InfoList_r9_t *const pmch_InfoList_r9_pP,
|
||||
const uint32_t sourceL2Id,
|
||||
const uint32_t destinationL2Id
|
||||
|
||||
) { return 0;}
|
||||
|
||||
|
||||
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
|
||||
const srb_flag_t srb_flagP,
|
||||
const MBMS_flag_t MBMS_flagP,
|
||||
const rb_id_t rb_idP,
|
||||
const mui_t muiP,
|
||||
confirm_t confirmP,
|
||||
sdu_size_t sdu_sizeP,
|
||||
mem_block_t *sdu_pP,
|
||||
const uint32_t *const sourceL2Id,
|
||||
const uint32_t *const destinationL2Id
|
||||
) {return 0;}
|
||||
|
||||
void
|
||||
rrc_data_ind(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
const rb_id_t Srb_id,
|
||||
const sdu_size_t sdu_sizeP,
|
||||
const uint8_t *const buffer_pP
|
||||
) {return;}
|
||||
|
||||
|
||||
void rlc_util_print_hex_octets(
|
||||
const comp_name_t componentP,
|
||||
unsigned char *const dataP,
|
||||
const signed long sizeP) {return;}
|
||||
|
||||
unsigned char NB_eNB_INST=1;
|
||||
uint16_t NB_UE_INST=1;
|
||||
int mbms_rab_id = 2047;
|
||||
int otg_enabled=0;
|
||||
int opp_enabled=0;
|
||||
pdcp_t pdcp_el;
|
||||
list_t pdu_tx_list;
|
||||
//Not sure at all about that, but I didn't knew which library I should include and I try with that.
|
||||
volatile int oai_exit=0;
|
||||
|
||||
//Same thing, but found it like that elsewhere
|
||||
void exit_function(const char *file, const char *function, const int line, const char *s) {
|
||||
}
|
||||
|
||||
#include "common/ran_context.h"
|
||||
RAN_CONTEXT_t RC;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// printf("1");
|
||||
/* int resQ;
|
||||
resQ=1;*/
|
||||
int ticks;
|
||||
/*if(argc < 2)
|
||||
{
|
||||
printf("You should pass the test you want as parameter");
|
||||
}
|
||||
resQ = atoi(argv[1]);
|
||||
*/pool_buffer_init();
|
||||
list_init(&pdu_tx_list, NULL);
|
||||
// printf("2");
|
||||
logInit();
|
||||
// printf("3");
|
||||
/*pdcp_el.next_pdcp_tx_sn = 0;
|
||||
pdcp_el.next_pdcp_rx_sn = 0;
|
||||
pdcp_el.tx_hfn = 0;
|
||||
pdcp_el.rx_hfn = 0;
|
||||
pdcp_el.last_submitted_pdcp_rx_sn = 4095;
|
||||
pdcp_el.seq_num_size = 12;
|
||||
pdcp_el.cipheringAlgorithm = (resQ==1?EEA1_128_ALG_ID:EEA2_128_ALG_ID);
|
||||
// printf("4");
|
||||
pdcp_init_seq_numbers(&pdcp_el);*/
|
||||
// printf("5");
|
||||
/*
|
||||
protocol_ctxt_t ctxt;
|
||||
ctxt.module_id = 0 ;
|
||||
ctxt.instance = 0;
|
||||
ctxt.rnti = 0;
|
||||
ctxt.enb_flag = 1;
|
||||
ctxt.frame = 0;
|
||||
ctxt.subframe = 0;*/
|
||||
|
||||
//Not working...???
|
||||
/*
|
||||
time_stats_t *t = malloc(sizeof(time_stats_t));
|
||||
reset_meas(t);
|
||||
start_meas(t);*/
|
||||
|
||||
clock_t t;
|
||||
t=clock();
|
||||
for(int i=0; i< NB_REPEAT; i++){
|
||||
|
||||
protocol_ctxt_t ctxt;
|
||||
ctxt.module_id = 0 ;
|
||||
ctxt.instance = 0;
|
||||
ctxt.rnti = 0;
|
||||
ctxt.enb_flag = 1;
|
||||
ctxt.frame = 0;
|
||||
ctxt.subframe = 0;
|
||||
pdcp_data_req(&ctxt, //ctxt_pP
|
||||
0, //srb_flagP
|
||||
3, // rb_id
|
||||
0, // muiP
|
||||
0, //confirmP
|
||||
DUMMY_BUFFER_SIZE, //sdu_buffer_size
|
||||
DUMMY_BUFFER, // sdu_buffer
|
||||
PDCP_TRANSMISSION_MODE_DATA, // pdcp_transmission_mod
|
||||
0,0);
|
||||
}
|
||||
t=clock()-t;
|
||||
// srand(time(0));
|
||||
|
||||
/*stop_meas(t);
|
||||
ticks = (int) (t->diff/NB_REPEAT);
|
||||
printf("Average time : %d\n", ticks);*/
|
||||
printf("%d \n",(int)t);
|
||||
|
||||
|
||||
}
|
||||
@@ -133,7 +133,7 @@ boolean_t pdcp_data_req(
|
||||
T(T_ENB_PDCP_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP));
|
||||
|
||||
#endif
|
||||
|
||||
// printf("I'm here !\n");
|
||||
if (sdu_buffer_sizeP == 0) {
|
||||
LOG_W(PDCP, "Handed SDU is of size 0! Ignoring...\n");
|
||||
return FALSE;
|
||||
@@ -144,7 +144,7 @@ boolean_t pdcp_data_req(
|
||||
*/
|
||||
AssertFatal(sdu_buffer_sizeP<= MAX_IP_PACKET_SIZE,"Requested SDU size (%d) is bigger than that can be handled by PDCP (%u)!\n",
|
||||
sdu_buffer_sizeP, MAX_IP_PACKET_SIZE);
|
||||
|
||||
//printf("line 147 ok\n");
|
||||
if (modeP == PDCP_TRANSMISSION_MODE_TRANSPARENT) {
|
||||
AssertError (rb_idP < NB_RB_MBMS_MAX, return FALSE, "RB id is too high (%ld/%d) %u %u!\n", rb_idP, NB_RB_MBMS_MAX, ctxt_pP->module_id, ctxt_pP->rnti);
|
||||
} else {
|
||||
@@ -154,16 +154,17 @@ boolean_t pdcp_data_req(
|
||||
AssertError (rb_idP < LTE_maxDRB, return FALSE, "RB id is too high (%ld/%d) %u %u!\n", rb_idP, LTE_maxDRB, ctxt_pP->module_id, ctxt_pP->rnti);
|
||||
}
|
||||
}
|
||||
|
||||
//printf("line 157 ok\n");
|
||||
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
|
||||
h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
|
||||
|
||||
if (h_rc != HASH_TABLE_OK) {
|
||||
//MODIFIED BELOW TO TRY--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
if (0){//h_rc != HASH_TABLE_OK) {
|
||||
if (modeP != PDCP_TRANSMISSION_MODE_TRANSPARENT) {
|
||||
LOG_W(PDCP, PROTOCOL_CTXT_FMT" Instance is not configured for rb_id %ld Ignoring SDU...\n",
|
||||
PROTOCOL_CTXT_ARGS(ctxt_pP),
|
||||
rb_idP);
|
||||
ctxt_pP->configured=FALSE;
|
||||
printf("ret false l 167 \n");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
@@ -176,7 +177,7 @@ boolean_t pdcp_data_req(
|
||||
} else {
|
||||
start_meas(&UE_pdcp_stats[ctxt_pP->module_id].data_req);
|
||||
}
|
||||
|
||||
//printf("line 179 ok \n");
|
||||
// PDCP transparent mode for MBMS traffic
|
||||
|
||||
if (modeP == PDCP_TRANSMISSION_MODE_TRANSPARENT) {
|
||||
@@ -209,7 +210,7 @@ boolean_t pdcp_data_req(
|
||||
pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE;
|
||||
pdcp_tailer_len = 0;
|
||||
}
|
||||
|
||||
// printf("line 212 ok\n");
|
||||
pdcp_pdu_size = sdu_buffer_sizeP + pdcp_header_len + pdcp_tailer_len;
|
||||
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT"Data request notification pdu size %d (header%d, trailer%d)\n",
|
||||
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
|
||||
@@ -271,6 +272,9 @@ boolean_t pdcp_data_req(
|
||||
/*
|
||||
* Validate incoming sequence number, there might be a problem with PDCP initialization
|
||||
*/
|
||||
// printf("line 273 ok\n");
|
||||
//BELOW COMMENTED FOR TEST ##################################################################################################################
|
||||
/*
|
||||
if (current_sn > pdcp_calculate_max_seq_num_for_given_size(pdcp_p->seq_num_size)) {
|
||||
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" Generated sequence number (%"PRIu16") is greater than a sequence number could ever be!\n"\
|
||||
"There must be a problem with PDCP initialization, ignoring this PDU...\n",
|
||||
@@ -287,7 +291,7 @@ boolean_t pdcp_data_req(
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*/// printf("line 292 ok\n");
|
||||
LOG_D(PDCP, "Sequence number %d is assigned to current PDU\n", current_sn);
|
||||
/* Then append data... */
|
||||
memcpy(&pdcp_pdu_p->data[pdcp_header_len], sdu_buffer_pP, sdu_buffer_sizeP);
|
||||
@@ -298,16 +302,66 @@ boolean_t pdcp_data_req(
|
||||
for (i=0; i<pdcp_tailer_len; i++) {
|
||||
pdcp_pdu_p->data[pdcp_header_len + sdu_buffer_sizeP + i] = 0x00;// pdu_header.mac_i[i];
|
||||
}
|
||||
// printf("Just before the if \n");
|
||||
//BELOW COMMENTED FOR TEST ##################################################################################################################
|
||||
/*
|
||||
|
||||
if ((pdcp_p->security_activated != 0) &&
|
||||
if ((pdcp_p->security_activated != 0) &&
|
||||
(((pdcp_p->cipheringAlgorithm) != 0) ||
|
||||
((pdcp_p->integrityProtAlgorithm) != 0))) {
|
||||
if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
|
||||
*/ //BELOW COMMENTED FOR TEST ##################################################################################################################
|
||||
/*if (ctxt_pP->enb_flag == ENB_FLAG_YES) {
|
||||
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security);
|
||||
} else {
|
||||
start_meas(&UE_pdcp_stats[ctxt_pP->module_id].apply_security);
|
||||
}
|
||||
*/
|
||||
pdcp_p= (pdcp_t*)malloc(sizeof(pdcp_t*));
|
||||
|
||||
pdcp_p->next_pdcp_tx_sn = 0;
|
||||
pdcp_p->next_pdcp_rx_sn = 0;
|
||||
pdcp_p->tx_hfn = 0;
|
||||
pdcp_p->rx_hfn = 0;
|
||||
pdcp_p->last_submitted_pdcp_rx_sn = 4095;
|
||||
pdcp_p->seq_num_size = 12;
|
||||
//ALGORITHM 1 CHOICE :
|
||||
pdcp_p->cipheringAlgorithm = EEA1_128_ALG_ID;
|
||||
|
||||
//ALGORITHM 2 CHOICE :
|
||||
//pdcp_p->cipheringAlgorithm = EEA2_128_ALG_ID;
|
||||
//tried to understand where to obtain the Kupenc key in code without success, only understood that it comes from kenb key and also that's it the one we need since our srb_flagP is 3
|
||||
//Also we give it a value thanks to osa_stream_eea.c
|
||||
/*
|
||||
|
||||
memcpy(K+3,stream_cipher->key+0,4); /*K[3] = key[0]; we assume
|
||||
K[3]=key[0]||key[1]||...||key[31] , with key[0] the
|
||||
* most important bit of key*//*
|
||||
memcpy(K+2,stream_cipher->key+4,4); /*K[2] = key[1];*//*
|
||||
memcpy(K+1,stream_cipher->key+8,4); /*K[1] = key[2];*//*
|
||||
memcpy(K+0,stream_cipher->key+12,4); /*K[0] = key[3]; we assume
|
||||
K[0]=key[96]||key[97]||...||key[127] , with key[127] the
|
||||
* least important bit of key*//*
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
uint8_t *keyTest;
|
||||
keyTest=(uint8_t*)malloc(128*sizeof(uint8_t));*/
|
||||
uint8_t keyTest[128];
|
||||
for( int i =0; i<128; i++)
|
||||
{
|
||||
keyTest[i]=2*i;
|
||||
}
|
||||
pdcp_p->kUPenc=keyTest;
|
||||
|
||||
//printf("4\n");
|
||||
pdcp_init_seq_numbers(pdcp_p);
|
||||
//printf("4bis\n");
|
||||
|
||||
|
||||
// printf("apply sec fct\n");
|
||||
pdcp_apply_security(ctxt_pP,
|
||||
pdcp_p,
|
||||
srb_flagP,
|
||||
@@ -317,13 +371,16 @@ boolean_t pdcp_data_req(
|
||||
pdcp_pdu_p->data,
|
||||
sdu_buffer_sizeP);
|
||||
|
||||
if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
|
||||
//BELOW COMMENTED FOR TEST ##################################################################################################################
|
||||
/*if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
|
||||
stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].apply_security);
|
||||
} else {
|
||||
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].apply_security);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
//}
|
||||
|
||||
//We jump over everything next
|
||||
return TRUE;
|
||||
/* Print octets of outgoing data in hexadecimal form */
|
||||
LOG_D(PDCP, "Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)\n",
|
||||
pdcp_pdu_size);
|
||||
|
||||
@@ -147,7 +147,7 @@ pdcp_apply_security(
|
||||
} else {
|
||||
LOG_D(PDCP, "[OSA][RB %ld] %s Applying user-plane security\n",
|
||||
rb_id, (pdcp_pP->is_ue != 0) ? "UE -> eNB" : "eNB -> UE");
|
||||
|
||||
//printf("line 150 pdcp_security\n");
|
||||
encrypt_params.key = pdcp_pP->kUPenc;// + 128;
|
||||
}
|
||||
|
||||
@@ -157,12 +157,13 @@ pdcp_apply_security(
|
||||
buffer_encrypted = &pdcp_pdu_buffer[pdcp_header_len];
|
||||
|
||||
/* Apply ciphering if any requested */
|
||||
stream_encrypt(pdcp_pP->cipheringAlgorithm,
|
||||
//printf("l160 pdcp_security.c\n");
|
||||
stream_encrypt(pdcp_pP->cipheringAlgorithm,
|
||||
&encrypt_params,
|
||||
&buffer_encrypted);
|
||||
|
||||
//printf("l163 pdcp_security.c\n");
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_APPLY_SECURITY, VCD_FUNCTION_OUT);
|
||||
|
||||
//printf("l165 before return pdcp_security.c\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,14 +77,15 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
DevAssert(stream_cipher->key != NULL);
|
||||
DevAssert(stream_cipher->key_length == 16);
|
||||
DevAssert(out != NULL);
|
||||
|
||||
//printf("stream encrypt eea1 (osa stream eea l80\n");
|
||||
n = ( stream_cipher->blength + 31 ) / 32;
|
||||
zero_bit = stream_cipher->blength & 0x7;
|
||||
|
||||
//printf("osa stream eea l82\n");
|
||||
memset(&snow_3g_context, 0, sizeof(snow_3g_context));
|
||||
/*Initialisation*/
|
||||
/* Load the confidentiality key for SNOW 3G initialization as in section
|
||||
3.4. */
|
||||
//printf("osa stream eea l88\n");
|
||||
memcpy(K+3,stream_cipher->key+0,4); /*K[3] = key[0]; we assume
|
||||
K[3]=key[0]||key[1]||...||key[31] , with key[0] the
|
||||
* most important bit of key*/
|
||||
@@ -93,6 +94,7 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
memcpy(K+0,stream_cipher->key+12,4); /*K[0] = key[3]; we assume
|
||||
K[0]=key[96]||key[97]||...||key[127] , with key[127] the
|
||||
* least important bit of key*/
|
||||
//printf("osa stream eea l97\n");
|
||||
K[3] = hton_int32(K[3]);
|
||||
K[2] = hton_int32(K[2]);
|
||||
K[1] = hton_int32(K[1]);
|
||||
@@ -103,12 +105,12 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
IV[2] = ((((uint32_t)stream_cipher->bearer) << 3) | ((((uint32_t)stream_cipher->direction) & 0x1) << 2)) << 24;
|
||||
IV[1] = IV[3];
|
||||
IV[0] = IV[2];
|
||||
|
||||
//printf("osa stream eea l106\n");
|
||||
/* Run SNOW 3G algorithm to generate sequence of key stream bits KS*/
|
||||
osa_snow3g_initialize(K, IV, &snow_3g_context);
|
||||
KS = (uint32_t *)malloc(4*n);
|
||||
osa_snow3g_generate_key_stream(n,(uint32_t*)KS, &snow_3g_context);
|
||||
|
||||
//printf("osa stream eea l113\n");
|
||||
if (zero_bit > 0) {
|
||||
|
||||
KS[n - 1] = KS[n - 1] & (uint32_t)(0xFFFFFFFF << (8 - zero_bit));
|
||||
@@ -117,7 +119,7 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
for (i=0; i<n; i++) {
|
||||
KS[i] = hton_int32(KS[i]);
|
||||
}
|
||||
|
||||
//printf("osa stream eea l122\n");
|
||||
/* Exclusive-OR the input data with keystream to generate the output bit
|
||||
stream */
|
||||
for (i=0; i<n*4; i++) {
|
||||
@@ -128,9 +130,12 @@ int stream_encrypt_eea1(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
int ceil_index = (stream_cipher->blength+7) >> 3;
|
||||
stream_cipher->message[ceil_index - 1] = stream_cipher->message[ceil_index - 1] & (uint8_t)(0xFF << (8 - zero_bit));
|
||||
}
|
||||
|
||||
//printf("osa stream eea l133\n");
|
||||
free(KS);
|
||||
*out = stream_cipher->message;
|
||||
*out = stream_cipher->message;
|
||||
|
||||
|
||||
//printf("osa stream eea l136\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -147,7 +152,7 @@ int stream_encrypt_eea2(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
|
||||
DevAssert(stream_cipher != NULL);
|
||||
DevAssert(out != NULL);
|
||||
|
||||
printf("stream encrypt eea2 (osa stream eea l150\n");
|
||||
LOG_D(OSA, "Entering stream_encrypt_eea2, bits length %u, bearer %u, "
|
||||
"count %u, direction %s\n", stream_cipher->blength,
|
||||
stream_cipher->bearer, stream_cipher->count, stream_cipher->direction == SECU_DIRECTION_DOWNLINK ?
|
||||
@@ -226,10 +231,16 @@ int stream_encrypt_eea2(stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
|
||||
int stream_encrypt(uint8_t algorithm, stream_cipher_t *stream_cipher, uint8_t **out)
|
||||
{
|
||||
if (algorithm == EEA0_ALG_ID) {
|
||||
//printf("l232 eea file\n");
|
||||
if (algorithm == EEA0_ALG_ID) {
|
||||
return stream_encrypt_eea0(stream_cipher, out);
|
||||
} else if (algorithm == EEA1_128_ALG_ID) {
|
||||
return stream_encrypt_eea1(stream_cipher, out);
|
||||
|
||||
//printf("before stream encrypt\n");
|
||||
int res= stream_encrypt_eea1(stream_cipher, out);
|
||||
|
||||
//printf("after stream encrypt res=%d \n",res);
|
||||
return res;
|
||||
} else if (algorithm == EEA2_128_ALG_ID) {
|
||||
return stream_encrypt_eea2(stream_cipher, out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user