Commit 153af28d authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

first version for supporting PC5-S

parent d5d6ecab
...@@ -34,7 +34,7 @@ OAI build/execute ...@@ -34,7 +34,7 @@ OAI build/execute
- cp ../../../targets/bin/.usim* . - cp ../../../targets/bin/.usim* .
- sudo insmod ../../../targets/bin/ue_ip.ko - sudo insmod ../../../targets/bin/ue_ip.ko
UE1: UE1:
- sudo ifconfig oip0 10.0.0.1 - sudo ifconfig oip0 10.0.0.1
- sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.1 -j MARK --set-mark 3 - sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.1 -j MARK --set-mark 3
- (if necessary) sudo route add default gw 10.10.10.1 eth0 - (if necessary) sudo route add default gw 10.10.10.1 eth0
...@@ -42,8 +42,11 @@ UE2: ...@@ -42,8 +42,11 @@ UE2:
- sudo ifconfig oip1 10.0.0.2 - sudo ifconfig oip1 10.0.0.2
- sudo iptables -A POSTROUTING -t mangle -o oip1 -d 224.0.0.1 -j MARK --set-mark 3 - sudo iptables -A POSTROUTING -t mangle -o oip1 -d 224.0.0.1 -j MARK --set-mark 3
- (if necessary) sudo route add default gw 10.10.10.1 eth0 - (if necessary) sudo route add default gw 10.10.10.1 eth0
Run UE1, then UE2
- sudo ./lte-softmodem-stub -U --emul_iface eth0 TEST ONE-TO-MANY
Run UE1 then UE2, for example:
UE1: sudo ./lte-softmodem-stub -U --emul_iface eth0
UE2: sudo ./lte-softmodem-stub -U --emul_iface eno1
Test with Ping Test with Ping
- Sender - UE1: ping -I oip0 224.0.0.1 - Sender - UE1: ping -I oip0 224.0.0.1
...@@ -57,5 +60,3 @@ Test with Iperf ...@@ -57,5 +60,3 @@ Test with Iperf
...@@ -1368,6 +1368,7 @@ typedef struct { ...@@ -1368,6 +1368,7 @@ typedef struct {
int sltx_active; int sltx_active;
SLSCH_t slsch; SLSCH_t slsch;
ULSCH_PDU slsch_pdu; ULSCH_PDU slsch_pdu;
int slsch_lcid;
#endif #endif
/// number of attempt for rach /// number of attempt for rach
uint8_t RA_attempt_number; uint8_t RA_attempt_number;
......
...@@ -77,6 +77,7 @@ extern UL_IND_t *UL_INFO; ...@@ -77,6 +77,7 @@ extern UL_IND_t *UL_INFO;
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
/* /*
*
#ifndef USER_MODE #ifndef USER_MODE
#define msg debug_msg #define msg debug_msg
#endif #endif
...@@ -753,7 +754,6 @@ void ue_send_sl_sdu(module_id_t module_idP, ...@@ -753,7 +754,6 @@ void ue_send_sl_sdu(module_id_t module_idP,
int rlc_sdu_len; int rlc_sdu_len;
char *rlc_sdu; char *rlc_sdu;
uint32_t sourceL2Id;
uint32_t destinationL2Id =0x00000000; uint32_t destinationL2Id =0x00000000;
// Notes: 1. no control elements are supported yet // Notes: 1. no control elements are supported yet
...@@ -762,7 +762,7 @@ void ue_send_sl_sdu(module_id_t module_idP, ...@@ -762,7 +762,7 @@ void ue_send_sl_sdu(module_id_t module_idP,
// extract header // extract header
SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu; SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu;
AssertFatal(longh->E==0,"E is non-zero\n"); AssertFatal(longh->E==0,"E is non-zero\n");
AssertFatal(longh->LCID==3,"LCID is %d (not 3)\n",longh->LCID); AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID);
//filter incoming packet based on destination address //filter incoming packet based on destination address
destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623); destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
LOG_I( MAC, "[DestinationL2Id: %"PRIu32"] \n", destinationL2Id ); LOG_I( MAC, "[DestinationL2Id: %"PRIu32"] \n", destinationL2Id );
...@@ -771,7 +771,6 @@ void ue_send_sl_sdu(module_id_t module_idP, ...@@ -771,7 +771,6 @@ void ue_send_sl_sdu(module_id_t module_idP,
LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n"); LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
return; return;
} }
//AssertFatal(((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (destinationL2Id == UE_mac_inst[module_idP].groupL2Id)), "Destination Id is neither matched with Source Id nor with Group Id \n")
if (longh->F==1) { if (longh->F==1) {
rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF); rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF);
...@@ -788,7 +787,7 @@ void ue_send_sl_sdu(module_id_t module_idP, ...@@ -788,7 +787,7 @@ void ue_send_sl_sdu(module_id_t module_idP,
frameP, frameP,
ENB_FLAG_NO, ENB_FLAG_NO,
MBMS_FLAG_NO, MBMS_FLAG_NO,
3, longh->LCID, //3/10
rlc_sdu, rlc_sdu,
rlc_sdu_len, rlc_sdu_len,
1, 1,
...@@ -2736,11 +2735,12 @@ SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t ...@@ -2736,11 +2735,12 @@ SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t
SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) { SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) {
mac_rlc_status_resp_t rlc_status; mac_rlc_status_resp_t rlc_status, rlc_status_data;
uint32_t absSF = (frameP*10)+subframeP; uint32_t absSF = (frameP*10)+subframeP;
UE_MAC_INST *ue = &UE_mac_inst[module_idP]; UE_MAC_INST *ue = &UE_mac_inst[module_idP];
int rvtab[4] = {0,2,3,1}; int rvtab[4] = {0,2,3,1};
int sdu_length; int sdu_length;
// Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH) // Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH)
SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch; SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch;
...@@ -2748,13 +2748,25 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -2748,13 +2748,25 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
ue->sltx_active = 0; ue->sltx_active = 0;
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO, rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
10,
0xFFFF);//for signaling - hardcoded
rlc_status_data = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3, 3,
0xFFFF); 0xFFFF); //for data - hardcoded
if (rlc_status.bytes_in_buffer > 2) {
if (rlc_status.bytes_in_buffer > 2){
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer); LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications // Fill in group id for off-network communications
ue->sltx_active = 1; ue->sltx_active = 1;
ue->slsch_lcid = 10;
}
else if (rlc_status_data.bytes_in_buffer >2){
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status_data.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
ue->slsch_lcid = 3;
} }
} // we're not in the SCCH period } // we're not in the SCCH period
else if (((absSF & 3) == 0 ) && else if (((absSF & 3) == 0 ) &&
...@@ -2763,12 +2775,13 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -2763,12 +2775,13 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
int TBS = 4584/8; int TBS = 4584/8;
int req; int req;
if (ue->slsch_lcid == 10) {
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (TBS<=rlc_status.bytes_in_buffer) req=TBS; if (TBS<=rlc_status.bytes_in_buffer) req=TBS;
else req = rlc_status.bytes_in_buffer; else req = rlc_status.bytes_in_buffer;
} else if (ue->slsch_lcid == 3){
if (TBS<=rlc_status_data.bytes_in_buffer) req=TBS;
else req = rlc_status_data.bytes_in_buffer;
}
if (req>0) { if (req>0) {
sdu_length = mac_rlc_data_req(module_idP, sdu_length = mac_rlc_data_req(module_idP,
...@@ -2777,7 +2790,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -2777,7 +2790,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
frameP, frameP,
ENB_FLAG_NO, ENB_FLAG_NO,
MBMS_FLAG_NO, MBMS_FLAG_NO,
3, ue->slsch_lcid,
req, req,
(char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG))); (char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG)));
...@@ -2787,8 +2800,8 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -2787,8 +2800,8 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
if (sdu_length > 0) { if (sdu_length > 0) {
LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req); LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req);
LOG_I(MAC,"sourceL2Id %d: \n",ue->sourceL2Id); LOG_I(MAC,"sourceL2Id: %d \n",ue->sourceL2Id);
LOG_I(MAC,"groupL2Id %d: \n",ue->groupL2Id); LOG_I(MAC,"groupL2Id: %d \n",ue->groupL2Id);
slsch->payload = (unsigned char*)ue->slsch_pdu.payload; slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
if (sdu_length < 128) { if (sdu_length < 128) {
...@@ -2797,14 +2810,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -2797,14 +2810,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
shorth->F=0; shorth->F=0;
shorth->L=sdu_length; shorth->L=sdu_length;
shorth->E=0; shorth->E=0;
shorth->LCID=3; shorth->LCID=ue->slsch_lcid;
/* shorth->SRC07=0x12;
shorth->SRC1623=0x56;
shorth->SRC815=0x34;
shorth->DST07=0x78;
shorth->DST815=0x9A;
shorth->DST1623=0xBC;*/
shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff; shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff;
shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
shorth->SRC1623 = ue->sourceL2Id & 0x000000ff; shorth->SRC1623 = ue->sourceL2Id & 0x000000ff;
...@@ -2820,15 +2826,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_ ...@@ -2820,15 +2826,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
longh->L_LSB=sdu_length&0xff; longh->L_LSB=sdu_length&0xff;
longh->L_MSB=(sdu_length>>8)&0x7f; longh->L_MSB=(sdu_length>>8)&0x7f;
longh->E=0; longh->E=0;
longh->LCID=3; longh->LCID=ue->slsch_lcid;
/*
longh->SRC07=0x12;
longh->SRC815=0x34;
longh->SRC1623=0x56;
longh->DST07=0x78;
longh->DST815=0x9A;
longh->DST1623=0xBC;
*/
longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff; longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff;
longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff; longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
longh->SRC1623 = ue->sourceL2Id & 0x000000ff; longh->SRC1623 = ue->sourceL2Id & 0x000000ff;
......
...@@ -403,6 +403,54 @@ struct pdcp_netlink_element_s { ...@@ -403,6 +403,54 @@ struct pdcp_netlink_element_s {
uint8_t *data; uint8_t *data;
}; };
//TTN for D2D (PC5S)
#ifdef Rel14
#define PDCP_SOCKET_PORT_NO 9999 //temporary value
int pdcp_pc5_sockfd;
struct sockaddr_in prose_app_addr;
struct sockaddr_in pdcp_sin;
int pdcp_pc5_socket_init();
typedef enum SL_PC5S_TYPES_e {
SL_PC5S_INIT=1,
SL_DIRECT_COMMUNICATION_REQUEST,
SL_DIRECT_COMMUNICATION_ACCEPT,
SL_DIRECT_COMMUNICATION_REJECT,
SL_DIRECT_SECURITY_MODE_COMMAND,
SL_DIRECT_SECURITY_MODE_COMPLETE
} SL_PC5S_TYPES_t;
typedef struct {
SL_PC5S_TYPES_t msg_type;
uint16_t rb_id;
int32_t data_size;
uint8_t inst;
} __attribute__((__packed__)) pdcp_data_header_t;
//should be completed with other IEs (3GPP TS 24.334)
typedef struct {
uint16_t sequenceNumber;
uint8_t ipAddressConfig;
} __attribute__((__packed__)) PC5SDirectCommunicationRequest;
typedef struct {
uint16_t sequenceNumber;
uint8_t ipAddressConfig;
} __attribute__((__packed__)) PC5SDirectCommunicationAccept;
//example of PC5-S messages
typedef struct {
pdcp_data_header_t pdcp_data_header;
union {
PC5SDirectCommunicationRequest pc5s_direct_communication_req;
PC5SDirectCommunicationAccept pc5s_direct_communication_accept;
uint8_t status;
} pc5sPrimitive;
} __attribute__((__packed__)) sidelink_pc5s_element;
#endif
#if 0 #if 0
/* /*
* Missing PDU information struct, a copy of this will be enqueued * Missing PDU information struct, a copy of this will be enqueued
......
...@@ -64,6 +64,7 @@ extern int otg_enabled; ...@@ -64,6 +64,7 @@ extern int otg_enabled;
#include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/vcd_signal_dumper.h"
#include "platform_constants.h" #include "platform_constants.h"
#include "msc.h" #include "msc.h"
#include "pdcp.h"
#include "assertions.h" #include "assertions.h"
...@@ -116,9 +117,9 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) ...@@ -116,9 +117,9 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
{ {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//#if defined(PDCP_USE_NETLINK) && defined(LINUX) //#if defined(PDCP_USE_NETLINK) && defined(LINUX)
int ret = 0; int ret = 0;
//#endif //#endif
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU #ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
#define THREAD_NAME_LEN 16 #define THREAD_NAME_LEN 16
...@@ -171,7 +172,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) ...@@ -171,7 +172,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
#else #else
#if ! defined(OAI_EMU) #if ! defined(OAI_EMU)
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; // ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
#endif #endif
#endif #endif
...@@ -205,6 +206,45 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) ...@@ -205,6 +206,45 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
#endif //PDCP_DEBUG #endif //PDCP_DEBUG
cont = 0; cont = 0;
//TTN - for D2D (PC5S)
#ifdef Rel14
sidelink_pc5s_element *sl_pc5s_msg_recv = NULL;
sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
char send_buf[BUFSIZE];
if ((((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id) == 10) { //hardcoded for PC5-Signaling
#ifdef PDCP_DEBUG
sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element));
memcpy((void*)sl_pc5s_msg_recv, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element));
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header msg_type: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.msg_type);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header rb_id: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.rb_id);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header data_size: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.data_size);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header inst: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.inst);
if (sl_pc5s_msg_recv->pdcp_data_header.msg_type == SL_DIRECT_COMMUNICATION_REQUEST){
LOG_D(PDCP,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S), seqno: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.sequenceNumber);
LOG_D(PDCP,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S), ipAddressConfig: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.ipAddressConfig);
}
//send to ProSe app
LOG_D(RRC,"[pdcp_fifo_flush_sdus]: Send DirectCommunicationRequest to ProSe App \n");
#endif
memset(send_buf, 0, BUFSIZE);
//memcpy((void *)send_buf, (void *)sl_pc5s_msg_recv, sizeof(sidelink_pc5s_element));
memcpy((void *)send_buf, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element));
//free(sl_ctrl_msg_send);
int prose_addr_len = sizeof(prose_app_addr);
int n = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
if (n < 0) {
LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
}
}
#endif
if (!pdcp_output_sdu_bytes_to_write) { if (!pdcp_output_sdu_bytes_to_write) {
if (!pdcp_output_header_bytes_to_write) { if (!pdcp_output_header_bytes_to_write) {
pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t);
...@@ -332,6 +372,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) ...@@ -332,6 +372,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
#else // PDCP_USE_RT_FIFO #else // PDCP_USE_RT_FIFO
bytes_wrote = pdcp_output_sdu_bytes_to_write; bytes_wrote = pdcp_output_sdu_bytes_to_write;
#endif // PDCP_USE_RT_FIFO #endif // PDCP_USE_RT_FIFO
LOG_D(PDCP, "THINH 2 bytes_wrote = %d\n", bytes_wrote);
if (bytes_wrote > 0) { if (bytes_wrote > 0) {
pdcp_output_sdu_bytes_to_write -= bytes_wrote; pdcp_output_sdu_bytes_to_write -= bytes_wrote;
...@@ -393,6 +434,21 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -393,6 +434,21 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
(void)data_p; (void)data_p;
module_id_t ue_id = 0; module_id_t ue_id = 0;
pdcp_t* pdcp_p = NULL; pdcp_t* pdcp_p = NULL;
//TTN for D2D (PC5S)
#ifdef Rel14
int prose_addr_len;
char send_buf[BUFSIZE], receive_buf[BUFSIZE];
int optval;
int bytes_received;
sidelink_pc5s_element *sl_pc5s_msg_recv = NULL;
sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
uint32_t sourceL2Id;
uint32_t groupL2Id;
module_id_t module_id = 0;
pdcp_data_header_t *pdcp_data_header;
#endif
# if defined(PDCP_USE_NETLINK_QUEUES) # if defined(PDCP_USE_NETLINK_QUEUES)
rb_id_t rab_id = 0; rb_id_t rab_id = 0;
...@@ -510,6 +566,216 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -510,6 +566,216 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
rb_id_t rab_id = 0; rb_id_t rab_id = 0;
int rlc_data_req_flag = 3; int rlc_data_req_flag = 3;
//TTN for D2D (PC5S)
#ifdef Rel14
// module_id = 0 ; //hardcoded for testing only
prose_addr_len = sizeof(prose_app_addr);
// receive a message from ProSe App
memset(receive_buf, 0, BUFSIZE);
bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
(struct sockaddr *) &prose_app_addr, &prose_addr_len);
// if (bytes_received < 0){
// LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n");
// exit(EXIT_FAILURE);
// }
if (bytes_received > 0) {
pdcp_data_header = calloc(1, sizeof(pdcp_data_header_t));
memcpy((void *)pdcp_data_header, (void *)receive_buf, sizeof(pdcp_data_header_t));
if (pdcp_data_header->msg_type == SL_PC5S_INIT){
//send reply to ProSe app
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus]: Send response to ProSe App [PDCP socket]\n");
memset(send_buf, 0, BUFSIZE);
sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element));
sl_pc5s_msg_send->pdcp_data_header.msg_type = SL_PC5S_INIT;
sl_pc5s_msg_send->pc5sPrimitive.status = 1;
memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element));
int prose_addr_len = sizeof(prose_app_addr);
int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
if (bytes_sent < 0) {
LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
}
} else if (pdcp_data_header->msg_type > SL_PC5S_INIT) { //if containing PC5-S message -> send to other UE
#ifdef PDCP_DEBUG
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus] Received PC5-S message, msg_type: %d)\n", pdcp_data_header->msg_type);
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus] Received PC5-S message, rbid: %d)\n", pdcp_data_header->rb_id);
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus] Received PC5-S message, data_size: %d)\n", pdcp_data_header->data_size);
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus] Received PC5-S message, inst: %d)\n", pdcp_data_header->inst);
sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element));
memcpy((void *)sl_pc5s_msg_recv, (void *)receive_buf, sizeof(sidelink_pc5s_element));
if (pdcp_data_header->msg_type == SL_DIRECT_COMMUNICATION_REQUEST){
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus] Received DirectCommunicationRequest (PC5-S), seqno: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.sequenceNumber);
LOG_D(PDCP,"[pdcp_fifo_read_input_sdus] Received DirectCommunicationRequest (PC5-S), ipAddressConfig: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.ipAddressConfig);
}
#endif
#ifdef OAI_EMU
// overwrite function input parameters, because only one netlink socket for all instances
if (pdcp_data_header->inst < oai_emulation.info.nb_enb_local) {
ctxt.frame = ctxt_cpy.frame;
ctxt.enb_flag = ENB_FLAG_YES;
ctxt.module_id = pdcp_data_header.inst + oai_emulation.info.first_enb_local;
ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_data_header->rb_id / maxDRB + oai_emulation.info.first_ue_local];
rab_id = pdcp_data_header->rb_id % maxDRB;
} else {
ctxt.frame = ctxt_cpy.frame;
ctxt.enb_flag = ENB_FLAG_NO;
ctxt.module_id = pdcp_data_header->inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local;
ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
rab_id = pdcp_data_header->rb_id % maxDRB;
}
CHECK_CTXT_ARGS(&ctxt);
AssertFatal (rab_id < maxDRB, "RB id is too high (%u/%d)!\n", rab_id, maxDRB);
/*LGpdcp_read_header.inst = (pdcp_data_header.inst >= oai_emulation.info.nb_enb_local) ? \
pdcp_data_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
pdcp_data_header.inst + oai_emulation.info.first_enb_local;*/
#else // OAI_EMU
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// pdcp_data_header.inst = 0;
//#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
ctxt.frame = ctxt_cpy.frame;
ctxt.enb_flag = ctxt_cpy.enb_flag;
LOG_I(PDCP, "[PDCP] pdcp_data_header->rb_id = %d\n", pdcp_data_header->rb_id);
if (ctxt_cpy.enb_flag) {
ctxt.module_id = 0;
rab_id = pdcp_data_header->rb_id % maxDRB;
ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index];
} else {
ctxt.module_id = 0;
rab_id = pdcp_data_header->rb_id % maxDRB;
ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
}
#endif
//UE
if (!ctxt.enb_flag) {
if (rab_id != 0) {
if (rab_id == UE_IP_DEFAULT_RAB_ID) {
LOG_I(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n",
key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
} else {
rab_id = rab_id % maxDRB;
LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n",
key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
}
if (h_rc == HASH_TABLE_OK) {
rab_id = pdcp_p->rb_id;
#ifdef PDCP_DEBUG
LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n",
ctxt.frame,
pdcp_data_header->inst,
bytes_received,
pdcp_data_header->rb_id);
LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
ctxt.frame,
pdcp_data_header->inst,
pdcp_data_header->rb_id,
pdcp_data_header->data_size,
ctxt.module_id,
ctxt.rnti,
rab_id);
#endif
MSC_LOG_RX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,
0,
MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
pdcp_data_header.inst,
pdcp_data_header.rb_id,
rab_id,
pdcp_data_header.data_size);
pdcp_data_req(
&ctxt,
SRB_FLAG_NO,
rab_id,
RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO,
pdcp_data_header->data_size,
(unsigned char *)receive_buf,
PDCP_TRANSMISSION_MODE_DATA);
} else {
MSC_LOG_RX_DISCARDED_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,
0,
MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
pdcp_data_header.inst,
pdcp_data_header.rb_id,
rab_id,
pdcp_data_header.data_size);
LOG_D(PDCP,
"[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
ctxt.frame,
pdcp_data_header->inst,
pdcp_data_header->rb_id,
pdcp_data_header->data_size,
ctxt.module_id,
ctxt.rnti,
rab_id,
key);
}
} else { //if (rab_id == 0)
LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
ctxt.frame,
pdcp_data_header->inst,
pdcp_data_header->rb_id,
pdcp_data_header->data_size,
ctxt.module_id,
ctxt.rnti,
DEFAULT_RAB_ID);
MSC_LOG_RX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,0,
MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
pdcp_data_header->inst,
pdcp_data_header->rb_id,
DEFAULT_RAB_ID,
pdcp_data_header->data_size);
pdcp_data_req (
&ctxt,
SRB_FLAG_NO,
DEFAULT_RAB_ID,
RLC_MUI_UNDEFINED,
RLC_SDU_CONFIRM_NO,
pdcp_data_header->data_size,
(unsigned char *)receive_buf,
PDCP_TRANSMISSION_MODE_DATA);
}
}
free (sl_pc5s_msg_recv);
free (sl_pc5s_msg_send);
}
}
#endif
while ((len > 0) && (rlc_data_req_flag !=0)) { while ((len > 0) && (rlc_data_req_flag !=0)) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 );
...@@ -555,6 +821,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -555,6 +821,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
#ifdef OAI_EMU #ifdef OAI_EMU
// overwrite function input parameters, because only one netlink socket for all instances // overwrite function input parameters, because only one netlink socket for all instances
if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) {
ctxt.frame = ctxt_cpy.frame; ctxt.frame = ctxt_cpy.frame;
...@@ -577,8 +844,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -577,8 +844,8 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/ pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/
#else // OAI_EMU #else // OAI_EMU
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */ /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// pdcp_read_header_g.inst = 0; // pdcp_read_header_g.inst = 0;
//#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id" //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
ctxt.frame = ctxt_cpy.frame; ctxt.frame = ctxt_cpy.frame;
ctxt.enb_flag = ctxt_cpy.enb_flag; ctxt.enb_flag = ctxt_cpy.enb_flag;
...@@ -655,7 +922,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -655,7 +922,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
} }
} else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast
// is a broadcast packet, we have to send this packet on all default RABS of all connected UEs // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs
//#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES
for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) { for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) {
if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) { if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) {
ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id]; ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id];
...@@ -800,6 +1067,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) ...@@ -800,6 +1067,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 );
} }
return len; return len;
# endif # endif
#else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO #else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO
...@@ -980,3 +1248,118 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP) ...@@ -980,3 +1248,118 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const ctxt_pP)
#endif #endif
} }
//TTN for D2D (PC5S)
#ifdef Rel14
int
pdcp_pc5_socket_init() {
pthread_attr_t attr;
struct sched_param sched_param;
int optval; // flag value for setsockopt
int n; // message byte size
//create PDCP socket
pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (pdcp_pc5_sockfd < 0){
LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno));
exit(EXIT_FAILURE);
}
optval = 1;
setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR,
(const void *)&optval , sizeof(int));
fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK);
bzero((char *) &pdcp_sin, sizeof(pdcp_sin));
pdcp_sin.sin_family = AF_INET;
pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY);
pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO);
// associate the parent socket with a port
if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin,
sizeof(pdcp_sin)) < 0) {
LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n");
exit(1);
}
}
//--------------------------------------------------------
void *pdcp_pc5_socket_thread_fct(void *arg)
{
int prose_addr_len;
char send_buf[BUFSIZE];
char receive_buf[BUFSIZE];
int optval; // flag value for setsockopt
int n; // message byte size
sidelink_pc5s_element *sl_pc5s_msg_recv = NULL;
sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
uint32_t sourceL2Id;
uint32_t groupL2Id;
module_id_t module_id;
module_id = 0 ; //hardcoded for testing only
LOG_I(PDCP,"*****************[pdcp_pc5_socket_thread_fct]**************\n");
//from the main program, listen for the incoming messages from control socket (ProSe App)
prose_addr_len = sizeof(prose_app_addr);
while (1) {
LOG_I(RRC,"[pdcp_pc5_socket_thread_fct]: Listening to incoming connection from ProSe App \n");
// receive a message from ProSe App
memset(receive_buf, 0, BUFSIZE);
n = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
(struct sockaddr *) &prose_app_addr, &prose_addr_len);
if (n < 0){
LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n");
exit(EXIT_FAILURE);
}
sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element));
memcpy((void *)sl_pc5s_msg_recv, (void *)receive_buf, sizeof(sidelink_pc5s_element));
//process the message (in reality, we don't need to do that, thus, forward to other ue)
// LOG_I(RRC,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S) on socket from ProSe App (msg type: %d)\n", sl_pc5s_msg_recv->type);
//TODO: get SL_UE_STATE from lower layer
/*
LOG_I(RRC,"[rrc_control_socket_thread_fct]: Send UEStateInformation to ProSe App \n");
memset(send_buf, 0, BUFSIZE);
sl_ctrl_msg_send = calloc(1, sizeof(struct sidelink_ctrl_element));
sl_ctrl_msg_send->type = UE_STATUS_INFO;
sl_ctrl_msg_send->sidelinkPrimitive.ue_state = UE_STATE_OFF_NETWORK; //off-network
memcpy((void *)send_buf, (void *)sl_ctrl_msg_send, sizeof(struct sidelink_ctrl_element));
free(sl_ctrl_msg_send);
prose_addr_len = sizeof(prose_app_addr);
n = sendto(ctrl_sock_fd, (char *)send_buf, sizeof(struct sidelink_ctrl_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
if (n < 0) {
LOG_E(RRC, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
}
#ifdef DEBUG_CTRL_SOCKET
struct sidelink_ctrl_element *ptr_ctrl_msg = NULL;
ptr_ctrl_msg = (struct sidelink_ctrl_element *) send_buf;
LOG_I(RRC,"[rrc_control_socket_thread_fct][UEStateInformation] msg type: %d\n",ptr_ctrl_msg->type);
LOG_I(RRC,"[rrc_control_socket_thread_fct][UEStateInformation] UE state: %d\n",ptr_ctrl_msg->sidelinkPrimitive.ue_state);
#endif
*/
}
free (sl_pc5s_msg_recv);
return 0;
}
#endif
...@@ -84,8 +84,6 @@ static uint32_t *pdcp_netlink_nb_element_ue = NULL; ...@@ -84,8 +84,6 @@ static uint32_t *pdcp_netlink_nb_element_ue = NULL;
time_stats_t ip_pdcp_stats_tmp; time_stats_t ip_pdcp_stats_tmp;
static void *pdcp_netlink_thread_fct(void *arg);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int int
pdcp_netlink_init( pdcp_netlink_init(
...@@ -152,6 +150,8 @@ pdcp_netlink_init( ...@@ -152,6 +150,8 @@ pdcp_netlink_init(
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
sched_param.sched_priority = 10; sched_param.sched_priority = 10;
pthread_attr_setschedpolicy(&attr, SCHED_RR); pthread_attr_setschedpolicy(&attr, SCHED_RR);
...@@ -168,6 +168,7 @@ pdcp_netlink_init( ...@@ -168,6 +168,7 @@ pdcp_netlink_init(
} }
pthread_setname_np( pdcp_netlink_thread, "PDCP netlink" ); pthread_setname_np( pdcp_netlink_thread, "PDCP netlink" );
} }
return 0; return 0;
...@@ -218,6 +219,7 @@ void *pdcp_netlink_thread_fct(void *arg) ...@@ -218,6 +219,7 @@ void *pdcp_netlink_thread_fct(void *arg)
len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); len = recvmsg(nas_sock_fd, &nas_msg_rx, 0);
if (len == 0) { if (len == 0) {
/* Other peer (kernel) has performed an orderly shutdown /* Other peer (kernel) has performed an orderly shutdown
*/ */
...@@ -311,8 +313,11 @@ void *pdcp_netlink_thread_fct(void *arg) ...@@ -311,8 +313,11 @@ void *pdcp_netlink_thread_fct(void *arg)
} }
} }
} }
} }
return NULL; return NULL;
} }
#endif #endif
...@@ -63,4 +63,7 @@ extern void pdcp_process_input_sdus_tr (struct pdcp_entity *pdcpP); ...@@ -63,4 +63,7 @@ extern void pdcp_process_input_sdus_tr (struct pdcp_entity *pdcpP);
extern void init_pdcp (struct pdcp_entity *pdcpP, struct rb_dispatcher *rbP, uint8_t rb_idP); extern void init_pdcp (struct pdcp_entity *pdcpP, struct rb_dispatcher *rbP, uint8_t rb_idP);
extern void *pdcp_tx (void *argP); extern void *pdcp_tx (void *argP);
#endif #endif
void pdcp_pc5_socket_init();
#endif #endif
...@@ -104,11 +104,19 @@ struct GroupCommunicationEstablishReq { ...@@ -104,11 +104,19 @@ struct GroupCommunicationEstablishReq {
uint8_t pppp; uint8_t pppp;
}; };
struct GroupCommunicationReleaseReq {
uint32_t sourceL2Id;
uint32_t groupL2Id;
int slrb_id;
};
struct DirectCommunicationEstablishReq { struct DirectCommunicationEstablishReq {
uint32_t sourceL2Id; uint32_t sourceL2Id;
uint32_t destinationL2Id; uint32_t destinationL2Id;
uint32_t pppp;
}; };
struct sidelink_ctrl_element { struct sidelink_ctrl_element {
unsigned short type; unsigned short type;
union { union {
...@@ -117,6 +125,7 @@ struct sidelink_ctrl_element { ...@@ -117,6 +125,7 @@ struct sidelink_ctrl_element {
Group_Communication_Status_t group_comm_release_rsp; Group_Communication_Status_t group_comm_release_rsp;
//struct DirectCommunicationReleaseReq direct_comm_release_req; //struct DirectCommunicationReleaseReq direct_comm_release_req;
SL_UE_STATE_t ue_state; SL_UE_STATE_t ue_state;
//struct GroupCommunicationReleaseReq group_comm_release_req;
int slrb_id; int slrb_id;
} sidelinkPrimitive; } sidelinkPrimitive;
...@@ -693,13 +702,19 @@ typedef struct UE_RRC_INST_s { ...@@ -693,13 +702,19 @@ typedef struct UE_RRC_INST_s {
SystemInformationBlockType11_t *sib11[NB_CNX_UE]; SystemInformationBlockType11_t *sib11[NB_CNX_UE];
uint8_t *MIB; uint8_t *MIB;
#ifdef Rel14 #ifdef Rel14
//TTN - SIB18 //SIB18
SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE]; SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE];
SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE]; SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE];
SBCCH_SL_BCH_MessageType_t mib_sl[NB_CNX_UE]; SBCCH_SL_BCH_MessageType_t mib_sl[NB_CNX_UE];
/// Preconfiguration for Sidelink /// Preconfiguration for Sidelink
struct SL_Preconfiguration_r12 *SL_Preconfiguration[NB_CNX_UE]; struct SL_Preconfiguration_r12 *SL_Preconfiguration[NB_CNX_UE];
//source L2 Id
uint32_t sourceL2Id;
//group L2 Id
uint32_t groupL2Id;
//destination L2 Id
uint32_t destinationL2Id;
#endif #endif
#if defined(Rel10) || defined(Rel14) #if defined(Rel10) || defined(Rel14)
......
...@@ -369,8 +369,15 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index ) ...@@ -369,8 +369,15 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long)); UE->DRB_config[0][0]->logicalChannelIdentity = CALLOC(1, sizeof(long));
*(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 *(UE->DRB_config[0][0]->logicalChannelIdentity) = UE->DRB_config[0][0]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
// TTN - Establish a new SLRB for PC5-S (using DRB 10 for now)
UE->DRB_config[0][1] = CALLOC(1,sizeof(struct DRB_ToAddMod));
UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long));
UE->DRB_config[0][1]->drb_Identity = 10;
UE->DRB_config[0][1]->eps_BearerIdentity = CALLOC(1, sizeof(long));
// allowed value 5..15, value : x+4
*(UE->DRB_config[0][1]->eps_BearerIdentity) = 10;
UE->DRB_config[0][1]->logicalChannelIdentity = CALLOC(1, sizeof(long));
*(UE->DRB_config[0][1]->logicalChannelIdentity) = UE->DRB_config[0][1]->drb_Identity; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2
struct RLC_Config *DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config)); struct RLC_Config *DRB_rlc_config = CALLOC(1,sizeof(struct RLC_Config));
struct PDCP_Config *DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config)); struct PDCP_Config *DRB_pdcp_config = CALLOC(1,sizeof(struct PDCP_Config));
...@@ -385,9 +392,11 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index ) ...@@ -385,9 +392,11 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10; DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = SN_FieldLength_size10;
DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35; DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = T_Reordering_ms35;
UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config; UE->DRB_config[0][0]->rlc_Config = DRB_rlc_config;
UE->DRB_config[0][1]->rlc_Config = DRB_rlc_config;
DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config));
UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config; UE->DRB_config[0][0]->pdcp_Config = DRB_pdcp_config;
UE->DRB_config[0][1]->pdcp_Config = DRB_pdcp_config;
DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long));
*DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity; *DRB_pdcp_config->discardTimer = PDCP_Config__discardTimer_infinity;
DRB_pdcp_config->rlc_AM = NULL; DRB_pdcp_config->rlc_AM = NULL;
...@@ -401,6 +410,7 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index ) ...@@ -401,6 +410,7 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed; DRB_pdcp_config->headerCompression.present = PDCP_Config__headerCompression_PR_notUsed;
UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config; UE->DRB_config[0][0]->logicalChannelConfig = DRB_lchan_config;
UE->DRB_config[0][1]->logicalChannelConfig = DRB_lchan_config;
DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters));
DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters;
...@@ -417,6 +427,7 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index ) ...@@ -417,6 +427,7 @@ void init_SL_preconfig(UE_RRC_INST *UE, const uint8_t eNB_index )
UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t)); UE->DRB_configList = CALLOC(1,sizeof(DRB_ToAddModList_t));
ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]); ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][0]);
ASN_SEQUENCE_ADD(&UE->DRB_configList->list,UE->DRB_config[0][1]);
rrc_pdcp_config_asn1_req(&ctxt, rrc_pdcp_config_asn1_req(&ctxt,
(SRB_ToAddModList_t *) NULL, (SRB_ToAddModList_t *) NULL,
...@@ -5422,6 +5433,7 @@ void *rrc_control_socket_thread_fct(void *arg) ...@@ -5422,6 +5433,7 @@ void *rrc_control_socket_thread_fct(void *arg)
uint32_t groupL2Id; uint32_t groupL2Id;
module_id_t module_id; module_id_t module_id;
module_id = 0 ; //hardcoded for testing only
//from the main program, listen for the incoming messages from control socket (ProSe App) //from the main program, listen for the incoming messages from control socket (ProSe App)
prose_addr_len = sizeof(prose_app_addr); prose_addr_len = sizeof(prose_app_addr);
...@@ -5488,8 +5500,7 @@ void *rrc_control_socket_thread_fct(void *arg) ...@@ -5488,8 +5500,7 @@ void *rrc_control_socket_thread_fct(void *arg)
case GROUP_COMMUNICATION_ESTABLISH_REQ: case GROUP_COMMUNICATION_ESTABLISH_REQ:
sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id; sourceL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.sourceL2Id;
groupL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id; groupL2Id = sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id;
//sourceL2Id = 0x123456;
//groupL2Id = 0x789ABC;
#ifdef DEBUG_CTRL_SOCKET #ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.type); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] type: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.type);
...@@ -5497,10 +5508,14 @@ void *rrc_control_socket_thread_fct(void *arg) ...@@ -5497,10 +5508,14 @@ void *rrc_control_socket_thread_fct(void *arg)
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] group Id: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] group Id: %d\n",sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupL2Id);
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] group IP Address: " IPV4_ADDR "\n",IPV4_ADDR_FORMAT(sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupIpAddress)); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] group IP Address: " IPV4_ADDR "\n",IPV4_ADDR_FORMAT(sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupIpAddress));
#endif #endif
//store sourceL2Id
UE_rrc_inst[module_id].sourceL2Id = sourceL2Id;
UE_rrc_inst[module_id].groupL2Id = groupL2Id;
// configure lower layers PDCP/MAC/PHY for this communication // configure lower layers PDCP/MAC/PHY for this communication
//init_SL_preconfig() //init_SL_preconfig()
//configure MAC with sourceL2Id/groupL2ID (to be used in MAC/ue_procedures.c) //configure MAC with sourceL2Id/groupL2ID (to be used in MAC/ue_procedures.c)
module_id = 0 ; //hardcoded for testing only
rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0 rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0
(RadioResourceConfigCommonSIB_t *)NULL, (RadioResourceConfigCommonSIB_t *)NULL,
(struct PhysicalConfigDedicated *)NULL, (struct PhysicalConfigDedicated *)NULL,
...@@ -5573,12 +5588,56 @@ void *rrc_control_socket_thread_fct(void *arg) ...@@ -5573,12 +5588,56 @@ void *rrc_control_socket_thread_fct(void *arg)
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishResponse] slrb_id: %d\n",ptr_ctrl_msg->sidelinkPrimitive.slrb_id); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishResponse] slrb_id: %d\n",ptr_ctrl_msg->sidelinkPrimitive.slrb_id);
#endif #endif
break; break;
case GROUP_COMMUNICATION_RELEASE_REQ: case GROUP_COMMUNICATION_RELEASE_REQ:
printf("-----------------------------------\n"); printf("-----------------------------------\n");
#ifdef DEBUG_CTRL_SOCKET #ifdef DEBUG_CTRL_SOCKET
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationReleaseRequest] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationReleaseRequest] Received on socket from ProSe App (msg type: %d)\n",sl_ctrl_msg_recv->type);
LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationReleaseRequest] Slrb Id: %i\n",sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id); LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationReleaseRequest] Slrb Id: %i\n",sl_ctrl_msg_recv->sidelinkPrimitive.slrb_id);
#endif #endif
//reset groupL2ID from MAC LAYER
UE_rrc_inst[module_id].groupL2Id = 0x00000000;
sourceL2Id = UE_rrc_inst[module_id].sourceL2Id;
rrc_mac_config_req_ue(module_id,0,0, //eNB_index =0
(RadioResourceConfigCommonSIB_t *)NULL,
(struct PhysicalConfigDedicated *)NULL,
#if defined(Rel10) || defined(Rel14)
(SCellToAddMod_r10_t *)NULL,
//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
#endif
(MeasObjectToAddMod_t **)NULL,
(MAC_MainConfig_t *)NULL,
0,
(struct LogicalChannelConfig *)NULL,
(MeasGapConfig_t *)NULL,
(TDD_Config_t *)NULL,
(MobilityControlInfo_t *)NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
#if defined(Rel10) || defined(Rel14)
,0,
(MBSFN_AreaInfoList_r9_t *)NULL,
(PMCH_InfoList_r9_t *)NULL
#endif
#ifdef CBA
,
0,
0
#endif
#if defined(Rel10) || defined(Rel14)
,
&sourceL2Id,
NULL
#endif
);
LOG_I(RRC,"[rrc_control_socket_thread_fct]Send GroupCommunicationReleaseResponse to ProSe App \n"); LOG_I(RRC,"[rrc_control_socket_thread_fct]Send GroupCommunicationReleaseResponse to ProSe App \n");
memset(send_buf, 0, BUFSIZE); memset(send_buf, 0, BUFSIZE);
......
...@@ -1067,6 +1067,8 @@ int main( int argc, char **argv ) ...@@ -1067,6 +1067,8 @@ int main( int argc, char **argv )
#ifdef Rel14 #ifdef Rel14
printf ("RRC control socket\n"); printf ("RRC control socket\n");
rrc_control_socket_init(); rrc_control_socket_init();
printf ("PDCP PC5S socket\n");
pdcp_pc5_socket_init();
#endif #endif
......
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