Commit 51d93911 authored by Eurecom's avatar Eurecom

Merge branch 'NR_SA_F1AP_5GRECORDS' of...

Merge branch 'NR_SA_F1AP_5GRECORDS' of https://gitlab.eurecom.fr/oai/openairinterface5g into NR_SA_F1AP_5GRECORDS

Conflicts:
	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
parents cf1b1257 5c33daa8
......@@ -434,6 +434,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
# define LOG_M(file, vector, data, len, dec, format) do { write_file_matlab(file, vector, data, len, dec, format, 0);} while(0)
# define LOG_VAR(A,B) A B
# define T_ACTIVE(a) (0)
# endif /* T_TRACER */
/* avoid warnings for variables only used in LOG macro's but set outside debug section */
#define GCC_NOTUSED __attribute__((unused))
......
#ifndef T_TRACER
int T_stdout;
#endif
void exit_function(const char *file, const char *function, const int line, const char *s) {
}
......@@ -73,7 +73,6 @@ int sync_var=-1; //!< protected by mutex \ref sync_mutex.
int config_sync_var=-1;
volatile int oai_exit = 0;
double cpuf;
msc_interface_t msc_interface;
THREAD_STRUCT thread_struct;
uint16_t sf_ahead=4;
......
......@@ -379,6 +379,7 @@ void init_gNB_Tpool(int inst) {
sprintf(ul_pool+2+s_offset,",-1");
s_offset += 3;
}
if (getenv("noThreads")) strcpy(ul_pool, "n");
initTpool(ul_pool, gNB->threadPool, false);
// ULSCH decoder result FIFO
gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
......
......@@ -858,28 +858,28 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
memset(prachF, 0, sizeof(int16_t)*2*1024 );
if (LOG_DUMPFLAG(PRACH)) {
LOG_M("prach_rxF0.m","prach_rxF0",rxsigF[0],N_ZC,1,1);
LOG_M("prach_rxF1.m","prach_rxF1",rxsigF[1],6144,1,1);
LOG_M("prach_rxF0.m","prach_rxF0",rxsigF[0],N_ZC,1,1);
LOG_M("prach_rxF1.m","prach_rxF1",rxsigF[1],6144,1,1);
}
for (aa=0;aa<nb_rx; aa++) {
// Do componentwise product with Xu* on each antenna
for (offset=0; offset<(N_ZC<<1); offset+=2) {
prachF[offset] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][offset] + (int32_t)Xu[offset+1]*rxsigF[aa][offset+1])>>15);
prachF[offset+1] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][offset+1] - (int32_t)Xu[offset+1]*rxsigF[aa][offset])>>15);
}
for (offset=0; offset<(N_ZC<<1); offset+=2) {
prachF[offset] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][offset] + (int32_t)Xu[offset+1]*rxsigF[aa][offset+1])>>15);
prachF[offset+1] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][offset+1] - (int32_t)Xu[offset+1]*rxsigF[aa][offset])>>15);
}
// Now do IFFT of size 1024 (N_ZC=839) or 256 (N_ZC=139)
if (N_ZC == 839) {
log2_ifft_size = 10;
idft(IDFT_1024,prachF,prach_ifft_tmp,1);
// compute energy and accumulate over receive antennas
for (i=0;i<2048;i++)
prach_ifft[i] += ((int32_t)prach_ifft_tmp[i<<1]*(int32_t)prach_ifft_tmp[i<<1] + (int32_t)prach_ifft_tmp[1+(i<<1)]*(int32_t)prach_ifft_tmp[1+(i<<1)])>>10;
} else {
idft(IDFT_256,prachF,prach_ifft_tmp,1);
log2_ifft_size = 8;
// Now do IFFT of size 1024 (N_ZC=839) or 256 (N_ZC=139)
if (N_ZC == 839) {
log2_ifft_size = 10;
idft(IDFT_1024,prachF,prach_ifft_tmp,1);
// compute energy and accumulate over receive antennas
for (i=0;i<2048;i++)
prach_ifft[i] += ((int32_t)prach_ifft_tmp[i<<1]*(int32_t)prach_ifft_tmp[i<<1] + (int32_t)prach_ifft_tmp[1+(i<<1)]*(int32_t)prach_ifft_tmp[1+(i<<1)])/nb_rx;
} else {
idft(IDFT_256,prachF,prach_ifft_tmp,1);
log2_ifft_size = 8;
// compute energy and accumulate over receive antennas and repetitions for BR
for (i=0;i<256;i++)
prach_ifft[i] += ((int32_t)prach_ifft_tmp[i<<1]*(int32_t)prach_ifft_tmp[(i<<1)] + (int32_t)prach_ifft_tmp[1+(i<<1)]*(int32_t)prach_ifft_tmp[1+(i<<1)])/nb_rx;
......@@ -887,7 +887,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
if (LOG_DUMPFLAG(PRACH)) {
if (aa==0) LOG_M("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
if (aa==1) LOG_M("prach_rxF_comp1.m","prach_rxF_comp1",prachF,1024,1,1);
if (aa==1) LOG_M("prach_rxF_comp1.m","prach_rxF_comp1",prachF,1024,1,1);
}
}// antennas_rx
} // new dft
......@@ -900,10 +900,10 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
lev = (int32_t)prach_ifft[(preamble_shift2+i)];
levdB = dB_fixed_times10(lev);
if (levdB>*max_preamble_energy) {
LOG_D(PHY,"preamble_index %d, delay %d en %d dB > %d dB\n",preamble_index,i,levdB,*max_preamble_energy);
*max_preamble_energy = levdB;
*max_preamble_delay = i; // Note: This has to be normalized to the 30.72 Ms/s sampling rate
*max_preamble = preamble_index;
LOG_D(PHY,"preamble_index %d, delay %d en %d dB > %d dB\n",preamble_index,i,levdB,*max_preamble_energy);
*max_preamble_energy = levdB;
*max_preamble_delay = i; // Note: This has to be normalized to the 30.72 Ms/s sampling rate
*max_preamble = preamble_index;
}
}
}// preamble_index
......
......@@ -10,12 +10,17 @@ unsigned int mmapped_dma=0;
int single_thread_flag;
uint32_t timing_advance;
int8_t threequarter_fs;
int usrp_tx_thread;
uint64_t downlink_frequency[MAX_NUM_CCs][4];
int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
int opp_enabled;
static double snr_dB=20;
THREAD_STRUCT thread_struct;
uint32_t target_ul_mcs = 9;
uint32_t target_dl_mcs = 9;
uint64_t dlsch_slot_bitmap = (1<<1);
uint64_t ulsch_slot_bitmap = (1<<8);
uint32_t target_ul_bw = 50;
uint32_t target_dl_bw = 50;
#include <executables/nr-softmodem.h>
int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_state) {return 0;}
......@@ -302,6 +307,9 @@ int main(int argc, char **argv) {
void ** samplesRx = (void **)malloc16(antennas* sizeof(struct complex16 *) );
void ** samplesTx = (void **)malloc16(antennas* sizeof(struct complex16 *) );
int fd=open(getenv("rftestInputFile"),O_RDONLY);
AssertFatal(fd>=0,"%s",strerror(errno));
for (int i=0; i<antennas; i++) {
samplesRx[i] = (int32_t *)malloc16_clear( DFT*sizeof(struct complex16) );
......@@ -313,14 +321,16 @@ int main(int argc, char **argv) {
rfdevice.trx_start_func(&rfdevice);
while(!oai_exit) {
for (int i=0; i<antennas; i++)
read(fd, samplesTx[i], DFT*sizeof(struct complex16));
int readBlockSize = rfdevice.trx_read_func(&rfdevice,
&timestamp,
samplesTx,
samplesRx,
DFT,
antennas);
int txs = rfdevice.trx_write_func(&rfdevice,
timestamp+TxAdvanceInDFTSize*DFT,
samplesRx,
samplesTx,
DFT,
antennas,
0);
......
......@@ -356,7 +356,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH
}
void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint8_t harq_pid, uint8_t crc_flag) {
void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint8_t harq_pid, uint8_t crc_flag) {
pthread_mutex_lock(&gNB->UL_INFO_mutex);
......@@ -675,9 +675,10 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot) + gNB->pusch_thres) {
NR_gNB_SCH_STATS_t *stats=get_ulsch_stats(gNB,ulsch);
LOG_I(PHY, "PUSCH not detected in %d.%d (%d,%d,%d)\n",frame_rx,slot_rx,
LOG_D(PHY, "PUSCH not detected in %d.%d (%d,%d,%d)\n",frame_rx,slot_rx,
dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot),
dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot),gNB->pusch_thres);
gNB->pusch_vars[ULSCH_id]->ulsch_power_tot = gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot;
nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1);
gNB->pusch_vars[ULSCH_id]->DTX=1;
if (stats) stats->DTX++;
......
......@@ -54,6 +54,87 @@ extern RAN_CONTEXT_t RC;
extern void mac_top_init_gNB(void);
extern uint8_t nfapi_mode;
void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list,
struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_bearer2release_list,
NR_UE_sched_ctrl_t *sched_ctrl) {
if (rlc_bearer2add_list)
// keep lcids
for (int i=0;i<rlc_bearer2add_list->list.count;i++) {
sched_ctrl->lcid_mask |= (1<<rlc_bearer2add_list->list.array[i]->logicalChannelIdentity);
LOG_I(NR_MAC,"Adding LCID %d (%s %d)\n",
(int)rlc_bearer2add_list->list.array[i]->logicalChannelIdentity,
rlc_bearer2add_list->list.array[i]->logicalChannelIdentity<4 ? "SRB" : "DRB",
(int)rlc_bearer2add_list->list.array[i]->logicalChannelIdentity);
}
if (rlc_bearer2release_list)
for (int i=0;i<rlc_bearer2release_list->list.count;i++)
sched_ctrl->lcid_mask |= (1<<*rlc_bearer2release_list->list.array[i]);
}
void process_drx_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_DRX_Config_t *drx_Config) {
if (!drx_Config) return;
AssertFatal(drx_Config->present != NR_SetupRelease_DRX_Config_PR_NOTHING, "Cannot have NR_SetupRelease_DRX_Config_PR_NOTHING\n");
if (drx_Config->present == NR_SetupRelease_DRX_Config_PR_setup) {
LOG_I(NR_MAC,"Adding DRX config\n");
}
else {
LOG_I(NR_MAC,"Removing DRX config\n");
}
}
void process_schedulingRequestConfig(NR_UE_sched_ctrl_t *sched_ctrl,NR_SchedulingRequestConfig_t *schedulingRequestConfig) {
if (!schedulingRequestConfig) return;
LOG_I(NR_MAC,"Adding SchedulingRequestconfig\n");
}
void process_bsrConfig(NR_UE_sched_ctrl_t *sched_ctrl,NR_BSR_Config_t *bsr_Config) {
if (!bsr_Config) return;
LOG_I(NR_MAC,"Adding BSR config\n");
}
void process_tag_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_TAG_Config_t *tag_Config) {
if (!tag_Config) return;
LOG_I(NR_MAC,"Adding TAG config\n");
}
void process_phr_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_PHR_Config_t *phr_Config) {
if (!phr_Config) return;
AssertFatal(phr_Config->present != NR_SetupRelease_PHR_Config_PR_NOTHING, "Cannot have NR_SetupRelease_PHR_Config_PR_NOTHING\n");
if (phr_Config->present == NR_SetupRelease_PHR_Config_PR_setup) {
LOG_I(NR_MAC,"Adding PHR config\n");
}
else {
LOG_I(NR_MAC,"Removing PHR config\n");
}
}
void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl) {
AssertFatal(CellGroup, "CellGroup is null\n");
NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = CellGroup->mac_CellGroupConfig;
if (mac_CellGroupConfig) {
process_drx_Config(sched_ctrl,mac_CellGroupConfig->drx_Config);
process_schedulingRequestConfig(sched_ctrl,mac_CellGroupConfig->schedulingRequestConfig);
process_bsrConfig(sched_ctrl,mac_CellGroupConfig->bsr_Config);
process_tag_Config(sched_ctrl,mac_CellGroupConfig->tag_Config);
process_phr_Config(sched_ctrl,mac_CellGroupConfig->phr_Config);
}
else {
// apply defaults
}
process_rlcBearerConfig(CellGroup->rlc_BearerToAddModList,CellGroup->rlc_BearerToReleaseList,sched_ctrl);
}
void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts, int pusch_AntennaPorts, NR_ServingCellConfigCommon_t *scc) {
nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[Mod_idP]->config[0];
......@@ -339,9 +420,9 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
int pdsch_AntennaPorts,
int pusch_AntennaPorts,
NR_ServingCellConfigCommon_t *scc,
int add_ue,
uint32_t rnti,
NR_CellGroupConfig_t *CellGroup){
int add_ue,
uint32_t rnti,
NR_CellGroupConfig_t *CellGroup) {
if (scc != NULL ) {
AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present);
......@@ -384,7 +465,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
ssb_SubcarrierOffset,
pdsch_AntennaPorts,
pusch_AntennaPorts,
scc);
scc);
LOG_E(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req);
// if in nFAPI mode
......@@ -409,12 +490,12 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
if (get_softmodem_params()->sa > 0) {
NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[0];
for (int n=0;n<NR_NB_RA_PROC_MAX;n++ ) {
cc->ra[n].cfra = false;
cc->ra[n].rnti = 0;
cc->ra[n].preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
cc->ra[n].preambles.preamble_list = (uint8_t *) malloc(MAX_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t));
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
cc->ra[n].preambles.preamble_list[i] = i;
cc->ra[n].cfra = false;
cc->ra[n].rnti = 0;
cc->ra[n].preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
cc->ra[n].preambles.preamble_list = (uint8_t *) malloc(MAX_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t));
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
cc->ra[n].preambles.preamble_list[i] = i;
}
}
}
......@@ -425,6 +506,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
if (add_ue == 1 && get_softmodem_params()->phy_test) {
const int UE_id = add_new_nr_ue(Mod_idP, rnti, CellGroup);
LOG_I(PHY,"Added new UE_id %d/%x with initial CellGroup\n",UE_id,rnti);
process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]);
} else if (add_ue == 1 && !get_softmodem_params()->phy_test) {
const int CC_id = 0;
NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[CC_id];
......@@ -440,7 +522,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
NR_RA_t *ra = &cc->ra[ra_index];
ra->CellGroup = CellGroup;
if (CellGroup->spCellConfig && CellGroup->spCellConfig->reconfigurationWithSync &&
CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated!=NULL) {
CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated!=NULL) {
if (CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra != NULL) {
ra->cfra = true;
ra->rnti = rnti;
......@@ -472,6 +554,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
const int UE_id = find_nr_UE_id(Mod_idP,rnti);
UE_info->CellGroup[UE_id] = CellGroup;
LOG_I(NR_MAC,"Modified UE_id %d/%x with CellGroup\n",UE_id,rnti);
process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]);
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
......
......@@ -77,10 +77,12 @@ void dump_mac_stats(gNB_MAC_INST *gNB)
stats->num_rsrp_meas = 0;
stats->cumul_rsrp = 0 ;
LOG_I(MAC, "UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes);
LOG_I(MAC, "UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_errors %d\n",
LOG_I(MAC, "UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n",
UE_id,
stats->ulsch_rounds[0], stats->ulsch_rounds[1],
stats->ulsch_rounds[2], stats->ulsch_rounds[3], stats->ulsch_errors);
stats->ulsch_rounds[2], stats->ulsch_rounds[3],
stats->ulsch_DTX,
stats->ulsch_errors);
LOG_I(MAC,
"UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n",
UE_id,
......
......@@ -343,11 +343,11 @@ void nr_store_dlsch_buffer(module_id_t module_id,
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
sched_ctrl->num_total_bytes = 0;
if (loop_dcch_dtch == DL_SCH_LCID_DCCH1)
if ((sched_ctrl->lcid_mask&(1<<4)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH1)
loop_dcch_dtch = DL_SCH_LCID_DTCH;
else if (loop_dcch_dtch == DL_SCH_LCID_DTCH)
else if ((sched_ctrl->lcid_mask&(1<<1)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DTCH)
loop_dcch_dtch = DL_SCH_LCID_DCCH;
else if (loop_dcch_dtch == DL_SCH_LCID_DCCH)
else if ((sched_ctrl->lcid_mask&(1<<2)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH)
loop_dcch_dtch = DL_SCH_LCID_DCCH1;
const int lcid = loop_dcch_dtch;
......@@ -374,11 +374,12 @@ void nr_store_dlsch_buffer(module_id_t module_id,
&& !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */
return;
LOG_I(NR_MAC,
"[%s][%d.%d], DTCH%d->DLSCH, RLC status %d bytes TA %d\n",
LOG_D(NR_MAC,
"[%s][%d.%d], %s%d->DLSCH, RLC status %d bytes TA %d\n",
__func__,
frame,
slot,
lcid<4?"DCCH":"DTCH",
lcid,
sched_ctrl->rlc_status[lcid].bytes_in_buffer,
sched_ctrl->ta_apply);
......@@ -722,6 +723,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
NR_list_t *UE_list = &UE_info->list;
for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
if (sched_ctrl->ul_failure==1) continue;
UE_info->mac_stats[UE_id].dlsch_current_bytes = 0;
/* update TA and set ta_apply every 10 frames.
......@@ -825,7 +827,8 @@ void nr_schedule_ue_spec(module_id_t module_id,
startSymbolIndex,
nrOfSymbols,
sched_ctrl->mcs,
TBS,((double)TBS)*(1<<scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing)/1000,
TBS,
((double)TBS)*(1<<scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing)/1000,
current_harq_pid,
harq->round,
harq->ndi);
......
......@@ -1722,6 +1722,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG
compute_csi_bitlen (CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup, UE_info, UE_id, mod_idP);
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
memset(sched_ctrl, 0, sizeof(*sched_ctrl));
sched_ctrl->lcid_mask = 0;
sched_ctrl->ta_frame = 0;
sched_ctrl->ta_update = 31;
sched_ctrl->ta_apply = false;
......
......@@ -126,6 +126,7 @@ void nr_schedule_pucch(int Mod_idP,
for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
if (sched_ctrl->ul_failure==1) continue;
const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch);
for (int i = 0; i < n; i++) {
NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i];
......@@ -975,7 +976,7 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id,
sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10,
uci_01->ul_cqi,
30);
LOG_I(NR_MAC,"pucch tpc %d\n",sched_ctrl->tpc1);
LOG_D(NR_MAC,"pucch tpc %d\n",sched_ctrl->tpc1);
NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon;
const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing];
if (((uci_01->pduBitmap >> 1) & 0x01)) {
......@@ -1149,7 +1150,7 @@ bool nr_acknack_scheduling(int mod_id,
}
}
LOG_I(MAC,"1. DL slot %d, UL_ACK %d\n",slot,pucch->ul_slot);
LOG_D(MAC,"1. DL slot %d, UL_ACK %d\n",slot,pucch->ul_slot);
/* if the UE's next PUCCH occasion is after the possible UL slots (within the
* same frame) or wrapped around to the next frame, then we assume there is
* no possible PUCCH allocation anymore */
......
......@@ -305,11 +305,11 @@ void nr_process_mac_pdu(
mac_subheader_len = 2;
}
LOG_I(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DTCH %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len);
int UE_id = find_nr_UE_id(module_idP, rnti);
RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len;
LOG_I(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-%s %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid<4?"DCCH":"DTCH",rx_lcid, module_idP, mac_sdu_len);
int UE_id = find_nr_UE_id(module_idP, rnti);
RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len;
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
log_dump(NR_MAC, pdu_ptr + mac_subheader_len, 32, LOG_DUMP_CHAR, "\n");
log_dump(NR_MAC, pdu_ptr + mac_subheader_len, 32, LOG_DUMP_CHAR, "\n");
#endif
......@@ -507,7 +507,10 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
if (UE_scheduling_control->sched_ul_bytes < 0)
UE_scheduling_control->sched_ul_bytes = 0;
}
if (ul_cqi < 128) UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt++;
if (ul_cqi <= 128) {
UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt++;
UE_info->mac_stats[UE_id].ulsch_DTX++;
}
if (UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt >= pusch_failure_thres) {
LOG_I(NR_MAC,"Detected UL Failure on PUSCH, stopping scheduling\n");
UE_info->UE_sched_ctrl[UE_id].ul_failure = 1;
......@@ -771,7 +774,7 @@ void pf_ul(module_id_t module_id,
sched_pusch->mcs = mcs;
sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table);
sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table);
LOG_W(NR_MAC, "Fixme: work around a NULL pointer (set in function nr_save_pusch_fields that is actually called)\n");
LOG_D(NR_MAC, "Fixme: work around a NULL pointer (set in function nr_save_pusch_fields that is actually called)\n");
if (ps->pusch_Config && (ps->pusch_Config->tp_pi2BPSK
&& ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6)))) {
sched_pusch->R >>= 1;
......@@ -1031,6 +1034,7 @@ void nr_schedule_ulsch(module_id_t module_id,
const NR_list_t *UE_list = &UE_info->list;
for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
if (sched_ctrl->ul_failure == 1) continue;
UE_info->mac_stats[UE_id].ulsch_current_bytes = 0;
/* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in
* every TTI are pre-populated by the preprocessor and used below */
......
......@@ -52,9 +52,9 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
int pdsch_AntennaPorts,
int pusch_AntennaPorts,
NR_ServingCellConfigCommon_t *scc,
int nsa_flag,
uint32_t rnti,
NR_CellGroupConfig_t *CellGroup
int nsa_flag,
uint32_t rnti,
NR_CellGroupConfig_t *CellGroup
);
void clear_nr_nfapi_information(gNB_MAC_INST * gNB,
......
......@@ -517,6 +517,7 @@ typedef struct {
/// DL HARQ PID to use for this UE, or -1 for "any new"
int8_t dl_harq_pid;
int lcid_mask;
uint16_t ta_frame;
int16_t ta_update;
bool ta_apply;
......@@ -562,6 +563,7 @@ typedef struct {
int dlsch_current_bytes;
int ulsch_rounds[8];
int ulsch_errors;
int ulsch_DTX;
int ulsch_total_bytes_scheduled;
int ulsch_total_bytes_rx;
int ulsch_current_bytes;
......
......@@ -911,6 +911,7 @@ boolean_t nr_rrc_pdcp_config_asn1_req(
//kUPenc != NULL ||
pmch_InfoList_r9 != NULL /*||
defaultDRB != NULL */) {
LOG_I(PDCP,"Releasing DRBs, oops\n");
TODO;
}
......
......@@ -44,6 +44,7 @@
#include "NR_BCCH-BCH-Message.h"
#include "rrc_gNB_UE_context.h"
#include <openair2/RRC/NR/MESSAGES/asn1_msg.h>
#include <openair2/UTIL/OPT/opt.h>
extern RAN_CONTEXT_t RC;
......@@ -207,6 +208,7 @@ nr_rrc_data_req(
message_p);
LOG_I(NR_RRC,"send RRC_DCCH_DATA_REQ to PDCP\n");
//trace_NRpdu(DIRECTION_DOWNLINK, message_buffer, sdu_sizeP, 0, WS_M_RNTI, ctxt_pP->rnti, ctxt_pP->frame, ctxt_pP->subframe,0, 0);
/* Hack: only trigger PDCP if in CU, otherwise it is triggered by RU threads
* Ideally, PDCP would not neet to be triggered like this but react to ITTI
* messages automatically */
......
......@@ -1631,13 +1631,14 @@ uint16_t do_RRCReconfiguration(
// *security_config->keyToUse = NR_SecurityConfig__keyToUse_master;
ie = calloc(1, sizeof(NR_RRCReconfiguration_IEs_t));
ie->radioBearerConfig = calloc(1, sizeof(NR_RadioBearerConfig_t));
ie->radioBearerConfig->srb_ToAddModList = SRB_configList;
ie->radioBearerConfig->drb_ToAddModList = DRB_configList;
ie->radioBearerConfig->securityConfig = security_config;
ie->radioBearerConfig->srb3_ToRelease = NULL;
ie->radioBearerConfig->drb_ToReleaseList = DRB_releaseList;
if (SRB_configList || DRB_configList) {
ie->radioBearerConfig = calloc(1, sizeof(NR_RadioBearerConfig_t));
ie->radioBearerConfig->srb_ToAddModList = SRB_configList;
ie->radioBearerConfig->drb_ToAddModList = DRB_configList;
ie->radioBearerConfig->securityConfig = security_config;
ie->radioBearerConfig->srb3_ToRelease = NULL;
ie->radioBearerConfig->drb_ToReleaseList = DRB_releaseList;
}
/******************** Secondary Cell Group ********************/
// rrc_gNB_carrier_data_t *carrier = &(gnb_rrc_inst->carrier);
// fill_default_secondaryCellGroup( carrier->servingcellconfigcommon,
......
......@@ -1003,7 +1003,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration(
memset(sdap_config, 0, sizeof(NR_SDAP_Config_t));
sdap_config->pdu_Session = ue_context_pP->ue_context.pdusession[i].param.pdusession_id;
sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_absent;
sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_present;
sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_absent;
sdap_config->defaultDRB = TRUE;
sdap_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
memset(sdap_config->mappedQoS_FlowsToAdd, 0, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd));
......@@ -1281,6 +1281,7 @@ rrc_gNB_process_RRCReconfigurationComplete(
NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid];
NR_DRB_Identity_t *drb_id_p = NULL;
// uint8_t nr_DRB2LCHAN[8];
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
ue_context_pP->ue_context.ue_reestablishment_timer = 0;
......@@ -1321,6 +1322,15 @@ rrc_gNB_process_RRCReconfigurationComplete(
ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList);
/* Refresh SRBs/DRBs */
if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) {
rrc_mac_config_req_gNB(rrc->module_id,
rrc->carrier.ssb_SubcarrierOffset,
rrc->carrier.pdsch_AntennaPorts,
rrc->carrier.pusch_AntennaPorts,
NULL,
0,
ue_context_pP->ue_context.rnti,
ue_context_pP->ue_context.masterCellGroup
);
LOG_I(NR_RRC,"Configuring RLC DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti);
nr_rrc_rlc_config_asn1_req(ctxt_pP,
SRB_configList, // NULL,
......
......@@ -355,8 +355,8 @@ nr_rrc_pdcp_config_security(
if (print_keys == 1 ) {
print_keys =0;
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, ue_context_pP->ue_context.kgnb, 32,"\nKgNB:" );
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCenc, 32,"\nKRRCenc:" );
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCint, 32,"\nKRRCint:" );
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCenc, 16,"\nKRRCenc:" );
LOG_DUMPMSG(NR_RRC, DEBUG_SECURITY, kRRCint, 16,"\nKRRCint:" );
}
}
......
How to configure wireshark for dissecting LTE protocols:
How to configure wireshark for dissecting LTE/NR protocols:
- start the wireshark as a sudoers
- goto analyze->enabled prototols
=> enable mac_lte_udp and rlc_lte_udp
=> enable mac_xxx_udp and rlc_xxx_udp (xxx is lte or nr)
- goto edit/preferences and expand Protocols
- select UDP and check "try heuristic sub-dissectors first"
- select MAC-LTE, and check all the options (checkboxes), and set the "which layer info to show in info column" to "MAC info"
- select RLC-LTE, and check all the options except the "May see RLC headers only", and
- select MAC-LTE (or MAC-NR), and check all the options (checkboxes), and set the "which layer info to show in info column" to "MAC info"
- select RLC-LTE (or NR), and check all the options except the "May see RLC headers only", and
set the "call PDCP dissector for DRB PDUs" to "12-bit SN". Optionally you may select the sequence analysis for RLC AM/UM.
- select PDCP-LTE (or NR)
How to use
- start eNB or UE with option --opt.type wireshark
......
......@@ -60,6 +60,12 @@ typedef uint32_t guint32;
typedef guint8 gboolean;
#include "packet-mac-lte.h"
#include "packet-rlc-lte.h"
#include "packet-pdcp-lte.h"
#include "packet-mac-nr.h"
#include "packet-rlc-nr.h"
#include "packet-pdcp-nr.h"
#include "mac_pcap.h"
/* OPT parameters definitions */
......@@ -107,9 +113,10 @@ typedef enum radio_type_e {
*/
extern int opt_enabled;
#define trace_pdu(x...) if (opt_enabled) trace_pdu_implementation(x)
#define trace_pdu(x...) if (opt_enabled) trace_pdu_implementation(0, x)
#define trace_NRpdu(x...) if (opt_enabled) trace_pdu_implementation(1, x)
void trace_pdu_implementation(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe,
int oob_event, int oob_event_value);
......
......@@ -15,7 +15,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*/
/*
this is wireshark, commit: commit eda834b6e29c36e05a63a6056afa98390ff79357
Date: Wed Aug 22 14:36:20 2018 +0200
......@@ -114,6 +114,7 @@ typedef struct mac_lte_info
/* Timing info */
guint16 sysframeNumber;
guint16 subframeNumber;
gboolean sfnSfInfoPresent;
/* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */
gboolean subframeNumberOfGrantPresent;
......@@ -197,49 +198,27 @@ typedef struct mac_lte_info
guint16 oob_rnti[MAX_SRs];
} mac_lte_info;
/* 0 to 10 and 32 to 38 */
#define MAC_LTE_DATA_LCID_COUNT_MAX 18
typedef struct mac_lte_tap_info {
/* Info from context */
guint16 rnti;
guint16 ueid;
guint8 rntiType;
guint8 isPredefinedData;
gboolean crcStatusValid;
mac_lte_crc_status crcStatus;
guint8 direction;
guint8 isPHYRetx;
guint16 ueInTTI;
nstime_t mac_lte_time;
/* Number of bytes (which part is used depends upon context settings) */
guint32 single_number_of_bytes;
guint32 bytes_for_lcid[11];
guint32 sdus_for_lcid[11];
guint8 number_of_rars;
guint8 number_of_paging_ids;
/* Number of padding bytes includes padding subheaders and trailing padding */
guint16 padding_bytes;
guint16 raw_length;
} mac_lte_tap_info;
/* Accessor function to check if a frame was considered to be ReTx */
/*****************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting MAC by framing */
/* PDUs over IP. A suggested format over UDP has been created */
/* and implemented by this dissector, using the definitions */
/* below. A link to an example program showing you how to encode */
/* these headers and send LTE MAC PDUs on a UDP socket is */
/* provided at https://wiki.wireshark.org/MAC-LTE */
/* */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/*****************************************************************/
/**********************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting MAC by framing */
/* PDUs over IP. A suggested format over UDP has been created */
/* and implemented by this dissector, using the definitions */
/* below. A link to an example program showing you how to encode */
/* these headers and send LTE MAC PDUs on a UDP socket is */
/* provided at https://gitlab.com/wireshark/wireshark/-/wikis/MAC-LTE */
/* */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/**********************************************************************/
/* Signature. Rather than try to define a port for this, or make the
......@@ -317,66 +296,4 @@ typedef struct mac_lte_tap_info {
continues until the end of the frame) */
#define MAC_LTE_PAYLOAD_TAG 0x01
/* Type to store parameters for configuring LCID->RLC channel settings for DRB */
/* Some are optional, and may not be seen (e.g. on reestablishment) */
typedef struct drb_mapping_t
{
guint16 ueid; /* Mandatory */
guint8 drbid; /* Mandatory */
gboolean lcid_present;
guint8 lcid; /* Part of LogicalChannelConfig - optional */
gboolean rlcMode_present;
guint8 rlcMode; /* Part of RLC config - optional */
gboolean rlc_ul_ext_li_field; /* Part of RLC config - optional */
gboolean rlc_dl_ext_li_field; /* Part of RLC config - optional */
gboolean rlc_ul_ext_am_sn; /* Part of RLC config - optional */
gboolean rlc_dl_ext_am_sn; /* Part of RLC config - optional */
gboolean um_sn_length_present;
guint8 um_sn_length; /* Part of RLC config - optional */
gboolean ul_priority_present;
guint8 ul_priority; /* Part of LogicalChannelConfig - optional */
gboolean pdcp_sn_size_present;
guint8 pdcp_sn_size; /* Part of pdcp-Config - optional */
} drb_mapping_t;
/* Dedicated DRX config. Used to verify that a sensible config is given.
Also, beginning to configure MAC with this config and (optionally) show
DRX config and state (cycles/timers) attached to each UL/DL PDU! */
typedef struct drx_config_t {
gboolean configured;
guint32 frameNum;
guint32 previousFrameNum;
guint32 onDurationTimer;
guint32 inactivityTimer;
guint32 retransmissionTimer;
guint32 longCycle;
guint32 cycleOffset;
/* Optional Short cycle */
gboolean shortCycleConfigured;
guint32 shortCycle;
guint32 shortCycleTimer;
} drx_config_t;
/* RRC can indicate whether simultaneous PUCCH/PUSCH is used */
typedef enum {
SIMULT_PUCCH_PUSCH_PCELL = 0,
SIMULT_PUCCH_PUSCH_PSCELL
} simult_pucch_pusch_cell_type;
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
#endif
/* packet-mac-nr.h
*
* Martin Mathieson
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* radioType */
#define FDD_RADIO 1
#define TDD_RADIO 2
/* Direction */
#define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1
/* rntiType */
#define WS_NO_RNTI 0
#define WS_P_RNTI 1
#define WS_RA_RNTI 2
#define WS_C_RNTI 3
#define WS_SI_RNTI 4
#define WS_CS_RNTI 5
/* Context info attached to each NR MAC frame */
typedef struct mac_nr_info
{
/* Needed for decode */
guint8 radioType;
guint8 direction;
guint8 rntiType;
/* Extra info to display */
guint16 rnti;
guint16 ueid;
guint8 harqid;
/* Will these be included in the ME PHR report? */
guint8 phr_type2_othercell;
/* Timing info */
gboolean sfnSlotInfoPresent;
guint16 sysframeNumber;
guint16 slotNumber;
/* Length of DL PDU or UL grant size in bytes */
guint16 length;
} mac_nr_info;
/*****************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting MAC by framing */
/* PDUs over IP. A suggested format over UDP has been created */
/* and implemented by this dissector, using the definitions */
/* below. */
/* */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/*****************************************************************/
/* Signature. Rather than try to define a port for this, or make the
port number a preference, frames will start with this string (with no
terminating NULL */
#define MAC_NR_START_STRING "mac-nr"
/* Fixed fields. This is followed by the following 3 mandatory fields:
- radioType (1 byte)
- direction (1 byte)
- rntiType (1 byte)
(where the allowed values are defined above */
/* Optional fields. Attaching this info to frames will allow you
to show you display/filter/plot/add-custom-columns on these fields, so should
be added if available.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag) */
#define MAC_NR_RNTI_TAG 0x02
/* 2 bytes, network order */
#define MAC_NR_UEID_TAG 0x03
/* 2 bytes, network order */
#define MAC_NR_FRAME_SUBFRAME_TAG 0x04
/* 2 bytes, deprecated, do not use it */
#define MAC_NR_PHR_TYPE2_OTHERCELL_TAG 0x05
/* 1 byte, TRUE/FALSE */
#define MAC_NR_HARQID 0x06
/* 1 byte */
#define MAC_NR_FRAME_SLOT_TAG 0x07
/* 4 bytes, network order, SFN is stored in the 2 first bytes and slot number in the 2 last bytes */
/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU
continues until the end of the frame) */
#define MAC_NR_PAYLOAD_TAG 0x01
/* Type to store parameters for configuring LCID->RLC channel settings for DRB */
/* Some are optional, and may not be seen (e.g. on reestablishment) */
typedef struct nr_drb_mac_rlc_mapping_t
{
gboolean active;
guint16 ueid; /* Mandatory */
guint8 drbid; /* Mandatory */
gboolean lcid_present;
guint8 lcid; /* Part of LogicalChannelConfig - optional */
gboolean rlcMode_present;
guint8 rlcMode; /* Part of RLC config - optional */
guint8 tempDirection; /* So know direction of next SN length... */
gboolean rlcUlSnLength_present;
guint8 rlcUlSnLength; /* Part of RLC config - optional */
gboolean rlcDlSnLength_present;
guint8 rlcDlSnLength; /* Part of RLC config - optional */
} nr_drb_mac_rlc_mapping_t;
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
/* packet-pdcp-lte.h
*
* Martin Mathieson
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* Direction */
#define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1
enum pdcp_plane
{
SIGNALING_PLANE = 1,
USER_PLANE = 2
};
typedef enum LogicalChannelType
{
Channel_DCCH=1,
Channel_BCCH=2,
Channel_CCCH=3,
Channel_PCCH=4,
Channel_DCCH_NB=5,
Channel_BCCH_NB=6,
Channel_CCCH_NB=7,
Channel_PCCH_NB=8
} LogicalChannelType;
typedef enum
{
BCH_TRANSPORT=1,
DLSCH_TRANSPORT=2
} BCCHTransportType;
#define PDCP_SN_LENGTH_5_BITS 5
#define PDCP_SN_LENGTH_7_BITS 7
#define PDCP_SN_LENGTH_12_BITS 12
#define PDCP_SN_LENGTH_15_BITS 15
#define PDCP_SN_LENGTH_18_BITS 18
enum lte_security_integrity_algorithm_e { eia0, eia1, eia2, eia3 };
enum lte_security_ciphering_algorithm_e { eea0, eea1, eea2, eea3 };
typedef struct pdcp_lte_security_info_t
{
guint32 configuration_frame;
gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */
enum lte_security_integrity_algorithm_e integrity;
enum lte_security_ciphering_algorithm_e ciphering;
/* Store previous settings so can revert if get SecurityModeFailure */
guint32 previous_configuration_frame;
enum lte_security_integrity_algorithm_e previous_integrity;
enum lte_security_ciphering_algorithm_e previous_ciphering;
} pdcp_lte_security_info_t;
/***********************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting PDCP by framing */
/* PDUs over IP. A suggested format over UDP has been defined */
/* and implemented by this dissector, using the definitions */
/* below. A link to an example program showing you how to encode */
/* these headers and send LTE PDCP PDUs on a UDP socket is */
/* provided at https://gitlab.com/wireshark/wireshark/-/wikis/PDCP-LTE */
/* */
/* A heuristic dissecter (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/* Until someone is using this format, suggestions for changes */
/* are welcome. */
/***********************************************************************/
/* Signature. Rather than try to define a port for this, or make the
port number a preference, frames will start with this string (with no
terminating NULL */
#define PDCP_LTE_START_STRING "pdcp-lte"
/* Fixed fields. This is followed by the following 3 mandatory fields:
- no_header_pdu (1 byte)
- plane (1 byte)
- rohc_compression ( byte)
(where the allowed values are defined above) */
/* Conditional field. This field is mandatory in case of User Plane PDCP PDU.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag). The allowed values are defined above. */
#define PDCP_LTE_SEQNUM_LENGTH_TAG 0x02
/* 1 byte */
/* Optional fields. Attaching this info to frames will allow you
to show you display/filter/plot/add-custom-columns on these fields, so should
be added if available.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag) */
#define PDCP_LTE_DIRECTION_TAG 0x03
/* 1 byte */
#define PDCP_LTE_LOG_CHAN_TYPE_TAG 0x04
/* 1 byte */
#define PDCP_LTE_BCCH_TRANSPORT_TYPE_TAG 0x05
/* 1 byte */
#define PDCP_LTE_ROHC_IP_VERSION_TAG 0x06
/* 2 bytes, network order */
#define PDCP_LTE_ROHC_CID_INC_INFO_TAG 0x07
/* 1 byte */
#define PDCP_LTE_ROHC_LARGE_CID_PRES_TAG 0x08
/* 1 byte */
#define PDCP_LTE_ROHC_MODE_TAG 0x09
/* 1 byte */
#define PDCP_LTE_ROHC_RND_TAG 0x0A
/* 1 byte */
#define PDCP_LTE_ROHC_UDP_CHECKSUM_PRES_TAG 0x0B
/* 1 byte */
#define PDCP_LTE_ROHC_PROFILE_TAG 0x0C
/* 2 bytes, network order */
#define PDCP_LTE_CHANNEL_ID_TAG 0x0D
/* 2 bytes, network order */
#define PDCP_LTE_UEID_TAG 0x0E
/* 2 bytes, network order */
/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU
continues until the end of the frame) */
#define PDCP_LTE_PAYLOAD_TAG 0x01
/* Called by RRC, or other configuration protocols */
/* Function to configure ciphering & integrity algorithms */
void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_lte_security_info_t *security_info);
/* Function to indicate securityModeCommand did not complete */
void set_pdcp_lte_security_algorithms_failed(guint16 ueid);
/* Called by external dissectors */
void set_pdcp_lte_rrc_ciphering_key(guint16 ueid, const char *key);
void set_pdcp_lte_rrc_integrity_key(guint16 ueid, const char *key);
void set_pdcp_lte_up_ciphering_key(guint16 ueid, const char *key);
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
/* packet-pdcp-nr.h
*
* Martin Mathieson
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* Direction */
#define PDCP_NR_DIRECTION_UPLINK 0
#define PDCP_NR_DIRECTION_DOWNLINK 1
enum pdcp_nr_plane
{
NR_SIGNALING_PLANE = 1,
NR_USER_PLANE = 2
};
typedef enum NRBearerType
{
Bearer_DCCH=1,
Bearer_BCCH_BCH=2,
Bearer_BCCH_DL_SCH=3,
Bearer_CCCH=4,
Bearer_PCCH=5,
} NRBearerType;
#define PDCP_NR_SN_LENGTH_12_BITS 12
#define PDCP_NR_SN_LENGTH_18_BITS 18
#define PDCP_NR_UL_SDAP_HEADER_PRESENT 0x01
#define PDCP_NR_DL_SDAP_HEADER_PRESENT 0x02
enum nr_security_integrity_algorithm_e { nia0, nia1, nia2, nia3 };
enum nr_security_ciphering_algorithm_e { nea0, nea1, nea2, nea3, nea_disabled=999};
typedef struct pdcp_nr_security_info_t
{
guint32 configuration_frame;
gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */
enum nr_security_integrity_algorithm_e integrity;
enum nr_security_ciphering_algorithm_e ciphering;
/* Store previous settings so can revert if get SecurityModeFailure */
guint32 previous_configuration_frame;
enum nr_security_integrity_algorithm_e previous_integrity;
enum nr_security_ciphering_algorithm_e previous_ciphering;
} pdcp_nr_security_info_t;
/*****************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting PDCP by framing */
/* PDUs over IP. A suggested format over UDP has been defined */
/* and implemented by this dissector, using the definitions */
/* below. */
/* */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/* Until someone is using this format, suggestions for changes */
/* are welcome. */
/*****************************************************************/
/* Signature. Rather than try to define a port for this, or make the
port number a preference, frames will start with this string (with no
terminating NULL */
#define PDCP_NR_START_STRING "pdcp-nr"
/* Fixed fields:
- plane (1 byte) */
/* Conditional field. This field is mandatory in case of User Plane PDCP PDU.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag). The allowed values are defined above. */
#define PDCP_NR_SEQNUM_LENGTH_TAG 0x02
/* 1 byte */
/* Optional fields. Attaching this info should be added if available.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag) */
#define PDCP_NR_DIRECTION_TAG 0x03
/* 1 byte */
#define PDCP_NR_BEARER_TYPE_TAG 0x04
/* 1 byte */
#define PDCP_NR_BEARER_ID_TAG 0x05
/* 1 byte */
#define PDCP_NR_UEID_TAG 0x06
/* 2 bytes, network order */
#define PDCP_NR_ROHC_COMPRESSION_TAG 0x07
/* 0 byte */
/* N.B. The following ROHC values only have significance if rohc_compression
is in use for the current channel */
#define PDCP_NR_ROHC_IP_VERSION_TAG 0x08
/* 1 byte */
#define PDCP_NR_ROHC_CID_INC_INFO_TAG 0x09
/* 0 byte */
#define PDCP_NR_ROHC_LARGE_CID_PRES_TAG 0x0A
/* 0 byte */
#define PDCP_NR_ROHC_MODE_TAG 0x0B
/* 1 byte */
#define PDCP_NR_ROHC_RND_TAG 0x0C
/* 0 byte */
#define PDCP_NR_ROHC_UDP_CHECKSUM_PRES_TAG 0x0D
/* 0 byte */
#define PDCP_NR_ROHC_PROFILE_TAG 0x0E
/* 2 bytes, network order */
#define PDCP_NR_MACI_PRES_TAG 0x0F
/* 0 byte */
#define PDCP_NR_SDAP_HEADER_TAG 0x10
/* 1 byte, bitmask with PDCP_NR_UL_SDAP_HEADER_PRESENT and/or PDCP_NR_DL_SDAP_HEADER_PRESENT */
#define PDCP_NR_CIPHER_DISABLED_TAG 0x11
/* 0 byte */
/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU
continues until the end of the frame) */
#define PDCP_NR_PAYLOAD_TAG 0x01
/* Called by RRC, or other configuration protocols */
/* Function to configure ciphering & integrity algorithms */
void set_pdcp_nr_security_algorithms(guint16 ueid, pdcp_nr_security_info_t *security_info);
/* Function to indicate securityModeCommand did not complete */
void set_pdcp_nr_security_algorithms_failed(guint16 ueid);
/* Called by external dissectors */
void set_pdcp_nr_rrc_ciphering_key(guint16 ueid, const char *key);
void set_pdcp_nr_rrc_integrity_key(guint16 ueid, const char *key);
void set_pdcp_nr_up_ciphering_key(guint16 ueid, const char *key);
void set_pdcp_nr_up_integrity_key(guint16 ueid, const char *key);
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
/* packet-rlc-lte.h
*
* Martin Mathieson
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PACKET_RLC_LTE_H
#define PACKET_RLC_LTE_H
/* rlcMode */
#define RLC_TM_MODE 1
#define RLC_UM_MODE 2
#define RLC_AM_MODE 4
#define RLC_PREDEF 8
/* direction */
#define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1
/* priority ? */
/* channelType */
#define CHANNEL_TYPE_CCCH 1
#define CHANNEL_TYPE_BCCH_BCH 2
#define CHANNEL_TYPE_PCCH 3
#define CHANNEL_TYPE_SRB 4
#define CHANNEL_TYPE_DRB 5
#define CHANNEL_TYPE_BCCH_DL_SCH 6
#define CHANNEL_TYPE_MCCH 7
#define CHANNEL_TYPE_MTCH 8
/* sequenceNumberLength */
#define UM_SN_LENGTH_5_BITS 5
#define UM_SN_LENGTH_10_BITS 10
#define AM_SN_LENGTH_10_BITS 10
#define AM_SN_LENGTH_16_BITS 16
typedef enum rlc_lte_nb_mode {
rlc_no_nb_mode = 0,
rlc_nb_mode = 1
} rlc_lte_nb_mode;
/* Info attached to each LTE RLC frame */
typedef struct rlc_lte_info
{
guint8 rlcMode;
guint8 direction;
guint8 priority;
guint8 sequenceNumberLength;
guint16 ueid;
guint16 channelType;
guint16 channelId; /* for SRB: 1=SRB1, 2=SRB2, 3=SRB1bis; for DRB: DRB ID */
guint16 pduLength;
gboolean extendedLiField;
rlc_lte_nb_mode nbMode;
} rlc_lte_info;
typedef struct rlc_lte_tap_info {
/* Info from context */
guint8 rlcMode;
guint8 direction;
guint8 priority;
guint16 ueid;
guint16 channelType;
guint16 channelId;
guint16 pduLength;
guint8 sequenceNumberLength;
nstime_t rlc_lte_time;
guint8 loggedInMACFrame;
guint16 sequenceNumber;
guint8 isResegmented;
guint8 isControlPDU;
guint16 ACKNo;
#define MAX_NACKs 128
guint16 noOfNACKs;
guint16 NACKs[MAX_NACKs];
guint16 missingSNs;
} rlc_lte_tap_info;
/* Signature. Rather than try to define a port for this, or make the
port number a preference, frames will start with this string (with no
terminating NULL */
#define RLC_LTE_START_STRING "rlc-lte"
/* Fixed field. This is followed by the following 1 mandatory field:
- rlcMode (1 byte)
(where the allowed values are defined above */
/* Conditional field. This field is mandatory in case of RLC Unacknowledged mode.
In case of RLC Acknowledged mode, the field is optional (assume 10 bits by default).
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag). The allowed values are defined above. */
#define RLC_LTE_SN_LENGTH_TAG 0x02
/* 1 byte */
/* Optional fields. Attaching this info to frames will allow you
to show you display/filter/plot/add-custom-columns on these fields, so should
be added if available.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag) */
#define RLC_LTE_DIRECTION_TAG 0x03
/* 1 byte */
#define RLC_LTE_PRIORITY_TAG 0x04
/* 1 byte */
#define RLC_LTE_UEID_TAG 0x05
/* 2 bytes, network order */
#define RLC_LTE_CHANNEL_TYPE_TAG 0x06
/* 2 bytes, network order */
#define RLC_LTE_CHANNEL_ID_TAG 0x07
/* 2 bytes, network order */
#define RLC_LTE_EXT_LI_FIELD_TAG 0x08
/* 0 byte, tag presence indicates that AM DRB PDU is using an extended LI field of 15 bits */
#define RLC_LTE_NB_MODE_TAG 0x09
/* 1 byte containing rlc_lte_nb_mode enum value */
/* RLC PDU. Following this tag comes the actual RLC PDU (there is no length, the PDU
continues until the end of the frame) */
#define RLC_LTE_PAYLOAD_TAG 0x01
#endif
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
/* packet-rlc-nr.h
*
* Pascal Quantin
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PACKET_RLC_NR_H
#define PACKET_RLC_NR_H
/* rlcMode */
#define RLC_TM_MODE 1
#define RLC_UM_MODE 2
#define RLC_AM_MODE 4
/* direction */
#define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1
/* bearerType */
#define BEARER_TYPE_CCCH 1
#define BEARER_TYPE_BCCH_BCH 2
#define BEARER_TYPE_PCCH 3
#define BEARER_TYPE_SRB 4
#define BEARER_TYPE_DRB 5
#define BEARER_TYPE_BCCH_DL_SCH 6
/* sequenceNumberLength */
#define TM_SN_LENGTH_0_BITS 0
#define UM_SN_LENGTH_6_BITS 6
#define UM_SN_LENGTH_12_BITS 12
#define AM_SN_LENGTH_12_BITS 12
#define AM_SN_LENGTH_18_BITS 18
/* Info attached to each NR RLC frame */
typedef struct rlc_nr_info
{
guint8 rlcMode;
guint8 direction;
guint8 sequenceNumberLength;
guint8 bearerType;
guint8 bearerId;
guint16 ueid;
guint16 pduLength;
} rlc_nr_info;
typedef struct nr_drb_rlc_pdcp_mapping_t
{
gboolean active;
guint16 ueid; /* Mandatory */
guint8 drbid; /* Mandatory */
gboolean pdcpUlSnLength_present;
guint8 pdcpUlSnLength; /* Part of PDCP config - optional */
gboolean pdcpDlSnLength_present;
guint8 pdcpDlSnLength; /* Part of PDCP config - optional */
gboolean pdcpUlSdap;
gboolean pdcpDlSdap;
gboolean pdcpIntegrityProtection;
gboolean pdcpCipheringDisabled;
} nr_drb_rlc_pdcp_mapping_t;
/* TODO: could probably merge this struct with above */
typedef struct pdcp_ue_parameters {
guint32 id;
guint8 pdcp_sn_bits_ul;
guint8 pdcp_sn_bits_dl;
gboolean pdcp_sdap_ul;
gboolean pdcp_sdap_dl;
gboolean pdcp_integrity;
gboolean pdcp_ciphering_disabled;
} pdcp_bearer_parameters;
/*****************************************************************/
/* UDP framing format */
/* ----------------------- */
/* Several people have asked about dissecting RLC by framing */
/* PDUs over IP. A suggested format over UDP has been defined */
/* and implemented by this dissector, using the definitions */
/* below. */
/* */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/*****************************************************************/
/* Signature. Rather than try to define a port for this, or make the
port number a preference, frames will start with this string (with no
terminating NULL */
#define RLC_NR_START_STRING "rlc-nr"
/* Fixed field. This is followed by the following 2 mandatory field:
- rlcMode (1 byte)
- sequenceNumberLength (1 byte)
(where the allowed values are defined above) */
/* Optional fields. Attaching this info to frames will allow you
to show you display/filter/plot/add-custom-columns on these fields, so should
be added if available.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag) */
#define RLC_NR_DIRECTION_TAG 0x02
/* 1 byte */
#define RLC_NR_UEID_TAG 0x03
/* 2 bytes, network order */
#define RLC_NR_BEARER_TYPE_TAG 0x04
/* 1 byte */
#define RLC_NR_BEARER_ID_TAG 0x05
/* 1 byte */
/* RLC PDU. Following this tag comes the actual RLC PDU (there is no length, the PDU
continues until the end of the frame) */
#define RLC_NR_PAYLOAD_TAG 0x01
#endif
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
/* packet-rohc.h
* Routines for RObust Header Compression (ROHC) dissection.
*
* Copyright 2011, Anders Broman <anders.broman[at]ericsson.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Ref:
* http://www.ietf.org/rfc/rfc3095.txt RObust Header Compression (ROHC): Framework and four profiles: RTP, UDP, ESP, and uncompressed
* http://datatracker.ietf.org/doc/rfc4815/ RObust Header Compression (ROHC): Corrections and Clarifications to RFC 3095
* http://datatracker.ietf.org/doc/rfc5225/ RObust Header Compression Version 2 (ROHCv2): Profiles for RTP, UDP, IP, ESP and UDP-Lite
*/
#ifndef PACKET_ROHC_H
#define PACKET_ROHC_H
#define MAX_CID 15
/* ROHC Profiles */
#define ROHC_PROFILE_UNCOMPRESSED 0
#define ROHC_PROFILE_RTP 1
#define ROHC_PROFILE_UDP 2
#define ROHC_PROFILE_IP 4
#define ROHC_PROFILE_UNKNOWN 0xFFFF
enum rohc_mode
{
MODE_NOT_SET = 0,
UNIDIRECTIONAL = 1,
OPTIMISTIC_BIDIRECTIONAL = 2,
RELIABLE_BIDIRECTIONAL = 3
};
enum rohc_d_mode
{
NO_CONTEXT = 1,
STATIC_CONTEXT = 2,
FULL_CONTEXT = 3
};
typedef struct rohc_info
{
gboolean rohc_compression;
guint8 rohc_ip_version;
gboolean cid_inclusion_info;
gboolean large_cid_present;
enum rohc_mode mode;
gboolean rnd;
gboolean udp_checksum_present;
guint16 profile;
proto_item *last_created_item;
} rohc_info;
typedef struct rohc_context
{
guint8 rohc_ip_version[MAX_CID+1];
gboolean large_cid_present[MAX_CID+1];
enum rohc_mode mode[MAX_CID+1];
enum rohc_d_mode d_mode[MAX_CID+1];
gboolean rnd[MAX_CID+1];
gboolean udp_checkum_present[MAX_CID+1];
guint16 profile[MAX_CID+1];
gboolean rohc_context_init[MAX_CID+1];
gint ir_frame_number[MAX_CID+1]; /* The frame number of the last IR packet seen */
} rohc_context;
#endif /* PACKET_ROHC_H */
......@@ -128,12 +128,6 @@ typedef struct {
opt_listener_t opt_listener;
static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
guint16 rnti, guint16 ueid, guint16 sysframeNumber,
guint8 isPredefinedData, guint8 retx, guint8 crcStatus,
guint8 oob_event, guint8 oob_event_value,
uint8_t *pdu_buffer, unsigned int pdu_buffer_size);
unsigned short checksum(unsigned short *ptr, int length) {
int sum = 0;
u_short answer = 0;
......@@ -152,7 +146,7 @@ unsigned short checksum(unsigned short *ptr, int length) {
}
/* Write an individual PDU (PCAP packet header + mac-context + mac-pdu) */
static int MAC_LTE_PCAP_WritePDU(const uint8_t *PDU,
static int PCAP_WritePDU(const uint8_t *PDU,
unsigned int length) {
pcaprec_hdr_t packet_header;
// IPv4 header
......@@ -288,7 +282,7 @@ int opt_create_listener_socket(char *ip_address, uint16_t port) {
*/
/* Add framing header to MAC PDU and send. */
static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
guint16 rnti, guint16 ueid, guint16 sfnSf,
guint16 rnti, guint16 ueid, guint16 frame, guint16 subframe,
guint8 isPredefinedData, guint8 retx, guint8 crcStatus,
guint8 oob_event, guint8 oob_event_value,
uint8_t *pdu_buffer, unsigned int pdu_buffer_size) {
......@@ -317,9 +311,9 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
tmp16 = htons(ueid);
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
/* Subframe number */
/* Subframe number */
frameBuffer[frameOffset++] = MAC_LTE_FRAME_SUBFRAME_TAG;
tmp16 = htons(sfnSf); // frame counter : this will give an expert info as wireshark expects SF and not F
tmp16 = htons((frame<<4)+subframe); // frame counter : this will give an expert info as wireshark expects SF and not F
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
frameBuffer[frameOffset++] = MAC_LTE_CRC_STATUS_TAG;
......@@ -400,7 +394,72 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
bytesSent = sendto(g_socksd, frameBuffer, frameOffset, 0,
(const struct sockaddr *)&g_serv_addr, sizeof(g_serv_addr));
else
bytesSent = MAC_LTE_PCAP_WritePDU(frameBuffer, frameOffset);
bytesSent = PCAP_WritePDU(frameBuffer, frameOffset);
if (bytesSent != frameOffset) {
LOG_W(OPT, "trace_pdu expected %d bytes, got %ld (errno=%d)\n",
frameOffset, bytesSent, errno);
//exit(1);
}
}
static void SendFrameNR(guint8 radioType, guint8 direction, guint8 rntiType,
guint16 rnti, guint16 ueid, guint16 frame, guint16 subframe,
guint8 isPredefinedData, guint8 retx, guint8 crcStatus,
guint8 oob_event, guint8 oob_event_value,
uint8_t *pdu_buffer, unsigned int pdu_buffer_size) {
unsigned char frameBuffer[9000];
unsigned int frameOffset;
ssize_t bytesSent;
frameOffset = 0;
uint16_t tmp16;
memcpy(frameBuffer+frameOffset, MAC_NR_START_STRING,
strlen(MAC_NR_START_STRING));
frameOffset += strlen(MAC_NR_START_STRING);
/******************************************************************************/
/* Now write out fixed fields (the mandatory elements of struct mac_lte_info) */
frameBuffer[frameOffset++] = radioType;
frameBuffer[frameOffset++] = direction;
frameBuffer[frameOffset++] = rntiType;
/*************************************/
/* Now optional fields */
/* RNTI */
frameBuffer[frameOffset++] = MAC_NR_RNTI_TAG;
tmp16 = htons(rnti);
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
/* UEId */
frameBuffer[frameOffset++] = MAC_NR_UEID_TAG;
tmp16 = htons(ueid);
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
/* Subframe number */
frameBuffer[frameOffset++] = MAC_NR_FRAME_SLOT_TAG;
tmp16 = htons(frame); // frame counter : this will give an expert info as wireshark expects SF and not F
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
tmp16 = htons(subframe); // frame counter : this will give an expert info as wireshark expects SF and not F
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
/***************************************/
/* Now write the MAC PDU */
frameBuffer[frameOffset++] = MAC_NR_PAYLOAD_TAG;
/* Append actual PDU */
//memcpy(frameBuffer+frameOffset, g_PDUBuffer, g_PDUOffset);
//frameOffset += g_PDUOffset;
if (pdu_buffer != NULL) {
memcpy(frameBuffer+frameOffset, (void *)pdu_buffer, pdu_buffer_size);
frameOffset += pdu_buffer_size;
}
if ( opt_type == OPT_WIRESHARK )
/* Send out the data over the UDP socket */
bytesSent = sendto(g_socksd, frameBuffer, frameOffset, 0,
(const struct sockaddr *)&g_serv_addr, sizeof(g_serv_addr));
else
bytesSent = PCAP_WritePDU(frameBuffer, frameOffset);
if (bytesSent != frameOffset) {
LOG_W(OPT, "trace_pdu expected %d bytes, got %ld (errno=%d)\n",
......@@ -413,20 +472,23 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
extern RAN_CONTEXT_t RC;
#include <openair1/PHY/phy_extern_ue.h>
/* Remote serveraddress (where Wireshark is running) */
void trace_pdu_implementation(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event,
int oob_event_value) {
int radioType=FDD_RADIO;
LOG_D(OPT,"sending packet to wireshark: direction=%s, size: %d, ueid: %d, rnti: %x, frame/sf: %d.%d\n",
direction?"DL":"UL", pdu_buffer_size, ueid, rnti, sysFrameNumber,subFrameNumber);
if (RC.eNB && RC.eNB[0][0]!=NULL)
radioType=RC.eNB[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
else if (PHY_vars_UE_g && PHY_vars_UE_g[0][0] != NULL)
radioType=PHY_vars_UE_g[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
else {
LOG_E(OPT,"not a eNB neither a UE!!! \n");
return;
if (nr) {
radioType=TDD_RADIO;
} else {
if (RC.eNB && RC.eNB[0][0]!=NULL)
radioType=RC.eNB[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
else if (PHY_vars_UE_g && PHY_vars_UE_g[0][0] != NULL)
radioType=PHY_vars_UE_g[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
else {
LOG_E(OPT,"not a 4G eNB neither a 4G UE!!! \n");
}
}
switch (opt_type) {
......@@ -448,9 +510,17 @@ void trace_pdu_implementation(int direction, uint8_t *pdu_buffer, unsigned int p
break;
}
if (nr)
SendFrameNR( radioType,
(direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK,
rntiType, rnti, ueid, sysFrameNumber, subFrameNumber,
1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus
oob_event,oob_event_value,
pdu_buffer, pdu_buffer_size);
else
SendFrame( radioType,
(direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK,
rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber,
rntiType, rnti, ueid, sysFrameNumber, subFrameNumber,
1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus
oob_event,oob_event_value,
pdu_buffer, pdu_buffer_size);
......
......@@ -142,7 +142,11 @@ extern int asn1_xer_print;
} \
} \
if (ie == NULL ) { \
NGAP_ERROR("NGAP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\
if (mandatory) {\
NGAP_ERROR("NGAP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL (searching for ie: %ld)\n",__FILE__,__LINE__, IE_ID);\
abort();\
}\
else NGAP_INFO("NGAP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL (searching for ie: %ld)\n",__FILE__,__LINE__, IE_ID);\
} \
} while(0)
/** \brief Function callback prototype.
......
......@@ -657,6 +657,7 @@ int ngap_gNB_handle_error_indication(uint32_t assoc_id,
case NGAP_CauseRadioNetwork_up_integrity_protection_not_possible:
NGAP_WARN("Received NG Error indication NGAP_CauseRadioNetwork_up_integrity_protection_not_possible\n");
break;
case NGAP_CauseRadioNetwork_up_confidentiality_protection_not_possible:
NGAP_WARN("Received NG Error indication NGAP_CauseRadioNetwork_up_confidentiality_protection_not_possible\n");
break;
......@@ -1069,13 +1070,14 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
//if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
NGAP_AllowedNSSAI_Item_t *allow_nssai_item_p = NULL;
NGAP_WARN("AllowedNSSAI.list.count %d\n", ie != NULL ? ie->value.choice.AllowedNSSAI.list.count : 2);
//NGAP_DEBUG("AllowedNSSAI.list.count %d\n", ie->value.choice.AllowedNSSAI.list.count);
//DevAssert(ie->value.choice.AllowedNSSAI.list.count > 0);
//DevAssert(ie->value.choice.AllowedNSSAI.list.count <= NGAP_maxnoofAllowedS_NSSAIs);
if (ie == NULL) {
NGAP_WARN("AllowedNSSAI not present, forging 2 NSSAI\n");
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_allowed_nssais = 2;
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).allowed_nssai[0].sST = 01;
......@@ -1092,7 +1094,7 @@ int ngap_gNB_handle_initial_context_request(uint32_t assoc_id,
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).allowed_nssai[1].sD[1] = 00;//22;
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).allowed_nssai[1].sD[2] = 01;//33;
} else {
NGAP_INFO("AllowedNSSAI.list.count %d\n", ie->value.choice.AllowedNSSAI.list.count);
NGAP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_allowed_nssais = ie->value.choice.AllowedNSSAI.list.count;
for(i = 0; i < ie->value.choice.AllowedNSSAI.list.count; i++) {
......
......@@ -581,7 +581,6 @@ void *trx_usrp_write_thread(void * arg){
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_USRP_SEND_RETURN, ret );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_THREAD, 0 );
if(0) break;
}
return NULL;
......
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