Commit e66f7865 authored by Navid Nikaein's avatar Navid Nikaein

* Wireshark support for MAC/RLC/PDCP/RRC of lte-softmodem (option -W, and -P [file])


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6930 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent d0b47397
......@@ -405,15 +405,14 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,un
&eNB->common_channels[CC_id].CCCH_pdu.payload[0],
rrc_sdu_length);
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled){
trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0],
rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id),
eNB->subframe,0,0);
LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
module_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length);
if (opt_enabled==1){
trace_pdu(1, (uint8_t *)eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0],
rrc_sdu_length, UE_id, 3, UE_RNTI(module_idP, UE_id),
eNB->subframe,0,0);
LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
module_idP, frameP, UE_RNTI(module_idP,UE_id), rrc_sdu_length);
}
#endif
nprb[CC_id]= nprb[CC_id] + 3;
nCCE[CC_id] = nCCE[CC_id] + 4;
}
......
......@@ -148,8 +148,7 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi
}
}
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled) {
if (opt_enabled == 1) {
trace_pdu(1,
&eNB->common_channels[CC_id].BCCH_pdu.payload[0],
bcch_sdu_length,
......@@ -159,11 +158,10 @@ void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned int *nprbP,unsi
eNB->subframe,
0,
0);
}
LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n",
LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n",
module_idP, frameP, 0xffff, bcch_sdu_length);
#endif
}
if (PHY_vars_eNB_g[module_idP][CC_id]->lte_frame_parms.frame_type == TDD) {
LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n",
frameP,
......
......@@ -991,16 +991,15 @@ void schedule_ue_spec(module_id_t module_idP,
UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff);
//eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff);
#if defined(USER_MODE) && defined(OAI_EMU)
/* Tracing of PDU is done on UE side */
if (oai_emulation.info.opt_enabled)
if (opt_enabled == 1){
trace_pdu(1, (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
TBS, module_idP, 3, UE_RNTI(module_idP,UE_id),
eNB->subframe,0,0);
LOG_D(OPT,"[eNB %d][DLSCH] Frame %d rnti %x with size %d\n",
module_idP, frameP, UE_RNTI(module_idP,UE_id), TBS);
#endif
LOG_D(OPT,"[eNB %d][DLSCH] Frame %d rnti %x with size %d\n",
module_idP, frameP, UE_RNTI(module_idP,UE_id), TBS);
}
aggregation = process_ue_cqi(module_idP,UE_id);
nCCE[CC_id]-=(1<<aggregation); // adjust the remaining nCCE
nCCE_used[CC_id]+=(1<<aggregation); // adjust the remaining nCCE
......
......@@ -534,15 +534,14 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra
for (j=0;j<(TBS-sdu_length_total-offset);j++)
eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
#if defined(USER_MODE) && defined(OAI_EMU)
/* Tracing of PDU is done on UE side */
if (oai_emulation.info.opt_enabled)
if (opt_enabled ==1 ){
trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].common_channels[CC_id].MCH_pdu.payload,
TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark
eNB_mac_inst[module_idP].subframe,0,0);
LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n",
module_idP, frameP, TBS);
#endif
TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark
eNB_mac_inst[module_idP].subframe,0,0);
LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n",
module_idP, frameP, TBS);
}
/*
for (j=0;j<sdu_length_total;j++)
printf("%2x.",eNB_mac_inst[module_idP].MCH_pdu.payload[j+offset]);
......
......@@ -211,14 +211,13 @@ void Msg1_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id
// start contention resolution timer
UE_mac_inst[module_idP].RA_attempt_number++;
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled) {
if (opt_enabled == 1) {
trace_pdu(0, NULL, 0, module_idP, 3, UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex,
UE_mac_inst[module_idP].subframe, 0, UE_mac_inst[module_idP].RA_attempt_number);
LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n",
module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size);
}
#endif
}
......@@ -235,14 +234,14 @@ void Msg3_tx(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id
UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0;
UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled) { // msg3
trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size,
module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0);
LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n",
module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size);
// msg3
if (opt_enabled == 1 ) {
trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size,
module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0);
LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n",
module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size);
}
#endif
}
......
......@@ -118,15 +118,14 @@ unsigned short fill_rar(module_id_t module_idP,
rarh->RAPID,eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[0].preamble_index,
eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].timing_offset);
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled){
trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1,
eNB_mac_inst[module_idP].subframe, 0, 0);
LOG_I(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n",
if (opt_enabled == 1){
trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1,
eNB_mac_inst[module_idP].subframe, 0, 0);
LOG_D(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n",
module_idP, frameP, eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti,
rarh->RAPID, input_buffer_length);
}
#endif
}
return(eNB_mac_inst[module_idP].common_channels[CC_id].RA_template[ra_idx].rnti);
}
......
......@@ -293,12 +293,10 @@ void ue_send_sdu(module_id_t module_idP, uint8_t CC_id,frame_t frameP,uint8_t *s
LOG_T(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]);
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled) {
trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti,
UE_mac_inst[module_idP].subframe, 0, 0);
if (opt_enabled == 1) {
trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti,
UE_mac_inst[module_idP].subframe, 0, 0);
}
#endif
payload_ptr = parse_header(sdu,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_len);
......@@ -1298,12 +1296,12 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
for (j=0;j<(buflen-sdu_length_total-payload_offset);j++)
ulsch_buffer[payload_offset+sdu_length_total+j] = (char)(taus()&0xff);
#if defined(USER_MODE) && defined(OAI_EMU)
if (oai_emulation.info.opt_enabled)
if (opt_enabled==1){
trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, subframe, 0, 0);
LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x with size %d\n",
LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x with size %d\n",
module_idP, frameP, UE_mac_inst[module_idP].crnti, buflen);
#endif
}
LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n",
module_idP,payload_offset, sdu_length_total);
......
......@@ -77,6 +77,8 @@ typedef enum radio_type_e {
} radio_type_t;
extern trace_mode_t opt_type;
extern char in_ip[40];
extern char in_path[100];
/**
* function def
......@@ -90,6 +92,7 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p);
void terminate_opt(void);
extern int opt_enabled;
//double *timing_analyzer(int index, int direction );
#endif /* OPT_H_ */
......@@ -123,6 +123,8 @@ what about the implementation
#include "opt.h"
int opt_enabled=0;
#define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
typedef uint8_t guint8;
......@@ -139,8 +141,8 @@ static unsigned char g_frameBuffer[1600];
//static unsigned char g_fileBuffer[1600];
static unsigned int g_frameOffset;
static char in_ip[40];
static char in_path[100];
char in_ip[40];
char in_path[100];
static uint16_t in_port;
FILE *file_fd = NULL;
......@@ -501,7 +503,7 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p)
strncpy( in_path, path, sizeof(in_path) );
in_path[sizeof(in_path) - 1] = 0; // terminate string
} else {
strcpy( in_path, "oai_opt.pcap" );
strcpy( in_path, "/tmp/oai_opt.pcap" );
}
if (ip != NULL) {
strncpy( in_ip, ip, sizeof(in_ip) );
......@@ -553,9 +555,13 @@ int init_opt(char *path, char *ip, char *port, radio_type_t radio_type_p)
opt_type = OPT_NONE;
break;
}
LOG_D(OPT,"mode %s init ip %s port %u path %s\n",
(opt_type == OPT_WIRESHARK)? "wireshark" : "pcap", in_ip, in_port, in_path);
if ( opt_type == OPT_WIRESHARK )
LOG_G(OPT,"mode Wireshark: ip %s port %d\n", in_ip, in_port);
else if (opt_type == OPT_PCAP)
LOG_G(OPT,"mode PCAB : path is %s \n",in_path);
else
LOG_G(OPT,"Unsupported or unknown mode %d \n", opt_type);
// mac_info = (mac_info*)malloc16(sizeof(mac_lte_info));
// memset(mac_info, 0, sizeof(mac_lte_info)+pdu_buffer_size + 8);
return (1);
......
......@@ -335,6 +335,9 @@ int16_t pdcp_log_level = LOG_INFO;
int16_t pdcp_log_verbosity = LOG_MED;
int16_t rrc_log_level = LOG_INFO;
int16_t rrc_log_verbosity = LOG_MED;
int16_t opt_log_level = LOG_INFO;
int16_t opt_log_verbosity = LOG_MED;
# if defined(ENABLE_USE_MME)
int16_t gtpu_log_level = LOG_DEBUG;
int16_t gtpu_log_verbosity = LOG_MED;
......@@ -1802,7 +1805,7 @@ static void get_options (int argc, char **argv) {
{"ue_rxgain", required_argument, NULL, LONG_OPTION_RXGAIN},
{NULL, 0, NULL, 0}};
while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRM:r:P:s:t:x:",long_options,NULL)) != -1) {
while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRM:r:P:Ws:t:x:",long_options,NULL)) != -1) {
switch (c) {
case LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS:
ULSCH_max_consecutive_errors = atoi(optarg);
......@@ -1884,23 +1887,35 @@ static void get_options (int argc, char **argv) {
target_ul_mcs = atoi (optarg);
break;
#ifdef OPENAIR2
case 'W':
opt_enabled=1;
opt_type = OPT_WIRESHARK;
strncpy(in_ip, "127.0.0.1", sizeof(in_ip));
in_ip[sizeof(in_ip) - 1] = 0; // terminate string
printf("Enabling OPT for wireshark for local interface");
/*
if (optarg == NULL){
in_ip[0] =NULL;
printf("Enabling OPT for wireshark for local interface");
} else {
strncpy(in_ip, optarg, sizeof(in_ip));
in_ip[sizeof(in_ip) - 1] = 0; // terminate string
printf("Enabling OPT for wireshark with %s \n",in_ip);
}
*/
break;
case 'P':
#ifdef OPENAIR2
/* enable openair packet tracer (OPT)*/
if ((strcmp(optarg, "wireshark") == 0) ||
(strcmp(optarg, "WIRESHARK") == 0)) {
opt_type = OPT_WIRESHARK;
printf("Enabling OPT for wireshark\n");
} else if ((strcmp(optarg, "pcap") == 0) ||
(strcmp(optarg, "PCAP") == 0)){
opt_type = OPT_PCAP;
printf("Enabling OPT for pcap\n");
opt_type = OPT_PCAP;
opt_enabled=1;
if (optarg == NULL){
strncpy(in_path, "/tmp/oai_opt.pcap", sizeof(in_path));
in_path[sizeof(in_path) - 1] = 0; // terminate string
printf("Enabling OPT for PCAP with the following path /tmp/oai_opt.pcap");
} else {
opt_type = OPT_NONE;
printf("Unrecognized option for OPT module\n");
printf("Possible values are either wireshark or pcap\n");
strncpy(in_path, optarg, sizeof(in_path));
in_path[sizeof(in_path) - 1] = 0; // terminate string
printf("Enabling OPT for PCAP with the following file %s \n",in_path);
}
#endif
break;
#endif
case 'V':
......@@ -2202,6 +2217,8 @@ int main(int argc, char **argv) {
set_comp_log(HW, hw_log_level, hw_log_verbosity, 1);
#ifdef OPENAIR2
set_comp_log(PHY, phy_log_level, phy_log_verbosity, 1);
if (opt_enabled == 1 )
set_comp_log(OPT, opt_log_level, opt_log_verbosity, 1);
#else
set_comp_log(PHY, LOG_INFO, LOG_HIGH, 1);
#endif
......@@ -2242,17 +2259,6 @@ int main(int argc, char **argv) {
if (opp_enabled ==1)
reset_opp_meas();
#ifdef OPENAIR2
if (opt_type != OPT_NONE) {
radio_type_t radio_type;
if (frame_parms[0]->frame_type == FDD)
radio_type = RADIO_TYPE_FDD;
else
radio_type = RADIO_TYPE_TDD;
if (init_opt(NULL, NULL, NULL, radio_type) == -1)
LOG_E(OPT,"failed to run OPT \n");
}
#endif
#if defined(ENABLE_ITTI)
if (UE_flag == 1) {
......@@ -2264,7 +2270,17 @@ int main(int argc, char **argv) {
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
#endif
#ifdef OPENAIR2
if (opt_type != OPT_NONE) {
radio_type_t radio_type;
if (frame_parms[0]->frame_type == FDD)
radio_type = RADIO_TYPE_FDD;
else
radio_type = RADIO_TYPE_TDD;
if (init_opt(in_path, in_ip, NULL, radio_type) == -1)
LOG_E(OPT,"failed to run OPT \n");
}
#endif
#ifdef NAS_NETLINK
netlink_init();
#endif
......@@ -2991,7 +3007,7 @@ int main(int argc, char **argv) {
vcd_signal_dumper_close();
#ifdef OPENAIR2
if (opt_type != OPT_NONE)
if (opt_enabled == 1)
terminate_opt();
#endif
......
......@@ -1785,7 +1785,7 @@ oai_shutdown (void) {
ShaF = 0;
}
if ((oai_emulation.info.opt_enabled == 1))
if (opt_enabled == 1)
terminate_opt ();
if (oai_emulation.info.cli_enabled)
......
......@@ -1168,7 +1168,7 @@ int ocg_config_emu(void){
oai_emulation.info.opt_enabled = ( oai_emulation.emulation_config.packet_trace.enabled == 0) ? oai_emulation.info.opt_enabled : oai_emulation.emulation_config.packet_trace.enabled;
if (oai_emulation.info.opt_enabled == 1) {
radio_type_t radio_type;
opt_enabled = 1;
if (oai_emulation.info.frame_type[0] == FDD) {
radio_type = RADIO_TYPE_FDD;
} else {
......
......@@ -527,7 +527,7 @@ void get_simulation_options(int argc, char *argv[]) {
case 'P':
oai_emulation.info.opt_enabled = 1;
opt_enabled = 1;
if (strcmp(optarg, "wireshark") == 0) {
opt_type = OPT_WIRESHARK;
printf("Enabling OPT for wireshark\n");
......@@ -539,6 +539,7 @@ void get_simulation_options(int argc, char *argv[]) {
printf("Possible values are either wireshark or pcap\n");
opt_type = OPT_NONE;
oai_emulation.info.opt_enabled = 0;
opt_enabled = 0;
}
oai_emulation.info.opt_mode = opt_type;
break;
......
......@@ -998,7 +998,7 @@ void run(int argc, char *argv[]) {
if ((oai_emulation.info.ocm_enabled == 1) && (ethernet_flag == 0) && (ShaF != NULL))
destroyMat(ShaF,map1, map2);
if ((oai_emulation.info.opt_enabled == 1) )
if (opt_enabled == 1 )
terminate_opt();
if (oai_emulation.info.cli_enabled)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment