diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index 023b8ec154..bcac887670 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -57,6 +57,9 @@ pipeline { echo '\u2705 \u001B[32mVerify Parameters\u001B[0m' def allParametersPresent = true + if (env.TESTPLATFORM_OWNER) { + echo "Platform is ${env.TESTPLATFORM_OWNER}" + } if (params.RedHatRemoteServer == null) { allParametersPresent = false diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh index c6854357fe..bb38c660ca 100755 --- a/ci-scripts/buildOnVM.sh +++ b/ci-scripts/buildOnVM.sh @@ -44,7 +44,7 @@ function build_on_vm { STATUS=1 return fi - if [ ! -f /etc/apt/apt.conf.d/01proxy ] + if [[ ! -f /etc/apt/apt.conf.d/01proxy ]] && [[ "$OPTIONAL_APTCACHER" != "true" ]] then echo "Missing /etc/apt/apt.conf.d/01proxy file!" echo "Is apt-cacher installed and configured?" @@ -96,12 +96,12 @@ function build_on_vm { else scp -o StrictHostKeyChecking=no $JENKINS_WKSP/localZip.zip ubuntu@$VM_IP_ADDR:/home/ubuntu fi - scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$VM_IP_ADDR:/home/ubuntu + [ -f /etc/apt/apt.conf.d/01proxy ] && scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$VM_IP_ADDR:/home/ubuntu echo "############################################################" echo "Running install and build script on VM ($VM_NAME)" echo "############################################################" - echo "sudo cp 01proxy /etc/apt/apt.conf.d/" > $VM_CMDS + echo "[ -f 01proxy ] && sudo cp 01proxy /etc/apt/apt.conf.d/" > $VM_CMDS echo "touch /home/ubuntu/.hushlogin" >> $VM_CMDS if [[ "$VM_NAME" == *"-cppcheck"* ]] then diff --git a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf index eff8b68857..ab89d13193 100644 --- a/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf +++ b/ci-scripts/conf_files/enb.band13.tm1.50PRB.emtc.conf @@ -233,6 +233,7 @@ eNBs = #pdsch_maxNumRepetitionCEmodeB_r13 = "r384"; # NULL - 2 pusch_maxNumRepetitionCEmodeA_r13 = "r8"; #0 + pusch_repetitionLevelCEmodeA_r13 = "l1"; #pusch_maxNumRepetitionCEmodeB_r13 = "r768"; #4 #NULL #pusch_HoppingOffset_v1310 = 5; #NULL diff --git a/ci-scripts/main.py b/ci-scripts/main.py index efd3df5afd..37cf76444a 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -540,9 +540,36 @@ class SSHConnection(): # here add a check if git clone or git fetch went smoothly self.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) self.command('git config user.name "OAI Jenkins"', '\$', 5) - if self.clean_repository: - pass - self.command('echo ' + self.UEPassword + ' | sudo -S git clean -x -d -ff', '\$', 30) + self.command('ls *.txt', '\$', 5) + result = re.search('LAST_BUILD_INFO', str(self.ssh.before)) + if result is not None: + mismatch = False + self.command('grep SRC_COMMIT LAST_BUILD_INFO.txt', '\$', 2) + result = re.search(self.ranCommitID, str(self.ssh.before)) + if result is None: + mismatch = True + self.command('grep MERGED_W_TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2) + if (self.ranAllowMerge): + result = re.search('YES', str(self.ssh.before)) + if result is None: + mismatch = True + self.command('grep TGT_BRANCH LAST_BUILD_INFO.txt', '\$', 2) + if self.ranTargetBranch == '': + result = re.search('develop', str(self.ssh.before)) + else: + result = re.search(self.ranTargetBranch, str(self.ssh.before)) + if result is None: + mismatch = True + else: + result = re.search('NO', str(self.ssh.before)) + if result is None: + mismatch = True + if not mismatch: + self.close() + self.CreateHtmlTestRow(self.Build_eNB_args, 'OK', ALL_PROCESSES_OK) + return + + self.command('echo ' + self.UEPassword + ' | sudo -S git clean -x -d -ff', '\$', 30) # if the commit ID is provided use it to point to it if self.ranCommitID != '': self.command('git checkout -f ' + self.ranCommitID, '\$', 5) @@ -570,12 +597,23 @@ class SSHConnection(): self.command('mkdir -p build_log_' + self.testCase_id, '\$', 5) self.command('mv log/* ' + 'build_log_' + self.testCase_id, '\$', 5) self.command('mv compile_oai_ue.log ' + 'build_log_' + self.testCase_id, '\$', 5) - self.close() if buildStatus: - logging.info('\u001B[1m Building OAI ' + ue_prefix + 'UE Pass\u001B[0m') + # Generating a BUILD INFO file + self.command('echo "SRC_BRANCH: ' + self.ranBranch + '" > ../LAST_BUILD_INFO.txt', '\$', 2) + self.command('echo "SRC_COMMIT: ' + self.ranCommitID + '" >> ../LAST_BUILD_INFO.txt', '\$', 2) + if (self.ranAllowMerge): + self.command('echo "MERGED_W_TGT_BRANCH: YES" >> ../LAST_BUILD_INFO.txt', '\$', 2) + if self.ranTargetBranch == '': + self.command('echo "TGT_BRANCH: develop" >> ../LAST_BUILD_INFO.txt', '\$', 2) + else: + self.command('echo "TGT_BRANCH: ' + self.ranTargetBranch + '" >> ../LAST_BUILD_INFO.txt', '\$', 2) + else: + self.command('echo "MERGED_W_TGT_BRANCH: NO" >> ../LAST_BUILD_INFO.txt', '\$', 2) + self.close() self.CreateHtmlTestRow(self.Build_OAI_UE_args, 'OK', ALL_PROCESSES_OK, 'OAI UE') else: - logging.error('\u001B[1m Building OAI ' + ue_prefix + 'UE Failed\u001B[0m') + self.close() + logging.error('\u001B[1m Building OAI UE Failed\u001B[0m') self.CreateHtmlTestRow(self.Build_OAI_UE_args, 'KO', ALL_PROCESSES_OK, 'OAI UE') self.CreateHtmlTabFooter(False) sys.exit(1) @@ -1125,7 +1163,7 @@ class SSHConnection(): html_queue = SimpleQueue() self.checkDevTTYisUnlocked() if attach_status: - html_cell = '
CAT-M module\nAttachment Completed in ' + str(attach_cnt+4) + ' seconds'
+			html_cell = '
CAT-M module Attachment Completed in ' + str(attach_cnt+4) + ' seconds'
 			if (nRSRQ is not None) and (nRSRP is not None):
 				html_cell += '\n   RSRQ = ' + str(-20+(nRSRQ/2)) + ' dB'
 				html_cell += '\n   RSRP = ' + str(-140+nRSRP) + ' dBm
' @@ -1134,9 +1172,11 @@ class SSHConnection(): html_queue.put(html_cell) self.CreateHtmlTestRowQueue('N/A', 'OK', 1, html_queue) else: - html_cell = '
CAT-M module\nAttachment Failed
' + logging.error('\u001B[1m CAT-M module Attachment Failed\u001B[0m') + html_cell = '
CAT-M module Attachment Failed
' html_queue.put(html_cell) self.CreateHtmlTestRowQueue('N/A', 'KO', 1, html_queue) + self.AutoTerminateUEandeNB() def PingCatM(self): if self.EPCIPAddress == '' or self.EPCUserName == '' or self.EPCPassword == '' or self.EPCSourceCodePath == '': @@ -1147,7 +1187,7 @@ class SSHConnection(): pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE) if (pStatus < 0): self.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) - self.prematureExit = True + self.AutoTerminateUEandeNB() return try: statusQueue = SimpleQueue() @@ -1166,6 +1206,8 @@ class SSHConnection(): if result is not None: moduleIPAddr = result.group('ipaddr') else: + self.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) + self.AutoTerminateUEandeNB() return ping_time = re.findall("-c (\d+)",str(self.ping_args)) device_id = 'catm' @@ -2397,15 +2439,16 @@ class SSHConnection(): os.kill(os.getppid(),signal.SIGUSR1) def IperfNoS1(self): + if self.eNBIPAddress == '' or self.eNBUserName == '' or self.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '': + Usage() + sys.exit('Insufficient Parameter') check_eNB = True check_OAI_UE = True pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE) if (pStatus < 0): self.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus) self.AutoTerminateUEandeNB() - if self.eNBIPAddress == '' or self.eNBUserName == '' or self.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '': - Usage() - sys.exit('Insufficient Parameter') + return server_on_enb = re.search('-R', str(self.iperf_args)) if server_on_enb is not None: iServerIPAddr = self.eNBIPAddress @@ -3416,6 +3459,11 @@ class SSHConnection(): self.ShowTestID() self.eNB_instance = '0' self.TerminateeNB() + if self.flexranCtrlInstalled and self.flexranCtrlStarted: + self.testCase_id = 'AUTO-KILL-flexran-ctl' + self.desc = 'Automatic Termination of FlexRan CTL' + self.ShowTestID() + self.TerminateFlexranCtrl() self.prematureExit = True def IdleSleep(self): @@ -4533,7 +4581,11 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re while cnt < SSH.repeatCounts[0] and SSH.prematureExit: SSH.prematureExit = False for test_case_id in todo_tests: + if SSH.prematureExit: + break for test in all_tests: + if SSH.prematureExit: + break id = test.get('id') if test_case_id != id: continue @@ -4614,10 +4666,6 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re SSH.Perform_X2_Handover() else: sys.exit('Invalid action') - if SSH.prematureExit: - break - if SSH.prematureExit: - break cnt += 1 if cnt == SSH.repeatCounts[0] and SSH.prematureExit: logging.debug('Testsuite failed ' + str(cnt) + ' time(s)') diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index a37c4f7b08..a310096e06 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -140,10 +140,25 @@ function command_options_usage { echo "" } +# function to set specific behavior depending on the TESTPLATFORM_OWNER variable +# which may be set by a jenkins server for exemple +function platform_set { + if [ "$TESTPLATFORM_OWNER" != "" ] + then + echo "Running on $TESTPLATFORM_OWNER platform" + if [ -x "/usr/local/bin/oai_${TESTPLATFORM_OWNER}_setenv.sh" ] + then + . /usr/local/bin/oai_${TESTPLATFORM_OWNER}_setenv.sh + fi + fi +} + function setvar_usage { declare -A HELP_VAR HELP_VAR["VM_OSREL"]="OS release to use in virtual machines" HELP_VAR["RUN_EXPERIMENTAL"]="Enforce execution of variants with EXPERIMENTAL variable set to \"true\"" + HELP_VAR["OPTIONAL_APTCACHER"]="build and Run tests will fail if apt-cacher not installed and this variable not set to \"true\"" + HELP_VAR["TESTPLATFORM_OWNER"]="Allow pipeline customization via execution of an externel scripts residing on the jenkins server" echo "--setvar_ where varname is one of:" for i in ${AUTHORIZED_VAR[@]}; do printf "%20s : %s\n" "$i" "${HELP_VAR[$i]}" ;done } @@ -328,6 +343,7 @@ function check_setvar { exit 1 } +platform_set MY_DIR=$(dirname $(readlink -f $0)) . $MY_DIR/createVM.sh . $MY_DIR/buildOnVM.sh @@ -337,6 +353,7 @@ MY_DIR=$(dirname $(readlink -f $0)) . $MY_DIR/reportBuildLocally.sh . $MY_DIR/reportTestLocally.sh + if [ $# -lt 1 ] then echo "Syntax Error: too few arguments" @@ -453,7 +470,7 @@ RUN_OPTIONS="none" # list of variables that can be set via the --setvar option -AUTHORIZED_VAR=("VM_OSREL RUN_EXPERIMENTAL") +AUTHORIZED_VAR=("VM_OSREL RUN_EXPERIMENTAL OPTIONAL_APTCACHER TESTPLATFORM_OWNER") #variables to set which OS VM should use diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index e93f23120c..9e69145a8f 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -476,7 +476,7 @@ function install_epc_on_vm { local LOC_EPC_VM_IP_ADDR=`uvt-kvm ip $LOC_EPC_VM_NAME` echo "$LOC_EPC_VM_NAME has for IP addr = $LOC_EPC_VM_IP_ADDR" - scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$LOC_EPC_VM_IP_ADDR:/home/ubuntu + [ -f /etc/apt/apt.conf.d/01proxy ] && scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$LOC_EPC_VM_IP_ADDR:/home/ubuntu # ltebox specific actions (install and start) LTE_BOX_TO_INSTALL=1 @@ -500,7 +500,7 @@ function install_epc_on_vm { echo "############################################################" echo "Install EPC on EPC VM ($LOC_EPC_VM_NAME)" echo "############################################################" - echo "sudo cp 01proxy /etc/apt/apt.conf.d/" > $LOC_EPC_VM_CMDS + echo "sudo [ -f 01proxy ] && cp 01proxy /etc/apt/apt.conf.d/" > $LOC_EPC_VM_CMDS echo "touch /home/ubuntu/.hushlogin" >> $LOC_EPC_VM_CMDS echo "echo \"sudo apt-get --yes --quiet install zip openjdk-8-jre libconfuse-dev libreadline-dev liblog4c-dev libgcrypt-dev libsctp-dev python2.7 python2.7-dev daemon iperf\"" >> $LOC_EPC_VM_CMDS echo "sudo apt-get update > zip-install.txt 2>&1" >> $LOC_EPC_VM_CMDS diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml index aac71198f1..4dbfe00821 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_epc_start.xml @@ -25,10 +25,23 @@ EPC-Start log-in + 010101 090101 050101 060101 070101 + + Build_eNB + Build eNB (USRP) + -w USRP -c --eNB + + + + Build_OAI_UE + Build OAI UE + -w USRP --UE + + Initialize_HSS Initialize HSS diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml index a2e74c6de9..3eca883aa6 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_test_05mhz_tm1.xml @@ -24,7 +24,7 @@ test-05-tm1-nos1-tunnel Test-05MHz-TM1-noS1-tunnel tasks - 2 + 4 030201 090109 030101 000001 090101 000002 040501 040502 000001 040601 040602 040641 040642 000001 090109 030201 diff --git a/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml b/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml index 07fb6951f8..e52faa7a31 100644 --- a/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml +++ b/ci-scripts/xml_files/enb_usrp210_band13_epc_closure.xml @@ -25,10 +25,16 @@ EPC-Closure log-out + 040202 050201 060201 070201 + + Terminate_CatM_module + Terminate CAT-M Module + + Terminate_HSS Terminate HSS diff --git a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml index 91280462b7..f8aaafd9a0 100644 --- a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml +++ b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_full_terminate.xml @@ -26,6 +26,7 @@ tasks 030201 030202 + 050202 @@ -43,4 +44,9 @@ 1 + + Terminate_FlexranCtrl + Stopping Flexran Controller + + diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index bd16f3efba..f7a1c6fd00 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2085,7 +2085,7 @@ add_library(LFDS7 # Simulation library ########################## -add_library(SIMU +set (SIMUSRC ${OPENAIR1_DIR}/SIMULATION/TOOLS/random_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/rangen_double.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c @@ -2096,9 +2096,13 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/channel_sim.c ${OPENAIR1_DIR}/SIMULATION/RF/rf.c ${OPENAIR1_DIR}/SIMULATION/RF/dac.c ${OPENAIR1_DIR}/SIMULATION/RF/adc.c -${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c +${OPENAIR_DIR}/targets/ARCH/rfsimulator/apply_channelmod.c +#${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ) +# Simulation library +########################## +add_library( SIMU SHARED ${SIMUSRC} ) add_library(SIMU_ETH ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -2404,7 +2408,6 @@ add_executable(lte-uesoftmodem ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/ru_control.c ${OPENAIR_TARGETS}/RT/USER/rfsim.c - ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index f24039369e..43b81b3d4e 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -154,7 +154,7 @@ Options --build-eclipse Build eclipse project files. Paths are auto corrected by fixprj.sh --build-lib - Build optional shared library, can be one or several of $OPTIONAL_LIBRARIES + Build optional shared library, can be one or several of $OPTIONAL_LIBRARIES or \"all\" --usrp-recplay Build for I/Q record-playback modes -h | --help @@ -355,16 +355,21 @@ function main() { shift 1;; --build-lib) BUILD_OPTLIB="" - for alib in $2 ; do + if [ "$2" == "all" ] ; then + BUILD_OPTLIB="$OPTIONAL_LIBRARIES" + echo_info "Enabling build of all optional shared libraries ($OPTIONAL_LIBRARIES)" + else + for alib in $2 ; do for oklib in $OPTIONAL_LIBRARIES ; do - if [ "$alib" = "$oklib" ] ; then - BUILD_OPTLIB="$BUILD_OPTLIB $alib" - echo_info "Enabling build of lib${alib}.so" - fi + if [ "$alib" = "$oklib" ] ; then + BUILD_OPTLIB="$BUILD_OPTLIB $alib" + echo_info "Enabling build of lib${alib}.so" + fi + done done - done - if [ "${BUILD_OPTLIB## }" != "$2" ] ; then - echo_fatal "Unknown optional library in $2, valid libraries are $OPTIONAL_LIBRARIES" + if [ "${BUILD_OPTLIB## }" != "$2" ] ; then + echo_fatal "Unknown optional library in $2, valid libraries are $OPTIONAL_LIBRARIES" + fi fi shift 2;; --usrp-recplay) @@ -591,7 +596,8 @@ function main() { nr-uesoftmodem $dbin/nr-uesoftmodem.$REL fi -# mandatory shared lib +# mandatory shared libraries common to UE and (e/g)NB + compilations \ $build_dir $config_libconfig_shlib \ lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so @@ -875,7 +881,6 @@ function main() { ln -sf $dbin/liboai_eth_transpro.so.$REL $dbin/liboai_transpro.so echo_info "liboai_transpro.so is linked to ETHERNET transport" fi - ################### # Doxygen Support # diff --git a/common/config/DOC/config/devusage/api.md b/common/config/DOC/config/devusage/api.md index 06c22dba6f..376e59abaf 100644 --- a/common/config/DOC/config/devusage/api.md +++ b/common/config/DOC/config/devusage/api.md @@ -1,3 +1,5 @@ +## config module management + ```c configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags) ``` @@ -14,23 +16,17 @@ void End_configmodule(void) * Free memory which has been allocated by the configuration module since its initialization. * Possibly calls the `config__end` function +## Retrieving parameter's values + ```c int config_get(paramdef_t *params,int numparams, char *prefix) ``` * Reads as many parameters as described in params, they must all be in the same configuration file section * Calls the `config__get` function * Calls the `config_process_cmdline` function -* `params` points to an array of `paramdef_t` structures which describes the parameters to be read, possibly including a pointer to a checking function. The following bits can possibly be set in the `paramflags` mask before calling - - `PARAMFLAG_MANDATORY`: -1 is returned if the parameter is not explicitly defined in the config source. - - `PARAMFLAG_DISABLECMDLINE`: parameter cannot be modified via the command line - - `PARAMFLAG_DONOTREAD`: ignore the parameter, can be used at run-time, to alter a pre-defined `paramdef_t` array which is used in several `config_get` or/and `config_getlist` calls. - - `PARAMFLAG_NOFREE`: do not free the memory possibly allocated by the config module to store the value of the parameter. Default behavior is for the config module to free the memory it has allocated when the `config_end` function is called. - - `PARAMFLAG_BOOL`: Only relevant for integer types. tell the config module that when processing the command line, the corresponding option can be specified without any arggument and that in this case it must set the value to 1. +* `params` points to an array of `paramdef_t` structures which describes the parameters to be read, possibly including a pointer to a checking function.The `paramflags` bit mask can be used to modify how a specific parameter is processed and the same mask is also used by the configuration module to return information about how the parameter has been processed. Bits definitions are described in the [`paramdef_t` structure description](./struct.md) + -* `params` is also used as an output parameter, `< XXX >ptr >` field is used by the config module to store the value it has read. The following bits can possibly be set in the `paramflags` mask after the call: - - `PARAMFLAG_MALLOCINCONFIG`: memory has been allocated for the ` < XXX >ptr > ` field - - `PARAMFLAG_PARAMSET`: parameter has been found in the config source, it is not set to default value. - - `PARAMFLAG_PARAMSET`: parameter has been set to its default value * `numparams` is the number of entries in the params array * `prefix` is a character string to be appended to the parameters name, it defines the parameters position in the configuration file hierarchy (the section name in libconfig terminology). * The returned value is the number of parameters which have been assigned a value or -1 if a severe error occured @@ -44,6 +40,9 @@ int config_libconfig_getlist(paramlist_def_t *ParamList, paramdef_t *params, int * `ParamList` points to a structure, where `paramarray` field points to an array of `paramdef_t` structure, allocated by the function. It is used to return the values of the parameters. * The returned value is the number of occurrences in the list or -1 in case of severe error +## utility functions and macros + +The configuration module also defines APIs to access the `paramdef_t` and `configmodule_interface_t` fields. They are listed in the configuration module [include file `common/config/config_userapi.h`](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/config/config_userapi.h) [Configuration module developer main page](../../config/devusage.md) [Configuration module home](../../config.md) diff --git a/common/config/DOC/config/devusage/struct.md b/common/config/DOC/config/devusage/struct.md index e8b15fc0f1..4c9cd15785 100644 --- a/common/config/DOC/config/devusage/struct.md +++ b/common/config/DOC/config/devusage/struct.md @@ -5,6 +5,7 @@ It is defined in include file [ common/config/config_paramdesc.h ](https://gitla |:-----------|:------------------------------------------------------------------|----:| | `optname` | parameter name, as used when looking for it in the config source, 63 bytes max (64 with trailing \0) | I | | `helstr` | pointer to a C string printed when using --help on the command line | I | +| `paramflags` | bit mask, used to modify how the parameter is processed, or to return to the API caller how the parameter has been set, see list in the next table | IO | | `strptr` `strlistptr` `u8ptr` `i8ptr` `u16ptr` `i16ptr` `uptr` `iptr` `u64ptr` `i64ptr` `dblptr` `voidptr` | a pointer to a variable where the parameter value(s) will be returned. This field is an anonymous union, the supported pointer types have been built to avoid type mismatch warnings at compile time. | O | | `defstrval` `defstrlistval` `defuintval` `defintval` `defint64val` `defintarrayval` `defdblval` | this field is an anonymous union, it can be used to define the default value for the parameter. It is ignored if `PARAMFLAG_MANDATORY` is set in the `paramflags` field.| I | | `type` | Supported parameter types are defined as integer macros. Supported simple types are `TYPE_STRING`, parameter value is returned in `strptr` field, `TYPE_INT8` `TYPE_UINT8` `TYPE_INT16` `TYPE_UINT16` `TYPE_INT32` `TYPE_UINT32` `TYPE_INT64` `TYPE_UINT64`, parameter value is returned in the corresponding uXptr or iXptr, `TYPE_MASK`, value is returned in `u32ptr`, `TYPE_DOUBLE` value is returned in `dblptr`, `TYPE_IPV4ADDR` value is returned in binary, network bytes order in `u32ptr` field. `TYPE_STRINGLIST`, `TYPE_INTARRAY` and `TYPE_UINTARRAY` are multiple values types. Multiple values are returned in respectively, `strlistptr`, `iptr` and `uptr` fields which then point to arrays. The `numelt` field gives the number of item in the array. | I | @@ -12,6 +13,22 @@ It is defined in include file [ common/config/config_paramdesc.h ](https://gitla | `chkPptr` | possible pointer to the structure containing the info used to check parameter values | I | | `processedvalue` | When `chkPptr` is not `ǸULL`, is used to return a value, computed from the original parameter, as read from the configuration source. | O | +## `paramflags` bits definition + + +| C macro bit definition | usage | I/O | +|:-------------------------------------|:---------------------------------------------------------------------------------------------------------------------|----:| +| `PARAMFLAG_MANDATORY` | parameter is mandatory, comfiguration module will stop the process if it is not specified. Default value is ignored | I | +| `PARAMFLAG_DISABLECMDLINE` | parameter cannot be specified on the command line | I | +| `PARAMFLAG_DONOTREAD` | ignore the parameter, usefull when a parameter group is used in different context | I | +| `PARAMFLAG_NOFREE` | The end_configmodule API won't free the memory which has been possibly allocated to store the value of the parameter.| I | +| `PARAMFLAG_BOOL` | Parameter is a boolean, it can be specified without a value to set it to true | I | +| `PARAMFLAG_CMDLINE_NOPREFIXENABLED` | parameter can be specified without the prefix on the command line. Must be used with care, carefuly checking unicity, especially for short parameter names | I | +| `PARAMFLAG_MALLOCINCONFIG` | Memory for the parameter value has been allocated by the configuration module |O | +| `PARAMFLAG_PARAMSET` | Parameter value has been explicitely set, as the parameter was specified either on the command line or the config source | O | +| `PARAMFLAG_PARAMSETDEF` | Parameter value has been set to it's default | O | + + # `paramlist_def_t`structure It is defined in include file [ common/config/config_paramdesc.h ](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/config/config_paramdesc.h#L160). It is used as an argument to `config_getlist` calls, to get values of multiple occurrences of group of parameters. diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 249765a46e..6d01d98c65 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -167,8 +167,8 @@ int config_check_unknown_cmdlineopt(char *prefix) { char testprefix[CONFIG_MAXOPTLENGTH]; int finalcheck = 0; memset(testprefix,0,sizeof(testprefix)); - memset(testprefix,0,sizeof(testprefix)); + if (prefix != NULL) { if (strcmp(prefix,CONFIG_CHECKALLSECTIONS) == 0) finalcheck = 1; @@ -253,7 +253,9 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) } if ( ((strlen(oneargv) == 2) && (strcmp(oneargv + 1,cfgpath) == 0)) || /* short option, one "-" */ - ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 )) ) { + ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 )) || /* long option beginning with "--" */ + ((strlen(oneargv) == 2) && (strcmp(oneargv + 1,cfgoptions[n].optname) == 0) && (cfgoptions[n].paramflags & PARAMFLAG_CMDLINE_NOPREFIXENABLED )) || + ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 ) && (cfgoptions[n].paramflags & PARAMFLAG_CMDLINE_NOPREFIXENABLED )) ) { char *valptr=NULL; int ret; config_get_if()->argv_info[i] |= CONFIG_CMDLINEOPT_PROCESSED; diff --git a/common/config/config_paramdesc.h b/common/config/config_paramdesc.h index 9aad79960d..86fc993a08 100644 --- a/common/config/config_paramdesc.h +++ b/common/config/config_paramdesc.h @@ -45,7 +45,7 @@ #define PARAMFLAG_DONOTREAD (1 << 2) // parameter must be ignored in get function #define PARAMFLAG_NOFREE (1 << 3) // don't free parameter in end function #define PARAMFLAG_BOOL (1 << 4) // integer param can be 0 or 1 - +#define PARAMFLAG_CMDLINE_NOPREFIXENABLED (1 << 5) // on the command line, allow a parameter to be specified without the prefix /* Flags used by config modules to return info to calling modules and/or to for internal usage*/ #define PARAMFLAG_MALLOCINCONFIG (1 << 15) // parameter allocated in config module diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index 13dd6730eb..e14f28f829 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -172,7 +172,7 @@ int config_get_processedint(paramdef_t *cfgoption) { return ret; } void config_printhelp(paramdef_t *params,int numparams, char *prefix) { - printf("\n-----Help for section %-26s: %03i entries------\n",(prefix==NULL)?"(root section)":prefix ,numparams); + printf("\n-----Help for section %-26s: %03i entries------\n",(prefix==NULL)?"(root section)":prefix,numparams); for (int i=0 ; inumelt ; j++) { - printf_params("[CONFIG] %s[%i] set to default value %i\n",cfgoptions->optname ,j,(int)cfgoptions->iptr[j]); + printf_params("[CONFIG] %s[%i] set to default value %i\n",cfgoptions->optname,j,(int)cfgoptions->iptr[j]); } } @@ -452,7 +462,7 @@ int config_setdefault_double(paramdef_t *cfgoptions, char *prefix) { if( ((cfgoptions->paramflags & PARAMFLAG_MANDATORY) == 0)) { *(cfgoptions->dblptr)=cfgoptions->defdblval; status=1; - printf_params("[CONFIG] %s set to default value %lf\n",cfgoptions->optname , *(cfgoptions->dblptr)); + printf_params("[CONFIG] %s set to default value %lf\n",cfgoptions->optname, *(cfgoptions->dblptr)); } return status; @@ -460,7 +470,7 @@ int config_setdefault_double(paramdef_t *cfgoptions, char *prefix) { int config_assign_ipv4addr(paramdef_t *cfgoptions, char *ipv4addr) { config_check_valptr(cfgoptions,(char **)&(cfgoptions->uptr), sizeof(int)); - int rst=inet_pton(AF_INET, ipv4addr ,cfgoptions->uptr ); + int rst=inet_pton(AF_INET, ipv4addr,cfgoptions->uptr ); if (rst == 1 && *(cfgoptions->uptr) > 0) { printf_params("[CONFIG] %s: %s\n",cfgoptions->optname, ipv4addr); diff --git a/common/config/config_userapi.h b/common/config/config_userapi.h index cc07b1af5f..c00526aa4c 100644 --- a/common/config/config_userapi.h +++ b/common/config/config_userapi.h @@ -39,6 +39,7 @@ extern "C" { #endif +/* utility functions to ease usage of config module structures */ #define CONFIG_GETSOURCE ( (config_get_if()==NULL) ? NULL : config_get_if()->cfgmode ) #define CONFIG_GETNUMP ( (config_get_if()==NULL) ? 0 : config_get_if()->num_cfgP ) #define CONFIG_GETP(P) ( (config_get_if()==NULL) ? NULL : config_get_if()->cfgP[P] ) @@ -46,6 +47,8 @@ extern "C" #define CONFIG_SETRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags |= P; } #define CONFIG_CLEARRTFLAG(P) if (config_get_if()) { config_get_if()->rtflags &= (~P); } #define CONFIG_ISPARAMFLAGSET(P,F) ( !!(P.paramflags & F)) +extern int config_paramidx_fromname(paramdef_t *params,int numparams, char *name); + /* utility functions, to be used by configuration module and/or configuration libraries */ extern configmodule_interface_t *config_get_if(void); extern char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) ; diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c index 7f8645be02..44ab07a49b 100644 --- a/common/utils/telnetsrv/telnetsrv.c +++ b/common/utils/telnetsrv/telnetsrv.c @@ -123,7 +123,7 @@ void client_printf(const char *message, ...) { if (telnetparams.new_socket > 0) { vsnprintf(telnetparams.msgbuff,sizeof(telnetparams.msgbuff)-1,message, va_args); - send(telnetparams.new_socket,telnetparams.msgbuff , strlen(telnetparams.msgbuff), MSG_NOSIGNAL); + send(telnetparams.new_socket,telnetparams.msgbuff, strlen(telnetparams.msgbuff), MSG_NOSIGNAL); } else { vprintf(message, va_args); } @@ -475,7 +475,7 @@ int process_command(char *buf) { memset(cmdb,0,sizeof(cmdb)); bufbck=strdup(buf); rt=CMDSTATUS_NOTFOUND; - j = sscanf(buf,"%9s %9s %9[^\t\n]",modulename,cmd,cmdb); + j = sscanf(buf,"%19s %19s %19[^\t\n]",modulename,cmd,cmdb); if (telnetparams.telnetdbg > 0) printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb); @@ -543,7 +543,7 @@ void run_telnetsrv(void) { char buf[TELNET_MAX_MSGLENGTH]; struct sockaddr cli_addr; unsigned int cli_len = sizeof(cli_addr); - int readc , filled; + int readc, filled; int status; int optval = 1; pthread_setname_np(pthread_self(), "telnet"); @@ -604,7 +604,7 @@ void run_telnetsrv(void) { } if (telnetparams.telnetdbg > 0) - printf("[TELNETSRV] Command received: readc %i filled %i \"%s\"\n", readc, filled ,buf); + printf("[TELNETSRV] Command received: readc %i filled %i \"%s\"\n", readc, filled,buf); if (buf[0] == '!') { if (buf[1] == '!') { diff --git a/doc/BUILD.md b/doc/BUILD.md index 65567cefa4..388f9f2658 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -54,7 +54,7 @@ cd cmake_targets/ ``` - The `-I` option is to install pre-requisites, you only need it the first time you build the softmodem or when some oai dependencies have changed. -- The `-w` option is to select the radio head support you want to include in your build. Radio head support is provided via a shared library, which is called the "oai device" The build script creates a soft link from `liboai_device.so` to the true device which will be used at run-time (here the USRP one,`liboai_usrpdevif.so` . USRP is the only hardware tested today in the Continuous Integration process. +- The `-w` option is to select the radio head support you want to include in your build. Radio head support is provided via a shared library, which is called the "oai device" The build script creates a soft link from `liboai_device.so` to the true device which will be used at run-time (here the USRP one,`liboai_usrpdevif.so` . USRP is the only hardware tested today in the Continuous Integration process. The RF simulator[RF simulator](../targets/ARCH/rfsimulator/README.md) is implemented as a specific device replacing RF hardware, it can be build using `-w SIMU` option. - `--eNB` is to build the `lte-softmodem` executable and all required shared libraries - `--UE` is to build the `lte-uesoftmodem` executable and all required shared libraries diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index e48d726a8e..922de0e025 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2025,6 +2025,11 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu ulsch->ue_type = 0; #endif + if(ulsch_pdu->ulsch_pdu_rel13.repetition_number >1) // Fill the Harq process parameters in the first Rep only + { + return; + } + //AssertFatal(ulsch->harq_processes[harq_pid]->nb_rb>0,"nb_rb = 0\n"); if(ulsch->harq_processes[harq_pid]->nb_rb == 0){ LOG_E(PHY, "fill_ulsch UE_id %d nb_rb = 0\n", UE_id); @@ -2034,6 +2039,9 @@ void fill_ulsch(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_ulsch_pdu *ulsch_pdu ulsch->harq_processes[harq_pid]->subframe = subframe; ulsch->harq_processes[harq_pid]->handled = 0; + ulsch->harq_processes[harq_pid]->repetition_number = ulsch_pdu->ulsch_pdu_rel13.repetition_number ; + ulsch->harq_processes[harq_pid]->total_number_of_repetitions = ulsch_pdu->ulsch_pdu_rel13.total_number_of_repetitions ; + ulsch->harq_processes[harq_pid]->first_rb = ulsch_pdu->ulsch_pdu_rel8.resource_block_start; ulsch->harq_processes[harq_pid]->nb_rb = ulsch_pdu->ulsch_pdu_rel8.number_of_resource_blocks; diff --git a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h index 735b8fd7ff..388a4f5b5f 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h @@ -318,6 +318,12 @@ typedef struct { // int calibration_flag; /// delta_TF for power control int32_t delta_TF; +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + // PUSCH Repetition Number for the current SF + uint32_t repetition_number ; + // PUSCH Total number of repetitions + uint32_t total_number_of_repetitions; +#endif } LTE_UL_eNB_HARQ_t; typedef struct { diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index f758b217c6..37bd711d8f 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -554,12 +554,18 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) int G = ulsch_harq->G; unsigned int E; decoder_if_t *tc; + static int32_t pusch_rep_buffer[3*(6144+64)]; + int max_Ncb; if (llr8_flag == 0) tc = *decoder16; else tc = *decoder8; + if(ulsch_harq->repetition_number == 1){ + memset(pusch_rep_buffer,0,(sizeof(int32_t)*3*(6144+64))) ; // reset the buffer every new repetitions + } + for (r=0; rC; r++) { // printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]); // Get Turbo interleaver parameters @@ -593,7 +599,7 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) 0, //Uplink 1, ulsch_harq->rvidx, - (ulsch_harq->round==0)?1:0, // clear + (ulsch_harq->rvidx==0)?1:0, // clear ulsch_harq->Qm, 1, r, @@ -603,6 +609,27 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) } stop_meas(&eNB->ulsch_rate_unmatching_stats); + + max_Ncb = 3*ulsch_harq->RTC[r]*32 ; + + if(ulsch_harq->total_number_of_repetitions > 1) + { + if (ulsch_harq->rvidx==1) + { // Store the result of HARQ combining in the last emtc repetitions of sequence 0,2,3,1 + for (int nn=0;nnw[r][nn] ; + } + } + if (ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions) + { + for (int nn=0;nnw[r][nn] = pusch_rep_buffer[nn] ; + } + } + } + r_offset += E; start_meas(&eNB->ulsch_deinterleaving_stats); sub_block_deinterleaving_turbo(4+Kr, diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index e5f2420b03..14babd829c 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -122,7 +122,6 @@ void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxt phich->config[phich->num_hi].n_DMRS = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms; phich->num_hi++; AssertFatal(phich->num_hi<32,"Maximum number of phich reached in subframe\n"); - } void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, @@ -186,6 +185,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro #endif harq_pid = dlsch0->harq_ids[proc->frame_tx%2][proc->subframe_tx]; + if((harq_pid < 0) || (harq_pid >= dlsch0->Mdlharq)) { LOG_E(PHY,"illegal harq_pid %d %s:%d\n", harq_pid, __FILE__, __LINE__); return; @@ -260,9 +260,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro dlsch0->harq_mask = 1; dlsch0_harq = dlsch0->harq_processes[0]; dlsch0_harq->pdu = sdu; - LOG_D(PHY,"NFAPI: frame %d, subframe %d (TX %d.%d): Programming SI-BR (%d) => %d\n",frame,subframe,proc->frame_tx,proc->subframe_tx,rel13->pdsch_payload_type,UE_id); - dlsch0->rnti = 0xFFFF; dlsch0->Kmimo = 1; dlsch0->Mdlharq = 4; @@ -569,8 +567,7 @@ void handle_uci_sr_pdu(PHY_VARS_eNB *eNB, nfapi_ul_config_request_pdu_t *ul_config_pdu, uint16_t frame, uint8_t subframe, - uint8_t srs_active) -{ + uint8_t srs_active) { LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id]; if (NFAPI_MODE==NFAPI_MODE_VNF) return; @@ -803,13 +800,13 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { // clear DCI allocation maps for new subframe if (NFAPI_MODE!=NFAPI_MODE_VNF) - for (i=0; iulsch[i]) { - ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid]; - ulsch_harq->dci_alloc=0; - ulsch_harq->rar_alloc=0; + for (i=0; iulsch[i]) { + ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid]; + ulsch_harq->dci_alloc=0; + ulsch_harq->rar_alloc=0; + } } - } } for (i=0; isfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu); + eNB->pdcch_vars[NFAPI_SFNSF2SF(DL_req->sfn_sf)&1].num_dci++; //LOG_E(PHY,"Incremented num_dci:%d but already set??? dl_config:num_dci:%d\n", eNB->pdcch_vars[subframe&1].num_dci, number_dci); do_oai=1; @@ -832,11 +830,13 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { TX_req->tx_request_body.number_of_pdus); eNB->pbch_configured=1; do_oai=1; + //LOG_D(PHY,"%s() NFAPI_DL_CONFIG_BCH_PDU_TYPE TX:%d/%d RX:%d/%d TXREQ:%d/%d\n", //__FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2SFN(TX_req->sfn_sf), NFAPI_SFNSF2SF(TX_req->sfn_sf)); if (NFAPI_MODE!=NFAPI_MODE_VNF) handle_nfapi_bch_pdu(eNB,proc,dl_config_pdu, - TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index].segments[0].segment_data); + TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu.bch_pdu_rel8.pdu_index].segments[0].segment_data); + break; case NFAPI_DL_CONFIG_MCH_PDU_TYPE: @@ -867,8 +867,8 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { dlsch_pdu_rel8->transport_blocks); if (1) { //sdu != NULL) - if (NFAPI_MODE!=NFAPI_MODE_VNF) - handle_nfapi_dlsch_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu, dlsch_pdu_rel8->transport_blocks-1, sdu); + if (NFAPI_MODE!=NFAPI_MODE_VNF) + handle_nfapi_dlsch_pdu(eNB,NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),proc,dl_config_pdu, dlsch_pdu_rel8->transport_blocks-1, sdu); } else { dont_send=1; LOG_E(MAC,"%s() NFAPI_DL_CONFIG_DLSCH_PDU_TYPE sdu is NULL DL_CFG:SFN/SF:%d:pdu_index:%d TX_REQ:SFN/SF:%d:pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(DL_req->sfn_sf), pdu_index, @@ -911,6 +911,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: if (NFAPI_MODE!=NFAPI_MODE_VNF) handle_nfapi_mpdcch_pdu(eNB,proc,dl_config_pdu); + eNB->mpdcch_vars[subframe&1].num_dci++; break; #endif @@ -918,10 +919,11 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) { } if ((NFAPI_MODE!=NFAPI_MONOLITHIC) && do_oai && !dont_send) { - if(Sched_INFO->TX_req->tx_request_body.number_of_pdus > 0){ + if(Sched_INFO->TX_req->tx_request_body.number_of_pdus > 0) { Sched_INFO->TX_req->sfn_sf = frame << 4 | subframe; oai_nfapi_tx_req(Sched_INFO->TX_req); } + Sched_INFO->DL_req->sfn_sf = frame << 4 | subframe; oai_nfapi_dl_config_req(Sched_INFO->DL_req); // DJP - .dl_config_request_body.dl_config_pdu_list[0]); // DJP - FIXME TODO - yuk - only copes with 1 pdu Sched_INFO->UE_release_req->sfn_sf = frame << 4 | subframe; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 2d493f8072..d39faf9395 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1159,6 +1159,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { const int subframe = proc->subframe_rx; const int frame = proc->frame_rx; uint32_t harq_pid0 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); + int rvidx_tab[4] = {0,2,3,1}; for (i = 0; i < NUMBER_OF_UE_MAX; i++) { ulsch = eNB->ulsch[i]; @@ -1175,8 +1176,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { if ((ulsch) && (ulsch->rnti>0) && (ulsch_harq->status == ACTIVE) && - (ulsch_harq->frame == frame) && - (ulsch_harq->subframe == subframe) && + ((ulsch_harq->frame == frame) || (ulsch_harq->repetition_number >1) ) && + ((ulsch_harq->subframe == subframe) || (ulsch_harq->repetition_number >1) ) && (ulsch_harq->handled == 0)) { // UE has ULSCH scheduling for (int rb=0; @@ -1233,6 +1234,10 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { ulsch_harq->cqi_crc_status, ulsch_harq->O_ACK, eNB->ulsch_decoding_stats.p_time, eNB->ulsch_decoding_stats.max); + if (ulsch_harq->repetition_number < ulsch_harq->total_number_of_repetitions){ + ulsch_harq->rvidx = rvidx_tab[(ulsch_harq->repetition_number%4)] ; // Set the correct rvidx for the next emtc repetitions + ulsch_harq->repetition_number +=1 ; // Increment repetition_number for the next ULSCH allocation + } //compute the expected ULSCH RX power (for the stats) ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered @@ -1288,7 +1293,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { */ ulsch_harq->handled = 1; } // ulsch in error - else { + else if(ulsch_harq->repetition_number == ulsch_harq->total_number_of_repetitions){ fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC ulsch_harq->status = SCH_IDLE; diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index f056d51b5d..41d8551e75 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -30,11 +30,32 @@ #include "sim.h" #include "scm_corrmat.h" #include "common/utils/LOG/log.h" +#include "common/config/config_userapi.h" +#include "common/utils/telnetsrv/telnetsrv.h" +#include "common/utils/load_module_shlib.h" + + //#define DEBUG_CH #include "assertions.h" extern void print_shorts(char *s,__m128i *x); +static mapping channelmod_names[] = { + CHANNELMOD_MAP_INIT +}; + +static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt); +static telnetshell_cmddef_t channelmod_cmdarray[] = { + {"show","",channelmod_show_cmd}, + {"","",NULL}, +}; + +static telnetshell_vardef_t channelmod_vardef[] = { + {"",0,NULL} +}; + +static double snr_dB=25; +static double sinr_dB=0; void fill_channel_desc(channel_desc_t *chan_desc, uint8_t nb_tx, @@ -43,7 +64,7 @@ void fill_channel_desc(channel_desc_t *chan_desc, uint8_t channel_length, double *amps, double *delays, - struct complex** R_sqrt, + struct complex **R_sqrt, double Td, double sampling_rate, double channel_bandwidth, @@ -53,30 +74,27 @@ void fill_channel_desc(channel_desc_t *chan_desc, double max_Doppler, int32_t channel_offset, double path_loss_dB, - uint8_t random_aoa) -{ - - + uint8_t random_aoa) { uint16_t i,j; double delta_tau; - LOG_I(OCM,"[CHANNEL] Getting new channel descriptor, nb_tx %d, nb_rx %d, nb_taps %d, channel_length %d\n", - nb_tx,nb_rx,nb_taps,channel_length); - + nb_tx,nb_rx,nb_taps,channel_length); chan_desc->nb_tx = nb_tx; chan_desc->nb_rx = nb_rx; chan_desc->nb_taps = nb_taps; chan_desc->channel_length = channel_length; chan_desc->amps = amps; LOG_D(OCM,"[CHANNEL] Doing delays ...\n"); + if (delays==NULL) { - chan_desc->delays = (double*) malloc(nb_taps*sizeof(double)); + chan_desc->delays = (double *) malloc(nb_taps*sizeof(double)); delta_tau = Td/nb_taps; + for (i=0; idelays[i] = ((double)i)*delta_tau; - } - else - chan_desc->delays = delays; + } else + chan_desc->delays = delays; + chan_desc->Td = Td; chan_desc->sampling_rate = sampling_rate; chan_desc->channel_bandwidth = channel_bandwidth; @@ -89,43 +107,46 @@ void fill_channel_desc(channel_desc_t *chan_desc, chan_desc->first_run = 1; chan_desc->ip = 0.0; chan_desc->max_Doppler = max_Doppler; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(nb_taps*sizeof(struct complex*)); - + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(nb_taps*sizeof(struct complex *)); LOG_D(OCM,"[CHANNEL] Filling ch \n"); for (i = 0; ich[i] = (struct complex*) malloc(channel_length * sizeof(struct complex)); + chan_desc->ch[i] = (struct complex *) malloc(channel_length * sizeof(struct complex)); for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); // allocate for up to 100 RBs, 12 samples per RB + chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); // allocate for up to 100 RBs, 12 samples per RB LOG_D(OCM,"[CHANNEL] Filling a (nb_taps %d)\n",nb_taps); + for (i = 0; ia[i],nb_tx*nb_rx * sizeof(struct complex)); - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); } LOG_D(OCM,"[CHANNEL] Doing R_sqrt ...\n"); + if (R_sqrt == NULL) { - chan_desc->R_sqrt = (struct complex**) calloc(nb_taps,sizeof(struct complex*)); + chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *)); + for (i = 0; iR_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); + chan_desc->R_sqrt[i] = (struct complex *) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; chan_desc->R_sqrt[i][j].y = 0.0; } } - } - else { - chan_desc->R_sqrt = (struct complex**) calloc(nb_taps,sizeof(struct complex*)); + } else { + chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *)); + for (i = 0; iR_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); - //chan_desc->R_sqrt = (struct complex*)&R_sqrt[i][0]; - /* all chan_desc share the same R_sqrt, coming from caller */ - chan_desc->R_sqrt[i] = R_sqrt[0]; - } + //chan_desc->R_sqrt[i] = (struct complex*) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); + //chan_desc->R_sqrt = (struct complex*)&R_sqrt[i][0]; + /* all chan_desc share the same R_sqrt, coming from caller */ + chan_desc->R_sqrt[i] = R_sqrt[0]; + } } for (i = 0; iricean_factor); - for (i=0;inb_taps;i++) + + for (i=0; inb_taps; i++) LOG_D(OCM,"[CHANNEL] tap %d: amp %f, delay %f\n",i,chan_desc->amps[i],chan_desc->delays[i]); chan_desc->nb_paths=10; - reset_meas(&chan_desc->random_channel); reset_meas(&chan_desc->interp_time); reset_meas(&chan_desc->interp_freq); reset_meas(&chan_desc->convolution); - } double mbsfn_delays[] = {0,.03,.15,.31,.37,1.09,12.490,12.52,12.64,12.80,12.86,13.58,27.49,27.52,27.64,27.80,27.86,28.58}; @@ -162,7 +182,7 @@ double eva_amps_dB[] = {0.0,-1.5,-1.4,-3.6,-0.6,-9.1,-7.0,-12.0,-16.9}; double etu_delays[] = { 0,.05,.12,.2,.23,.5,1.6,2.3,5.0}; double etu_amps_dB[] = {-1.0,-1.0,-1.0,0.0,0.0,0.0,-3.0,-5.0,-7.0}; -double default_amps_lin[] = {0.3868472 , 0.3094778 , 0.1547389 , 0.0773694 , 0.0386847 , 0.0193424 , 0.0096712 , 0.0038685}; +double default_amps_lin[] = {0.3868472, 0.3094778, 0.1547389, 0.0773694, 0.0386847, 0.0193424, 0.0096712, 0.0038685}; double default_amp_lin[] = {1}; double ts_shift_delays[] = {0, 1/7.68}; @@ -170,9 +190,10 @@ double ts_shift_amps[] = {0, 1}; //correlation matrix for a 2x2 channel with full Tx correlation struct complex R_sqrt_22_corr_tap[16] = {{0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0}, - {0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0}}; + {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0}, + {0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, + {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {0.70711,0} +}; struct complex *R_sqrt_22_corr[1] = {R_sqrt_22_corr_tap}; //correlation matrix for a fully correlated 2x1 channel (h1==h2) @@ -181,9 +202,10 @@ struct complex *R_sqrt_21_corr[1] = {R_sqrt_21_corr_tap}; //correlation matrix for a 2x2 channel with full Tx anti-correlation struct complex R_sqrt_22_anticorr_tap[16] = {{0.70711,0}, {0.0, 0.0}, {-0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {-0.70711,0}, - {-0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, - {0.0, 0.0}, {-0.70711,0}, {0.0, 0.0}, {0.70711,0}}; + {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, {-0.70711,0}, + {-0.70711,0}, {0.0, 0.0}, {0.70711,0}, {0.0, 0.0}, + {0.0, 0.0}, {-0.70711,0}, {0.0, 0.0}, {0.70711,0} +}; struct complex *R_sqrt_22_anticorr[1] = {R_sqrt_22_anticorr_tap}; //correlation matrix for a fully anti-correlated 2x1 channel (h1==-h2) @@ -195,9 +217,10 @@ struct complex **R_sqrt_ptr2; // full correlation matrix in vectorized form for 2x2 channel, where h1 is perfectly orthogonal to h2 struct complex R_sqrt_22_orthogonal_tap[16] = {{0.70711,0.0}, {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, - {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.70711,0.0}}; + {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, + {0.0,0.0}, {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, + {0.0, 0.0}, {0.0,0.0}, {0.0, 0.0}, {0.70711,0.0} +}; struct complex *R_sqrt_22_orthogonal[1] = {R_sqrt_22_orthogonal_tap}; // full correlation matrix for TM4 to make orthogonal effective channel @@ -206,37 +229,43 @@ struct complex *R_sqrt_22_orthogonal[1] = {R_sqrt_22_orthogonal_tap}; struct complex R_sqrt_22_orth_eff_ch_TM4_prec_real_tap[16] = {{0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {-0.70711,0.0}, - {0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}}; + {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {-0.70711,0.0}, + {0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, + {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, {0.70711,0.0} +}; struct complex *R_sqrt_22_orth_eff_ch_TM4_prec_real[1] = {R_sqrt_22_orth_eff_ch_TM4_prec_real_tap}; struct complex R_sqrt_22_orth_eff_ch_TM4_prec_imag_tap[16] = {{0.70711,0.0}, {0.0,0.0}, {0.0, -0.70711}, {0.0,0.0}, - {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {0.0,0.70711}, - {0.0,-0.70711}, {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, - {0.0, 0.0}, {0.0,0.70711}, {0.0, 0.0}, {-0.70711,0.0}}; + {0.0, 0.0}, {0.70711,0.0}, {0.0, 0.0}, {0.0,0.70711}, + {0.0,-0.70711}, {0.0, 0.0}, {-0.70711,0.0}, {0.0, 0.0}, + {0.0, 0.0}, {0.0,0.70711}, {0.0, 0.0}, {-0.70711,0.0} +}; struct complex *R_sqrt_22_orth_eff_ch_TM4_prec_imag[1] = {R_sqrt_22_orth_eff_ch_TM4_prec_imag_tap}; //Correlation matrix for EPA channel struct complex R_sqrt_22_EPA_low_tap[16] = {{1.0,0.0}, {0.0,0.0}, {0.0,0.0}, {0.0,0.0}, - {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, {0.0,0.0}, - {0.0,0.0}, {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, - {0.0,0.0}, {0.0,0.0}, {0.0,0.0}, {1.0,0.0}}; + {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, {0.0,0.0}, + {0.0,0.0}, {0.0,0.0}, {1.0,0.0}, {0.0,0.0}, + {0.0,0.0}, {0.0,0.0}, {0.0,0.0}, {1.0,0.0} +}; struct complex *R_sqrt_22_EPA_low[1] = {R_sqrt_22_EPA_low_tap}; -struct complex R_sqrt_22_EPA_high_tap[16] = {{0.7179,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.2821,0.0}, - {0.4500,0.0}, {0.7179,0.0}, {0.2821,0.0}, {0.4500,0.0}, - {0.4500,0.0}, {0.2821,0.0}, {0.7179,0.0}, {0.4500,0.0}, - {0.2821,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.7179,0.0}}; +struct complex R_sqrt_22_EPA_high_tap[16] = { + {0.7179,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.2821,0.0}, + {0.4500,0.0}, {0.7179,0.0}, {0.2821,0.0}, {0.4500,0.0}, + {0.4500,0.0}, {0.2821,0.0}, {0.7179,0.0}, {0.4500,0.0}, + {0.2821,0.0}, {0.4500,0.0}, {0.4500,0.0}, {0.7179,0.0} +}; struct complex *R_sqrt_22_EPA_high[1] = {R_sqrt_22_EPA_high_tap}; struct complex R_sqrt_22_EPA_medium_tap[16] = {{0.8375,0.0}, {0.5249,0.0}, {0.1286,0.0}, {0.0806,0.0}, - {0.5249,0.0}, {0.8375,0.0}, {0.0806,0.0}, {0.1286,0.0}, - {0.1286,0.0}, {0.0806,0.0}, {0.8375,0.0}, {0.5249,0.0}, - {0.0806,0.0}, {0.1286,0.0}, {0.5249,0.0}, {0.8375,0.0}}; + {0.5249,0.0}, {0.8375,0.0}, {0.0806,0.0}, {0.1286,0.0}, + {0.1286,0.0}, {0.0806,0.0}, {0.8375,0.0}, {0.5249,0.0}, + {0.0806,0.0}, {0.1286,0.0}, {0.5249,0.0}, {0.8375,0.0} +}; struct complex *R_sqrt_22_EPA_medium[1] = {R_sqrt_22_EPA_medium_tap}; @@ -250,15 +279,12 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, double channel_bandwidth, double forgetting_factor, int32_t channel_offset, - double path_loss_dB) -{ - + double path_loss_dB) { channel_desc_t *chan_desc = (channel_desc_t *)malloc(sizeof(channel_desc_t)); uint16_t i,j; double sum_amps; double aoa,ricean_factor,Td,maxDoppler; int channel_length,nb_taps; - chan_desc->nb_tx = nb_tx; chan_desc->nb_rx = nb_rx; chan_desc->sampling_rate = sampling_rate; @@ -268,424 +294,514 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, chan_desc->path_loss_dB = path_loss_dB; chan_desc->first_run = 1; chan_desc->ip = 0.0; - LOG_I(OCM,"Channel Model (inside of new_channel_desc_scm)=%d\n\n", channel_model); switch (channel_model) { - case SCM_A: - LOG_W(OCM,"channel model not yet supported\n"); - free(chan_desc); - return(NULL); - case SCM_B: - LOG_W(OCM,"channel model not yet supported\n"); - free(chan_desc); - return(NULL); - case SCM_C: - chan_desc->nb_taps = 18; - chan_desc->Td = 4.625; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = scm_c_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + case SCM_A: + LOG_W(OCM,"channel model not yet supported\n"); + free(chan_desc); + return(NULL); - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - if (nb_tx==2 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else if (nb_tx==2 && nb_rx==1) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R21_sqrt[i][0]; - } - else if (nb_tx==1 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R12_sqrt[i][0]; - } - else { - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); - } - } - break; - case SCM_D: - LOG_W(OCM,"This is not the real SCM-D model! It is just SCM-C with an additional Rice factor!\n"); - chan_desc->nb_taps = 18; - chan_desc->Td = 4.625; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = scm_c_delays; - chan_desc->ricean_factor = 0.1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + case SCM_B: + LOG_W(OCM,"channel model not yet supported\n"); + free(chan_desc); + return(NULL); - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - if (nb_tx==2 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else if (nb_tx==2 && nb_rx==1) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R21_sqrt[i][0]; - } - else if (nb_tx==1 && nb_rx==2) { - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R12_sqrt[i][0]; - } - else { - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); + case SCM_C: + chan_desc->nb_taps = 18; + chan_desc->Td = 4.625; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); + sum_amps += chan_desc->amps[i]; } - } - break; - case EPA: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - } - break; - case EPA_low: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex**)); + for (i = 0; inb_taps; i++) - chan_desc->R_sqrt[i] = R_sqrt_22_EPA_low[0]; - } - else { - printf("Correlation matrices are implemented for 2 x 2 only"); - } - /*else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - }*/ - break; - case EPA_high: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex**)); + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = scm_c_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + for (i = 0; inb_taps; i++) - chan_desc->R_sqrt[i] = R_sqrt_22_EPA_high[0]; - } - else { - printf("Correlation matrices are implemented for 2 x 2 only"); - } - /*else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + if (nb_tx==2 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else if (nb_tx==2 && nb_rx==1) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0]; + } else if (nb_tx==1 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0]; + } else { + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); } - }*/ - break; + + break; + + case SCM_D: + LOG_W(OCM,"This is not the real SCM-D model! It is just SCM-C with an additional Rice factor!\n"); + chan_desc->nb_taps = 18; + chan_desc->Td = 4.625; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = scm_c_delays; + chan_desc->ricean_factor = 0.1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + if (nb_tx==2 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else if (nb_tx==2 && nb_rx==1) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0]; + } else if (nb_tx==1 && nb_rx==2) { + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0]; + } else { + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); + } + } + + break; + + case EPA: + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + } + + break; + + case EPA_low: + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex **)); + + for (i = 0; inb_taps; i++) + chan_desc->R_sqrt[i] = R_sqrt_22_EPA_low[0]; + } else { + printf("Correlation matrices are implemented for 2 x 2 only"); + } + + /*else { + chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + }*/ + break; + + case EPA_high: + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex **)); + + for (i = 0; inb_taps; i++) + chan_desc->R_sqrt[i] = R_sqrt_22_EPA_high[0]; + } else { + printf("Correlation matrices are implemented for 2 x 2 only"); + } + + /*else { + chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + }*/ + break; + case EPA_medium: - chan_desc->nb_taps = 7; - chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = epa_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex**)); + chan_desc->nb_taps = 7; + chan_desc->Td = .410; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + for (i = 0; inb_taps; i++) - chan_desc->R_sqrt[i] = R_sqrt_22_EPA_medium[0]; - } else { - printf("Correlation matrices are implemented for 2 x 2 only"); - } - /*else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - }*/ - break; - case EVA: - chan_desc->nb_taps = 9; - chan_desc->Td = 2.51; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = eva_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - } - break; - case ETU: - chan_desc->nb_taps = 9; - chan_desc->Td = 5.0; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = etu_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); - if (nb_tx==2 && nb_rx==2) { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) - chan_desc->R_sqrt[i] = (struct complex*) &R22_sqrt[i][0]; - } - else { - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - } - break; - case MBSFN: - chan_desc->nb_taps = 18; - chan_desc->Td = 28.58; - chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); - sum_amps = 0; - chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); - for (i = 0; inb_taps; i++) { - chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]); - sum_amps += chan_desc->amps[i]; - } - for (i = 0; inb_taps; i++) - chan_desc->amps[i] /= sum_amps; - chan_desc->delays = mbsfn_delays; - chan_desc->ricean_factor = 1; - chan_desc->aoa = 0; - chan_desc->random_aoa = 0; - chan_desc->ch = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->chF = (struct complex**) malloc(nb_tx*nb_rx*sizeof(struct complex*)); - chan_desc->a = (struct complex**) malloc(chan_desc->nb_taps*sizeof(struct complex*)); - for (i = 0; ich[i] = (struct complex*) malloc(chan_desc->channel_length * sizeof(struct complex)); - for (i = 0; ichF[i] = (struct complex*) malloc(1200 * sizeof(struct complex)); - for (i = 0; inb_taps; i++) - chan_desc->a[i] = (struct complex*) malloc(nb_tx*nb_rx * sizeof(struct complex)); + chan_desc->amps[i] /= sum_amps; - chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex*)); - for (i = 0; i<6; i++) { - chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); - for (j = 0; jR_sqrt[i][j].x = 1.0; - chan_desc->R_sqrt[i][j].y = 0.0; - } - LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); - } - break; - case Rayleigh8: + chan_desc->delays = epa_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex **)); + + for (i = 0; inb_taps; i++) + chan_desc->R_sqrt[i] = R_sqrt_22_EPA_medium[0]; + } else { + printf("Correlation matrices are implemented for 2 x 2 only"); + } + + /*else { + chan_desc->R_sqrt = (struct complex**) malloc(6*sizeof(struct complex**)); + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex*) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + }*/ + break; + + case EVA: + chan_desc->nb_taps = 9; + chan_desc->Td = 2.51; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = eva_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + } + + break; + + case ETU: + chan_desc->nb_taps = 9; + chan_desc->Td = 5.0; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = etu_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + if (nb_tx==2 && nb_rx==2) { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) + chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; + } else { + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + } + + break; + + case MBSFN: + chan_desc->nb_taps = 18; + chan_desc->Td = 28.58; + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); + sum_amps = 0; + chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); + + for (i = 0; inb_taps; i++) { + chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]); + sum_amps += chan_desc->amps[i]; + } + + for (i = 0; inb_taps; i++) + chan_desc->amps[i] /= sum_amps; + + chan_desc->delays = mbsfn_delays; + chan_desc->ricean_factor = 1; + chan_desc->aoa = 0; + chan_desc->random_aoa = 0; + chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *)); + chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *)); + + for (i = 0; ich[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex)); + + for (i = 0; ichF[i] = (struct complex *) malloc(1200 * sizeof(struct complex)); + + for (i = 0; inb_taps; i++) + chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex)); + + chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex *)); + + for (i = 0; i<6; i++) { + chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); + + for (j = 0; jR_sqrt[i][j].x = 1.0; + chan_desc->R_sqrt[i][j].y = 0.0; + } + + LOG_W(OCM,"correlation matrix only implemented for nb_tx==2 and nb_rx==2, using identity\n"); + } + + break; + + case Rayleigh8: nb_taps = 8; Td = 0.8; channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 1; aoa = .03; maxDoppler = 0; - fill_channel_desc(chan_desc, nb_tx, nb_rx, @@ -706,88 +822,85 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, 0); break; - case Rice8: + case Rice8: nb_taps = 8; Td = 0.8; channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 0.1; aoa = 0.7854; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amps_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amps_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rayleigh1: + case Rayleigh1: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 1; aoa = .03; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_800: + case Rayleigh1_800: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 1; aoa = .03; maxDoppler = 800; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_corr: + case Rayleigh1_corr: nb_taps = 1; Td = 0; channel_length = 1; @@ -797,33 +910,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { R_sqrt_ptr2 = R_sqrt_21_corr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_corr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_anticorr: + case Rayleigh1_anticorr: nb_taps = 1; Td = 0; channel_length = 1; @@ -833,118 +944,111 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { //check this R_sqrt_ptr2 = R_sqrt_21_anticorr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_anticorr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rice1: + case Rice1: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 0.1; aoa = 0.7854; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case AWGN: + case AWGN: nb_taps = 1; Td = 0; channel_length = 1; ricean_factor = 0.0; aoa = 0.0; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); printf("AWGN: ricean_factor %f\n",chan_desc->ricean_factor); - break; - case TS_SHIFT: + case TS_SHIFT: nb_taps = 2; Td = ts_shift_delays[1]; channel_length = 10; ricean_factor = 0.0; aoa = 0.0; maxDoppler = 0; - fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - ts_shift_amps, - ts_shift_delays, - NULL, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + ts_shift_amps, + ts_shift_delays, + NULL, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); printf("TS_SHIFT: ricean_factor %f\n",chan_desc->ricean_factor); - break; - case Rice1_corr: + case Rice1_corr: nb_taps = 1; Td = 0; channel_length = 1; @@ -954,33 +1058,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { R_sqrt_ptr2 = R_sqrt_21_corr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_corr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rice1_anticorr: + case Rice1_anticorr: nb_taps = 1; Td = 0; channel_length = 1; @@ -990,33 +1092,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, if ((nb_tx==2) && (nb_rx==1)) { R_sqrt_ptr2 = R_sqrt_21_anticorr; - } - else if ((nb_tx==2) && (nb_rx==2)) { + } else if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_anticorr; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rayleigh1_orthogonal: + case Rayleigh1_orthogonal: nb_taps = 1; Td = 0; channel_length = 1; @@ -1024,33 +1124,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, aoa = 0.03; maxDoppler = 0; - if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orthogonal; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh1_orth_eff_ch_TM4_prec_real: + case Rayleigh1_orth_eff_ch_TM4_prec_real: nb_taps = 1; Td = 0; channel_length = 1; @@ -1058,33 +1156,31 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, aoa = 0.03; maxDoppler = 0; - if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_real; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 1); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 1); break; - case Rayleigh1_orth_eff_ch_TM4_prec_imag: + case Rayleigh1_orth_eff_ch_TM4_prec_imag: nb_taps = 1; Td = 0; channel_length = 1; @@ -1092,48 +1188,75 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, aoa = 0.03; maxDoppler = 0; - if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_imag; - } - else + } else R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc,nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amp_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); + nb_rx, + nb_taps, + channel_length, + default_amp_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); break; - case Rayleigh8_orth_eff_ch_TM4_prec_real: - - if ((nb_tx==2) && (nb_rx==2)) { + case Rayleigh8_orth_eff_ch_TM4_prec_real: + if ((nb_tx==2) && (nb_rx==2)) { R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_real; //R_sqrt_ptr2 = NULL; - } - else + } else R_sqrt_ptr2 = NULL; - nb_taps = 8; Td = 0.8; channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 1; aoa = .03; maxDoppler = 0; + fill_channel_desc(chan_desc, + nb_tx, + nb_rx, + nb_taps, + channel_length, + default_amps_lin, + NULL, + R_sqrt_ptr2, + Td, + sampling_rate, + channel_bandwidth, + ricean_factor, + aoa, + forgetting_factor, + maxDoppler, + channel_offset, + path_loss_dB, + 0); + break; + + case Rayleigh8_orth_eff_ch_TM4_prec_imag: + nb_taps = 8; + Td = 0.8; + channel_length = (int)11+2*sampling_rate*Td; + ricean_factor = 1; + aoa = .03; + maxDoppler = 0; + + if ((nb_tx==2) && (nb_rx==2)) { + R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_imag; + } else + R_sqrt_ptr2 = NULL; fill_channel_desc(chan_desc, nb_tx, @@ -1153,77 +1276,40 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, channel_offset, path_loss_dB, 0); - break; - case Rayleigh8_orth_eff_ch_TM4_prec_imag: - nb_taps = 8; - Td = 0.8; - channel_length = (int)11+2*sampling_rate*Td; - ricean_factor = 1; - aoa = .03; - maxDoppler = 0; - - if ((nb_tx==2) && (nb_rx==2)) { - R_sqrt_ptr2 = R_sqrt_22_orth_eff_ch_TM4_prec_imag; - } - else - R_sqrt_ptr2 = NULL; - - fill_channel_desc(chan_desc, - nb_tx, - nb_rx, - nb_taps, - channel_length, - default_amps_lin, - NULL, - R_sqrt_ptr2, - Td, - sampling_rate, - channel_bandwidth, - ricean_factor, - aoa, - forgetting_factor, - maxDoppler, - channel_offset, - path_loss_dB, - 0); - break; - - default: - LOG_W(OCM,"channel model not yet supported\n"); - free(chan_desc); - return(NULL); + default: + LOG_W(OCM,"channel model not yet supported\n"); + free(chan_desc); + return(NULL); } + LOG_D(OCM,"[CHANNEL] RF %f\n",chan_desc->ricean_factor); - for (i=0;inb_taps;i++) + + for (i=0; inb_taps; i++) LOG_D(OCM,"[CHANNEL] tap %d: amp %f, delay %f\n",i,chan_desc->amps[i],chan_desc->delays[i]); chan_desc->nb_paths = 10; - return(chan_desc); } -void free_channel_desc_scm(channel_desc_t * ch) { - // Must be made cleanly, a lot of leaks... - free(ch); +void free_channel_desc_scm(channel_desc_t *ch) { + // Must be made cleanly, a lot of leaks... + free(ch); } int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { - double s; int i,k,l,aarx,aatx; struct complex anew[NB_ANTENNAS_TX*NB_ANTENNAS_RX],acorr[NB_ANTENNAS_TX*NB_ANTENNAS_RX]; struct complex phase, alpha, beta; - AssertFatal(desc->nb_tx<=NB_ANTENNAS_TX && desc->nb_rx <= NB_ANTENNAS_RX, - "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); - + "random_channel.c: Error: temporary buffer for channel not big enough (%d,%d)\n",desc->nb_tx,desc->nb_rx); start_meas(&desc->random_channel); - for (i=0;i<(int)desc->nb_taps;i++) { - for (aarx=0;aarxnb_rx;aarx++) { - for (aatx=0;aatxnb_tx;aatx++) { + for (i=0; i<(int)desc->nb_taps; i++) { + for (aarx=0; aarxnb_rx; aarx++) { + for (aatx=0; aatxnb_tx; aatx++) { anew[aarx+(aatx*desc->nb_rx)].x = sqrt(desc->ricean_factor*desc->amps[i]/2) * gaussdouble(0.0,1.0); anew[aarx+(aatx*desc->nb_rx)].y = sqrt(desc->ricean_factor*desc->amps[i]/2) * gaussdouble(0.0,1.0); @@ -1237,10 +1323,10 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { // that we can safely assume plane wave propagation. phase.x = cos(M_PI*((aarx-aatx)*sin(desc->aoa))); phase.y = sin(M_PI*((aarx-aatx)*sin(desc->aoa))); - anew[aarx+(aatx*desc->nb_rx)].x += phase.x * sqrt(1.0-desc->ricean_factor); anew[aarx+(aatx*desc->nb_rx)].y += phase.y * sqrt(1.0-desc->ricean_factor); } + #ifdef DEBUG_CH printf("(%d,%d,%d) %f->(%f,%f) (%f,%f) phase (%f,%f)\n",aarx,aatx,i,desc->amps[i],anew[aarx+(aatx*desc->nb_rx)].x,anew[aarx+(aatx*desc->nb_rx)].y,desc->aoa,desc->ricean_factor,phase.x,phase.y); #endif @@ -1263,10 +1349,9 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { alpha.y = 0.0; beta.x = 0.0; beta.y = 0.0; - cblas_zgemv(CblasRowMajor, CblasNoTrans, desc->nb_tx*desc->nb_rx, desc->nb_tx*desc->nb_rx, - (void*) &alpha, (void*) desc->R_sqrt[i/3], desc->nb_rx*desc->nb_tx, - (void*) anew, 1, (void*) &beta, (void*) acorr, 1); + (void *) &alpha, (void *) desc->R_sqrt[i/3], desc->nb_rx*desc->nb_tx, + (void *) anew, 1, (void *) &beta, (void *) acorr, 1); /* for (aarx=0;aarxnb_rx;aarx++) { @@ -1278,10 +1363,9 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { } */ - if (desc->first_run==1){ - cblas_zcopy(desc->nb_tx*desc->nb_rx, (void*) acorr, 1, (void*) desc->a[i], 1); - } - else { + if (desc->first_run==1) { + cblas_zcopy(desc->nb_tx*desc->nb_rx, (void *) acorr, 1, (void *) desc->a[i], 1); + } else { // a = alpha*acorr+beta*a // a = beta*a // a = a+alpha*acorr @@ -1289,9 +1373,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { alpha.y = 0; beta.x = sqrt(desc->forgetting_factor); beta.y = 0; - cblas_zscal(desc->nb_tx*desc->nb_rx, (void*) &beta, (void*) desc->a[i], 1); - cblas_zaxpy(desc->nb_tx*desc->nb_rx, (void*) &alpha, (void*) acorr, 1, (void*) desc->a[i], 1); - + cblas_zscal(desc->nb_tx*desc->nb_rx, (void *) &beta, (void *) desc->a[i], 1); + cblas_zaxpy(desc->nb_tx*desc->nb_rx, (void *) &alpha, (void *) acorr, 1, (void *) desc->a[i], 1); // desc->a[i][aarx+(aatx*desc->nb_rx)].x = (sqrt(desc->forgetting_factor)*desc->a[i][aarx+(aatx*desc->nb_rx)].x) + sqrt(1-desc->forgetting_factor)*anew.x; // desc->a[i][aarx+(aatx*desc->nb_rx)].y = (sqrt(desc->forgetting_factor)*desc->a[i][aarx+(aatx*desc->nb_rx)].y) + sqrt(1-desc->forgetting_factor)*anew.y; } @@ -1305,8 +1388,8 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { } } */ - } //nb_taps + stop_meas(&desc->random_channel); //memset((void *)desc->ch[aarx+(aatx*desc->nb_rx)],0,(int)(desc->channel_length)*sizeof(struct complex)); @@ -1320,7 +1403,6 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { desc->ch[aarx+(aatx*desc->nb_rx)][0].x = desc->a[0][aarx+(aatx*desc->nb_rx)].x; desc->ch[aarx+(aatx*desc->nb_rx)][0].y = desc->a[0][aarx+(aatx*desc->nb_rx)].y; } else { - for (k=0; k<(int)desc->channel_length; k++) { desc->ch[aarx+(aatx*desc->nb_rx)][k].x = 0.0; desc->ch[aarx+(aatx*desc->nb_rx)][k].y = 0.0; @@ -1335,18 +1417,18 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { desc->ch[aarx+(aatx*desc->nb_rx)][k].x += s*desc->a[l][aarx+(aatx*desc->nb_rx)].x; desc->ch[aarx+(aatx*desc->nb_rx)][k].y += s*desc->a[l][aarx+(aatx*desc->nb_rx)].y; // printf("l %d : desc->ch.x %f\n",l,desc->a[l][aarx+(aatx*desc->nb_rx)].x); - } //nb_taps #ifdef DEBUG_CH - k=0; - printf("(%d,%d,%d)->(%f,%f)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y); + k=0; + printf("(%d,%d,%d)->(%f,%f)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].x,desc->ch[aarx+(aatx*desc->nb_rx)][k].y); #endif - } - } //channel_length - } //aatx - } //aarx - stop_meas(&desc->interp_time); + } + } //channel_length + } //aatx + } //aarx + + stop_meas(&desc->interp_time); } if (desc->first_run==1) @@ -1355,69 +1437,103 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) { return (0); } -double N_RB2sampling_rate(uint16_t N_RB) -{ +double N_RB2sampling_rate(uint16_t N_RB) { double sampling_rate; + switch (N_RB) { - case 6: - sampling_rate = 1.92; - break; + case 6: + sampling_rate = 1.92; + break; - case 25: - sampling_rate = 7.68; - break; + case 25: + sampling_rate = 7.68; + break; - case 50: - sampling_rate = 15.36; - break; + case 50: + sampling_rate = 15.36; + break; - case 100: - sampling_rate = 30.72; - break; + case 100: + sampling_rate = 30.72; + break; - default: - AssertFatal(1==0,"Unknown N_PRB %d",N_RB); + default: + AssertFatal(1==0,"Unknown N_PRB %d",N_RB); } return(sampling_rate); } -double N_RB2channel_bandwidth(uint16_t N_RB) -{ +double N_RB2channel_bandwidth(uint16_t N_RB) { double channel_bandwidth; + switch (N_RB) { - case 6: - channel_bandwidth = 1.25; - break; + case 6: + channel_bandwidth = 1.25; + break; - case 25: - channel_bandwidth = 5.00; - break; + case 25: + channel_bandwidth = 5.00; + break; - case 50: - channel_bandwidth = 10.00; - break; + case 50: + channel_bandwidth = 10.00; + break; - case 100: - channel_bandwidth = 20.00; - break; + case 100: + channel_bandwidth = 20.00; + break; - default: - LOG_E(PHY,"Unknown N_PRB\n"); - return(-1); + default: + LOG_E(PHY,"Unknown N_PRB\n"); + return(-1); } + return(channel_bandwidth); } +static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) { + for(int i=0; channelmod_names[i].name != NULL ; i++) { + prnt(" %i %s\n", i, map_int_to_str(channelmod_names,i )); + } + + return 0; +} + +int modelid_fromname(char *modelname) { + int modelid=map_str_to_int(channelmod_names,modelname); + AssertFatal(modelid>0, + "random_channel.c: Error channel model %s unknown\n",modelname); + return modelid; +} + +double channelmod_get_snr_dB(void) { + return snr_dB; +} + +double channelmod_get_sinr_dB(void) { + return sinr_dB; +} + +void init_channelmod(void) { + paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC; + int ret = config_get( channelmod_params,sizeof(channelmod_params)/sizeof(paramdef_t),CHANNELMOD_SECTION); + AssertFatal(ret >= 0, "configuration couldn't be performed"); + /* look for telnet server, if it is loaded, add the channel modeling commands to it */ + add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME); + + if (addcmd != NULL) { + addcmd("channelmod",channelmod_vardef,channelmod_cmdarray); + } +} + #ifdef RANDOM_CHANNEL_MAIN #define sampling_rate 5.0 #define Td 2.0 main(int argc,char **argv) { - double amps[8] = {.8,.2,.1,.04,.02,.01,.005}; struct complex ch[(int)(1+2*sampling_rate*Td)],phase; int i; - randominit(); phase.x = 1.0; phase.y = 0; diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 1d5c43232e..0bc5975d99 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -147,7 +147,7 @@ typedef struct { /// Rice factor??? /// Walls (penetration loss) /// Nodes in the scenario - node_desc_t* nodes; + node_desc_t *nodes; } scenario_desc_t; typedef enum { @@ -180,29 +180,66 @@ typedef enum { EPA_medium, EPA_high, } SCM_t; +#define CHANNELMOD_MAP_INIT \ + {"custom",custom},\ + {"SCM_A",SCM_A},\ + {"SCM_B",SCM_B},\ + {"SCM_C",SCM_C},\ + {"SCM_D",SCM_D},\ + {"EPA",EPA},\ + {"EVA",EVA},\ + {"ETU",ETU},\ + {"MBSFN",MBSFN},\ + {"Rayleigh8",Rayleigh8},\ + {"Rayleigh1",Rayleigh1},\ + {"Rayleigh1_800",Rayleigh1_800},\ + {"Rayleigh1_corr",Rayleigh1_corr},\ + {"Rayleigh1_anticorr",Rayleigh1_anticorr},\ + {"Rice8",Rice8},\ + {"Rice1",Rice1},\ + {"Rice1_corr",Rice1_corr},\ + {"Rice1_anticorr",Rice1_anticorr},\ + {"AWGN",AWGN},\ + {"Rayleigh1_orthogonal",Rayleigh1_orthogonal},\ + {"Rayleigh1_orth_eff_ch_TM4_prec_real",Rayleigh1_orth_eff_ch_TM4_prec_real},\ + {"Rayleigh1_orth_eff_ch_TM4_prec_imag",Rayleigh1_orth_eff_ch_TM4_prec_imag},\ + {"Rayleigh8_orth_eff_ch_TM4_prec_real",Rayleigh8_orth_eff_ch_TM4_prec_real},\ + {"Rayleigh8_orth_eff_ch_TM4_prec_imag",Rayleigh8_orth_eff_ch_TM4_prec_imag},\ + {"TS_SHIFT",TS_SHIFT},\ + {"EPA_low",EPA_low},\ + {"EPA_medium",EPA_medium},\ + {"EPA_high",EPA_high},\ + {NULL, -1} + +#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" +#define CHANNELMOD_SECTION "channelmod" +#define CHANNELMOD_PARAMS_DESC { \ + {"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB , defdblval:25, TYPE_DOUBLE, 0},\ + {"sinr_dB", NULL , 0 , dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\ + } #include "platform_constants.h" typedef struct { - channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; - channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - double r_re_DL[NUMBER_OF_UE_MAX][2][30720]; - double r_im_DL[NUMBER_OF_UE_MAX][2][30720]; - double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; - double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; - int RU_output_mask[NUMBER_OF_UE_MAX]; - int UE_output_mask[NUMBER_OF_RU_MAX]; - pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; - pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; - pthread_mutex_t subframe_mutex; - int subframe_ru_mask; - int subframe_UE_mask; - openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; - openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; - double ru_amp[NUMBER_OF_RU_MAX]; - pthread_t rfsim_thread; + channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM_CCs]; + channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + double r_re_DL[NUMBER_OF_UE_MAX][2][30720]; + double r_im_DL[NUMBER_OF_UE_MAX][2][30720]; + double r_re_UL[NUMBER_OF_eNB_MAX][2][30720]; + double r_im_UL[NUMBER_OF_eNB_MAX][2][30720]; + int RU_output_mask[NUMBER_OF_UE_MAX]; + int UE_output_mask[NUMBER_OF_RU_MAX]; + pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; + pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; + pthread_mutex_t subframe_mutex; + int subframe_ru_mask; + int subframe_UE_mask; + openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; + openair0_timestamp last_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + openair0_timestamp last_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; + double ru_amp[NUMBER_OF_RU_MAX]; + pthread_t rfsim_thread; } sim_t; @@ -395,23 +432,40 @@ void multipath_tv_channel(channel_desc_t *desc, /**@} */ /**@} */ +void rxAddInput( struct complex16 *input_sig, + struct complex16 *after_channel_sig, + int rxAnt, + channel_desc_t *channelDesc, + int nbSamples, + uint64_t TS, + uint32_t CirSize + ); + +int modelid_fromname(char *modelname); +double channelmod_get_snr_dB(void); +double channelmod_get_sinr_dB(void); +void init_channelmod(void) ; + double N_RB2sampling_rate(uint16_t N_RB); double N_RB2channel_bandwidth(uint16_t N_RB); -//#include "targets/RT/USER/rfsim.h" +#include "targets/RT/USER/rfsim.h" void do_DL_sig(sim_t *sim, uint16_t subframe, uint32_t offset, uint32_t length, - uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *ue_frame_parms, + uint8_t abstraction_flag, + LTE_DL_FRAME_PARMS *ue_frame_parms, uint8_t UE_id, int CC_id); void do_UL_sig(sim_t *sim, - uint16_t subframe,uint8_t abstraction_flag,LTE_DL_FRAME_PARMS *frame_parms, - uint32_t frame,int ru_id,uint8_t CC_id); + uint16_t subframe, + uint8_t abstraction_flag, + LTE_DL_FRAME_PARMS *frame_parms, + uint32_t frame, + int ru_id, + uint8_t CC_id); #endif - - diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index f7e5c3e68b..71c1877062 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -276,6 +276,7 @@ typedef struct RrcConfigurationReq_s { long *pdsch_maxNumRepetitionCEmodeB_r13 [MAX_NUM_CCs]; long *pusch_maxNumRepetitionCEmodeA_r13 [MAX_NUM_CCs]; long *pusch_maxNumRepetitionCEmodeB_r13 [MAX_NUM_CCs]; + long *pusch_repetitionLevelCEmodeA_r13 [MAX_NUM_CCs]; long *pusch_HoppingOffset_v1310 [MAX_NUM_CCs]; #endif //SIB18 diff --git a/openair2/ENB_APP/enb_config_eMTC.c b/openair2/ENB_APP/enb_config_eMTC.c index 45d67120bd..cfd057bad8 100644 --- a/openair2/ENB_APP/enb_config_eMTC.c +++ b/openair2/ENB_APP/enb_config_eMTC.c @@ -859,6 +859,21 @@ void fill_eMTC_configuration(MessageDef *msg_p, ccparams_eMTC_t *eMTCconfig, in config_fname); } + RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = CALLOC(1, sizeof(long)); + if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l1")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 0; + } else if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l2")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 1; + } else if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l3")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 2; + } else if (!strcmp(eMTCconfig->pusch_repetitionLevelCEmodeA_r13, "l4")) { + *RRC_CONFIGURATION_REQ(msg_p).pusch_repetitionLevelCEmodeA_r13[cc_idx] = 3; + } else { + AssertFatal (0, + "Failed to parse eNB configuration file %s, pusch_repetitionLevelCEmodeA_r13 unknown value!\n", + config_fname); + } + char rachCELevelInfoListPath[MAX_OPTNAME_SIZE * 2]; config_getlist(&rachcelevellist, NULL, 0, brparamspath); RRC_CONFIGURATION_REQ (msg_p).rach_CE_LevelInfoList_r13_size[cc_idx] = rachcelevellist.numelt; diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index a7b3ac8bda..b8710f57d3 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -395,6 +395,7 @@ typedef enum { #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13 "pusch_maxNumRepetitionCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_B_R13 "pusch_maxNumRepetitionCEmodeB_r13" +#define ENB_CONFIG_STRING_PUSCH_REPETITION_LEVEL_CE_MODE_A_R13 "pusch_repetitionLevelCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_HOPPING_OFFSET_V1310 "pusch_HoppingOffset_v1310" diff --git a/openair2/ENB_APP/enb_paramdef_emtc.h b/openair2/ENB_APP/enb_paramdef_emtc.h index 3c23b2a557..1e7705ed1a 100644 --- a/openair2/ENB_APP/enb_paramdef_emtc.h +++ b/openair2/ENB_APP/enb_paramdef_emtc.h @@ -64,6 +64,7 @@ #define ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_B_R13 "pdsch_maxNumRepetitionCEmodeB_r13" #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13 "pusch_maxNumRepetitionCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_B_R13 "pusch_maxNumRepetitionCEmodeB_r13" +#define ENB_CONFIG_STRING_PUSCH_REPETITION_LEVEL_CE_MODE_A_R13 "pusch_repetitionLevelCEmodeA_r13" #define ENB_CONFIG_STRING_PUSCH_HOPPING_OFFSET_V1310 "pusch_HoppingOffset_v1310" #define ENB_CONFIG_STRING_SYSTEM_INFO_VALUE_TAG_LIST "system_info_value_tag_SI" #define ENB_CONFIG_STRING_FIRST_PREAMBLE_R13 "firstPreamble_r13" @@ -161,6 +162,7 @@ typedef struct ccparams_eMTC_s { char *pdsch_maxNumRepetitionCEmodeB_r13; char *pusch_maxNumRepetitionCEmodeA_r13; char *pusch_maxNumRepetitionCEmodeB_r13; + char *pusch_repetitionLevelCEmodeA_r13; } ccparams_eMTC_t; @@ -230,6 +232,7 @@ typedef struct ccparams_eMTC_s { {ENB_CONFIG_STRING_PRACH_HOPPING_OFFSET_R13, NULL, 0, iptr:&eMTCconfig->prach_HoppingOffset_r13, defintval:0, TYPE_INT, 0}, \ {ENB_CONFIG_STRING_PDSCH_MAX_NUM_REPETITION_CE_MODE_A_R13, NULL, 0, strptr:&eMTCconfig->pdsch_maxNumRepetitionCEmodeA_r13, defstrval:"r16", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PUSCH_MAX_NUM_REPETITION_CE_MODE_A_R13, NULL, 0, strptr:&eMTCconfig->pusch_maxNumRepetitionCEmodeA_r13, defstrval:"r8", TYPE_STRING, 0}, \ + {ENB_CONFIG_STRING_PUSCH_REPETITION_LEVEL_CE_MODE_A_R13, NULL, 0, strptr:&eMTCconfig->pusch_repetitionLevelCEmodeA_r13, defstrval:"l1", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_CELL_SELECTION_INFO_CE_R13, NULL, 0, strptr:&eMTCconfig->cellSelectionInfoCE_r13, defstrval:"ENABLE", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_Q_RX_LEV_MIN_CE_R13, NULL, 0, iptr:&eMTCconfig->q_RxLevMinCE_r13, defintval:-70, TYPE_INT, 0}, \ {ENB_CONFIG_STRING_BANDWIDTH_REDUCED_ACCESS_RELATED_INFO_R13, NULL, 0, strptr:&eMTCconfig->bandwidthReducedAccessRelatedInfo_r13, defstrval:"ENABLE", TYPE_STRING, 0}, \ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 24b6e74bf0..8f05508c73 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -68,6 +68,7 @@ extern RAN_CONTEXT_t RC; +extern const uint8_t pusch_repetition_Table8_2_36213[3][4]; extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -98,6 +99,7 @@ void add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, sub_frame_t subframeP) { eNB_MAC_INST *mac = RC.mac[module_idP]; + eNB_RRC_INST *rrc = RC.rrc[module_idP]; COMMON_channels_t *cc = &mac->common_channels[CC_id]; uint8_t j; nfapi_ul_config_request_t *ul_req; @@ -108,6 +110,7 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; uint8_t sf_ahead_dl; uint8_t rvseq[4] = {0, 2, 3, 1}; + uint8_t pusch_maxNumRepetitionCEmodeA_r13; ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe]; ul_req_body = &ul_req->ul_config_request_body; AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n", @@ -140,7 +143,13 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP, ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL (ra->msg3_mcs, ra->msg3_nb_rb); // Re13 fields ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.ue_type = ra->rach_resource_type > 2 ? 2 : 1; - ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions = 1; + if (ra->rach_resource_type > 0) { + pusch_maxNumRepetitionCEmodeA_r13= *(rrc->configuration.pusch_maxNumRepetitionCEmodeA_r13[CC_id]); + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions= pusch_repetition_Table8_2_36213[pusch_maxNumRepetitionCEmodeA_r13][ra->pusch_repetition_levels]; + } + else{ + ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions=1; + } ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number = 1; ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.initial_transmission_sf_io = (ra->Msg3_frame * 10) + ra->Msg3_subframe; ul_req_body->number_of_pdus++; @@ -238,6 +247,7 @@ void generate_Msg2(module_id_t module_idP, //------------------------------------------------------------------------------ { eNB_MAC_INST *mac = RC.mac[module_idP]; + eNB_RRC_INST *rrc = RC.rrc[module_idP]; COMMON_channels_t *cc = mac->common_channels; uint8_t *vrb_map = NULL; int first_rb = 0; @@ -250,6 +260,7 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu]; N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + uint8_t PUSCH_Rep_Level; int rmax = 0; int rep = 0; int reps = 0; @@ -261,6 +272,13 @@ void generate_Msg2(module_id_t module_idP, uint16_t absSF = (10 * frameP) + subframeP; uint16_t absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe; + if (ra->rach_resource_type > 0) { + PUSCH_Rep_Level= *(rrc->configuration.pusch_repetitionLevelCEmodeA_r13[CC_idP]); + } + else { + PUSCH_Rep_Level= 0; + } + if (absSF > absSF_Msg2) { return; // we're not ready yet } @@ -402,6 +420,8 @@ void generate_Msg2(module_id_t module_idP, ra->msg2_mpdcch_repetition_cnt++; } + ra->pusch_repetition_levels = PUSCH_Rep_Level; + if((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) { /* Program PDSCH */ LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n", @@ -1270,6 +1290,7 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, UE_id = find_UE_id(module_idP, ra->rnti); DevAssert(UE_id != -1); mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured = TRUE; + mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].pusch_repetition_levels=ra->pusch_repetition_levels; cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti); } } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index be1f838aaa..6d752eb3a6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -84,6 +84,14 @@ uint8_t rb_table[34] = { 81, 90, 96, 100 // 30-33 }; +// This table hold the possible number of MTC repetition for CE ModeA +const uint8_t pusch_repetition_Table8_2_36213[3][4]= +{ + {1 , 2 , 4 , 8 }, + {1 , 4 , 8 , 16}, + {1 , 4 , 16, 32} +}; + extern mui_t rrc_eNB_mui; //----------------------------------------------------------------------------- @@ -301,16 +309,22 @@ rx_sdu(const module_id_t enb_mod_idP, if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); } else { - // first_rb = UE_template_ptr->first_rb_ul[harq_pid]; // UE_id = -1 !!!! - ra->msg3_round++; - /* Prepare handling of retransmission */ - get_Msg3allocret(&mac->common_channels[CC_idP], - ra->Msg3_subframe, - ra->Msg3_frame, - &ra->Msg3_frame, - &ra->Msg3_subframe); - // prepare handling of retransmission - add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP); + if (ra->rach_resource_type > 0) { + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); // TODO: Currently we don't support retransmission of Msg3 ( If in error Cancel RA procedure and reattach) + } + else + { + // first_rb = UE_template_ptr->first_rb_ul[harq_pid]; // UE_id = -1 !!!! + ra->msg3_round++; + /* Prepare handling of retransmission */ + get_Msg3allocret(&mac->common_channels[CC_idP], + ra->Msg3_subframe, + ra->Msg3_frame, + &ra->Msg3_frame, + &ra->Msg3_subframe); + // prepare handling of retransmission + add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP); + } } /* TODO: program NACK for PHICH? */ @@ -1958,10 +1972,13 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, int tpc = 0; int cqi_req = 0; eNB_MAC_INST *eNB = RC.mac[module_idP]; + eNB_RRC_INST *rrc = RC.rrc[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list = &(eNB->UE_list); UE_TEMPLATE *UE_template = NULL; UE_sched_ctrl_t *UE_sched_ctrl = NULL; + uint8_t Total_Num_Rep_ULSCH,pusch_maxNumRepetitionCEmodeA_r13; + uint8_t UL_Scheduling_DCI_SF,UL_Scheduling_DCI_Frame_Even_Odd_Flag; //TODO: To be removed after scheduler relaxation Task if (sched_subframeP < subframeP) { sched_frame++; @@ -1970,11 +1987,9 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, nfapi_hi_dci0_request_body_t *hi_dci0_req = &(eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body); nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = NULL; nfapi_ul_config_request_body_t *ul_req_tmp = &(eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body); - - /* If frameP odd don't schedule */ - if ((frameP & 1) == 1) { - return; - } + nfapi_ul_config_request_body_t *ul_req_body_Rep; + nfapi_ul_config_request_pdu_t *ul_config_pdu; + nfapi_ul_config_request_pdu_t *ul_config_pdu_Rep; /* Loop over all active UEs */ for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) { @@ -2032,8 +2047,18 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->estimated_ul_buffer; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, UE_template->estimated_ul_buffer); + pusch_maxNumRepetitionCEmodeA_r13= *(rrc->configuration.pusch_maxNumRepetitionCEmodeA_r13[CC_id]); + Total_Num_Rep_ULSCH = pusch_repetition_Table8_2_36213[pusch_maxNumRepetitionCEmodeA_r13][UE_template->pusch_repetition_levels]; + UL_Scheduling_DCI_SF = (40-4 - Total_Num_Rep_ULSCH)%10; //TODO: [eMTC Scheduler] To be removed after scheduler relaxation task + UL_Scheduling_DCI_Frame_Even_Odd_Flag= ! (((40-4 - Total_Num_Rep_ULSCH)/10 )%2); //TODO: [eMTC Scheduler] To be removed after scheduler relaxation task + + /* If frameP odd don't schedule */ + if ((frameP&1) == UL_Scheduling_DCI_Frame_Even_Odd_Flag) //TODO: [eMTC Scheduler] To be removed after scheduler relaxation task + { + + //if ((UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0) && (subframeP == 5)) { - if ((UE_template->ul_SR > 0 || round_UL > 0 || status < RRC_CONNECTED) && (subframeP == 5)) { + if ((UE_template->ul_SR > 0 || round_UL > 0 || status < RRC_CONNECTED) && (subframeP == UL_Scheduling_DCI_SF)) { /* * if there is information on bsr of DCCH, DTCH, * or if there is UL_SR, @@ -2184,7 +2209,7 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid]; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6; hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB = 3 - hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0; + hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = UE_template->pusch_repetition_levels; AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13 == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off, "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n"); hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag = 1 - epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13; @@ -2234,7 +2259,7 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, ); fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus], UE_template->rach_resource_type > 2 ? 2 : 1, - 1, // total_number_of_repetitions + Total_Num_Rep_ULSCH, // total_number_of_repetitions 1, // repetition_number (frameP * 10) + subframeP); ul_req_tmp->number_of_pdus++; @@ -2363,6 +2388,25 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, } } // UE_is_to_be_scheduled } // ULCCs - } // loop over UE_id + } // loop over UE_id + } // Schedule new ULSCH + + // This section is to repeat ULSCH PDU for a number of MTC repetitions + for(int i=0;inumber_of_pdus;i++) + { + ul_config_pdu = &ul_req_tmp->ul_config_pdu_list[i]; + if (ul_config_pdu->pdu_type!=NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) // Repeat ULSCH PDUs only + continue ; + + if(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number < ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.total_number_of_repetitions) + { + ul_req_body_Rep = &eNB->UL_req_tmp[CC_id][(sched_subframeP+1)%10].ul_config_request_body; + ul_config_pdu_Rep = &ul_req_body_Rep->ul_config_pdu_list[ul_req_body_Rep->number_of_pdus]; + memcpy ((void *) ul_config_pdu_Rep, ul_config_pdu, sizeof (nfapi_ul_config_request_pdu_t)); + ul_config_pdu_Rep->ulsch_pdu.ulsch_pdu_rel8.handle = eNB->ul_handle++; + ul_config_pdu_Rep->ulsch_pdu.ulsch_pdu_rel13.repetition_number = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel13.repetition_number +1; + ul_req_body_Rep->number_of_pdus++; + } //repetition_number < total_number_of_repetitions + } // For loop on PDUs } #endif diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h index 1760355f61..33502c00da 100644 --- a/openair2/LAYER2/MAC/mac.h +++ b/openair2/LAYER2/MAC/mac.h @@ -921,6 +921,8 @@ typedef struct { uint8_t rach_resource_type; uint16_t mpdcch_repetition_cnt; frame_t Msg2_frame; + /// Repetition column in pusch_repetition Table 8.2.b in TS36.213 + uint8_t pusch_repetition_levels; #endif sub_frame_t Msg2_subframe; @@ -1133,6 +1135,8 @@ typedef struct { uint8_t msg2_narrowband; uint8_t msg34_narrowband; int msg4_rrc_sdu_length; + /// Repetition column in pusch_repetition Table 8.2.b in TS36.213 + uint8_t pusch_repetition_levels; #endif int32_t crnti_rrc_mui; int8_t crnti_harq_pid; diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 284c0af19e..cb18d8dffe 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -127,7 +127,6 @@ unsigned short fill_rar_br(eNB_MAC_INST *eNB, uint8_t *rar = (uint8_t *)(dlsch_buffer + 1); uint32_t rballoc = 0; - uint32_t reps = 0; uint32_t ULdelay = 0; uint32_t cqireq = 0; uint32_t mpdcch_nb_index = 0; @@ -159,7 +158,6 @@ unsigned short fill_rar_br(eNB_MAC_INST *eNB, N_NB_index = get_numnarrowbandbits(cc->mib->message.dl_Bandwidth); /* UL Grant */ - reps = 0; ra->msg3_mcs = 7; TPC = 3; // no power increase ULdelay = 0; @@ -170,7 +168,7 @@ unsigned short fill_rar_br(eNB_MAC_INST *eNB, uint32_t buffer = 0; buffer |= ra->msg34_narrowband << (16 + (4 - N_NB_index)); buffer |= ((rballoc & 0x0F) << (12 + (4 - N_NB_index))); - buffer |= ((reps & 0x03) << (10 + (4 - N_NB_index))); + buffer |= ((ra->pusch_repetition_levels & 0x03) << (10 + (4 - N_NB_index))); buffer |= ((ra->msg3_mcs & 0x07) << (7 + (4 - N_NB_index))); buffer |= ((TPC & 0x07) << (4 + (4 - N_NB_index))); buffer |= ((cqireq & 0x01) << (3 + (4 - N_NB_index))); diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 603ee67ed3..531ef9045b 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -420,7 +420,6 @@ typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_ #define OPTION_LZ4 0x00000001 // LZ4 compression (option_value is set to compressed size) -#define sample_t struct complex16 // 2*16 bits complex number typedef struct { uint64_t magic; // Magic value (see defines above) diff --git a/targets/ARCH/rfsimulator/README.md b/targets/ARCH/rfsimulator/README.md index 510a54adb4..e3ce219d73 100644 --- a/targets/ARCH/rfsimulator/README.md +++ b/targets/ARCH/rfsimulator/README.md @@ -1,63 +1,81 @@ -#General -This is an RF simulator that allows to test OAI without an RF board. +# General +This is an RF simulator that allows to test OAI without an RF board. It replaces an actual RF board driver. -It replaces an actual RF board driver. +As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound). -As much as possible, it works like an RF board, but not in realtime: It can run faster than realtime if there is enough CPU or slower (it is CPU bound instead of real time RF sampling bound) +# build -#build +## From [build_oai](../../../doc/BUILD.md) script +The RF simulator is implemented as an OAI device and always built when you build the OAI eNB or the OAI UE. -## From build_oai -You can build it the same way, and together with actual RF driver +Using the `-w SIMU` option it is possible to just re-build the RF simulator device. Example: ```bash -./build_oai --ue-nas-use-tun --UE --eNB -w SIMU +./build_oai --UE --eNB +Will compile UE +Will compile eNB +CMAKE_CMD=cmake .. +No local radio head and no transport protocol selected +No radio head has been selected (HW set to None) +No transport protocol has been selected (TP set to None) +RF HW set to None +Flags for Deadline scheduler: False +...................... +...................... +Compiling rfsimulator +Log file for compilation has been written to: /usr/local/oai/rfsimu_config/openairinterface5g/cmake_targets/log/rfsimulator.Rel15.txt +rfsimulator compiled +...................... +...................... ``` -It is also possible to build actual RF and use choose on each run: -```bash -./build_oai --ue-nas-use-tun --UE --eNB -w USRP --rfsimulator -``` -Will build both the eNB (lte-softmodem) and the UE (lte-uesoftmodem) -We recommend using the option --ue-nas-use-tun that is much simpler to use than the OAI kernel driver. ## Add the rfsimulator after initial build -After any regular build, you can compile the driver - +After any regular build you can compile the device from the build directory: ```bash -cd /build +cd /openairinterface5g/cmake_targets/ran_build/build make rfsimulator ``` -Then, you can use it freely +This is equivalent to using `-w SIMU` when running the `build_oai` script. # Usage -Setting the env variable RFSIMULATOR enables the RF board simulator. It should be set to "server" in the eNB or gNB. +To use the RF simulator add the `--rfsim` option to the command line. By default the RF simulator device will try to connect to host 127.0.0.1, port 4043, which is usually the behavior for the UE. + +The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator". + +| parameter | usage | default | +|:---------------------|:------------------------------------------------------------------------------------------------------------------|----:| +| serveraddr | ip address to connect to, or "enb" to behave as a tcp server | 127.0.0.1 | +| serverport | port number to connect to or to listen on (eNB, which behaves as a tcp server) | 4043 | +| options | list of comma separated run-time options, two are supported: `chanmod` to enable channel modeling and `saviq` to write transmitted iqs to a file | all options disabled | +| modelname | Name of the channel model to apply on received iqs when the `chanmod` option is enabled | AWGN | +| IQfile | Path to the file to be used to store iqs, when the `saviq` option is enabled | /tmp/rfsimulator.iqs | + +Setting the env variable RFSIMULATOR can be used instead of using the serveraddr parameter; it is to preserve compatibility with previous version. ## 4G case -For the UE, it should be set to the IP address of the eNB -example: +For the UE, it should be set to the IP address of the eNB. For example: ```bash sudo RFSIMULATOR=192.168.2.200 ./lte-uesoftmodem -C 2685000000 -r 50 ``` -For the eNodeB, use a valid configuration file setup for USRP board tests and start the softmodem as usual, **but** adding the `--rfsim` option. - +For the eNB, use a valid configuration file setup for the USRP board tests and start the softmodem as usual, **but**, adding the `--rfsim` option. ```bash sudo RFSIMULATOR=enb ./lte-softmodem -O --rfsim ``` -Except this, the UE and the eNB can be used as if the RF is real - -If you reach 'RA not active' on UE, be careful to generate a valid SIM +Except this, the UE and the eNB can be used as if the RF is real. noS1 mode can also be used with the RF simulator. +If you reach 'RA not active' on UE, be careful to generate a valid SIM. ```bash $OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o . ``` ## 5G case -After regular build, add the simulation driver -(don't use ./build_oai -w SIMU until we merge 4G and 5G branches) +The 5G RF simulator will be aligned with the 4G as the efforts for merging the 5G specific branches into the develop make progresses. + +After regular build, add the simulation driver (do not use ./build_oai -w SIMU until 4G and 5G branches are merged). ```bash cd ran_build/build make rfsimulator @@ -77,46 +95,40 @@ sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem --numerology 1 -r 106 -C 3510000000 Of course, set the gNB machine IP address if the UE and the gNB are not on the same machine. -In UE, you can add "-d" to get the softscope +In the UE, you can add `-d` option to get the softscope. ### Store and replay -You can store emitted I/Q samples: +You can store emitted I/Q samples. If you set the option `saviq`, the simulator will write all the I/Q samples into this file. Then, you can replay with the executable `replay_node`. -If you set the environment variable: saveIQfile to a file name -The simulator will write all IQ samples into this file - -Then, you can replay with the executable "replay_node" - -First compile it, as the other binaries -``` +First compile it like other binaries: +```bash make replay_node ``` -You can use this binary as I/Q data source to feed whatever UE or NB with recorded I/Q samples. +You can use this binary as I/Q data source to feed whatever UE or gNB with recorded I/Q samples. -The file format is successive blocks of a header followed by the I/Q array. -If you have existing stored I/Q, you can adpat the tool "replay_node" to convert your format to the rfsimulator format. +The file format is successive blocks of a header followed by the I/Q array. If you have existing stored I/Q, you can adapt the tool `replay_node` to convert your format to the rfsimulator format. -The format intend to be compatible with the OAI store/replay feature on USRP +The format intends to be compatible with the OAI store/replay feature on USRP. ### Channel simulation -The RF channel simulator is called. -In current version all channel paramters are hard coded in the call to: +When the `chanmod` option is enabled, the RF channel simulator is called. + +In the current version all channel parameters are set depending on the model name via a call to: ```bash new_channel_desc_scm(bridge->tx_num_channels, bridge->rx_num_channels, - AWGN, + , bridge->sample_rate, bridge->tx_bw, 0.0, // forgetting_factor - 0, // maybe used for TA - 0); // path_loss in dB + 0, // maybe used for TA + 0); // path_loss in dB ``` +Only the input noise can be changed on command line with the `-s` parameter. -Only the input noise can be changed on command line with -s parameter. +With path loss = 0 set `-s 5` to see a little noise. `-s` is a shortcut to `channelmod.s`. It is expected to enhance the channel modelization flexibility by the addition of more parameters in the channelmod section. -With path loss = 0 set "-s 5" to see a little noise. - -## Caveats -Still issues in power control: txgain, rxgain are not used +# Caveats +Still issues in power control: txgain, rxgain are not used. diff --git a/targets/ARCH/rfsimulator/apply_channelmod.c b/targets/ARCH/rfsimulator/apply_channelmod.c new file mode 100644 index 0000000000..ef4e564343 --- /dev/null +++ b/targets/ARCH/rfsimulator/apply_channelmod.c @@ -0,0 +1,97 @@ +/* + Author: Laurent THOMAS, Open Cells for Nokia + copyleft: OpenAirInterface Software Alliance and it's licence + +*/ + + +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include + +/* + Legacy study: + The parameters are: + gain&loss (decay, signal power, ...) + either a fixed gain in dB, a target power in dBm or ACG (automatic control gain) to a target average + => don't redo the AGC, as it was used in UE case, that must have a AGC inside the UE + will be better to handle the "set_gain()" called by UE to apply it's gain (enable test of UE power loop) + lin_amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); + a lot of operations in legacy, grouped in one simulation signal decay: txgain*decay*rxgain + + multi_path (auto convolution, ISI, ...) + either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes + legacy: we regenerate each sub frame in UL, and each frame only in DL +*/ +void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_sig, + int rxAnt, + channel_desc_t *channelDesc, + int nbSamples, + uint64_t TS, + uint32_t CirSize + ) { + // channelDesc->path_loss_dB should contain the total path gain + // so, in actual RF: tx gain + path loss + rx gain (+antenna gain, ...) + // UE and NB gain control to be added + // Fixme: not sure when it is "volts" so dB is 20*log10(...) or "power", so dB is 10*log10(...) + const double pathLossLinear = pow(10,channelDesc->path_loss_dB/20.0); + // Energy in one sample to calibrate input noise + //Fixme: modified the N0W computation, not understand the origin value + const double KT=1.38e-23*290; //Boltzman*temperature + // sampling rate is linked to acquisition band (the input pass band filter) + const double noise_figure_watt = KT*channelDesc->sampling_rate; + // Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ? + // the parameter "-s" is declared as SNR, but the input power is not well defined + // −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise) + const double rxGain= 132.24 - channelmod_get_snr_dB(); + // sqrt(4*noise_figure_watt) is the thermal noise factor (volts) + // fixme: the last constant is pure trial results to make decent noise + const double noise_per_sample = sqrt(4*noise_figure_watt) * pow(10,rxGain/20) *10; + // Fixme: we don't fill the offset length samples at begining ? + // anyway, in today code, channel_offset=0 + const int dd = abs(channelDesc->channel_offset); + const int nbTx=channelDesc->nb_tx; + + for (int i=0; i<((int)nbSamples-dd); i++) { + struct complex16 *out_ptr=after_channel_sig+dd+i; + struct complex rx_tmp= {0}; + + for (int txAnt=0; txAnt < nbTx; txAnt++) { + const struct complex *channelModel= channelDesc->ch[rxAnt+(txAnt*channelDesc->nb_rx)]; + + //const struct complex *channelModelEnd=channelModel+channelDesc->channel_length; + for (int l = 0; l<(int)channelDesc->channel_length; l++) { + // let's assume TS+i >= l + // fixme: the rfsimulator current structure is interleaved antennas + // this has been designed to not have to wait a full block transmission + // but it is not very usefull + // it would be better to split out each antenna in a separate flow + // that will allow to mix ru antennas freely + struct complex16 tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize]; + rx_tmp.x += tx16.r * channelModel[l].x - tx16.i * channelModel[l].y; + rx_tmp.y += tx16.i * channelModel[l].x + tx16.r * channelModel[l].y; + } //l + } + + out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); + out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); + out_ptr++; + } + + if ( (TS*nbTx)%CirSize+nbSamples <= CirSize ) + // Cast to a wrong type for compatibility ! + LOG_D(HW,"Input power %f, output power: %f, channel path loss %f, noise coeff: %f \n", + 10*log10((double)signal_energy((int32_t *)&input_sig[(TS*nbTx)%CirSize], nbSamples)), + 10*log10((double)signal_energy((int32_t *)after_channel_sig, nbSamples)), + channelDesc->path_loss_dB, + 10*log10(noise_per_sample)); +} diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index 1acaa69050..dcf338c31c 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -24,12 +24,15 @@ #include #include +#include +#include #include "common_lib.h" #include #include "openair1/PHY/defs_UE.h" +#define CHANNELMOD_DYNAMICLOAD #include -#define PORT 4043 //TCP port for this simulator +#define PORT 4043 //default TCP port for this simulator #define CirSize 3072000 // 100ms is enough #define sampleToByte(a,b) ((a)*(b)*sizeof(sample_t)) #define byteToSample(a,b) ((a)/(sizeof(sample_t)*(b))) @@ -39,12 +42,31 @@ // Fixme: datamodel, external variables in .h files, ... #include -extern double snr_dB; + extern RAN_CONTEXT_t RC; // +#define RFSIMU_SECTION "rfsimulator" +#define RFSIMU_OPTIONS_PARAMNAME "options" +# define RFSIM_CONFIG_HELP_OPTIONS " list of comma separated options to enable rf simulator functionalities. Available options: \n"\ + " chanmod: enable channel modelisation\n"\ + " saviq: enable saving written iqs to a file\n" +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +/* configuration parameters for the rfsimulator device */ +/* optname helpstr paramflags XXXptr defXXXval type numelt */ +/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ +#define RFSIMULATOR_PARAMS_DESC {\ + {"serveraddr", "\n", 0, strptr:&(rfsimulator->ip), defstrval:"127.0.0.1", TYPE_STRING, 0 },\ + {"serverport", "\n", 0, u16ptr:&(rfsimulator->port), defuintval:PORT, TYPE_UINT16, 0 },\ + {RFSIMU_OPTIONS_PARAMNAME, RFSIM_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST,0},\ + {"IQfile", "\n", 0, strptr:&(saveF), defstrval:"/tmp/rfsimulator.iqs",TYPE_STRING, 0 },\ + {"modelname", "\n", 0, strptr:&(modelname), defstrval:"AWGN", TYPE_STRING, 0 }\ + }; + pthread_mutex_t Sockmutex; +typedef struct complex16 sample_t; // 2*16 bits complex number + typedef struct buffer_s { int conn_sock; openair0_timestamp lastReceivedTS; @@ -63,91 +85,16 @@ typedef struct { openair0_timestamp nextTimestamp; uint64_t typeStamp; char *ip; + uint16_t port; int saveIQfile; buffer_t buf[FD_SETSIZE]; int rx_num_channels; int tx_num_channels; double sample_rate; double tx_bw; + int channelmod; } rfsimulator_state_t; -/* - Legacy study: - The parameters are: - gain&loss (decay, signal power, ...) - either a fixed gain in dB, a target power in dBm or ACG (automatic control gain) to a target average - => don't redo the AGC, as it was used in UE case, that must have a AGC inside the UE - will be better to handle the "set_gain()" called by UE to apply it's gain (enable test of UE power loop) - lin_amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); - a lot of operations in legacy, grouped in one simulation signal decay: txgain*decay*rxgain - - multi_path (auto convolution, ISI, ...) - either we regenerate the channel (call again random_channel(desc,0)), or we keep it over subframes - legacy: we regenerate each sub frame in UL, and each frame only in DL -*/ -void rxAddInput( struct complex16 *input_sig, - struct complex16 *after_channel_sig, - int rxAnt, - channel_desc_t *channelDesc, - int nbSamples, - uint64_t TS - ) { - // channelDesc->path_loss_dB should contain the total path gain - // so, in actual RF: tx gain + path loss + rx gain (+antenna gain, ...) - // UE and NB gain control to be added - // Fixme: not sure when it is "volts" so dB is 20*log10(...) or "power", so dB is 10*log10(...) - const double pathLossLinear = pow(10,channelDesc->path_loss_dB/20.0); - // Energy in one sample to calibrate input noise - //Fixme: modified the N0W computation, not understand the origin value - const double KT = 1.38e-23*290; //Boltzman*temperature - // sampling rate is linked to acquisition band (the input pass band filter) - const double noise_figure_watt = KT*channelDesc->sampling_rate; - // Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ? - // the parameter "-s" is declared as SNR, but the input power is not well defined - // −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise) - const double rxGain = 132.24 - snr_dB; - // sqrt(4*noise_figure_watt) is the thermal noise factor (volts) - // fixme: the last constant is pure trial results to make decent noise - const double noise_per_sample = sqrt(4*noise_figure_watt) * pow(10,rxGain/20) *10; - // Fixme: we don't fill the offset length samples at begining ? - // anyway, in today code, channel_offset=0 - const int dd = abs(channelDesc->channel_offset); - const int nbTx = channelDesc->nb_tx; - - for (int i=0; i<((int)nbSamples-dd); i++) { - struct complex16 *out_ptr=after_channel_sig+dd+i; - struct complex rx_tmp= {0}; - - for (int txAnt=0; txAnt < nbTx; txAnt++) { - const struct complex *channelModel= channelDesc->ch[rxAnt+(txAnt*channelDesc->nb_rx)]; - - //const struct complex *channelModelEnd=channelModel+channelDesc->channel_length; - for (int l = 0; l<(int)channelDesc->channel_length; l++) { - // let's assume TS+i >= l - // fixme: the rfsimulator current structure is interleaved antennas - // this has been designed to not have to wait a full block transmission - // but it is not very usefull - // it would be better to split out each antenna in a separate flow - // that will allow to mix ru antennas freely - struct complex16 tx16=input_sig[((TS+i-l)*nbTx+txAnt)%CirSize]; - rx_tmp.x += tx16.r * channelModel[l].x - tx16.i * channelModel[l].y; - rx_tmp.y += tx16.i * channelModel[l].x + tx16.r * channelModel[l].y; - } //l - } - - out_ptr->r += round(rx_tmp.x*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); - out_ptr->i += round(rx_tmp.y*pathLossLinear + noise_per_sample*gaussdouble(0.0,1.0)); - out_ptr++; - } - - if ( (TS*nbTx)%CirSize+nbSamples <= CirSize ) - // Cast to a wrong type for compatibility ! - LOG_D(HW,"Input power %f, output power: %f, channel path loss %f, noise coeff: %f \n", - 10*log10((double)signal_energy((int32_t *)&input_sig[(TS*nbTx)%CirSize], nbSamples)), - 10*log10((double)signal_energy((int32_t *)after_channel_sig, nbSamples)), - channelDesc->path_loss_dB, - 10*log10(noise_per_sample)); -} void allocCirBuf(rfsimulator_state_t *bridge, int sock) { buffer_t *ptr=&bridge->buf[sock]; @@ -165,26 +112,29 @@ void allocCirBuf(rfsimulator_state_t *bridge, int sock) { ev.events = EPOLLIN | EPOLLRDHUP; ev.data.fd = sock; AssertFatal(epoll_ctl(bridge->epollfd, EPOLL_CTL_ADD, sock, &ev) != -1, ""); - // create channel simulation model for this mode reception - // snr_dB is pure global, coming from configuration paramter "-s" - // Fixme: referenceSignalPower should come from the right place - // but the datamodel is inconsistant - // legacy: RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower - // (must not come from ru[]->frame_parms as it doesn't belong to ru !!!) - // Legacy sets it as: - // ptr->channel_model->path_loss_dB = -132.24 + snr_dB - RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower; - // we use directly the paramter passed on the command line ("-s") - // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) - // Legacy changes directlty the variable channel_model->path_loss_dB place to place - // while calling new_channel_desc_scm() with path losses = 0 - ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels, - AWGN, - bridge->sample_rate, - bridge->tx_bw, - 0.0, // forgetting_factor - 0, // maybe used for TA - 0); // path_loss in dB - random_channel(ptr->channel_model,false); + + if ( bridge->channelmod > 0) { + // create channel simulation model for this mode reception + // snr_dB is pure global, coming from configuration paramter "-s" + // Fixme: referenceSignalPower should come from the right place + // but the datamodel is inconsistant + // legacy: RC.ru[ru_id]->frame_parms.pdsch_config_common.referenceSignalPower + // (must not come from ru[]->frame_parms as it doesn't belong to ru !!!) + // Legacy sets it as: + // ptr->channel_model->path_loss_dB = -132.24 + snr_dB - RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower; + // we use directly the paramter passed on the command line ("-s") + // the value channel_model->path_loss_dB seems only a storage place (new_channel_desc_scm() only copy the passed value) + // Legacy changes directlty the variable channel_model->path_loss_dB place to place + // while calling new_channel_desc_scm() with path losses = 0 + ptr->channel_model=new_channel_desc_scm(bridge->tx_num_channels,bridge->rx_num_channels, + bridge->channelmod, + bridge->sample_rate, + bridge->tx_bw, + 0.0, // forgetting_factor + 0, // maybe used for TA + 0); // path_loss in dB + random_channel(ptr->channel_model,false); + } } void removeCirBuf(rfsimulator_state_t *bridge, int sock) { @@ -213,6 +163,7 @@ void socketError(rfsimulator_state_t *bridge, int sock) { rfsimulator: error: you have to run one UE and one eNB\n\ For this, export RFSIMULATOR=enb (eNB case) or \n\ RFSIMULATOR= (UE case)\n\ + or use rfsimulator.serveraddr configuration option\n\ \x1b[m" enum blocking_t { @@ -267,6 +218,48 @@ void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t) { } } + + +void rfsimulator_readconfig(rfsimulator_state_t *rfsimulator) { + char *saveF=NULL; + char *modelname=NULL; + paramdef_t rfsimu_params[] = RFSIMULATOR_PARAMS_DESC; + int p = config_paramidx_fromname(rfsimu_params,sizeof(rfsimu_params)/sizeof(paramdef_t), RFSIMU_OPTIONS_PARAMNAME) ; + int ret = config_get( rfsimu_params,sizeof(rfsimu_params)/sizeof(paramdef_t),RFSIMU_SECTION); + AssertFatal(ret >= 0, "configuration couldn't be performed"); + rfsimulator->saveIQfile = -1; + + for(int i=0; isaveIQfile=open(saveF,O_APPEND| O_CREAT|O_TRUNC | O_WRONLY, 0666); + + if ( rfsimulator->saveIQfile != -1 ) + LOG_I(HW,"rfsimulator: will save written IQ samples in %s\n", saveF); + else + LOG_E(HW, "can't open %s for IQ saving (%s)\n", saveF, strerror(errno)); + + break; + } else if (strcmp(rfsimu_params[p].strlistptr[i],"chanmod") == 0) { + init_channelmod(); + rfsimulator->channelmod=modelid_fromname(modelname); + } else { + fprintf(stderr,"Unknown rfsimulator option: %s\n",rfsimu_params[p].strlistptr[i]); + exit(-1); + } + } + + /* for compatibility keep environment variable usage */ + if ( getenv("RFSIMULATOR") != NULL ) { + rfsimulator->ip=getenv("RFSIMULATOR"); + } + + if ( strncasecmp(rfsimulator->ip,"enb",3) == 0 || + strncasecmp(rfsimulator->ip,"server",3) == 0 ) + rfsimulator->typeStamp = ENB_MAGICDL_FDD; + else + rfsimulator->typeStamp = UE_MAGICDL_FDD; +} + int server_start(openair0_device *device) { rfsimulator_state_t *t = (rfsimulator_state_t *) device->priv; t->typeStamp=ENB_MAGICDL_FDD; @@ -277,7 +270,7 @@ int server_start(openair0_device *device) { sin_family: AF_INET, sin_port: - htons(PORT), + htons(t->port), sin_addr: { s_addr: INADDR_ANY } }; @@ -299,7 +292,7 @@ int start_ue(openair0_device *device) { sin_family: AF_INET, sin_port: - htons(PORT), + htons(t->port), sin_addr: { s_addr: INADDR_ANY } }; @@ -307,7 +300,7 @@ sin_addr: bool connected=false; while(!connected) { - LOG_I(HW,"rfsimulator: trying to connect to %s:%d\n", t->ip, PORT); + LOG_I(HW,"rfsimulator: trying to connect to %s:%d\n", t->ip, t->port); if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) { LOG_I(HW,"rfsimulator: connection established\n"); @@ -327,15 +320,15 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi rfsimulator_state_t *t = device->priv; LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp); - for (int i=0; ibuf[i]; if (b->conn_sock >= 0 ) { - if ( abs((double)b->lastWroteTS-timestamp) > (double)CirSize) + if ( abs((double)b->lastWroteTS-timestamp) > (double)CirSize ) LOG_E(HW,"Tx/Rx shift too large Tx:%lu, Rx:%lu\n", b->lastWroteTS, b->lastReceivedTS); + samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp}; - fullwrite(b->conn_sock,&header, sizeof(header), t); + fullwrite(b->conn_sock, &header, sizeof(header), t); sample_t tmpSamples[nsamps][nbAnt]; for(int a=0; anextTimestamp == 0) + LOG_W(HW,"No connected device, generating void samples...\n"); + if (!flushInput(t, 10)) { for (int x=0; x < nbAnt; x++) memset(samplesVoid[x],0,sampleToByte(nsamps,1)); t->nextTimestamp+=nsamps; - LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp); + + if ( ((t->nextTimestamp/nsamps)%100) == 0) + LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp); + *ptimestamp = t->nextTimestamp-nsamps; pthread_mutex_unlock(&Sockmutex); return nsamps; } } else { - bool have_to_wait; do { have_to_wait=false; - for ( int sock=0; sockbuf[sock]; + if ( b->circularBuf) { LOG_D(HW,"sock: %d, lastWroteTS: %lu, lastRecvTS: %lu, TS must be avail: %lu\n", sock, b->lastWroteTS, b->lastReceivedTS, t->nextTimestamp+nsamps); + if ( b->lastReceivedTS > b->lastWroteTS ) { - // The caller momdem (NB, UE, ...) must send Tx in advance, so we fill TX if Rx is in advance - // This occurs for example when UE is in sync mode: it doesn't transmit - // with USRP, it seems ok: if "tx stream" is off, we may consider it actually cuts the Tx power - struct complex16 v={0}; - void *samplesVoid[b->th.nbAnt]; - for ( int i=0; i th.nbAnt; i++) - samplesVoid[i]=(void*)&v; - rfsimulator_write(device, b->lastReceivedTS, samplesVoid, 1, b->th.nbAnt, 0); + // The caller modem (NB, UE, ...) must send Tx in advance, so we fill TX if Rx is in advance + // This occurs for example when UE is in sync mode: it doesn't transmit + // with USRP, it seems ok: if "tx stream" is off, we may consider it actually cuts the Tx power + struct complex16 v = {0}; + void *samplesVoid[b->th.nbAnt]; + + for ( int i=0; i < b->th.nbAnt; i++) + samplesVoid[i]=(void *)&v; + + rfsimulator_write(device, b->lastReceivedTS, samplesVoid, 1, b->th.nbAnt, 0); } } @@ -556,13 +558,24 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo if (reGenerateChannel) random_channel(ptr->channel_model,0); - for (int a=0; acircularBuf, (struct complex16 *) samplesVoid[a], - a, - ptr->channel_model, - nsamps, - t->nextTimestamp - ); + for (int a=0; achannel_model != NULL ) // apply a channel model + rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a], + a, + ptr->channel_model, + nsamps, + t->nextTimestamp, + CirSize + ); + else { // no channel modeling + sample_t *out=(sample_t *)samplesVoid[a]; + + for ( int i=0; i < nsamps; i++ ) { + out[i].r+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].r; + out[i].i+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt+a)%CirSize].i; + } + } // end of no channel modeling + } // end for a... } } @@ -605,33 +618,9 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { // --log_config.hw_log_level debug // (for phy layer, replace "hw" by "phy") rfsimulator_state_t *rfsimulator = (rfsimulator_state_t *)calloc(sizeof(rfsimulator_state_t),1); - - if ((rfsimulator->ip=getenv("RFSIMULATOR")) == NULL ) { - LOG_E(HW,helpTxt); - exit(1); - } - + rfsimulator_readconfig(rfsimulator); pthread_mutex_init(&Sockmutex, NULL); - - if ( strncasecmp(rfsimulator->ip,"enb",3) == 0 || - strncasecmp(rfsimulator->ip,"server",3) == 0 ) - rfsimulator->typeStamp = ENB_MAGICDL_FDD; - else - rfsimulator->typeStamp = UE_MAGICDL_FDD; - LOG_I(HW,"rfsimulator: running as %s\n", rfsimulator-> typeStamp == ENB_MAGICDL_FDD ? "(eg)NB" : "UE"); - char *saveF; - - if ((saveF=getenv("saveIQfile")) != NULL) { - rfsimulator->saveIQfile=open(saveF,O_APPEND| O_CREAT|O_TRUNC | O_WRONLY, 0666); - - if ( rfsimulator->saveIQfile != -1 ) - LOG_I(HW,"rfsimulator: will save written IQ samples in %s\n", saveF); - else - LOG_E(HW, "can't open %s for IQ saving (%s)\n", saveF, strerror(errno)); - } else - rfsimulator->saveIQfile = -1; - device->trx_start_func = rfsimulator->typeStamp == ENB_MAGICDL_FDD ? server_start : start_ue; diff --git a/targets/ARCH/rfsimulator/stored_node.c b/targets/ARCH/rfsimulator/stored_node.c index 2d13f56a5e..1ddd853fc1 100644 --- a/targets/ARCH/rfsimulator/stored_node.c +++ b/targets/ARCH/rfsimulator/stored_node.c @@ -5,6 +5,7 @@ #include +volatile int oai_exit = 0; void fullwrite(int fd, void *_buf, int count) { char *buf = _buf; @@ -123,7 +124,7 @@ int main(int argc, char *argv[]) { setblocking(serviceSock, blocking); AssertFatal(read(fd,&header,sizeof(header)), ""); fullwrite(serviceSock, &header, sizeof(header)); - int dataSize=sizeof(sample_t)*header.size*header.nbAnt; + int dataSize=sizeof(int32_t)*header.size*header.nbAnt; if (dataSize>bufSize) { void * new_buff = realloc(buff, dataSize); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf index d79f5402d0..a761579018 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf @@ -230,6 +230,7 @@ eNBs = pdsch_maxNumRepetitionCEmodeA_r13 = "r16"; #0 + pusch_repetitionLevelCEmodeA_r13 = "l1"; #0 #pdsch_maxNumRepetitionCEmodeB_r13 = "r384"; # NULL - 2 pusch_maxNumRepetitionCEmodeA_r13 = "r8"; #0 diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index 3449479256..d6f44e2b96 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -275,12 +275,24 @@ NETWORK_CONTROLLER : THREAD_STRUCT = ( { #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" - parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; + parallel_config = "PARALLEL_SINGLE_THREAD"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; } ); +/* +#example config for rfsimulator +rfsimulator : +{ + serveraddr = "enb"; + serverport = "4043"; + options = ("saviq"); + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; +*/ + log_config : { global_log_level ="info"; diff --git a/targets/RT/USER/lte-softmodem-common.c b/targets/RT/USER/lte-softmodem-common.c index a5fee5397f..5cc18362da 100644 --- a/targets/RT/USER/lte-softmodem-common.c +++ b/targets/RT/USER/lte-softmodem-common.c @@ -38,7 +38,7 @@ static softmodem_params_t softmodem_params; char *parallel_config=NULL; char *worker_config=NULL; -double snr_dB=25; + uint64_t get_softmodem_optmask(void) { return softmodem_params.optmask; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 12f74e23bb..d818b179ac 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -78,7 +78,6 @@ #define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n" #define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n" #define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n" -#define CONFIG_HLP_SNR "Set average SNR in dB (for --siml1 option)\n" #define CONFIG_HLP_UE "Set the lte softmodem as a UE\n" #define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n" #define CONFIG_HLP_TPORT "tracer port\n" @@ -197,7 +196,6 @@ {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ - {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:0, TYPE_INT, 0}, \ {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \ {"parallel-config", CONFIG_HLP_PARALLEL_CMD,0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ @@ -308,9 +306,9 @@ typedef struct { int numerology; unsigned int start_msc; uint32_t clock_source; - uint32_t timing_source; + uint32_t timing_source; int hw_timing_advance; - uint32_t send_dmrs_sync; + uint32_t send_dmrs_sync; } softmodem_params_t; #define IS_SOFTMODEM_NOS1 ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT) @@ -329,7 +327,6 @@ uint64_t get_pdcp_optmask(void); extern pthread_cond_t sync_cond; extern pthread_mutex_t sync_mutex; extern int sync_var; -extern double snr_dB; extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; @@ -339,7 +336,7 @@ extern uint8_t exit_missed_slots; extern uint64_t num_missed_slots; // counter for the number of missed slots extern int oaisim_flag; -extern volatile int oai_exit; +extern volatile int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern pthread_cond_t sync_cond; @@ -351,8 +348,7 @@ extern double cpuf; // In lte-enb.c extern void stop_eNB(int); extern void kill_eNB_proc(int inst); -extern void init_eNB(int single_thread_flag, - int wait_for_sync); +extern void init_eNB(int single_thread_flag, int wait_for_sync); // In lte-ru.c extern void stop_ru(RU_t *ru); @@ -361,15 +357,10 @@ extern void init_RU_proc(RU_t *ru); extern void stop_RU(int nb_ru); extern void kill_RU_proc(RU_t *ru); extern void set_function_spec_param(RU_t *ru); -extern void init_RU(char*, - clock_source_t clock_source, - clock_source_t time_source, - int send_dmrssync); +extern void init_RU(char *, clock_source_t clock_source, clock_source_t time_source, int send_dmrssync); // In lte-ue.c -extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, - openair0_config_t *openair0_cfg); - +extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); extern void init_UE(int nb_inst, @@ -384,11 +375,7 @@ extern void init_UE(int nb_inst, int txpowermax, LTE_DL_FRAME_PARMS *fp); -extern void init_thread(int sched_runtime, - int sched_deadline, - int sched_fifo, - cpu_set_t *cpuset, - char *name); +extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char *name); extern void reset_opp_meas(void); extern void print_opp_meas(void); @@ -399,24 +386,17 @@ extern void kill_td_thread(PHY_VARS_eNB *); extern void kill_te_thread(PHY_VARS_eNB *); extern void RCConfig_sim(void); -extern void init_ocm(double,double); +extern void init_ocm(void); extern void init_ue_devices(PHY_VARS_UE *); -PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); +PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); void init_eNB_afterRU(void); extern int stop_L1L2(module_id_t enb_id); extern int restart_L1L2(module_id_t enb_id); -extern void init_UE_stub_single_thread(int nb_inst, - int eMBMS_active, - int uecap_xer_in, - char *emul_iface); +extern void init_UE_stub_single_thread(int nb_inst, int eMBMS_active, int uecap_xer_in, char *emul_iface); -extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); +extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag); #endif diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 02a11602ad..661b600305 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -318,7 +318,6 @@ static void get_options(void) { int CC_id; int tddflag = 0; char *loopfile = NULL; - int dumpframe = 0; int timingadv = 0; uint8_t nfapi_mode = NFAPI_MONOLITHIC; @@ -592,7 +591,7 @@ int main( int argc, char **argv ) { if (config_mod == NULL) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); } - + mode = normal_txrx; memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); set_latency_target(); @@ -792,7 +791,7 @@ int main( int argc, char **argv ) { //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; if (IS_SOFTMODEM_SIML1 ) { - init_ocm(snr_dB,0); + init_ocm(); PHY_vars_UE_g[0][0]->no_timing_correction = 1; } diff --git a/targets/RT/USER/rfsim.c b/targets/RT/USER/rfsim.c index 8b3ee97e50..bd8305682c 100644 --- a/targets/RT/USER/rfsim.c +++ b/targets/RT/USER/rfsim.c @@ -64,65 +64,52 @@ sim_t sim; void init_ru_devices(void); -void init_RU(char*,clock_source_t clock_source,clock_source_t time_source,int send_dmrssync); +void init_RU(char *,clock_source_t clock_source,clock_source_t time_source,int send_dmrssync); void *rfsim_top(void *n_frames); -void wait_RUs(void) -{ +void wait_RUs(void) { int i; - // wait for all RUs to be configured over fronthaul pthread_mutex_lock(&RC.ru_mutex); - + while (RC.ru_mask>0) { pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); } - + pthread_mutex_unlock(&RC.ru_mutex); // copy frame parameters from RU to UEs - for (i=0;iframe_parms->samples_per_tti + RC.ru[0]->frame_parms->ofdm_symbol_size + RC.ru[0]->frame_parms->nb_prefix_samples0; - } - for (int ru_id=0;ru_idframe_parms->samples_per_tti; + for (int ru_id=0; ru_idframe_parms->samples_per_tti; printf("RUs are ready, let's go\n"); } -void wait_eNBs(void) -{ +void wait_eNBs(void) { return; } void RCConfig_sim(void) { - paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; - // Get num RU instances config_getlist( &RUParamList,NULL,0, NULL); RC.nb_RU = RUParamList.numelt; - AssertFatal(RC.nb_RU>0,"we need at least 1 RU for simulation\n"); printf("returned with %d rus\n",RC.nb_RU); - init_RU(NULL,internal,internal,0); - - printf("Waiting for RUs to get set up\n"); + printf("Waiting for RUs to get set up\n"); wait_RUs(); - init_ru_devices(); - static int nframes = 100000; - AssertFatal(0 == pthread_create(&sim.rfsim_thread, NULL, rfsim_top, - (void*)&nframes), ""); - + (void *)&nframes), ""); } @@ -165,75 +152,65 @@ extern int subframe_ru_mask,subframe_UE_mask; int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { - int ru_id = device->Mod_id; int CC_id = device->CC_id; - int subframe; int sample_count=0; - *ptimestamp = sim.last_ru_rx_timestamp[ru_id][CC_id]; - - LOG_D(SIM,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id], (unsigned long long)sim.last_ru_rx_timestamp[ru_id][CC_id], - (int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10)); + (int)((*ptimestamp/RC.ru[ru_id]->frame_parms->samples_per_tti)%10)); + // if we're at a subframe boundary generate UL signals for this ru while (sample_countframe_parms->samples_per_tti)%10; + if (subframe_select(RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms->frame_type == FDD) { LOG_D(SIM,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1); + subframe,(unsigned long long)*ptimestamp, + (unsigned long long)sim.current_ru_rx_timestamp[ru_id][CC_id]); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,1); do_UL_sig(&sim, - subframe, - 0, // abstraction_flag - RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id); + subframe, + 0, // abstraction_flag + RC.ru[ru_id]->frame_parms, + 0, // frame is only used for abstraction + ru_id, + CC_id); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_UL_SIGNAL,0); } + sim.last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms->samples_per_tti; sample_count += RC.ru[ru_id]->frame_parms->samples_per_tti; } - return(nsamps); } -int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) -{ +int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_UE_TRX_READ,1); int UE_id = device->Mod_id; int CC_id = device->CC_id; - int subframe; int sample_count=0; int read_size; int sptti = PHY_vars_UE_g[UE_id][CC_id]->frame_parms.samples_per_tti; - *ptimestamp = sim.last_UE_rx_timestamp[UE_id][CC_id]; - LOG_D(PHY,"UE %d DL simulation 0: UE_trx_read nsamps %d TS %llu (%llu, offset %d) antenna %d\n", UE_id, nsamps, (unsigned long long)sim.current_UE_rx_timestamp[UE_id][CC_id], (unsigned long long)sim.last_UE_rx_timestamp[UE_id][CC_id], (int)(sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti), - cc); - + cc); if (nsamps < sptti) read_size = nsamps; @@ -242,49 +219,43 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** while (sample_countframe_parms, - UE_id, - CC_id); + subframe, + sim.last_UE_rx_timestamp[UE_id][CC_id]%sptti, + sptti, + 0, //abstraction_flag, + &PHY_vars_UE_g[UE_id][CC_id]->frame_parms, + UE_id, + CC_id); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SIM_DO_DL_SIGNAL,0); LOG_D(PHY,"UE %d: DL simulation 6: UE_trx_read @ TS %"PRIi64" (%"PRIi64")=> frame %d, subframe %d\n", - UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id], - sim.last_UE_rx_timestamp[UE_id][CC_id], - (int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), - subframe); - + UE_id, sim.current_UE_rx_timestamp[UE_id][CC_id], + sim.last_UE_rx_timestamp[UE_id][CC_id], + (int)((sim.last_UE_rx_timestamp[UE_id][CC_id]/(sptti*10))&1023), + subframe); sim.last_UE_rx_timestamp[UE_id][CC_id] += read_size; sample_count += read_size; } @@ -295,245 +266,222 @@ int UE_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** int ru_trx_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - int ru_id = device->Mod_id; - LTE_DL_FRAME_PARMS *frame_parms = RC.ru[ru_id]->frame_parms; - pthread_mutex_lock(&sim.subframe_mutex); LOG_D(SIM,"[TXPATH] ru_trx_write: RU %d mask %d\n",ru_id,sim.subframe_ru_mask); - pthread_mutex_unlock(&sim.subframe_mutex); - + pthread_mutex_unlock(&sim.subframe_mutex); // compute amplitude of TX signal from first symbol in subframe - // note: assumes that the packet is an entire subframe - + // note: assumes that the packet is an entire subframe sim.ru_amp[ru_id] = 0; - for (int aa=0; aanb_tx; aa++) { - sim.ru_amp[ru_id] += (double)signal_energy((int32_t*)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); - } - sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]); - LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t*)buff[0],frame_parms->ofdm_symbol_size))); + for (int aa=0; aanb_tx; aa++) { + sim.ru_amp[ru_id] += (double)signal_energy((int32_t *)buff[aa],frame_parms->ofdm_symbol_size)/(12*frame_parms->N_RB_DL); + } + + sim.ru_amp[ru_id] = sqrt(sim.ru_amp[ru_id]); + LOG_D(PHY,"Setting amp for RU %d to %f (%d)\n",ru_id,sim.ru_amp[ru_id], dB_fixed((double)signal_energy((int32_t *)buff[0],frame_parms->ofdm_symbol_size))); // tell top-level we are done pthread_mutex_lock(&sim.subframe_mutex); sim.subframe_ru_mask|=(1<rfdevice.Mod_id = ru_id; - ru->rfdevice.CC_id = 0; - ru->rfdevice.trx_start_func = ru_trx_start; - ru->rfdevice.trx_read_func = ru_trx_read; - ru->rfdevice.trx_write_func = ru_trx_write; - ru->rfdevice.trx_end_func = ru_trx_end; - ru->rfdevice.trx_stop_func = ru_trx_stop; - ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; - ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; - sim.last_ru_rx_timestamp[ru_id][0] = 0; + if (RC.ru[ru_id]==NULL) RC.ru[ru_id] = (RU_t *)malloc(sizeof(RU_t)); + + ru = RC.ru[ru_id]; + ru->rfdevice.Mod_id = ru_id; + ru->rfdevice.CC_id = 0; + ru->rfdevice.trx_start_func = ru_trx_start; + ru->rfdevice.trx_read_func = ru_trx_read; + ru->rfdevice.trx_write_func = ru_trx_write; + ru->rfdevice.trx_end_func = ru_trx_end; + ru->rfdevice.trx_stop_func = ru_trx_stop; + ru->rfdevice.trx_set_freq_func = ru_trx_set_freq; + ru->rfdevice.trx_set_gains_func = ru_trx_set_gains; + sim.last_ru_rx_timestamp[ru_id][0] = 0; } } void init_ue_devices(PHY_VARS_UE *UE) { - - AssertFatal(UE!=NULL,"UE context is not allocated\n"); - printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id); - UE->rfdevice.Mod_id = UE->Mod_id; - UE->rfdevice.CC_id = UE->CC_id; - UE->rfdevice.trx_start_func = UE_trx_start; - UE->rfdevice.trx_read_func = UE_trx_read; - UE->rfdevice.trx_write_func = UE_trx_write; - UE->rfdevice.trx_end_func = UE_trx_end; - UE->rfdevice.trx_stop_func = UE_trx_stop; - UE->rfdevice.trx_set_freq_func = UE_trx_set_freq; - UE->rfdevice.trx_set_gains_func = UE_trx_set_gains; - sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0; + AssertFatal(UE!=NULL,"UE context is not allocated\n"); + printf("Initializing UE %d.%d\n",UE->Mod_id,UE->CC_id); + UE->rfdevice.Mod_id = UE->Mod_id; + UE->rfdevice.CC_id = UE->CC_id; + UE->rfdevice.trx_start_func = UE_trx_start; + UE->rfdevice.trx_read_func = UE_trx_read; + UE->rfdevice.trx_write_func = UE_trx_write; + UE->rfdevice.trx_end_func = UE_trx_end; + UE->rfdevice.trx_stop_func = UE_trx_stop; + UE->rfdevice.trx_set_freq_func = UE_trx_set_freq; + UE->rfdevice.trx_set_gains_func = UE_trx_set_gains; + sim.last_UE_rx_timestamp[UE->Mod_id][UE->CC_id] = 0; } -void init_ocm(double snr_dB,double sinr_dB) -{ +void init_ocm(void) { module_id_t UE_id, ru_id; int CC_id; - randominit(0); set_taus_seed(0); - - + init_channelmod(); + double snr_dB = channelmod_get_snr_dB(); + double sinr_dB = channelmod_get_sinr_dB(); init_channel_vars ();//fp, &s_re, &s_im, &r_re, &r_im, &r_re0, &r_im0); - // initialize channel descriptors LOG_I(PHY,"Initializing channel descriptors (nb_RU %d, nb_UE %d)\n",RC.nb_RU,NB_UE_INST); + for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { for (CC_id=0; CC_idframe_parms->N_RB_DL); + LOG_I(PHY,"Initializing channel descriptors (RU %d, UE %d) for N_RB_DL %d\n",ru_id,UE_id, + RC.ru[ru_id]->frame_parms->N_RB_DL); sim.RU2UE[ru_id][UE_id][CC_id] = - new_channel_desc_scm(RC.ru[ru_id]->nb_tx, - PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), - 0.0, - 0, - 0); + new_channel_desc_scm(RC.ru[ru_id]->nb_tx, + PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_rx, + AWGN, + N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_DL), + N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_DL), + 0.0, + 0, + 0); random_channel(sim.RU2UE[ru_id][UE_id][CC_id],0); - LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN",UE_id, ru_id); - - - sim.UE2RU[UE_id][ru_id][CC_id] = - new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, - RC.ru[ru_id]->nb_rx, - AWGN, - N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), - N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), - 0.0, - 0, - 0); + LOG_D(OCM,"[SIM] Initializing channel (%s) from UE %d to ru %d\n", "AWGN", UE_id, ru_id); + sim.UE2RU[UE_id][ru_id][CC_id] = + new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->frame_parms.nb_antennas_tx, + RC.ru[ru_id]->nb_rx, + AWGN, + N_RB2sampling_rate(RC.ru[ru_id]->frame_parms->N_RB_UL), + N_RB2channel_bandwidth(RC.ru[ru_id]->frame_parms->N_RB_UL), + 0.0, + 0, + 0); random_channel(sim.UE2RU[UE_id][ru_id][CC_id],0); - // to make channel reciprocal uncomment following line instead of previous. However this only works for SISO at the moment. For MIMO the channel would need to be transposed. //UE2RU[UE_id][ru_id] = RU2UE[ru_id][UE_id]; + AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); + AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); - AssertFatal(sim.RU2UE[ru_id][UE_id][CC_id]!=NULL,"RU2UE[%d][%d][%d] is null\n",ru_id,UE_id,CC_id); - AssertFatal(sim.UE2RU[UE_id][ru_id][CC_id]!=NULL,"UE2RU[%d][%d][%d] is null\n",UE_id,ru_id,CC_id); - //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE - if (ru_id == (UE_id % RC.nb_RU)) { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } - - LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower,snr_dB); - + //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE + if (ru_id == (UE_id % RC.nb_RU)) { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } else { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } + LOG_I(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, + RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, + snr_dB); } } } } -void update_ocm(double snr_dB,double sinr_dB) -{ +void update_ocm(double snr_dB,double sinr_dB) { module_id_t UE_id, ru_id; int CC_id; + for (ru_id = 0; ru_id < RC.nb_RU; ru_id++) { + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { + for (CC_id=0; CC_idpath_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } else { - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; - } + //pathloss: -132.24 dBm/15kHz RE + target SNR - eNB TX power per RE + if (ru_id == (UE_id % RC.nb_RU)) { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + snr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } else { + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + sim.UE2RU[UE_id][ru_id][CC_id]->path_loss_dB = -132.24 + sinr_dB - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower; + } - LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, - sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, - RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower,snr_dB); - - } - } - } + LOG_D(OCM,"Path loss from eNB %d to UE %d (CCid %d)=> %f dB (eNB TX %d, SNR %f)\n",ru_id,UE_id,CC_id, + sim.RU2UE[ru_id][UE_id][CC_id]->path_loss_dB, + RC.ru[ru_id]->frame_parms->pdsch_config_common.referenceSignalPower, + snr_dB); + } + } + } } -void init_channel_vars(void) -{ - +void init_channel_vars(void) { int i; - memset(sim.RU_output_mask,0,sizeof(int)*NUMBER_OF_UE_MAX); - for (i=0;iframe_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<frame_parms,(sf+4)%10)!=SF_UL) ? sim.subframe_ru_mask : ((1<frame_parms->frame_type == FDD || subframe_select(RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? sim.subframe_UE_mask : ((1<frame_parms->samples_per_tti; - LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]); + + for (int ru_id=0; ru_idframe_parms->samples_per_tti; + LOG_D(SIM,"RU %d/%d: TS %"PRIi64"\n",ru_id,CC_id,sim.current_ru_rx_timestamp[ru_id][CC_id]); } - for (int UE_inst = 0; UE_instframe_parms.samples_per_tti; - LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]); + + for (int UE_inst = 0; UE_instframe_parms.samples_per_tti; + LOG_D(SIM,"UE %d/%d: TS %"PRIi64"\n",UE_inst,CC_id,sim.current_UE_rx_timestamp[UE_inst][CC_id]); } - if (oai_exit == 1) return((void*)NULL); + + if (oai_exit == 1) return((void *)NULL); } } - return((void*)NULL); + return((void *)NULL); } diff --git a/targets/RT/USER/rfsim.h b/targets/RT/USER/rfsim.h index f263b1067c..801ab5eb56 100644 --- a/targets/RT/USER/rfsim.h +++ b/targets/RT/USER/rfsim.h @@ -27,7 +27,7 @@ #include "PHY/defs_UE.h" #include "PHY/defs_eNB.h" -void init_ocm(double snr_dB,double sinr_dB); +void init_ocm(void); void update_ocm(double snr_dB,double sinr_dB); @@ -37,4 +37,4 @@ void update_ocm(double snr_dB,double sinr_dB); void init_channel_vars(void); -#endif +#endif