Added ConnectionSetup processing to mac_test.cc

master
ismagom 10 years ago
parent d46622d802
commit 8f40bb2f73

@ -104,8 +104,10 @@ bool bsr_proc::check_highest_channel() {
}
if (pending_data) {
pending_bsr.buff_size[lcg[pending_data_lcid]] = pending_data;
if (triggered_bsr_type != REGULAR) {
Info("Triggered REGULAR BSR for Max Priority LCID=%d\n", pending_data_lcid);
}
triggered_bsr_type = REGULAR;
Info("Triggered REGULAR BSR for Max Priority LCID=%d\n", pending_data_lcid);
return true;
} else {
return false;

@ -84,6 +84,7 @@ void sr_proc::start()
if (params_db->get_param(mac_params::SR_PUCCH_CONFIGURED)) {
if (!is_pending_sr) {
sr_counter = 0;
is_pending_sr = true;
dsr_transmax = params_db->get_param(mac_params::SR_TRANS_MAX);
Info("SR starting dsrTransMax=%d. Setting sr_counter=0\n", dsr_transmax);
}

@ -201,6 +201,7 @@ void setup_mac_phy_sib2(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2, srslte::u
void process_connsetup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *msg, srslte::ue::mac *mac, srslte::ue::phy *phy) {
mac->set_param(srslte::ue::mac_params::HARQ_MAXTX,
liblte_rrc_max_harq_tx_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.max_harq_tx]);
printf("Set MAX HARQ reTX: %d\n", liblte_rrc_max_harq_tx_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.max_harq_tx]);
phy->set_param(srslte::ue::phy_params::SR_PUCCH_RESINDEX,
msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx);
@ -211,12 +212,62 @@ void process_connsetup(LIBLTE_RRC_CONNECTION_SETUP_STRUCT *msg, srslte::ue::mac
liblte_rrc_dsr_trans_max_num[msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.dsr_trans_max]);
mac->set_param(srslte::ue::mac_params::SR_PUCCH_CONFIGURED, 1);
printf("Set SR configuration: TransMAX: %d, n_pucch=%d, configIndex=%d\n",
liblte_rrc_dsr_trans_max_num[msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.dsr_trans_max],
msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_pucch_resource_idx,
msg->rr_cnfg.phy_cnfg_ded.sched_request_cnfg.sr_cnfg_idx);
mac->set_param(srslte::ue::mac_params::BSR_TIMER_RETX,
liblte_rrc_retransmission_bsr_timer_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.retx_bsr_timer]);
mac->set_param(srslte::ue::mac_params::BSR_TIMER_PERIODIC,
liblte_rrc_periodic_bsr_timer_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.periodic_bsr_timer]);
printf("Set MAC BSR configuration: ReTX timer: %d, Periodic: %d\n",
liblte_rrc_retransmission_bsr_timer_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.retx_bsr_timer],
liblte_rrc_periodic_bsr_timer_num[msg->rr_cnfg.mac_main_cnfg.explicit_value.ulsch_cnfg.periodic_bsr_timer]);
phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_ACK, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ack_idx);
phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_CQI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_cqi_idx);
phy->set_param(srslte::ue::phy_params::UCI_I_OFFSET_RI, msg->rr_cnfg.phy_cnfg_ded.pusch_cnfg_ded.beta_offset_ri_idx);
// Setup radio bearers
for (int i=0;i<msg->rr_cnfg.srb_to_add_mod_list_size;i++) {
if (msg->rr_cnfg.srb_to_add_mod_list[i].lc_default_cnfg_present) {
printf("Setting up Default Configuration for SRB%d \n", msg->rr_cnfg.srb_to_add_mod_list[i].srb_id);
switch(msg->rr_cnfg.srb_to_add_mod_list[i].srb_id) {
case 1:
mac->setup_lcid(1, 0, 1, -1, -1);
break;
case 2:
mac->setup_lcid(2, 0, 3, -1, -1);
break;
}
}
}
for (int i=0;i<msg->rr_cnfg.drb_to_add_mod_list_size;i++) {
printf("Setting up DRB%d\n", msg->rr_cnfg.drb_to_add_mod_list[i].drb_id);
// todo
}
}
// Hex bytes for the connection setup complete packet
// Got hex bytes from http://www.sharetechnote.com/html/RACH_LTE.html
uint8_t setupComplete_segm[10][12] ={{0x88, 0x00, 0x00, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x01, 0x20, 0x80, 0x01, 0x00, 0x59, 0x17, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x02, 0x39, 0x45, 0xE5, 0x34, 0x0B, 0x07, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x03, 0x41, 0x02, 0x0B, 0xF6, 0x03, 0x02, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x04, 0x27, 0x80, 0x01, 0x00, 0xD0, 0xCC, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x05, 0x71, 0x51, 0x04, 0xE0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x06, 0xE0, 0xC0, 0x40, 0x00, 0x21, 0x02, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x07, 0x03, 0xD0, 0x11, 0xD1, 0x27, 0x1A, 0x0, 0x0, 0x0, 0x0},
{0x98, 0x08, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x0, 0x0, 0x0, 0x0},
{0xB0, 0x09, 0x00, 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06}};
uint8_t last_segm[54];
uint32_t lengths[10] = {4, 8, 8, 8, 8, 6, 8, 8, 8, 12};
int main(int argc, char *argv[])
{
prog_args_t prog_args;
@ -265,7 +316,7 @@ int main(int argc, char *argv[])
uint32_t si_window_len, sib2_period;
int tti;
enum {START, SIB1, SIB2, CONNECT} state = START;
enum {START, SIB1, SIB2, CONNECT, SETUPCOMPLETE} state = START;
int n;
while(1) {
@ -342,6 +393,29 @@ int main(int argc, char *argv[])
case LIBLTE_RRC_DL_CCCH_MSG_TYPE_RRC_CON_SETUP:
// Process ConnectionSetup
process_connsetup(&dl_ccch_msg.msg.rrc_con_setup, &mac, &phy);
// Generate and send ConnectionSetupComplete
for (int i=0;i<9;i++) {
printf("Sending Connection Setup Complete %d\n", i);
srslte_bit_pack_vector(setupComplete_segm[i], bit_msg.msg, lengths[i]);
n=mac.send_dcch0_sdu(bit_msg.msg, lengths[i]*8);
if (n < 0) {
fprintf(stderr, "Error writting to DCCH0\n");
exit(-1);
}
}
// Last segment is 54 bytes long
printf("Sending Connection Setup Complete Last segment\n");
bzero(last_segm, 54*sizeof(uint8_t));
memcpy(last_segm, setupComplete_segm[9], lengths[9]*sizeof(uint8_t));
srslte_bit_pack_vector(last_segm, bit_msg.msg, 54);
n=mac.send_dcch0_sdu(bit_msg.msg, 54*8);
if (n < 0) {
fprintf(stderr, "Error writting to DCCH0\n");
exit(-1);
}
state = SETUPCOMPLETE;
break;
case LIBLTE_RRC_DL_CCCH_MSG_TYPE_RRC_CON_REJ:
mac.set_param(srslte::ue::mac_params::RNTI_C, 0);
@ -350,6 +424,13 @@ int main(int argc, char *argv[])
// exit(0);
}
break;
case SETUPCOMPLETE:
// Wait for ConnectionSetup
n = mac.recv_dtch0_sdu(bit_msg.msg, LIBLTE_MAX_MSG_SIZE);
if (n > 0) {
printf("Received on DTCH0 %d bytes\n", n/8);
}
break;
}
usleep(10000);

@ -185,6 +185,7 @@ void phy::send_sr(bool enable)
return;
}
sr_n_pucch = params_db.get_param(phy_params::SR_PUCCH_RESINDEX);
Info("SR I_sr=%d, periodicity=%d, N_offset=%d, n_pucch=%d\n", I_sr, sr_periodicity, sr_N_offset, sr_n_pucch);
}
sr_enabled = enable;
}
@ -192,6 +193,7 @@ void phy::send_sr(bool enable)
bool phy::sr_is_ready_to_send(uint32_t tti_) {
if (sr_enabled) {
if ((10*tti_to_SFN(tti_)+tti_to_subf(tti_)-sr_N_offset)%sr_periodicity==0) {
Info("SR ready to send\n");
return true;
}
}

@ -96,6 +96,7 @@ bool ul_buffer::generate_cqi_report()
bool ul_buffer::generate_sr() {
uci_data.scheduling_request = true;
uci_pending = true;
Info("SR Generating\n");
return true;
}

Loading…
Cancel
Save