Commit fe21cd8c authored by IvanG's avatar IvanG

MAC UDP socket added. Opening of socket and packet reception tested

parent 94cca321
...@@ -202,6 +202,23 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, ...@@ -202,6 +202,23 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
uint16_t sfn_sf = frameP << 7 | slotP; uint16_t sfn_sf = frameP << 7 | slotP;
int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value; int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value;
//socket_mac_gNB_data *socket_data;
//socket_data = calloc(1, sizeof(*socket_data));
//memset((void *)socket_data, 0, sizeof(socket_data));
const char *ip_address = "10.102.81.239";
const uint16_t port = 53108;
//const uint16_t port = 554; //RTSP port
//const uint16_t port = 50202; //Custom port
char* pdu[5888] = {0};
//Connect socket
//connect_mac_socket_to_data_source(ip_address, port, nr_mac->socket_mac_data);
// everything here is hard-coded to 30 kHz // everything here is hard-coded to 30 kHz
int scs = get_dlscs(cfg); int scs = get_dlscs(cfg);
int slots_per_frame = get_spf(cfg); int slots_per_frame = get_spf(cfg);
...@@ -300,6 +317,20 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, ...@@ -300,6 +317,20 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
dl_req->number_pdsch_rnti++; dl_req->number_pdsch_rnti++;
dl_req->number_pdu+=2; dl_req->number_pdu+=2;
//while(1){
//Call get_mac_pdu_from_socket() around here?
//LOG_I(MAC, "get_mac_pdu_from_socket\n");
get_mac_pdu_from_socket(pdu, 5888, nr_mac->socket_mac_data);
//get_mac_pdu_from_socket(pdu, dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15.transport_block_size, socket_mac_gNB_data *socket_data);
//}
TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus]; TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus];
TX_req->pdu_length = 6; TX_req->pdu_length = 6;
TX_req->pdu_index = nr_mac->pdu_index[CC_id]++; TX_req->pdu_index = nr_mac->pdu_index[CC_id]++;
...@@ -321,4 +352,139 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, ...@@ -321,4 +352,139 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP,
nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
} }
//disconnect_mac_socket_from_data_source(nr_mac->socket_mac_data);
}
/* Function to get the MAC PDU from socket data */
int get_mac_pdu_from_socket(char* pdu,
uint32_t TBS,
socket_mac_gNB_data *socket_data)
{
//LOG_I(MAC, "[get_mac_pdu_from_socket] TEST\n");
/* Should I set the socket as non-blocking? */
//fcntl(socket_data->sd, F_SETFL, O_NONBLOCK);
//If listening to more than one socket (e.g. for TCP and UDP listening) select() should be used
int recv_ret;
//struct sockaddr *from_addr;
struct sockaddr_in from_addr;
socklen_t from_addr_len;
from_addr_len = sizeof(struct sockaddr_in);
//LOG_I(MAC, "[get_mac_pdu_from_socket] TEST1, socket_data->sd=%d\n", socket_data->sd);
//recv_ret = recv(socket_data->sd, pdu, (size_t)TBS, 0);
recv_ret = recvfrom(socket_data->sd, pdu, (size_t)TBS, 0, &from_addr, &from_addr_len);
//LOG_I(MAC, "[get_mac_pdu_from_socket] TEST2\n");
if (recv_ret == -1) {
/* Failure case */
switch (errno) {
//case EWOULDBLOCK:
case EAGAIN:
return -1;
default:
//g_info("recv failed: %s", g_strerror(errno));
LOG_I(MAC, "[get_mac_pdu_from_socket] ERROR. Received %d bytes in MAC socket. Errno=%d\n", recv_ret, errno);
return -1;
break;
}
//} else if (recv_ret == 0) {
// /* We lost the connection with other peer or shutdown asked */
// ui_pipe_write_message(socket_data->pipe_fd,
// UI_PIPE_CONNECTION_LOST, NULL, 0);
// free(socket_data->ip_address);
// free(socket_data);
// pthread_exit(NULL);
}else{
//Source IP address could be checked to only transmit RTP packets for video flow
LOG_I(MAC, "[get_mac_pdu_from_socket] Received %d bytes in MAC socket.\n", recv_ret);
}
return recv_ret;
} }
/* Function to open a socket and connect to the MAC data source*/
int connect_mac_socket_to_data_source(const char *ip_address,
const uint16_t port, socket_mac_gNB_data *socket_mac)
{
//LOG_I(MAC, "[connect_mac_socket_to_data_source]TEST\n");
//socket_mac_gNB_data *socket_data;
//socket_data = calloc(1, sizeof(*socket_data));
socket_mac->ip_address = strdup(ip_address);
socket_mac->port = port;
socket_mac->sd = -1;
struct sockaddr_in si_me;
//g_assert(socket_data != NULL);
/* Preparing the socket */
//if ((socket_data->sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
if ((socket_mac->sd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
//g_warning("socket failed: %s", g_strerror(errno));
LOG_I(MAC, "socket failed\n");
free(socket_mac->ip_address);
free(socket_mac);
return RESULT_FAILED;
}
memset((void *)&si_me, 0, sizeof(si_me));
si_me.sin_family = AF_INET;
si_me.sin_port = htons(socket_mac->port);
//si_me.sin_addr.s_addr = htonl(INADDR_ANY);
//si_me.sin_addr.s_addr = htonl(socket_data->ip_address);
si_me.sin_addr.s_addr = inet_addr(socket_mac->ip_address);
if (inet_aton(socket_mac->ip_address, &si_me.sin_addr) == 0) {
//g_warning("inet_aton() failed\n");
LOG_I(MAC, "inet_aton() failed\n");
free(socket_mac->ip_address);
free(socket_mac);
return RESULT_FAILED;
}
if(bind(socket_mac->sd, (struct sockaddr *)&si_me, sizeof(struct sockaddr_in)) == -1){
//g_warning("binding socket failed\n");
LOG_I(MAC, "binding socket failed\n");
free(socket_mac->ip_address);
free(socket_mac);
return RESULT_FAILED;
}
//Set socket as non-blocking
fcntl(socket_mac->sd, F_SETFL, O_NONBLOCK);
//If more than one socket, there should be a set of sockets to use select() with them
//The socket should be added to the set in this function.
//memcpy(socket_mac, socket_data, sizeof(socket_data));
//&socket_mac = &socket_data;
LOG_I(MAC, "[connect_mac_socket_to_data_source]MAC socket connected; socket_mac->sd= %d\n", socket_mac->sd);
return RESULT_OK;
}
/* Function to close the MAC data source socket */
int disconnect_mac_socket_from_data_source(socket_mac_gNB_data *socket_data)
{
close(socket_data->sd);
free(socket_data->ip_address);
free(socket_data);
LOG_I(MAC, "[disconnect_mac_socket_from_data_source] Disconnecting MAC socket\n");
return RESULT_OK;
}
...@@ -119,6 +119,9 @@ void mac_top_init_gNB(void) ...@@ -119,6 +119,9 @@ void mac_top_init_gNB(void)
nr_init_search_space(&RC.nrmac[i]->search_space[j][1]); nr_init_search_space(&RC.nrmac[i]->search_space[j][1]);
} }
RC.nrmac[i]->socket_mac_data = calloc(1, sizeof(socket_mac_gNB_data));
//Open socket for receiving data to send from MAC layer (should have different ports for different nrmac)
connect_mac_socket_to_data_source("10.102.81.239", 53108, RC.nrmac[i]->socket_mac_data);
}//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
......
...@@ -62,6 +62,27 @@ ...@@ -62,6 +62,27 @@
#include "LAYER2/MAC/mac_extern.h" #include "LAYER2/MAC/mac_extern.h"
#include "common/ran_context.h" #include "common/ran_context.h"
#define RESULT_OK 0
#define RESULT_FAILED -1
/* structure for socket as source of MAC gNB data; copied from common/utils/itti_analyzer/libbuffer/socket.h */
typedef struct {
pthread_t thread;
int sd;
char *ip_address;
uint16_t port;
/* The pipe used between main thread (running GTK) and the socket thread */
int pipe_fd;
/* Time used to avoid refreshing UI every time a new signal is incoming */
//gint64 last_data_notification;
//uint8_t nb_signals_since_last_update;
/* The last signals received which are not yet been updated in GUI */
//GList *signal_list;
} socket_mac_gNB_data;
/*! \brief gNB common channels */ /*! \brief gNB common channels */
typedef struct { typedef struct {
int physCellId; int physCellId;
...@@ -148,6 +169,9 @@ typedef struct gNB_MAC_INST_s { ...@@ -148,6 +169,9 @@ typedef struct gNB_MAC_INST_s {
/// UL handle /// UL handle
uint32_t ul_handle; uint32_t ul_handle;
//Socket to receive data that will be sent from MAC
socket_mac_gNB_data *socket_mac_data;
// MAC function execution peformance profiler // MAC function execution peformance profiler
/// processing time of eNB scheduler /// processing time of eNB scheduler
time_stats_t eNB_scheduler; time_stats_t eNB_scheduler;
...@@ -175,4 +199,16 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, ...@@ -175,4 +199,16 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP,
frame_t frameP, frame_t frameP,
sub_frame_t subframeP); sub_frame_t subframeP);
/* Function to get the MAC PDU from socket data */
int get_mac_pdu_from_socket(char* pdu, uint32_t TBS, socket_mac_gNB_data *socket_data);
/* Function to open a socket and connect to the MAC data source*/
int connect_mac_socket_to_data_source(const char *remote_ip, const uint16_t port, socket_mac_gNB_data *socket_data);
/* Function to close the MAC data source socket */
int disconnect_mac_socket_from_data_source(socket_mac_gNB_data *socket_data);
#endif /*__LAYER2_NR_MAC_GNB_H__ */ #endif /*__LAYER2_NR_MAC_GNB_H__ */
Active_gNBs = ( "gNB-Eurecom-5GNRBox");
# Asn1_verbosity, choice in: none, info, annoying
Asn1_verbosity = "none";
gNBs =
(
{
////////// Identification parameters:
gNB_ID = 0xe00;
cell_type = "CELL_MACRO_GNB";
gNB_name = "gNB-Eurecom-5GNRBox";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;});
tr_s_preference = "local_mac"
////////// Physical parameters:
component_carriers = (
{
node_function = "3GPP_gNODEB";
node_timing = "synch_to_ext_device";
node_synch_ref = 0;
frame_type = "TDD";
DL_prefix_type = "NORMAL";
UL_prefix_type = "NORMAL";
eutra_band = 22;
//downlink_frequency = 2300000000L;
downlink_frequency = 3510000000L;
uplink_frequency_offset = -120000000;
Nid_cell = 0;
N_RB_DL = 106;
nb_antenna_ports = 1;
nb_antennas_tx = 1;
nb_antennas_rx = 1;
tx_gain = 130;
//tx_gain = 90;
rx_gain = 125;
MIB_subCarrierSpacingCommon = 30;
MIB_ssb_SubcarrierOffset = 0;
MIB_dmrs_TypeA_Position = 2;
pdcch_ConfigSIB1 = 0;
SIB1_frequencyOffsetSSB = "khz5";
SIB1_ssb_PeriodicityServingCell = 5;
SIB1_ss_PBCH_BlockPower = -60;
absoluteFrequencySSB = 0;
DL_FreqBandIndicatorNR = 15;
DL_absoluteFrequencyPointA = 15;
DL_offsetToCarrier = 15;
DL_SCS_SubcarrierSpacing = "kHz30";
DL_SCS_SpecificCarrier_k0 = 0;
DL_carrierBandwidth = 40;
DL_locationAndBandwidth = 40;
DL_BWP_SubcarrierSpacing = "kHz30";
DL_BWP_prefix_type = "NORMAL";
UL_FreqBandIndicatorNR = 15;
UL_absoluteFrequencyPointA = 13;
UL_additionalSpectrumEmission = 3;
UL_p_Max = -1;
UL_frequencyShift7p5khz = "TRUE";
UL_offsetToCarrier = 10;
UL_SCS_SubcarrierSpacing = "kHz30";
UL_SCS_SpecificCarrier_k0 = 0;
UL_carrierBandwidth = 40;
UL_locationAndBandwidth = 40;
UL_BWP_SubcarrierSpacing = "kHz30";
UL_BWP_prefix_type = "NORMAL";
UL_timeAlignmentTimerCommon = "infinity";
ServingCellConfigCommon_n_TimingAdvanceOffset = "n0"
ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap";
ServingCellConfigCommon_ssb_periodicityServingCell = 10;
ServingCellConfigCommon_dmrs_TypeA_Position = 2;
NIA_SubcarrierSpacing = "kHz15";
ServingCellConfigCommon_ss_PBCH_BlockPower = -60;
referenceSubcarrierSpacing = "kHz15";
dl_UL_TransmissionPeriodicity = "ms0p5";
nrofDownlinkSlots = 10;
nrofDownlinkSymbols = 10;
nrofUplinkSlots = 10;
nrofUplinkSymbols = 10;
rach_totalNumberOfRA_Preambles = 63;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice = "oneEighth";
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth = 4;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth = 8;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf = 16;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one = 24;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two = 32;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four = 8;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight = 4;
rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen = 2;
rach_groupBconfigured = "ENABLE";
rach_ra_Msg3SizeGroupA = 56;
rach_messagePowerOffsetGroupB = "dB0";
rach_numberOfRA_PreamblesGroupA = 32;
rach_ra_ContentionResolutionTimer = 8;
rsrp_ThresholdSSB = 64;
rsrp_ThresholdSSB_SUL = 64;
prach_RootSequenceIndex_choice = "l839";
prach_RootSequenceIndex_l839 = 0;
prach_RootSequenceIndex_l139 = 0;
prach_msg1_SubcarrierSpacing = "kHz30";
restrictedSetConfig = "unrestrictedSet";
msg3_transformPrecoding = "ENABLE";
prach_ConfigurationIndex = 10;
prach_msg1_FDM = "one";
prach_msg1_FrequencyStart = 10;
zeroCorrelationZoneConfig = 10;
preambleReceivedTargetPower = -150;
preambleTransMax = 6;
powerRampingStep = "dB0";
ra_ResponseWindow = 8;
groupHoppingEnabledTransformPrecoding = "ENABLE";
msg3_DeltaPreamble = 0;
p0_NominalWithGrant = 0;
PUSCH_TimeDomainResourceAllocation_k2 = 0;
PUSCH_TimeDomainResourceAllocation_mappingType = "typeA";
PUSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0;
pucch_ResourceCommon = 0;
pucch_GroupHopping = "neither";
hoppingId = 0;
p0_nominal = -30;
PDSCH_TimeDomainResourceAllocation_k0 = 2;
PDSCH_TimeDomainResourceAllocation_mappingType = "typeA";
PDSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0;
rateMatchPatternId = 0;
RateMatchPattern_patternType = "bitmaps";
symbolsInResourceBlock = "oneSlot";
periodicityAndPattern = 2;
RateMatchPattern_controlResourceSet = 5;
RateMatchPattern_subcarrierSpacing = "kHz30";
RateMatchPattern_mode = "dynamic";
controlResourceSetZero = 0;
searchSpaceZero = 0;
searchSpaceSIB1 = 10;
searchSpaceOtherSystemInformation = 10;
pagingSearchSpace = 10;
ra_SearchSpace = 10;
PDCCH_common_controlResourceSetId = 5;
PDCCH_common_ControlResourceSet_duration = 2;
PDCCH_cce_REG_MappingType = "nonInterleaved";
PDCCH_reg_BundleSize = 3;
PDCCH_interleaverSize = 3;
PDCCH_shiftIndex = 10;
PDCCH_precoderGranularity = "sameAsREG-bundle";
PDCCH_TCI_StateId = 32;
tci_PresentInDCI = "ENABLE";
PDCCH_DMRS_ScramblingID = 0;
SearchSpaceId = 10;
commonSearchSpaces_controlResourceSetId = 5;
SearchSpace_monitoringSlotPeriodicityAndOffset_choice = "sl1";
SearchSpace_monitoringSlotPeriodicityAndOffset_value = 0;
SearchSpace_duration = 2;
SearchSpace_nrofCandidates_aggregationLevel1 = 0;
SearchSpace_nrofCandidates_aggregationLevel2 = 0;
SearchSpace_nrofCandidates_aggregationLevel4 = 0;
SearchSpace_nrofCandidates_aggregationLevel8 = 0;
SearchSpace_nrofCandidates_aggregationLevel16 = 0;
SearchSpace_searchSpaceType = "common";
Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 = 1;
Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 = 1;
Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 = 1;
Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 = 1;
Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 = 1;
Common_dci_Format2_3_monitoringPeriodicity = 1;
Common_dci_Format2_3_nrofPDCCH_Candidates = 1;
ue_Specific__dci_Formats = "formats0-0-And-1-0";
RateMatchPatternLTE_CRS_carrierFreqDL = 6;
RateMatchPatternLTE_CRS_carrierBandwidthDL = 6;
RateMatchPatternLTE_CRS_nrofCRS_Ports = 1;
RateMatchPatternLTE_CRS_v_Shift = 0;
RateMatchPatternLTE_CRS_radioframeAllocationPeriod = 1;
RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0;
RateMatchPatternLTE_CRS_subframeAllocation_choice = "oneFrame";
}
);
srb1_parameters :
{
# timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
timer_poll_retransmit = 80;
# timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
timer_reordering = 35;
# timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
timer_status_prohibit = 0;
# poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
poll_pdu = 4;
# poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
poll_byte = 99999;
# max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
max_retx_threshold = 4;
}
# ------- SCTP definitions
SCTP :
{
# Number of streams to use in input/output
SCTP_INSTREAMS = 2;
SCTP_OUTSTREAMS = 2;
};
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.12.26";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
}
);
NETWORK_INTERFACES :
{
GNB_INTERFACE_NAME_FOR_S1_MME = "eth0";
GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24";
GNB_INTERFACE_NAME_FOR_S1U = "eth0";
GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24";
GNB_PORT_FOR_S1U = 2152; # Spec 2152
};
}
);
MACRLCs = (
{
num_cc = 1;
tr_s_preference = "local_L1";
tr_n_preference = "local_RRC";
}
);
L1s = (
{
num_cc = 1;
tr_n_preference = "local_mac";
}
);
RUs = (
{
local_rf = "yes"
nb_tx = 1
nb_rx = 1
att_tx = 0;
att_rx = 0;
bands = [7];
max_pdschReferenceSignalPower = -27; //default: -27
max_rxgain = 114;
eNB_instances = [0];
#sdr_addrs = "addr=192.168.20.2,second_addr=192.168.10.2,mgmt_addr=192.168.20.2";
sdr_addrs = "addr=192.168.20.2,mgmt_addr=192.168.20.2";
}
);
THREAD_STRUCT = (
{
#three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT"
parallel_config = "PARALLEL_SINGLE_THREAD";
#two option for worker "WORKER_DISABLE" or "WORKER_ENABLE"
worker_config = "WORKER_DISABLE";
}
);
NETWORK_CONTROLLER :
{
FLEXRAN_ENABLED = "no";
FLEXRAN_INTERFACE_NAME = "lo";
FLEXRAN_IPV4_ADDRESS = "127.0.0.1";
FLEXRAN_PORT = 2210;
FLEXRAN_CACHE = "/mnt/oai_agent_cache";
FLEXRAN_AWAIT_RECONF = "no";
};
log_config :
{
global_log_level ="info";
global_log_verbosity ="medium";
hw_log_level ="info";
hw_log_verbosity ="medium";
phy_log_level ="info";
phy_log_verbosity ="medium";
mac_log_level ="info";
mac_log_verbosity ="high";
rlc_log_level ="info";
rlc_log_verbosity ="medium";
pdcp_log_level ="info";
pdcp_log_verbosity ="medium";
rrc_log_level ="info";
rrc_log_verbosity ="medium";
};
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