removal of EXPRESS MIMO HW drivers/libraries, same for mobipass.

This commit is contained in:
Raymond Knopp
2019-04-28 11:11:11 +02:00
parent 17eb5eedaf
commit e47829af6c
158 changed files with 7 additions and 590420 deletions
@@ -1,58 +0,0 @@
Active_eNBs = ( "eNB_Eurecom_LTEBox");
# Asn1_verbosity, choice in: none, info, annoying
Asn1_verbosity = "none";
eNBs =
(
{
# real_time choice in {hard, rt-preempt, no}
real_time = "hard";
////////// Identification parameters:
eNB_ID = 0xe00;
cell_type = "CELL_MACRO_ENB";
eNB_name = "eNB_Eurecom_LTEBox";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 15;
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
////////// Channel parameters:
// Default Paging DRX of the eNB as defined in TS 36.304
default_paging_drx = "PAGING_DRX_256";
////////// Physical parameters:
frame_type = "FDD";
prefix_type = "NORMAL";
eutra_band = 7;
downlink_frequency = 2680000000L;
uplink_frequency_offset = -120000000;
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.13.11";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
}
);
///X2
enable_x2 = "no";
t_reloc_prep = 1000; /* unit: millisecond */
tx2_reloc_overall = 2000; /* unit: millisecond */
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "eth0";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.13.10/24";
ENB_INTERFACE_NAME_FOR_S1U = "eth0";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.13.10/24";
ENB_IPV4_ADDRESS_FOR_X2C = "192.168.13.10/24";
ENB_PORT_FOR_X2C = 36422; # Spec 36422
};
}
);
@@ -1,89 +0,0 @@
Active_eNBs = ( "eNB_Eurecom_LTEBox");
# Asn1_verbosity, choice in: none, info, annoying
Asn1_verbosity = "none";
eNBs =
(
{
# real_time choice in {hard, rt-preempt, no}
real_time = "hard";
////////// Identification parameters:
eNB_ID = 0xe00;
cell_type = "CELL_MACRO_ENB";
eNB_name = "eNB_Eurecom_LTEBox";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 15;
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
////////// Channel parameters:
// Default Paging DRX of the eNB as defined in TS 36.304
default_paging_drx = "PAGING_DRX_256";
////////// Physical parameters:
frame_type = "FDD";
prefix_type = "NORMAL";
eutra_band = 7;
downlink_frequency = 2680000000L;
uplink_frequency_offset = -120000000;
component_carriers = (
{
cell_id = 0;
N_RB_DL = 25;
},
{
cell_id = 1;
N_RB_DL = 50;
}
);
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.13.11";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
}
);
///X2
enable_x2 = "no";
t_reloc_prep = 1000; /* unit: millisecond */
tx2_reloc_overall = 2000; /* unit: millisecond */
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "eth0";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.13.10/24";
ENB_INTERFACE_NAME_FOR_S1U = "eth0";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.13.10/24";
ENB_IPV4_ADDRESS_FOR_X2C = "192.168.13.10/24";
ENB_PORT_FOR_X2C = 36422; # Spec 36422
};
# available options for level: error, warn, notice, info, debug, trace
# available options for verbosity: none, low, medium, high, full
log_config :
{
global_log_level ="debug";
global_log_verbosity ="medium";
hw_log_level ="debug";
hw_log_verbosity ="medium";
phy_log_level ="info";
phy_log_verbosity ="medium";
mac_log_level ="debug";
mac_log_verbosity ="high";
rlc_log_level ="info";
rlc_log_verbosity ="medium";
pdcp_log_level ="info";
pdcp_log_verbosity ="medium";
rrc_log_level ="info";
rrc_log_verbosity ="medium";
};
}
);
@@ -1,57 +0,0 @@
Active_eNBs = ( "eNB_Eurecom_LTEBox");
# Asn1_verbosity, choice in: none, info, annoying
Asn1_verbosity = "none";
eNBs =
(
{
////////// Identification parameters:
hard_real_time = "yes";
eNB_ID = 0xe00;
cell_type = "CELL_MACRO_ENB";
eNB_name = "eNB_Eurecom_LTEBox";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 15;
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
////////// Channel parameters:
// Default Paging DRX of the eNB as defined in TS 36.304
default_paging_drx = "PAGING_DRX_256";
////////// Physical parameters:
frame_type = "FDD";
prefix_type = "NORMAL";
eutra_band = 7;
downlink_frequency = 2680000000L;
uplink_frequency_offset = -120000000;
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.13.11";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
}
);
///X2
enable_x2 = "no";
t_reloc_prep = 1000; /* unit: millisecond */
tx2_reloc_overall = 2000; /* unit: millisecond */
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "eth1";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.13.10/24";
ENB_INTERFACE_NAME_FOR_S1U = "eth1";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.13.10/24";
ENB_IPV4_ADDRESS_FOR_X2C = "192.168.13.10/24";
ENB_PORT_FOR_X2C = 36422; # Spec 36422
};
}
);
-92
View File
@@ -1,92 +0,0 @@
#! /bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file build_all.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
###########################################################
echo_success "\n###############################"
echo_success "# Check installed utils and libs"
echo_success "###############################"
test_command_install_package "gccxml" "gccxml" "--force-yes"
test_command_install_package "iptables" "iptables"
#test_command_install_package "ebtables" "ebtables" "--force-yes"
test_command_install_package "ip" "iproute"
test_install_package "openssl"
test_install_package "libblas-dev"
# for itti analyser
test_install_package "libgtk-3-dev"
test_install_package "libxml2"
test_install_package "libxml2-dev"
test_install_package "libforms-bin" "--force-yes"
test_install_package "libforms-dev"
test_install_package "libatlas-dev"
test_install_package "libatlas-base-dev"
test_install_package "libpgm-5.1-0" "--force-yes"
test_install_package "libpgm-dev" "--force-yes"
test_install_package linux-headers-`uname -r`
test_install_package "tshark" "--force-yes"
# for ODTONE git clone
test_install_package "git"
test_install_asn1c_4_rrc_cellular
echo_success "\n###############################"
echo_success "# COMPILE oaisim"
echo_success "###############################"
cd $OPENAIR_TARGETS/SIMU/USER
echo_success "Executing: make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo `"
make oaisim NAS=1 OAI_NW_DRIVER_TYPE_ETHERNET=1 ENABLE_ITTI=1 OPENAIR2=1 Rel10=1 -j`grep -c ^processor /proc/cpuinfo `
if [[ $? -eq 2 ]] ; then
exit 1
fi
echo_success "\n###############################"
echo_success "# COMPILE IP kernel drivers"
echo_success "###############################"
echo_success "Compiling IP Drivers"
cd $OPENAIR2_DIR
make naslite_netlink_ether.ko
cd $OPENAIR2_DIR/NAS/DRIVER/LITE/RB_TOOL/
make
echo_success "\n###############################"
echo_success "# COMPILE ITTI ANALYSER"
echo_success "###############################"
#cd $OPENAIR_DIR/common/utils/itti_analyzer
#if [ ! -f $OPENAIR_DIR/common/utils/itti_analyzer/Makefile ]
# then
# ./autogen.sh
# ./configure
# fi
#make install
-41
View File
@@ -1,41 +0,0 @@
Active_eNBs = ( "eNB_Eurecom_0");
eNBs =
(
{
////////// Identification parameters:
eNB_ID = 347472;
cell_type = "CELL_MACRO_ENB";
eNB_name = "eNB_Eurecom_0";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ( { mcc = 208; mnc = 10; mnc_length = 2; } );
////////// Channel parameters:
// Default Paging DRX of the eNB as defined in TS 36.304
default_paging_drx = "PAGING_DRX_256";
////////// Physical parameters:
frame_type = "TDD";
prefix_type = "NORMAL";
eutra_band = 33;
downlink_frequency = 1907.6e6;
uplink_frequency_offset = 0.0;
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.12.31";
ipv6 = "2192:168:30::17";
active = "yes";
preference = "ipv4";
},
{ ipv4 = "192.168.12.86";
ipv6 = "2192:168:30::18";
active = "yes";
preference = "ipv4";
}
);
}
);
-140
View File
@@ -1,140 +0,0 @@
#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file start_enb.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
# OAI NETWORKING--------------------------------
declare -x EMULATION_DEV_INTERFACE="eth0"
declare -x IP_DRIVER_NAME="oai_nw_drv"
declare -x LTEIF="oai0"
declare -x ENB_IPv4="10.0.1.1"
declare -x UE_IPv4="10.0.1.11"
declare -x ENB_IPv6="9998::1"
declare -x UE_IPv6="9998::11"
declare -x ENB_IPv6_CIDR=$ENB_IPv6"/64"
declare -x ENB_IPv4_CIDR=$ENB_IPv4"/24"
declare -a NAS_IMEI=( 3 9 1 8 3 6 6 2 0 0 0 0 0 0 )
declare -x DEFAULT_RB_ID=3
declare -x MBMS_RB_ID=225
#------------------------------------------------
LOG_FILE="/tmp/oai_sim_enb.log"
###########################################################
IPTABLES=/sbin/iptables
declare -x OPENAIR_DIR=""
declare -x OPENAIR1_DIR=""
declare -x OPENAIR2_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR_TARGETS=""
#######################################
#######################################
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
source $THIS_SCRIPT_PATH/utils.bash
###########################################################
set_openair
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green
cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green
bash_exec "/sbin/iptables -t mangle -F"
bash_exec "/sbin/iptables -t nat -F"
bash_exec "/sbin/iptables -t raw -F"
bash_exec "/sbin/iptables -t filter -F"
bash_exec "/sbin/ip6tables -t mangle -F"
bash_exec "/sbin/ip6tables -t filter -F"
bash_exec "/sbin/ip6tables -t raw -F"
##################################################
# LAUNCH eNB executable
##################################################
source $THIS_SCRIPT_PATH/build_all.bash
echo "Bringup eNB interface"
pkill oaisim > /dev/null 2>&1
pkill oaisim > /dev/null 2>&1
rmmod -f $IP_DRIVER_NAME > /dev/null 2>&1
bash_exec "insmod $OPENAIR2_DIR/NAS/DRIVER/LITE/$IP_DRIVER_NAME.ko oai_nw_drv_IMEI=${NAS_IMEI[0]},${NAS_IMEI[1]},${NAS_IMEI[2]},${NAS_IMEI[3]},${NAS_IMEI[4]},${NAS_IMEI[5]},${NAS_IMEI[6]},${NAS_IMEI[7]},${NAS_IMEI[8]},${NAS_IMEI[9]},${NAS_IMEI[10]},${NAS_IMEI[11]},${NAS_IMEI[12]},${NAS_IMEI[13]}"
bash_exec "ip route flush cache"
bash_exec "ip link set $LTEIF up"
sleep 1
bash_exec "ip addr add dev $LTEIF $ENB_IPv4_CIDR"
bash_exec "ip addr add dev $LTEIF $ENB_IPv6_CIDR"
sleep 1
bash_exec "sysctl -w net.ipv4.conf.all.log_martians=1"
assert " `sysctl -n net.ipv4.conf.all.log_martians` -eq 1" $LINENO
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
bash_exec "ip route flush cache"
# please add table 200 lte in /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark $DEFAULT_RB_ID table lte
ip rule add fwmark $MBMS_RB_ID table lte
ip route add default dev $LTEIF table lte
ip route add 239.0.0.160/28 dev $EMULATION_DEV_INTERFACE
/sbin/ebtables -t nat -A POSTROUTING -p arp -j mark --mark-set $DEFAULT_RB_ID
#/sbin/ip6tables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/iptables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type broadcast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/iptables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/ip6tables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/iptables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type broadcast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/iptables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type multicast -j MARK --set-mark $DEFAULT_RB_ID
#All other traffic is sent on the RAB you want (mark = RAB ID)
/sbin/ip6tables -A POSTROUTING -t mangle -o oai0 -j MARK --set-mark $MBMS_RB_ID
#/sbin/ip6tables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/ip6tables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/iptables -A POSTROUTING -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark $DEFAULT_RB_ID
#/sbin/iptables -A OUTPUT -t mangle -o oai0 -m pkttype --pkt-type unicast -j MARK --set-mark $DEFAULT_RB_ID
rotate_log_file $LOG_FILE
#xterm -hold -e gdb --args
#$OPENAIR_TARGETS/SIMU/USER/oaisim -a -Q3 -s15 -K $LOG_FILE -l9 -u0 -b1 -M0 -p2 -g1 -D $EMULATION_DEV_INTERFACE -O $THIS_SCRIPT_PATH/enb.conf &
#$OPENAIR_TARGETS/SIMU/USER/oaisim -a -l3 -u0 -b1 -M0 -p2 -g1 -D $EMULATION_DEV_INTERFACE -O $THIS_SCRIPT_PATH/enb.conf &
$OPENAIR_TARGETS/SIMU/USER/oaisim -a -Q3 -l7 -u0 -b1 -M0 -p2 -g1 -D 192.168.55.51 -O $THIS_SCRIPT_PATH/enb.conf | grep "PDCP\|RLC\|RRC" &
wait_process_started oaisim
sleep 100000
-106
View File
@@ -1,106 +0,0 @@
#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file start_ue.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
# OAI NETWORKING--------------------------------
declare -x EMULATION_DEV_INTERFACE="eth4"
declare -x IP_DRIVER_NAME="oai_nw_drv"
declare -x LTEIF="oai0"
declare -x UE_IPv4="10.0.0.11"
declare -x UE_IPv6="9998::11"
declare -x UE_IPv6_CIDR=$UE_IPv6"/64"
declare -x UE_IPv4_CIDR=$UE_IPv4"/24"
declare -a NAS_IMEI=( 3 9 1 8 3 6 7 3 0 2 0 0 0 0 )
#------------------------------------------------
LOG_FILE="/tmp/oai_sim_ue.log"
###########################################################
IPTABLES=/sbin/iptables
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
declare -x OPENAIR_DIR=""
declare -x OPENAIR1_DIR=""
declare -x OPENAIR2_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR_TARGETS=""
###########################################################
###########################################################
source $THIS_SCRIPT_PATH/utils.bash
source $THIS_SCRIPT_PATH/build_all.bash
###########################################################
##################################################
# LAUNCH UE
##################################################
echo "Bringup UE interface"
pkill oaisim > /dev/null 2>&1
pkill oaisim > /dev/null 2>&1
rmmod -f $IP_DRIVER_NAME > /dev/null 2>&1
bash_exec "insmod $OPENAIR2_DIR/NAS/DRIVER/LITE/$IP_DRIVER_NAME.ko oai_nw_drv_IMEI=${NAS_IMEI[0]},${NAS_IMEI[1]},${NAS_IMEI[2]},${NAS_IMEI[3]},${NAS_IMEI[4]},${NAS_IMEI[5]},${NAS_IMEI[6]},${NAS_IMEI[7]},${NAS_IMEI[8]},${NAS_IMEI[9]},${NAS_IMEI[10]},${NAS_IMEI[11]},${NAS_IMEI[12]},${NAS_IMEI[13]}"
bash_exec "ip route flush cache"
bash_exec "ip link set $LTEIF up"
sleep 1
bash_exec "ip addr add dev $LTEIF $UE_IPv4_CIDR"
bash_exec "ip addr add dev $LTEIF $UE_IPv6_CIDR"
sleep 1
bash_exec "sysctl -w net.ipv4.conf.all.log_martians=1"
assert " `sysctl -n net.ipv4.conf.all.log_martians` -eq 1" $LINENO
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
bash_exec "ip route flush cache"
# please add table 200 lte in file /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 5 table lte
ip -4 route add default dev $LTEIF table lte
ip -6 route add default dev $LTEIF table lte
ip route add 239.0.0.160/28 dev $EMULATION_DEV_INTERFACE
NOW=$(date +"%Y-%m-%d.%Hh_%Mm_%Ss")
rotate_log_file $LOG_FILE
#xterm -hold -e gdb --args
$OPENAIR_TARGETS/SIMU/USER/oaisim -a -Q3 -s15 -K $LOG_FILE -l9 -u1 -b0 -M1 -p2 -g1 -D $EMULATION_DEV_INTERFACE
wait_process_started oaisim
# start MIH-USER
sleep 100000
-371
View File
@@ -1,371 +0,0 @@
#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file utils.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
cidr2mask() {
local i mask=""
local full_octets=$(($1/8))
local partial_octet=$(($1%8))
for ((i=0;i<4;i+=1)); do
if [ $i -lt $full_octets ]; then
mask+=255
elif [ $i -eq $full_octets ]; then
mask+=$((256 - 2**(8-$partial_octet)))
else
mask+=0
fi
test $i -lt 3 && mask+=.
done
echo $mask
}
black='\E[30m'
red='\E[31m'
green='\E[32m'
yellow='\E[33m'
blue='\E[34m'
magenta='\E[35m'
cyan='\E[36m'
white='\E[37m'
reset_color='\E[00m'
ROOT_UID=0
E_NOTROOT=67
HOSTNAME=$(hostname -f)
trim ()
{
echo "$1" | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'
}
trim2()
{
local var=$@
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
cecho() # Color-echo
# arg1 = message
# arg2 = color
{
local default_msg="No Message."
message=${1:-$default_msg}
color=${2:-$green}
echo -e -n "$color$message$reset_color"
echo
return
}
echo_error() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $red
}
echo_warning() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $yellow
}
echo_success() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $green
}
bash_exec() {
output=$($1 2>&1)
result=$?
if [ $result -eq 0 ]
then
echo_success "$1"
else
echo_error "$1: $output"
fi
}
rotate_log_file () {
if [ -f $1 ]; then
TIMESTAMP=`date +%Y-%m-%d.%Hh_%Mm_%Ss`
NEWLOGFILE=$1.$TIMESTAMP
mv $1 $NEWLOGFILE
cat /dev/null > $1
nohup gzip -f -9 $NEWLOGFILE &
fi
}
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo_error "'$1' cannot be extracted via >extract<" ; return 1;;
esac
else
echo_error "'$1' is not a valid file"
return 1
fi
return 0
}
set_openair() {
path=`pwd`
declare -i length_path
declare -i index
length_path=${#path}
for i in 'openair1' 'openair2' 'openair3' 'openair3' 'targets'
do
index=`echo $path | grep -b -o $i | cut -d: -f1`
#echo ${path%$token*}
if [[ $index -lt $length_path && index -gt 0 ]]
then
declare -x OPENAIR_DIR
index=`expr $index - 1`
openair_path=`echo $path | cut -c1-$index`
#openair_path=`echo ${path:0:$index}`
export OPENAIR_DIR=$openair_path
export OPENAIR_DIR=$openair_path
export OPENAIR1_DIR=$openair_path/openair1
export OPENAIR2_DIR=$openair_path/openair2
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR_TARGETS=$openair_path/targets
return 0
fi
done
return -1
}
test_install_asn1c_4_rrc_cellular() {
if [ -d $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c ]; then
if [ -x $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c/asn1c/asn1c ]; then
if [ -x /usr/local/bin/asn1c ]; then
diff /usr/local/bin/asn1c $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c/asn1c/asn1c >/dev/null 2>&1;
if [ $? -eq 0 ]; then
echo_success "asn1c for RRC cellular installed"
return 0
fi
fi
echo_warning "Installing asn1c for RRC cellular..."
cd $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c
make install
return 0
fi
else
echo_warning "asn1c for RRC cellular is not installed in $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/. Installing it"
cd $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c
svn co https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk asn1c
fi
echo_warning "Configuring and building and installing asn1c for RRC cellular..."
cd $OPENAIR2_DIR/RRC/LITE/MESSAGES/asn1c/asn1c
./configure
make
make install
}
wait_process_started () {
if [ -z "$1" ]
then
echo_error "WAITING FOR PROCESS START: NO PROCESS"
return 1
fi
ps -C $1 > /dev/null 2>&1
while [ $? -ne 0 ]; do
echo_warning "WAITING FOR $1 START"
sleep 2
ps -C $1 > /dev/null 2>&1
done
echo_success "PROCESS $1 STARTED"
return 0
}
is_process_started () {
if [ -z "$1" ]
then
echo_error "WAITING FOR PROCESS START: ERROR NO PROCESS NAME IN ARGUMENT"
return 1
fi
ps -C $1 > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo_success "PROCESS $1 NOT STARTED"
return 1
fi
echo_success "PROCESS $1 STARTED"
return 0
}
assert() {
# If condition false
# exit from script with error message
E_PARAM_ERR=98
E_PARAM_FAILED=99
if [ -z "$2" ] # Not enought parameters passed.
then
return $E_PARAM_ERR
fi
lineno=$2
if [ ! $1 ]
then
echo "Assertion failed: \"$1\""
echo "File \"$0\", line $lineno"
exit $E_ASSERT_FAILED
fi
}
test_install_package() {
# usage: test_install_package package_name_to_be_installed optional_option_to_apt_get_install
dpkg --get-selections $1 | grep -i install > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo_warning "Package $1 is not installed. Installing it." >&2
apt-get install $2 $1 -y
dpkg --get-selections $1 | grep -i install > /dev/null 2>&1
if [ $? -ne 0 ]; then
exit 1
fi
else
echo_success "$1 is installed"
fi
return 0
}
test_command_install_package() {
# usage: test_command_install_package searched_binary package_to_be_installed_if_binary_not_found optional_option_to_apt_get_install
if [ $# -eq 2 ]; then
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; apt-get install $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
else
if [ $# -eq 3 ]; then
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it (apt-get install $3 $2)." >&2; apt-get install $3 $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
else
echo_success "test_command_install_package: BAD PARAMETER"
exit 1
fi
fi
echo_success "$1 available"
}
test_command_install_script() {
# usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };}
echo_success "$1 available"
}
start_openswitch_daemon() {
rmmod -s bridge
if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then
bash_exec "insmod /lib/modules/`uname -r`/extra/openvswitch.ko"
else
echo_error "/lib/modules/`uname -r`/extra/openvswitch.ko not found, exiting"
exit -1
fi
is_process_started "ovsdb-server"
if [ $? -ne 0 ]
then
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --pidfile --detach
wait_process_started "ovsdb-server"
fi
# To be done after installation
# ovs-vsctl --no-wait init
is_process_started "ovs-vswitchd"
if [ $? -ne 0 ]
then
ovs-vswitchd --pidfile --detach
wait_process_started "ovs-vswitchd"
fi
}
check_enb_config() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf ]
then
echo "Cannot find file $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf"
echo "Please make sure to create one that fits your use (you can use mme_default.conf file as template)"
exit -1
fi
}
check_for_root_rights() {
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit -1
fi
}
###########################################################
declare -x OPENAIR_DIR=""
declare -x OPENAIR_DIR=""
declare -x OPENAIR1_DIR=""
declare -x OPENAIR2_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR_TARGETS=""
###########################################################
set_openair
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green
cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green
@@ -1,257 +0,0 @@
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file interfaces.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
cidr2mask() {
local i mask=""
local full_octets=$(($1/8))
local partial_octet=$(($1%8))
for ((i=0;i<4;i+=1)); do
if [ $i -lt $full_octets ]; then
mask+=255
elif [ $i -eq $full_octets ]; then
mask+=$((256 - 2**(8-$partial_octet)))
else
mask+=0
fi
test $i -lt 3 && mask+=.
done
echo $mask
}
# example: netcalc 192.168.12.100 255.255.255.0
netcalc(){
local IFS='.' ip i
local -a oct msk
read -ra oct <<<"$1"
read -ra msk <<<"$2"
for i in ${!oct[@]}; do
ip+=( "$(( oct[i] & msk[i] ))" )
done
echo "${ip[*]}"
}
# example: s
bcastcalc(){
local IFS='.' ip i
local -a oct msk
read -ra oct <<<"$1"
read -ra msk <<<"$2"
for i in ${!oct[@]}; do
ip+=( "$(( oct[i] + ( 255 - ( oct[i] | msk[i] ) ) ))" )
done
echo "${ip[*]}"
}
is_real_interface() {
my_bool=1
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [ "a$var" == "anone" ]; then
return 0
fi
IF=`cat /etc/udev/rules.d/70-persistent-net.rules | grep $var | sed 's/^.*NAME=//' | tr -d '"'`
if [ "$IF" == "$var" ]; then
if [ "a${var:0:3}" != "aeth" ]; then
if [ "a${var:0:4}" != "awlan" ]; then
if [ "a${var:0:4}" != "awifi" ]; then
my_bool=0;
fi
fi
fi
fi
done
return $my_bool
}
is_vlan_interface() {
my_bool=1
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [[ $var == *.* ]]
then
interface_name=`echo $var | cut -f1 -d '.'`
vlan=`echo $var | cut -f2 -d '.'`
IF=`cat /etc/udev/rules.d/70-persistent-net.rules | grep $interface_name | sed 's/^.*NAME=//' | tr -d '"'`
if [ "$IF" == "$interface_name" ]; then
if [ "a${interface_name:0:3}" != "aeth" ]; then
if [ "a${interface_name:0:4}" != "awlan" ]; then
if [ "a${interface_name:0:4}" != "awifi" ]; then
return 0;
fi
fi
fi
fi
else
return 0;
fi
done
return $my_bool
}
is_tun_interface() {
my_bool=1
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [[ "$IF" != *tun* ]]; then
return 0;
fi
bus_info=`ethtool -i $var | grep bus-info | cut -d: -f2`
bus_info=trim2 $bus_info
if [[ "$bus_info" != *tun* ]]; then
return 0;
fi
done
return $my_bool
}
is_openvswitch_interface() {
for var in "$@"
do
if [ "a$var" == "a" ]; then
return 0
fi
if [ "a${var:0:3}" != "aeth" ]; then
if [ "a${var:0:4}" != "awlan" ]; then
if [ "a${var:0:4}" != "awifi" ]; then
if [ "a${var:0:4}" != "anone" ]; then
if [ "a${var:0:3}" != "atun" ]; then
if [ "a${var:0:4}" != "avbox" ]; then
return 1;
fi
fi
fi
fi
fi
fi
done
return 0;
}
delete_tun_interface() {
is_tun_interface $1
if [ $? -eq 1 ]; then
ip link set $1 down > /dev/null 2>&1
openvpn --rmtun --dev $1 > /dev/null 2>&1
fi
}
delete_vlan_interface() {
is_vlan_interface $1
if [ $? -eq 1 ]; then
bash_exec "ifconfig $1 down "
bash_exec "vconfig rem $1 "
fi
}
delete_openvswitch_interface() {
is_openvswitch_interface $1
if [ $? -eq 1 ]; then
bash_exec "ifconfig $1 down "
bash_exec "tunctl -d $1 "
fi
}
create_tun_interface() {
is_tun_interface $1
if [ $? -eq 1 ]; then
bash_exec "openvpn --mktun --dev $1"
fi
}
create_vlan_interface() {
is_vlan_interface $1
if [ $? -eq 1 ]; then
interface_name=`echo $1 | cut -f1 -d '.'`
vlan=`echo $1 | cut -f2 -d '.'`
bash_exec "vconfig add $interface_name $vlan"
fi
}
create_openvswitch_interface() {
is_openvswitch_interface $1
if [ $? -eq 1 ]; then
bash_exec "tunctl -t $1"
fi
}
# arg1 = interface name
# arg2 = ipv4 addr cidr
# arg3 = netmask cidr
set_interface_up() {
interface=$1
address=$2
cidr_netmask=$3
if [ "a${interface:0:4}" == "anone" ]; then
return;
fi
bash_exec "ifconfig $interface up"
sync
netmask=`cidr2mask $cidr_netmask`
broadcast=`bcastcalc $address $netmask`
bash_exec "ip -4 addr add $address/$cidr_netmask broadcast $broadcast dev $interface"
sync
}
# input is hostname, you should have checked it is reachable by
# ping -c 1 $the_hostname > /dev/null || { echo_fatal "the_hostname does not respond to ping" >&2 ; }
get_ip() {
IP=$(python -c 'import socket; print socket.gethostbyname("'$1'")')
echo "$IP"
}
get_mac_router() {
echo_success "Resolving router.eur"
ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
IP_ROUTER=$(get_ip router.eur)
#IP_ROUTER=`python -c 'import socket; print socket.gethostbyname("router.eur")'`
export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER' ' | cut -d ' ' -f5 | tr -d ':'`
echo_success "ROUTER IP ADDRESS= $IP_ROUTER"
echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER"
}
@@ -1,301 +0,0 @@
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file networks.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
# example: netcalc 192.168.12.100 255.255.255.0
netcalc(){
local IFS='.' ip i
local -a oct msk
read -ra oct <<<"$1"
read -ra msk <<<"$2"
for i in ${!oct[@]}; do
ip+=( "$(( oct[i] & msk[i] ))" )
done
echo "${ip[*]}"
}
build_enb_vlan_network() {
# create vlan interface
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
if [ $? -eq 1 ]; then
delete_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
sync
create_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
sync
set_interface_up $ENB_INTERFACE_NAME_FOR_S1_MME $ENB_IPV4_ADDRESS_FOR_S1_MME $ENB_IPV4_NETMASK_FOR_S1_MME
else
echo_fatal "BAD INTERFACE NAME FOR ENB S1-MME $ENB_INTERFACE_NAME_FOR_S1_MME"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
if [ $? -eq 1 ]; then
delete_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
sync
create_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
sync
set_interface_up $ENB_INTERFACE_NAME_FOR_S1U $ENB_IPV4_ADDRESS_FOR_S1U $ENB_IPV4_NETMASK_FOR_S1U
sync
else
echo_fatal "BAD INTERFACE NAME FOR ENB S1U $ENB_INTERFACE_NAME_FOR_S1U"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
}
clean_enb_vlan_network() {
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
if [ $? -eq 1 ]; then
echo_success "Found VLAN interface $ENB_INTERFACE_NAME_FOR_S1_MME ... deleting"
delete_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME
fi;
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
if [ $? -eq 1 ]; then
echo_success "Found VLAN interface $ENB_INTERFACE_NAME_FOR_S1U ... deleting"
delete_vlan_interface $ENB_INTERFACE_NAME_FOR_S1U
fi;
sync;
clean_network
}
build_mme_spgw_vlan_network() {
# hss.eur
# |
# +-----------+ +-----------+ v +----------+
# | eNB +------+ VLAN 1+------+ MME +----+ +---+ HSS |
# | |ethx.1+------------------+ethy.1| | +------+ | |
# | +------+ +------+ +----+ +---+ |
# | |ethx.2+-------+ | | +----------+
# | +------+ | +-+-------+-+
# | | | | s11mme|
# | | | +---+---+
# | | | (optional)| VLAN 3
# +-----------+ | +---+---+
# | | s11sgw| router.eur
# | +-+-------+-+ | +--------------+
# | | S+P-GW | v | ROUTER |
# | VLAN2 +------+ +-------+ +----+ +----+
# +----------+ethy.2| |sgi +-...-+ | | +---...Internet
# +------+ +-------+ +----+ +----+
# | | 11 VLANS | |
# +-----------+ ids=[5..15] +--------------+
bash_exec "modprobe 8021q"
# create vlan interface
is_vlan_interface $MME_INTERFACE_NAME_FOR_S1_MME
if [ $? -eq 1 ]; then
delete_vlan_interface $MME_INTERFACE_NAME_FOR_S1_MME
sync
create_vlan_interface $MME_INTERFACE_NAME_FOR_S1_MME
sync
set_interface_up $MME_INTERFACE_NAME_FOR_S1_MME $MME_IPV4_ADDRESS_FOR_S1_MME $MME_IPV4_NETMASK_FOR_S1_MME
else
echo_fatal "BAD INTERFACE NAME FOR SGW S1-MME $MME_INTERFACE_NAME_FOR_S1_MME"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
is_vlan_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
if [ $? -eq 1 ]; then
delete_vlan_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
sync
create_vlan_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
sync
set_interface_up $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP $SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP
else
echo_fatal "BAD INTERFACE NAME FOR SGW S1U $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP"' (waiting for ethx.y, wlanx.y or wifix.y)'
fi;
#
is_real_interface $PGW_INTERFACE_NAME_FOR_SGI
if [ $? -eq 1 ]; then
create_sgi_vlans
else
echo_warning "SGI interface disabled by config file"
fi
}
clean_epc_vlan_network() {
bash_exec "modprobe 8021q"
delete_vlan_interface $MME_INTERFACE_NAME_FOR_S1_MME
delete_vlan_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# delete vlan interface
delete_vlan_interface $PGW_INTERFACE_NAME_FOR_SGI.$i
done
clean_network
}
# arg1 is IF1 IP addr
# arg2 is IF2 IP addr
test_local_iperf() {
TRY_NO=3
until [ $TRY_NO -lt 1 ]; do
iperf --bind $1 -u -s 2>&1 > /dev/null &
iperf --bind $2 -u --num 1K -c $1 2>&1 | grep -i WARNING > /dev/null
if [ $? -eq 0 ]; then
pkill iperf 2>&1 > /dev/null
echo_warning "NETWORK TEST FAILED between $1 and $2"
else
echo_success "NETWORK TEST SUCCESS between $1 and $2"
pkill iperf 2>&1 > /dev/null
return
fi
let TRY_NO-=1
pkill iperf 2>&1 > /dev/null
done
echo_fatal "FATAL: NETWORK TEST FAILED between $1 and $2"
}
test_network() {
# TEST INTERFACES
if [ "a${MME_INTERFACE_NAME_FOR_S1_MME:0:4}" != "anone" ]; then
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S1_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S1_MME $LINENO"; fi;
fi
if [ "a${SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP:0:4}" != "anone" ]; then
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP $LINENO"; fi;
fi
if [ "a${ENB_INTERFACE_NAME_FOR_S1_MME:0:4}" != "anone" ]; then
ping -q -c 1 $ENB_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $ENB_INTERFACE_NAME_FOR_S1_MME ADDR ERROR, ADDRESS IS $ENB_IPV4_ADDRESS_FOR_S1_MME $LINENO"; fi;
fi
if [ "a${ENB_INTERFACE_NAME_FOR_S1U:0:4}" != "anone" ]; then
ping -q -c 1 $ENB_IPV4_ADDRESS_FOR_S1U > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $ENB_INTERFACE_NAME_FOR_S1U ERROR, ADDRESS IS $ENB_IPV4_ADDRESS_FOR_S1U $LINENO"; fi;
fi
if [ "a${MME_INTERFACE_NAME_FOR_S11_MME:0:4}" != "anone" ]; then
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S11_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S11_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S11_MME $LINENO"; fi;
fi
if [ "a${SGW_INTERFACE_NAME_FOR_S11:0:4}" != "anone" ]; then
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S11 > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $SGW_INTERFACE_NAME_FOR_S11 ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S11 $LINENO"; fi;
fi
if [ "a${MME_INTERFACE_NAME_FOR_S6A:0:4}" != "anone" ]; then
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S6A > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S6A ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S6A $LINENO"; fi;
fi
if [ "a${HSS_INTERFACE_NAME_FOR_S6A:0:4}" != "anone" ]; then
ping -q -c 1 $HSS_IPV4_ADDRESS_FOR_S6A > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $HSS_INTERFACE_NAME_FOR_S6A ERROR, ADDRESS IS $HSS_IPV4_ADDRESS_FOR_S6A $LINENO"; fi;
fi
## TEST NETWORK BETWEEN ENB-MME-SP-GW
if [ "a${MME_INTERFACE_NAME_FOR_S1_MME:0:4}" != "anone" ] && [ "a${ENB_INTERFACE_NAME_FOR_S1_MME:0:4}" != "anone" ]; then
test_local_iperf $ENB_IPV4_ADDRESS_FOR_S1_MME $MME_IPV4_ADDRESS_FOR_S1_MME
fi
if [ "a${ENB_INTERFACE_NAME_FOR_S1U:0:4}" != "anone" ] && [ "a${SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP:0:4}" != "anone" ]; then
test_local_iperf $ENB_IPV4_ADDRESS_FOR_S1U $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP
fi
if [ "a${MME_INTERFACE_NAME_FOR_S11_MME:0:4}" != "anone" ] && [ "a${SGW_INTERFACE_NAME_FOR_S11:0:4}" != "anone" ]; then
test_local_iperf $MME_IPV4_ADDRESS_FOR_S11_MME $SGW_IPV4_ADDRESS_FOR_S11
fi
if [ "a${MME_INTERFACE_NAME_FOR_S6A:0:4}" != "anone" ] && [ "a${HSS_INTERFACE_NAME_FOR_S6A:0:4}" != "anone" ]; then
test_local_iperf $MME_IPV4_ADDRESS_FOR_S6A $HSS_IPV4_ADDRESS_FOR_S6A
fi
# Get MAC address of router.eur
ping -c 1 hss.eur > /dev/null || { echo_fatal "hss.eur does not respond to ping" >&2 ; }
ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
return 0
}
clean_network() {
interfaces=`ifconfig | grep HWaddr | cut -d " " -f1-2 | tr -d '\n'`
for interface in $interfaces
do
is_vlan_interface $interface
if [ $? -eq 1 ]; then
echo_success "Found VLAN interface $interface ... deleting"
delete_vlan_interface $interface
fi
done
}
delete_sgi_vlans() {
for i in 5 6 7 8 9 10 11 12 13 14 15
do
delete_vlan_interface $PGW_INTERFACE_NAME_FOR_SGI.$i
done
}
create_sgi_vlans() {
get_mac_router
bash_exec "modprobe 8021q"
bash_exec "ip link set $PGW_INTERFACE_NAME_FOR_SGI promisc on"
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# create vlan interface
delete_vlan_interface $PGW_INTERFACE_NAME_FOR_SGI.$i
sync
create_vlan_interface $PGW_INTERFACE_NAME_FOR_SGI.$i
sync
# configure vlan interface
base=200
NET=$(( $i + $base ))
set_interface_up $PGW_INTERFACE_NAME_FOR_SGI.$i "10.0."$NET".2" 24
done
}
@@ -1,234 +0,0 @@
#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file start_enb_and_ue.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
###########################################
# INPUT OF THIS SCRIPT:
# THE DIRECTORY WHERE ARE LOCATED THE CONFIGURATION FILES
#########################################
# This script start ENB+UE (all in one executable, on one host)
# MME+SP-GW executable have to be launched by your own (start_epc.bash) before this script is invoked.
#
###########################################################
# Parameters
###########################################################
declare MAKE_LTE_ACCESS_STRATUM_TARGET="oaisim LIBCONFIG_LONG=1 DEBUG=1 ENABLE_ITTI=1 USE_MME=R10 LINK_ENB_PDCP_TO_GTPV1U=1 NAS=1 SECU=1 Rel10=1 TRACE_RLC_AM_PDU=1 TRACE_RLC_UM_PDU=1"
declare MAKE_IP_DRIVER_TARGET="ue_ip.ko"
declare IP_DRIVER_NAME="ue_ip"
declare LTEIF="oip1"
declare UE_IPv4="10.0.0.8"
declare UE_IPv6="2001:1::8"
declare UE_IPv6_CIDR=$UE_IPv6"/64"
declare UE_IPv4_CIDR=$UE_IPv4"/24"
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
. $THIS_SCRIPT_PATH/utils.bash
. $THIS_SCRIPT_PATH/interfaces.bash
. $THIS_SCRIPT_PATH/networks.bash
###########################################################
if [ $# -eq 1 ]; then
declare -x CONFIG_FILE_DIR=$1
if [ ! -d $CONFIG_FILE_DIR ]; then
echo_error "ERROR while invoking this script, as first argument to this script you have to provide the path to a directory (./CONF/VLAN.VIRTUAL.$HOSTNAME for example) containing valid epc and enb config files"
exit 1
fi
else
echo_error "ERROR while invoking this script, as first argument to this script you have to provide the path to a directory (./CONF/VLAN.VIRTUAL.$HOSTNAME for example) containing valid epc and enb config files"
exit 1
fi
#check_install_epc_software
cd $THIS_SCRIPT_PATH
#######################################################
# FIND CONFIG FILE
#######################################################
SEARCHED_CONFIG_FILE_ENB="enb*.conf"
CONFIG_FILE_ENB=`find $CONFIG_FILE_DIR -iname $SEARCHED_CONFIG_FILE_ENB`
if [ -f $CONFIG_FILE_ENB ]; then
echo_warning "eNB config file found is now $CONFIG_FILE_ENB"
else
echo_error "eNB config file not found, exiting"
exit 1
fi
#######################################################
# SOURCE CONFIG FILE
#######################################################
rm -f /tmp/source.txt
VARIABLES="
ENB_INTERFACE_NAME_FOR_S1_MME\|\
ENB_IPV4_ADDRESS_FOR_S1_MME\|\
ENB_INTERFACE_NAME_FOR_S1U\|\
ENB_IPV4_ADDRESS_FOR_S1U"
VARIABLES=$(echo $VARIABLES | sed -e 's/\\r//g')
VARIABLES=$(echo $VARIABLES | tr -d ' ')
cat $CONFIG_FILE_ENB | grep -w "$VARIABLES"| tr -d " " | tr -d ";" > /tmp/source.txt
source /tmp/source.txt
declare ENB_IPV4_NETMASK_FOR_S1_MME=$( echo $ENB_IPV4_ADDRESS_FOR_S1_MME | cut -f2 -d '/')
declare ENB_IPV4_NETMASK_FOR_S1U=$( echo $ENB_IPV4_ADDRESS_FOR_S1U | cut -f2 -d '/')
ENB_IPV4_ADDRESS_FOR_S1_MME=$( echo $ENB_IPV4_ADDRESS_FOR_S1_MME | cut -f1 -d '/')
ENB_IPV4_ADDRESS_FOR_S1U=$( echo $ENB_IPV4_ADDRESS_FOR_S1U | cut -f1 -d '/')
is_vlan_interface $ENB_INTERFACE_NAME_FOR_S1_MME \
$ENB_INTERFACE_NAME_FOR_S1U
if [ $? -eq 1 ]; then
echo_success "Found VLAN network configuration"
clean_enb_vlan_network
build_enb_vlan_network
test_enb_vlan_network
fi
#######################################################
# USIM, NVRAM files
#######################################################
export NVRAM_DIR=$THIS_SCRIPT_PATH
if [ ! -f $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data ] || [ ! -f $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data ]; then
if [ ! -f /tmp/nas_cleaned ]; then
echo_success "make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS veryveryclean"
make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS veryveryclean
fi
echo_success "make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS -f Makefile PROCESS=UE all"
make -f Makefile --debug=b --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS PROCESS=UE all
rm .ue.nvram0
rm .usim.nvram0
touch /tmp/nas_cleaned
fi
if [ ! -f .ue.nvram0 ]; then
echo_success "generate .ue_emm.nvram0 .ue.nvram0"
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --gen
fi
if [ ! -f .usim.nvram0 ]; then
echo_success "generate .usim.nvram0"
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --gen
fi
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --print
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --print
##################################################
# LAUNCH eNB + UE executable
##################################################
pkill oaisim
bash_exec "rmmod $IP_DRIVER_NAME" > /dev/null 2>&1
echo_success "make $MAKE_IP_DRIVER_TARGET $MAKE_LTE_ACCESS_STRATUM_TARGET ....."
#bash_exec "make --directory=$OPENAIR2_DIR $MAKE_IP_DRIVER_TARGET "
make --directory=$OPENAIR2_DIR $MAKE_IP_DRIVER_TARGET || exit 1
echo_success "make --debug=b --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET || exit 1"
#make --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET -j`grep -c ^processor /proc/cpuinfo ` || exit 1
make --debug=b --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET || exit 1
echo_success "Bringup UE interface..."
bash_exec "insmod $OPENAIR2_DIR/NETWORK_DRIVER/UE_IP/$IP_DRIVER_NAME.ko"
bash_exec "ip route flush cache"
#bash_exec "ip link set $LTEIF up"
sleep 1
#bash_exec "ip addr add dev $LTEIF $UE_IPv4_CIDR"
#bash_exec "ip addr add dev $LTEIF $UE_IPv6_CIDR"
sleep 1
bash_exec "sysctl -w net.ipv4.conf.all.log_martians=1"
assert " `sysctl -n net.ipv4.conf.all.log_martians` -eq 1" $LINENO
echo " Disabling reverse path filtering"
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
bash_exec "ip route flush cache"
# Check table 200 lte in /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 5 table lte
ip route add default dev $LTEIF table lte
echo_warning "Be careful of the lines below, for a specific virtual box setting"
bash_exec "/sbin/iptables -t mangle -F"
bash_exec "/sbin/iptables -t nat -F"
bash_exec "/sbin/iptables -t raw -F"
bash_exec "/sbin/iptables -t filter -F"
bash_exec "/sbin/ip6tables -t mangle -F"
bash_exec "/sbin/ip6tables -t filter -F"
bash_exec "/sbin/ip6tables -t raw -F"
bash_exec "iptables -A OUTPUT -o eth0 -p sctp -j DROP"
bash_exec "iptables -A INPUT -i eth0 -p sctp -j DROP"
bash_exec "iptables -A FORWARD -i eth0 -p sctp -j DROP"
bash_exec "iptables -A OUTPUT -o eth1 -p sctp -j DROP"
bash_exec "iptables -A INPUT -i eth1 -p sctp -j DROP"
bash_exec "iptables -A FORWARD -i eth1 -p sctp -j DROP"
cd $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME
ITTI_LOG_FILE=itti_enb_ue.$HOSTNAME.log
#rotate_log_file $ITTI_LOG_FILE
STDOUT_LOG_FILE=stdout_enb_ue.$HOSTNAME.log
#rotate_log_file $STDOUT_LOG_FILE
rotate_log_file $STDOUT_LOG_FILE.filtered
#rotate_log_file tshark_enb_ue.$HOSTNAME.pcap
cd $THIS_SCRIPT_PATH
#nohup tshark -i $ENB_INTERFACE_NAME_FOR_S1_MME -i $ENB_INTERFACE_NAME_FOR_S1U -w OUTPUT/$HOSTNAME/tshark_enb_ue.$HOSTNAME.pcap &
# To start NAS connectivity: AT+CFUN=1
# nohup xterm -hold -e $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/UserProcess &
export MALLOC_TRACE=/tmp/malloc_trace.txt
touch /tmp/malloc_trace.txt
#--malloc-trace-enabled
#-a
gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim -u1 -l9 -K OUTPUT/$HOSTNAME/$ITTI_LOG_FILE --enb-conf $CONFIG_FILE_ENB 2>&1 | tee OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE
# > OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE
# | tee OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE
#pkill tshark
echo_warning "oaisim ended, filtering stdout from oaisim"
cat OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE | grep 'RRC\|S1AP\|SCTP\|NAS' | grep -v 'RRC_MAC_IN_SYNC_IND' | grep -v 'serving becomes better than threshold' > OUTPUT/$HOSTNAME/$STDOUT_LOG_FILE.filtered
@@ -1,190 +0,0 @@
#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file start_ue.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
###########################################
# INPUT OF THIS SCRIPT:
# THE DIRECTORY WHERE ARE LOCATED THE CONFIGURATION FILES
#########################################
# This script start UE
###########################################################
# Parameters
###########################################################
declare -x hard_real_time= "no"
declare -x EMULATION_DEV_INTERFACE="eth2"
declare EMULATION_MULTICAST_GROUP=1
declare MAKE_LTE_ACCESS_STRATUM_TARGET="oaisim DEBUG=1 ENABLE_ITTI=1 USE_MME=R10 NAS=1 Rel10=1 SECU=1 RRC_MSG_PRINT=1"
declare MAKE_LTE_ACCESS_STRATUM_TARGET_RT="lte-softmodem HARD_RT=1 ENABLE_ITTI=1 USE_MME=R10 DISABLE_XER_PRINT=1 SECU=1 RRC_MSG_PRINT=1 "
declare MAKE_IP_DRIVER_TARGET="ue_ip.ko"
declare IP_DRIVER_NAME="ue_ip"
declare LTEIF="oip1"
declare UE_IPv4="10.0.0.8"
declare UE_IPv6="2001:1::8"
declare UE_IPv6_CIDR=$UE_IPv6"/64"
declare UE_IPv4_CIDR=$UE_IPv4"/24"
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
. $THIS_SCRIPT_PATH/utils.bash
. $THIS_SCRIPT_PATH/interfaces.bash
. $THIS_SCRIPT_PATH/networks.bash
###########################################################
check_install_epc_software
cd $THIS_SCRIPT_PATH
EMULATION_DEV_ADDRESS=`ifconfig $EMULATION_DEV_INTERFACE | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
#######################################################
# USIM, NVRAM files
#######################################################
export NVRAM_DIR=$THIS_SCRIPT_PATH
if [ ! -f $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data ]; then
make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS veryveryclean
make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS PROCESS=UE
rm .ue.nvram0
fi
if [ ! -f $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data ]; then
make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS veryveryclean
make --directory=$OPENAIR3_DIR/NAS/EURECOM-NAS PROCESS=UE
rm .usim.nvram0
fi
if [ ! -f .ue.nvram0 ]; then
# generate .ue_emm.nvram0 .ue.nvram0
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --gen
fi
if [ ! -f .usim.nvram0 ]; then
# generate .usim.nvram0
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --gen
fi
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/ue_data --print
$OPENAIR3_DIR/NAS/EURECOM-NAS/bin/usim_data --print
##################################################
# LAUNCH UE executable
##################################################
echo "Bringup UE interface"
pkill oaisim
bash_exec "rmmod $IP_DRIVER_NAME" > /dev/null 2>&1
if [ ! -d $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME ]; then
mkdir -m 777 -p $THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME
fi
make --directory=$OPENAIR2_DIR $MAKE_IP_DRIVER_TARGET || exit 1
bash_exec "insmod $OPENAIR2_DIR/NETWORK_DRIVER/UE_IP/$IP_DRIVER_NAME.ko"
bash_exec "ip route flush cache"
sleep 1
bash_exec "sysctl -w net.ipv4.conf.all.log_martians=1"
assert " `sysctl -n net.ipv4.conf.all.log_martians` -eq 1" $LINENO
echo " Disabling reverse path filtering"
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
bash_exec "ip route flush cache"
# Check table 200 lte in /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 5 table lte
ip route add default dev $LTEIF table lte
if [ x$hard_real_time != "xyes" ]; then
make --directory=$OPENAIR_TARGETS/SIMU/USER $MAKE_LTE_ACCESS_STRATUM_TARGET -j`grep -c ^processor /proc/cpuinfo ` || exit 1
ip route add 239.0.0.160/28 dev $EMULATION_DEV_INTERFACE
ITTI_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/itti_ue.$HOSTNAME.log
#rotate_log_file $ITTI_LOG_FILE
STDOUT_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/stdout_ue.$HOSTNAME.log
#rotate_log_file $STDOUT_LOG_FILE
#rotate_log_file $STDOUT_LOG_FILE.filtered
PCAP_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/tshark_ue.$HOSTNAME.pcap
#rotate_log_file $PCAP_LOG_FILE
cd $THIS_SCRIPT_PATH
nohup xterm -e $OPENAIR3_DIR/NAS/EURECOM-NAS/bin/UserProcess &
cp $OPENAIR_TARGETS/SIMU/USER/oaisim $OPENAIR_TARGETS/SIMU/USER/oaisim_ue
gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim_ue -a -l9 -u1 -b0 -M1 -p2 -g$EMULATION_MULTICAST_GROUP -D $EMULATION_DEV_ADDRESS -K $ITTI_LOG_FILE 2>&1 | tee $STDOUT_LOG_FILE
else
#make --directory=$OPENAIR_TARGETS/RTAI/USER drivers || exit 1
# 2 lines below replace the line above
cd $OPENAIR_TARGETS/ARCH/EXMIMO/DRIVER/eurecom && make clean && make || exit 1
cd $OPENAIR_TARGETS/ARCH/EXMIMO/USERSPACE/OAI_FW_INIT && make clean && make || exit 1
cd $THIS_SCRIPT_PATH
make --directory=$OPENAIR_TARGETS/RT/USER $MAKE_LTE_ACCESS_STRATUM_TARGET_RT -j`grep -c ^processor /proc/cpuinfo ` || exit 1
ITTI_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/itti_ue_rf.$HOSTNAME.log
#rotate_log_file $ITTI_LOG_FILE
STDOUT_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/stdout_ue_rf.$HOSTNAME.log
#rotate_log_file $STDOUT_LOG_FILE
#rotate_log_file $STDOUT_LOG_FILE.filtered
PCAP_LOG_FILE=$THIS_SCRIPT_PATH/OUTPUT/$HOSTNAME/tshark_ue_rf.$HOSTNAME.pcap
#rotate_log_file $PCAP_LOG_FILE
if [ ! -f /tmp/init_rt_done.tmp ]; then
echo_warning "STARTING REAL TIME (RTAI)"
insmod /usr/realtime/modules/rtai_hal.ko > /dev/null 2>&1
insmod /usr/realtime/modules/rtai_sched.ko > /dev/null 2>&1
insmod /usr/realtime/modules/rtai_sem.ko > /dev/null 2>&1
insmod /usr/realtime/modules/rtai_fifos.ko > /dev/null 2>&1
insmod /usr/realtime/modules/rtai_mbx.ko > /dev/null 2>&1
touch /tmp/init_rt_done.tmp
chmod 666 /tmp/init_rt_done.tmp
else
echo_warning "REAL TIME FOUND STARTED (RTAI)"
fi
cd $OPENAIR_TARGETS/RT/USER
bash ./init_exmimo2.sh
echo_warning "STARTING SOFTMODEM..."
./lte-softmodem -K $ITTI_LOG_FILE -O $CONFIG_FILE_ENB 2>&1
#cat /dev/rtf62 > $STDOUT_LOG_FILE
cd $THIS_SCRIPT_PATH
fi
cat $STDOUT_LOG_FILE | grep -v '[PHY]' | grep -v '[MAC]' | grep -v '[EMU]' | \
grep -v '[OCM]' | grep -v '[OMG]' | \
grep -v 'RLC not configured' | grep -v 'check if serving becomes' | \
grep -v 'mac_rrc_data_req' | grep -v 'BCCH request =>' > $STDOUT_LOG_FILE.filtered
-718
View File
@@ -1,718 +0,0 @@
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
# file utils.bash
# brief
# author Lionel Gauthier
# company Eurecom
# email: lionel.gauthier@eurecom.fr
#
black='\E[30m'
red='\E[31m'
green='\E[32m'
yellow='\E[33m'
blue='\E[34m'
magenta='\E[35m'
cyan='\E[36m'
white='\E[37m'
reset_color='\E[00m'
ROOT_UID=0
E_NOTROOT=67
HOSTNAME=$(hostname -f)
if [ $? -eq 1 ]
then
HOSTNAME=$(hostname)
fi
IPTABLES=`which iptables`
trim ()
{
echo "$1" | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'
}
trim2()
{
local var=$@
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
cecho() # Color-echo
# arg1 = message
# arg2 = color
{
local default_msg="No Message."
message=${1:-$default_msg}
color=${2:-$green}
echo -e -n "$color$message$reset_color"
echo
return
}
echo_error() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $red
}
echo_fatal() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
echo_error "$my_string"
exit -1
}
echo_warning() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $yellow
}
echo_success() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
cecho "$my_string" $green
}
bash_exec() {
output=$($1 2>&1)
result=$?
if [ $result -eq 0 ]
then
echo_success "$1"
else
echo_error "$1: $output"
fi
}
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo_error "'$1' cannot be extracted via >extract<" ; return 1;;
esac
else
echo_error "'$1' is not a valid file"
return 1
fi
return 0
}
rotate_log_file () {
FULLPATH=$1
if [ -f $FULLPATH ]; then
FILENAME=${FULLPATH##*/}
FILEEXTENSION=${FILENAME##*.}
BASEDIRECTORY=${FULLPATH%$FILENAME}
if [ "a$BASEDIRECTORY" == "a" ]; then
BASEDIRECTORY='.'
fi
FILENAME_NO_EXT=$(echo "$FILENAME" | sed 's/\.[^\.]*$//')
# use file last modification time
TIMESTAMP=`date -r $FULLPATH +%Y-%m-%d.%Hh_%Mm_%Ss`
NEWLOGFILE=$TIMESTAMP.$FILENAME_NO_EXT.$FILEEXTENSION
mv $FULLPATH /tmp/$NEWLOGFILE
cat /dev/null > $FULLPATH
sync
gzip -c --name -f -9 /tmp/$NEWLOGFILE > $BASEDIRECTORY/$NEWLOGFILE.gz &
fi
}
set_openair() {
fullpath=`readlink -f $BASH_SOURCE`
[ -f "/.$fullpath" ] || fullpath=`readlink -f $PWD/$fullpath`
openair_path=${fullpath%/targets/*}
export OPENAIR_DIR=$openair_path
export OPENAIR_DIR=$openair_path
export OPENAIR1_DIR=$openair_path/openair1
export OPENAIR2_DIR=$openair_path/openair2
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR3_DIR=$openair_path/openair3
export OPENAIR_TARGETS=$openair_path/targets
export CDPATH=$CDPATH:$openair_path
}
wait_process_started () {
if [ -z "$1" ]
then
echo_error "WAITING FOR PROCESS START: NO PROCESS"
return 1
fi
ps -C $1 > /dev/null 2>&1
while [ $? -ne 0 ]; do
echo_warning "WAITING FOR $1 START"
sleep 2
ps -C $1 > /dev/null 2>&1
done
echo_success "PROCESS $1 STARTED"
return 0
}
is_process_started () {
if [ -z "$1" ]
then
echo_error "WAITING FOR PROCESS START: NO PROCESS"
return 1
fi
ps -C $1 > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo_success "PROCESS $1 NOT STARTED"
return 1
fi
echo_success "PROCESS $1 STARTED"
return 0
}
assert() {
# If condition false
# exit from script with error message
E_PARAM_ERR=98
E_PARAM_FAILED=99
if [ -z "$2" ] # Not enought parameters passed.
then
return $E_PARAM_ERR
fi
lineno=$2
if [ ! $1 ]
then
echo_error "Assertion failed: \"$1\""
echo_fatal "File \"$0\", line $lineno"
fi
}
test_install_package() {
# usage: test_install_package package_name
if [ $# -eq 1 ]; then
dpkg -s "$1" > /dev/null 2>&1 && {
echo "$1 is installed."
} || {
echo "$1 is not installed."
apt-get install --assume-yes $1
}
fi
}
test_command_install_script() {
# usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_fatal "Program $1 is not installed. Aborting." >&2; };}
echo_success "$1 available"
}
check_for_epc_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/oai_epc ]
then
echo_error "Cannot find oai_epc executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/"
echo_fatal "Please make sure you have compiled OAI EPC with --enable-standalone-epc option"
fi
}
check_for_sgw_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/oai_sgw ]
then
echo_error "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/"
echo_fatal "Please make sure you have compiled OAI EPC without --enable-standalone-epc option"
fi
}
check_for_mme_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/oaisim_mme ]
then
echo_error "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/"
echo_fatal "Please make sure you have compiled OAI EPC without --enable-standalone-epc option"
fi
}
check_for_root_rights() {
if [[ $EUID -ne 0 ]]; then
echo_fatal "This script must be run as root" 1>&2
fi
}
start_openswitch_daemon() {
rmmod -s bridge
if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then
bash_exec "insmod /lib/modules/`uname -r`/extra/openvswitch.ko" > /dev/null 2>&1
else
echo_error "/lib/modules/`uname -r`/extra/openvswitch.ko not found"
bash $OPENAIR3_DIR/SCRIPTS/install_openvswitch1.9.0.bash
fi
is_process_started "ovsdb-server"
if [ $? -ne 0 ]
then
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --pidfile --detach
wait_process_started "ovsdb-server"
fi
# To be done after installation
# ovs-vsctl --no-wait init
is_process_started "ovs-vswitchd"
if [ $? -ne 0 ]
then
ovs-vswitchd --pidfile --detach
wait_process_started "ovs-vswitchd"
fi
}
stop_openswitch_daemon() {
pkill ovs-vswitchd
pkill ovsdb-server
sync
if ! is_process_started ovs-vswitchd ; then
pkill -9 ovs-vswitchd
fi
if ! is_process_started ovsdb-server ; then
pkill -9 ovsdb-server
fi
rmmod -f openvswitch
}
check_epc_s6a_certificate() {
if [ -d /usr/local/etc/freeDiameter ]
then
if [ -f /usr/local/etc/freeDiameter/user.cert.pem ]
then
full_hostname=`cat /usr/local/etc/freeDiameter/user.cert.pem | grep "Subject" | grep "CN" | cut -d '=' -f6`
if [ a$full_hostname == a`hostname`.${1:-'eur'} ]
then
echo_success "MME S6A: Found valid certificate in /usr/local/etc/freeDiameter"
return 1
fi
fi
fi
echo_error "MME S6A: Did not find valid certificate in /usr/local/etc/freeDiameter"
echo_warning "MME S6A: generatting new certificate in /usr/local/etc/freeDiameter..."
cd $OPENAIR3_DIR/S6A/freediameter
./make_certs.sh ${1:-'eur'}
check_epc_s6a_certificate ${1:-'eur'}
return 1
}
check_hss_s6a_certificate() {
if [ -f $OPENAIR3_DIR/OPENAIRHSS/conf/hss.cert.pem ]
then
full_hostname=`cat $OPENAIR3_DIR/OPENAIRHSS/conf/hss.cert.pem | grep "Subject" | grep "CN" | cut -d '=' -f6`
# we should replace 'hss' with hostname
if [ a$full_hostname == ahss.${1:-'eur'} ]
then
echo_success "HSS S6A: Found valid certificate in $OPENAIR3_DIR/OPENAIRHSS/conf/"
return 1
fi
fi
echo_error "HSS S6A: Did not find valid certificate in $OPENAIR3_DIR/OPENAIRHSS/conf"
echo_warning "HSS S6A: generatting new certificate in $OPENAIR3_DIR/OPENAIRHSS/conf..."
cd $OPENAIR3_DIR/OPENAIRHSS/conf
./make_certs.sh ${1:-'eur'}
check_hss_s6a_certificate ${1:-'eur'}
return 1
}
generate_ssh_keys() {
ssh-keygen -t dsa
}
# arg 1 is dest machine
copy_ssh_keys() {
ssh-copy-id -i ~/.ssh/id_dsa.pub $LOGNAME@$1
}
# arg 1 is mysql user (root)
# arg 2 is mysql password (linux)
create_hss_database(){
EXPECTED_ARGS=2
E_BADARGS=65
MYSQL=`which mysql`
if [ $# -ne $EXPECTED_ARGS ]
then
echo_fatal "Usage: $0 dbuser dbpass"
fi
set_openair
Q1="CREATE DATABASE IF NOT EXISTS ${BTICK}oai_db${BTICK};"
SQL="${Q1}"
$MYSQL -u $1 --password=$2 -e "$SQL"
if [ $? -ne 0 ]; then
echo_error "oai_db creation failed"
else
echo_success "oai_db creation succeeded"
fi
$MYSQL -u $1 --password=$2 oai_db < $OPENAIR3_DIR/OPENAIRHSS/db/oai_db.sql
if [ $? -ne 0 ]; then
echo_error "oai_db tables creation failed"
else
echo_success "oai_db tables creation succeeded"
fi
Q1="GRANT ALL PRIVILEGES ON *.* TO 'hssadmin'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;"
Q2="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}"
$MYSQL -u $1 --password=$2 -e "$SQL"
if [ $? -ne 0 ]; then
echo_error "hssadmin permissions failed"
else
echo_success "hssadmin permissions succeeded"
fi
}
check_install_hss_software() {
test_install_package autoconf
test_install_package automake
test_install_package bison
test_install_package build-essential
test_install_package cmake
test_install_package cmake-curses-gui
test_install_package dkms
test_install_package flex
test_install_package gawk
test_install_package gcc
test_install_package gdb
test_install_package guile-2.0-dev
test_install_package g++
test_install_package libgmp-dev
test_install_package libgcrypt11-dev
test_install_package libidn11-dev
test_install_package libidn2-0-dev
test_install_package libmysqlclient-dev
test_install_package libtasn1-3-dev
test_install_package libsctp1
test_install_package libsctp-dev
test_install_package libxml2-dev
test_install_package linux-headers-`uname -r`
test_install_package make
test_install_package mysql-client
test_install_package mysql-common
test_install_package mysql-server
test_install_package openssh-client
test_install_package openssh-server
test_install_package phpmyadmin
test_install_package python-dev
test_install_package sshfs
test_install_package swig
test_install_package unzip
test_install_package valgrind
}
check_install_vbox_software() {
test_install_package dkms
test_install_package openssh-client
test_install_package openssh-server
test_install_package sshfs
test_install_package virtualbox
test_install_package virtualbox-dkms
test_install_package virtualbox-guest-additions-iso
test_install_package virtualbox-qt
test_install_package virtualbox-guest-utils
}
check_install_epc_software() {
test_install_package autoconf
test_install_package automake
test_install_package bison
test_install_package build-essential
test_install_package check
test_install_package cmake
test_install_package cmake-curses-gui
test_install_package ethtool
test_install_package flex
test_install_package g++
test_install_package gawk
test_install_package gcc
test_install_package gccxml
test_install_package gdb
test_install_package guile-2.0-dev
test_install_package gtkwave
test_install_package iperf
test_install_package iproute
test_install_package iptables
test_install_package iptables-dev
test_install_package libatlas-base-dev
test_install_package libatlas-dev
test_install_package libblas
test_install_package libblas-dev
if [ x$UTILS_ARCH == x64 ]; then
test_install_package libconfig8-dev
else
test_install_package libconfig-dev
fi
test_install_package libforms-bin
test_install_package libforms-dev
test_install_package libgcrypt11-dev
test_install_package libgmp-dev
test_install_package libgtk-3-dev
test_install_package libidn11-dev
test_install_package libidn2-0-dev
test_install_package libmysqlclient-dev
test_install_package libpgm-dev
test_install_package libpthread-stubs0-dev
test_install_package libsctp1
test_install_package libsctp-dev
test_install_package libtasn1-3-dev
test_install_package libxml2
test_install_package libxml2-dev
test_install_package linux-headers-`uname -r`
test_install_package make
test_install_package openssh-client
test_install_package openssh-server
test_install_package openssl
test_install_package openvpn
test_install_package pkg-config
test_install_package python-dev
test_install_package sshfs
test_install_package subversion
test_install_package swig
test_install_package tshark
test_install_package uml-utilities
test_install_package unzip
test_install_package valgrind
test_install_package vlan
if [ ! -d /usr/local/etc/freeDiameter ]
then
# This script make certificates also
cd $OPENAIR3_DIR/S6A/freediameter && ./install_freediameter.sh
else
echo_success "freediameter is installed"
check_epc_s6a_certificate
fi
test_command_install_script "asn1c" "$OPENAIR3_DIR/SCRIPTS/install_asn1c_0.9.24.modified.bash"
# One mor check about version of asn1c
ASN1C_COMPILER_REQUIRED_VERSION_MESSAGE="ASN.1 Compiler, v0.9.24"
ASN1C_COMPILER_VERSION_MESSAGE=`asn1c -h 2>&1 | grep -i ASN\.1\ Compiler`
##ASN1C_COMPILER_VERSION_MESSAGE=`trim $ASN1C_COMPILER_VERSION_MESSAGE`
if [ "$ASN1C_COMPILER_VERSION_MESSAGE" != "$ASN1C_COMPILER_REQUIRED_VERSION_MESSAGE" ]
then
diff <(echo -n "$ASN1C_COMPILER_VERSION_MESSAGE") <(echo -n "$ASN1C_COMPILER_REQUIRED_VERSION_MESSAGE")
echo_error "Version of asn1c is not the required one, do you want to install the required one (overwrite installation) ? (Y/n)"
echo_error "$ASN1C_COMPILER_VERSION_MESSAGE"
while read -r -n 1 -s answer; do
if [[ $answer = [YyNn] ]]; then
[[ $answer = [Yy] ]] && $OPENAIR3_DIR/SCRIPTS/install_asn1c_0.9.24.modified.bash
[[ $answer = [Nn] ]] && echo_error "Version of asn1c is not the required one, exiting." && exit 1
break
fi
done
fi
}
function cgrp()
{
OPTIND=1
local case=""
local usage="cgrp: find string in files.
Usage: cgrp \"pattern\" "
set_openair
find $OPENAIR2_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR1_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR3_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR3_DIR -name *.c -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR_TARGETS -name *.c -exec grep --color=auto -Hni $1 {} \;
}
function hgrp()
{
OPTIND=1
local case=""
local usage="hgrp: find string in files.
Usage: hgrp \"pattern\" "
set_openair
find $OPENAIR2_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR1_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR3_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR3_DIR -name *.h -exec grep --color=auto -Hni $1 {} \;
find $OPENAIR_TARGETS -name *.h -exec grep --color=auto -Hni $1 {} \;
}
function svn_find_str_in_file_history()
{
for REV in `svn log $1 | grep ^r[0-9] | awk '{print $1}'`; do
svn cat $1 -r $REV | grep $2
if [ $? -eq 0 ]; then
echo "$REV"
fi
done
}
compile_hss() {
cd $OPENAIR3_DIR/OPENAIRHSS
OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*`
if [ ! -n "$OBJ_DIR" ]
then
OBJ_DIR="objs"
bash_exec "mkdir -m 777 ./$OBJ_DIR"
echo_success "Created $OBJ_DIR directory"
else
OBJ_DIR=`basename $OBJ_DIR`
fi
if [ ! -f $OBJ_DIR/Makefile ]
then
if [ ! -n "m4" ]
then
mkdir -m 777 m4
fi
echo_success "Invoking autogen"
bash_exec "./autogen.sh"
cd ./$OBJ_DIR
echo_success "Invoking configure"
../configure
else
cd ./$OBJ_DIR
fi
if [ -f Makefile ]
then
echo_success "Compiling..."
make -j `cat /proc/cpuinfo | grep processor | wc -l`
if [ $? -ne 0 ]; then
echo_error "Build failed, exiting"
exit 1
fi
else
echo_error "Configure failed, exiting"
exit 1
fi
}
compile_epc() {
cd $OPENAIR3_DIR
OBJ_DIR=`find . -maxdepth 1 -type d -iname obj*`
if [ ! -n "$OBJ_DIR" ]
then
OBJ_DIR="objs"
bash_exec "mkdir -m 777 ./$OBJ_DIR"
echo_success "Created $OBJ_DIR directory"
else
OBJ_DIR=`basename $OBJ_DIR`
fi
if [ ! -f $OBJ_DIR/Makefile ]
then
if [ ! -n "m4" ]
then
mkdir -m 777 m4
fi
echo_success "Invoking autogen"
bash_exec "./autogen.sh"
cd ./$OBJ_DIR
echo_success "Invoking configure"
../configure --enable-standalone-epc --enable-raw-socket-for-sgi LDFLAGS=-L/usr/local/lib
else
cd ./$OBJ_DIR
fi
pkill oai_epc
pkill tshark
if [ -f Makefile ]
then
echo_success "Compiling..."
make -j `cat /proc/cpuinfo | grep processor | wc -l`
if [ $? -ne 0 ]; then
echo_error "Build failed, exiting"
exit 1
fi
else
echo_error "Configure failed, exiting"
exit 1
fi
}
###########################################################
IPTABLES=/sbin/iptables
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
declare -x OPENAIR_DIR=""
declare -x OPENAIR1_DIR=""
declare -x OPENAIR2_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR3_DIR=""
declare -x OPENAIR_TARGETS=""
###########################################################
set_openair
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
cecho "OPENAIR_DIR = $OPENAIR_DIR" $green
cecho "OPENAIR1_DIR = $OPENAIR1_DIR" $green
cecho "OPENAIR2_DIR = $OPENAIR2_DIR" $green
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
cecho "OPENAIR3_DIR = $OPENAIR3_DIR" $green
cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green
export UTILS_ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
export OS=$DISTRIB_ID
export VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
export OS=Debian # XXX or Ubuntu??
export VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
# TODO add code for Red Hat and CentOS here
...
else
export OS=$(uname -s)
export VER=$(uname -r)
fi
@@ -1,293 +0,0 @@
#!/bin/bash
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
################################################################################
export HSS_VM_NAME='hss-vm-ubuntu-12.04.4-server-amd64'
export MME_VM_NAME='mme-vm-ubuntu-12.04.4-server-amd64'
export OS_INSTALL_IMAGE="/root/ubuntu-12.04.4-server-amd64.iso"
export OS_TYPE="Ubuntu"
export HOST_BRIDGED_IF_NAME="eth1"
export DEFAULT_VIRTUAL_BOX_VM_PATH='/root/VirtualBox VMs'
###########################################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
. ./utils.bash
###########################################################
# NETWORK SETTING AT EURECOM IN EXPERIMENTAL NETWORK (192.168.12.X)
#
#
# INTERNET GW 192.168.12.100
# |
# |
# 192.168.12.17/24 |
# +-----------+----------------+---+--+---------------------------------------+
# | COMPUTER 1| | eth0 | |
# +-----------+ +---+--+ |
# | | |
# | | |
# | +-----+------+ |
# | |MASQUERADING| |
# | +-----+------+ |
# | | |
# | | |
# | | |
# | | |
# | | |
# | +---+--+ |
# | | eth1 | |
# +----------------------------+---+--+---------------------------------------+
# 192.168.13.17/24 |
# | INTERNET GW 192.168.12.100
# | |
# 192.168.13.175/24 | 192.168.12.175/24 |
# +-----------+----------------+---+--+---------------------+---+--+----------+
# | COMPUTER 2| | eth1 | Physical | eth0 | |
# +-----------+ +-+--+-+ Interface +------+ |
# | | | 'HOST_BRIDGED_IF_NAME' |
# | | | |
# | | | +-----------+ |
# | | | +------+ HSS | |
# | | +----------+ eth0 | (VM) | |
# | | +------+ | |
# | bridged network | 192.168.13.177 | | |
# | | +-+------+--+ |
# | | |eth1 |192.168.57.101|
# | | +--+---+ |
# | | | |
# | | 192.168.13.178 | host |
# | +------------------+ | network vboxnet1 |
# | | | 192.168.57.0/24 |
# | | | 192.168.57.100 |
# | +-+--++--+--+ |
# | |eth0||eth1 | |
# |+-----------+192.168.56.1 192.168.56.100+-+----+------+---+ |
# || LTE eNB 1 +--------+ +--------+ MME | |
# || (HOST) |vboxnet0+--------------+ eth2 | S+P/GW | |
# || +--------+ host +--------+ (VM) | |
# || | network vboxnet0 | | |
# || | 192.168.56.0/24 | | |
# || +--------+ +--------+ | |
# || LTE n UEs |vboxnet2+--------------+ eth3 | | |
# |+-----------+--------+ host +--------+-----------------+ |
# | 192.168.58.1 network vboxnet2 192.168.58.100 |
# | 192.168.58.0/24 |
# +---------------------------------------------------------------------------+
#
check_install_vbox_software
build_vbox_vm_mme() {
if [ $OS_TYPE ]; then
echo_success "OS_TYPE: $OS_TYPE"
else
echo_fatal "OS_TYPE bash variable must be set to any of the following values (The type of OS you want to install on your VM): `VBoxManage list ostypes | grep ID | cut -d: -f2 | tr -d ' ' | sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}'`"
fi
if [ $MME_VM_NAME ]; then
echo_success "MME_VM_NAME: $MME_VM_NAME"
else
echo_fatal "MME_VM_NAME bash variable must be set"
fi
if [ $OS_INSTALL_IMAGE ]; then
if [[ ! -e "$OS_INSTALL_IMAGE" ]] ; then
echo_fatal "$OS_INSTALL_IMAGE: File not found"
else
echo_success "OS_INSTALL_IMAGE: $OS_INSTALL_IMAGE"
fi
else
echo_fatal "OS_INSTALL_IMAGE bash variable must be set to a valid ISO OS installation file"
fi
bash_exec "VBoxManage unregistervm $MME_VM_NAME --delete"
rm -Rf "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"
bash_exec "VBoxManage createvm --name $MME_VM_NAME --register"
UUID=`VBoxManage showvminfo $MME_VM_NAME | grep Hardware\ UUID | cut -d: -f2 | tr -d ' '`
echo ENB UUID=$UUID
bash_exec "VBoxManage modifyvm $UUID --ostype $OS_TYPE --memory 512 --vram 12 --cpus 1 \
--rtcuseutc on --cpuhotplug off --cpuexecutioncap 100 --pae on --hpet on \
--hwvirtex on --nestedpaging on \
--firmware bios --biosbootmenu messageandmenu --boot1 dvd --boot2 disk \
--nic1 bridged --nic2 hostonly --nic3 hostonly --nic4 hostonly \
--nictype1 82545EM --nictype2 82545EM --nictype3 82545EM --nictype4 82545EM \
--cableconnected1 on --cableconnected2 on --cableconnected3 on --cableconnected4 on \
--macaddress1 c8d3a3020201 --macaddress2 c8d3a3020202 \
--macaddress3 c8d3a3020203 --macaddress4 c8d3a3020204 \
--bridgeadapter1 $HOST_BRIDGED_IF_NAME \
--hostonly2 vboxnet1 \
--hostonly3 vboxnet0 \
--hostonly4 vboxnet2 \
--nicpromisc1 allow-all \
--nicpromisc2 allow-all \
--nicpromisc3 allow-all \
--nicpromisc4 allow-all \
--audio none \
--usb off --usbehci off"
# BRIDGED_MAC_ADDRESS=`vboxmanage showvminfo $UUID | grep Bridged\ Interface | sed 's/^.*MAC:\ //' | cut --delimiter=',' -f 1`
mkdir -p -m 777 "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/MKISO
rm -Rf "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/MKISO/*
chmod -Rf 777 "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/MKISO
# mkisofs -max-iso9660-filenames -untranslated-filenames -no-iso-translate -o "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/cd_guest_setup.iso "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/MKISO/
VBoxManage createhd --filename "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/"$MME_VM_NAME".vdi --size 16384 --format VDI
VBoxManage storagectl $UUID --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on --bootable on
VBoxManage storageattach $UUID --storagectl "IDE Controller" --type dvddrive --passthrough off --port 1 --device 0 --medium $OS_INSTALL_IMAGE
# VBoxManage storageattach $UUID --storagectl "IDE Controller" --type dvddrive --passthrough off --port 1 --device 1 --medium "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/cd_guest_setup.iso
VBoxManage storagectl $UUID --name "SATA Controller" --add sata --controller IntelAhci --sataportcount 4 --hostiocache off --bootable on
VBoxManage storageattach $UUID --storagectl "SATA Controller" --type hdd --port 0 --device 0 --medium "$DEFAULT_VIRTUAL_BOX_VM_PATH"/"$MME_VM_NAME"/"$MME_VM_NAME".vdi
bash_exec "VBoxManage sharedfolder add $MME_VM_NAME --name $TRUNK_SHARED_FOLDER_NAME --hostpath $OPENAIR_DIR"
}
build_vbox_vm_hss() {
UUID=`VBoxManage clonevm $MME_VM_NAME --mode all --name $HSS_VM_NAME --register`
HSS_UUID=`VBoxManage showvminfo $HSS_VM_NAME | grep Hardware\ UUID | cut -d: -f2 | tr -d ' '`
echo HSS_UUID=$HSS_UUID
bash_exec "VBoxManage modifyvm $HSS_UUID --ostype $OS_TYPE --memory 512 --vram 12 --cpus 1 \
--rtcuseutc on --cpuhotplug off --cpuexecutioncap 100 --pae on --hpet on \
--hwvirtex on --nestedpaging on \
--firmware bios --biosbootmenu messageandmenu --boot1 disk \
--nic1 bridged --nic2 hostonly --nic3 none --nic4 none \
--nictype1 82545EM --nictype2 82545EM --nictype3 82545EM --nictype4 82545EM \
--cableconnected1 on --cableconnected2 on --cableconnected3 off --cableconnected4 off \
--macaddress1 c8d3a3020101 --macaddress2 c8d3a3020102 \
--macaddress3 c8d3a3020103 --macaddress4 c8d3a3020104 \
--bridgeadapter1 $HOST_BRIDGED_IF_NAME \
--hostonly2 vboxnet1 \
--nicpromisc1 allow-all \
--nicpromisc2 allow-all \
--audio none \
--usb off --usbehci off"
}
build_vms() {
build_vbox_vm_mme
build_vbox_vm_hss
echo_warning "!!!!!!! once VM are created, you have to harmonize IP addresses and MAC addresses !!!!!!!"
echo_warning "!!!!!!! /etc/network/interfaces and /etc/udev/rules.d/70-persistent-net.rules !!!!!!!"
echo_warning "!!!!!!! !!!!!!!"
echo_warning "!!!!!!! to share open air source code: use sshfs (you can use vbox shared folders,!!!!!!!"
echo_warning "!!!!!!! in this case, help yourself...) !!!!!!!"
echo_warning "!!!!!!! exchange ssh keys between host and guests !!!!!!!"
echo_warning "!!!!!!! in /etc/fstab on guests: add following line: !!!!!!!"
echo_warning "!!!!!!! sshfs#root@<IP@ of host>:/root/trunk /mnt/sshfs/trunk fuse comment=sshfs !!!!!!!"
echo_warning "!!!!!!! ,noauto,users,exec,uid=0,gid=0,allow_other,reconnect,transform_symlinks, !!!!!!!"
echo_warning "!!!!!!! BatchMode=yes 0 0 !!!!!!!"
echo_warning "!!!!!!! on guest: create a mount point: /mnt/sshfs/trunk for example, then mount: !!!!!!!"
echo_warning "!!!!!!! mount /mnt/sshfs/trunk !!!!!!!"
}
##########################
# #
# A N N E X #
# #
##########################
################################################################################
## MME: FILE /etc/network/interfaces (Remove one '#' at each start of line)
################################################################################
## This file describes the network interfaces available on your system
## and how to activate them. For more information, see interfaces(5).
## The loopback network interface
#auto lo
#iface lo inet loopback
## The primary network interface
#auto eth0
#iface eth0 inet static
# address 192.168.13.178
# netmask 255.255.255.0
# network 192.168.13.0
# broadcast 192.168.13.255
# gateway 192.168.13.17
# # dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 192.168.12.100
#
#auto eth2
#iface eth2 inet static
# address 192.168.56.100
# netmask 255.255.255.0
# network 192.168.56.0
# broadcast 192.168.56.255
#
#auto eth1
#iface eth1 inet static
# address 192.168.57.100
# netmask 255.255.255.0
# network 192.168.57.0
# broadcast 192.168.57.255
#
#auto eth3
#iface eth3 inet static
# address 192.168.58.100
# netmask 255.255.255.0
# network 192.168.58.0
# broadcast 192.168.58.255
################################################################################
## HSS: FILE /etc/network/interfaces (Remove one '#' at each start of line)
################################################################################
## This file describes the network interfaces available on your system
## and how to activate them. For more information, see interfaces(5).
#
## The loopback network interface
#auto lo
#iface lo inet loopback
#
## The primary network interface
#auto eth0
#iface eth0 inet static
# address 192.168.13.177
# netmask 255.255.255.0
# network 192.168.13.0
# broadcast 192.168.13.255
# gateway 192.168.13.17
# # dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 192.168.12.100
#
#auto eth1
#iface eth1 inet static
# address 192.168.57.101
# netmask 255.255.255.0
# network 192.168.57.0
# broadcast 192.168.57.255
File diff suppressed because one or more lines are too long
@@ -1,27 +0,0 @@
addpath('../../../openair1/SIMULATION/LTE_PHY/')
addpath('../../../openair1/PHY/LTE_ESTIMATION/')
addpath('../../../openair1/PHY/LTE_REFSIG/')
addpath('../../../targets/ARCH/EXMIMO/USERSPACE/OCTAVE')
nb_rb = 100;
num_carriers = 2048/100*nb_rb;
num_zeros = num_carriers-(12*nb_rb+1);
prefix_length = num_carriers/4;
num_symbols_frame = 120;
preamble_length = 120;
[s,f] = OFDM_TX_FRAME(num_carriers,num_zeros,prefix_length,num_symbols_frame,preamble_length);
s=s*sqrt(num_carriers);
primary_synch;
primary_synch0_time;
pss0_up = interp(primary_synch0_time,num_carriers/128);
pss0_up_cp = [pss0_up(num_carriers-prefix_length+1:end) pss0_up];
s(1:num_carriers+prefix_length) = pss0_up_cp;
plot(abs(s))
save(sprintf('ofdm_pilots_sync_%d.mat',num_carriers),'-v7','s','f','num_carriers','num_zeros','prefix_length','num_symbols_frame','preamble_length');
mat2wv(s, sprintf('ofdm_pilots_sync_%d.wv',num_carriers), 30.72e6/2048*num_carriers, 1)
@@ -1,43 +0,0 @@
%clear all
%close all
addpath([getenv('OPENAIR1_DIR') '/PHY/LTE_REFSIG/']);
addpath([getenv('OPENAIR1_DIR') '/PHY/LTE_TRANSPORT/']);
primary_synch; %loads the primary sync signal
%sss_gen; %loads the secondary sync signal
% grab a frame
% load frame
%addpath([getenv('OPENAIR_TARGETS') '/SIMU/USER/']);
%eNBtxsig1
%keyboard
%figure(1)
%plot(real(s))
%pss_t = upsample(primary_synch0_time,4);
primary_synch;
primary_synch0_time;
pss0_up = interp(primary_synch0_time,4);
pss0_up_cp = [pss0_up(512-127:end) pss0_up];
% plot(real(pss0_up_cp))
pss0_up_cp = [pss0_up(512-127:end) pss0_up]*1024;
% plot(real(pss0_up_cp))
pss_t = pss0_up_cp;
s = receivedA2B1;
[corr,lag] = xcorr(s(:,1).',pss_t.');
[pss_amp, pss_pos0] = max(abs(corr));
pss_pos = lag(pss_pos0);
pss_ref=pss_pos;
frame_start=pss_ref
@@ -1,55 +0,0 @@
# % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se
addpath('/homes/kaltenbe/Devel/openair/openair4G/trunk/targets/ARCH/EXMIMO/USERSPACE/OCTAVE');
%clear
paramsinitialized=false;
limeparms;
rxgain=0;
txgain=10;
eNB_flag = 0;
card = 0;
Ntrx=4;
dual_tx=0;
active_rfA=[0 0 0 0];
active_rfB=[1 1 1 1];
active_rf=active_rfA+active_rfB;
if(active_rfA*active_rfB'!=0) error("The A and B transceive chains must be orthogonal./n") endif
%fc = 2660000000;
fc = 1917600000;
%fc = 859.5e6;
autocal_mode=active_rf;
%rf_mode=(RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1) * active_rf;
%rf_mode=(TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM) * active_rf;
% we have to enable both DMA transfers so that the switching signal in the LSB of the TX buffer gets set
rf_mode=(TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * active_rf;
tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_TESTRX; LSBSWITCH_FLAG=false; %we also need the LSB switching for the woduplex script, otherwise we don't receive anything
%tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB; LSBSWITCH_FLAG=true;
syncmode = SYNCMODE_FREE;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rf_vcocal=rf_vcocal_19G*active_rf;
rffe_rxg_low = 61*active_rf;
rffe_rxg_final = 61*active_rf;
rffe_band = B19G_TDD*active_rf;
rf_rxdc = rf_rxdc*active_rf;
freq_rx = fc*active_rf;
freq_tx = freq_rx; %+1.92e6;
tx_gain = txgain.*active_rf;
rx_gain = rxgain*active_rf;
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode);
autocal_mode=0*active_rf; % Autocalibration is only needed the first time we conf. exmimo
amp = pow2(14)-1;
n_bit = 16;
chanest_full = 1;
paramsinitialized=true;
-21
View File
@@ -1,21 +0,0 @@
close all
figure
for i=1:4
subplot(220+i);plot(20*log10(abs(fftshift(fft(received(:,i))))));
axis([0 76799 10 140])
endfor
figure
t=[0:512-1]/7.68;%512*1e-2;
plot(t,20*log10(abs(tchanests)))
xlabel('time (usec)')
ylabel('|h|')
legend('SMBV->Antenna1','SMBV->Antenna2','SMBV->Antenna3','SMBV->Antenna4');
axis([0 10 10 60])
figure
plot(20*log10(abs(fchanests)));
ylim([40 100])
xlabel('freq')
ylabel('|h|')
legend('SMBV->Antenna1','SMBV->Antenna2','SMBV->Antenna3','SMBV->Antenna4');
-76
View File
@@ -1,76 +0,0 @@
clear all
addpath([getenv('OPENAIR_TARGETS') '/ARCH/EXMIMO/USERSPACE/OCTAVE'])
Nmeas=1
rx_spec
Niter=1
meas=1
for meas=1:Nmeas
close all
receivedA2B1=oarf_get_frame(card);
%oarf_stop(card);
initial_sync
N=76800;
indA=[1 0 0 0];
indB=[1 2 3 4];
Nanta=length(indA);
Nantb=length(indB);
fchan=zeros(512,Nantb);
tchan=fchan;
frame_start=abs(frame_start)
I= [frame_start:N,1:frame_start-1];
receivedA2B=receivedA2B1(I',:);
%load where2_v1_final.mat data
load filesave0811.mat data
Nofs=3840; % The offset in samples between the downlink and uplink sequences. It must be a multiple of 640, 3840 samples is 0.5 ms.
maskA2B=kron(ones(1,N/(2*Nofs)),[ones(1,Nofs) zeros(1,Nofs)])';
datamaskA2B=diag(kron(ones(1,N/(2*Nofs)),[ones(1,Nofs/640) zeros(1,Nofs/640)]));
%signalA2B=s2;
Da2b_T=datamaskA2B*data;
%tmps=s2;
Da2b_R=zeros(Niter*120,Nantb*301);
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:,meas)=vec(fblock);
endfor
HA2B=repmat(conj(Da2b_T),Niter,Nantb).*Da2b_R(:,:,meas);
phasesA2B=unwrap(angle(HA2B));
if(mean(var(phasesA2B))>0.5)
disp("The phases of your estimates from A to B are a bit high (larger than 0.5 rad.), something is wrong.");
endif
chanestsA2B(:,:,meas)=reshape(diag(repmat(Da2b_T,Niter,Nantb)'*Da2b_R(:,:,meas))/size(Da2b_T,1),301,Nantb);
#fchanestsA2B=zeros(512,Nantb);
#for i=1:Nantb
# fchanestsA2B(:,i)=[0; chanestsA2B([1:150],i,meas); zeros(210,1); chanestsA2B(151:301,i,meas)];
#endfor
fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)];
tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
%keyboard
end %% Nmeas
received = receivedA2B;
phases = phasesA2B;
tchanests = [tchanestsA2B(:,:,end)];% , tchanestsB2A(:,:,end)];
fchanests = [fchanestsA2B(:,:,end)];% , fchanestsB2A(:,:,end)];
plots
-220
View File
@@ -1,220 +0,0 @@
# % Author: Wael Guibene, Mirsad Cirkic, Florian Kaltenberger
# % Organisation: Eurecom
# % E-mail: guibene@eurecom.fr
# % Model: A: the SMVB (1Tx), B: ExpressMIMO2 Card with 4Rx
clear all
initparams;
if(paramsinitialized && ~LSBSWITCH_FLAG)
disp(["\n\n------------\nThis code is, so far, only written for single runs. Multiple " ...
"runs will overwrite the previous measurement data, i.e., the " ...
"data structures are not defined for multiple runs. You will need to " ...
"add code in order to save the intermediate measurements and the " ...
"corresponding timestamps.\n------------"])
N=76800;
M=8;
indA=[1 0 0 0];%find(active_rfA==1);
indB=[1 2 3 4];%find(active_rfB==1);
Nanta=length(indA);
Nantb=length(indB);
% if(Nanta!=1)
% error("Node A can only have one antenna active\n");
% endif
Niter=1;
if(Niter!=1)
error("We should only use one get_frame at each run.\n");
endif
Nmeas = 1;
# %% ------- Prepare the signals for A2B ---------- %%
%rx_spec;
load where2_v1_final.mat
close all;
sig_ref=real(s2);
signalA2B=sig_ref;%zeros(N,4);
%signalB2A=zeros(N,4);
%ia=1; ib=1;
%Db2a_T=[];
%for i=1:4
% if(indA(ia)==i)
Da2b_T=data;
tmps=sig_ref;
% signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
% signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
% if(length(indA)> ia) ia=ia+1; endif
% endif
% % if(indB(ib)==i)
% % % This part could be improved by creating fully orthogonal sequences
% % [tmpd, tmps]=genrandpskseq(N,M,amp);
% % signalB2A(:,i)=tmps*2;
% % signalA2B(:,i)=repmat(1+1j,76800,1);
% % Db2a_T=[Db2a_T tmpd];
% % if(length(indB)> ib) ib=ib+1; endif
% % endif
%endfor
%#%%------------Prepare the signals for B2A---------------%%
% for i=1:4
% if(indB(ib)==i)
% [tmpd, tmps]=genrandpskseq(N,M,amp);
% signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
% signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
% Db2a_T=[Db2a_T tmpd];
% if(length(indB)> ib) ib=ib+1; endif
% endif
% endfor
% if (!chanest_full)
% signalB2A(1:38400,3)=0;
% signalB2A(38401:end,2)=0;
% Db2a_T(1:60,302:end) = 0;
% Db2a_T(61:end,1:301) = 0;
% end
% Da2b_R=zeros(Niter*120,Nantb*301,Nmeas);
% Db2a_R=zeros(Niter*120,Nanta*301,Nmeas);
for meas=1:Nmeas
# %% ------- Node A to B transmission ------- %%
%oarf_send_frame(card,signalA2B,n_bit);
%keyboard
%sleep(0.01);
receivedA2B1=oarf_get_frame(card);
initial_sync;
frame_start=abs(frame_start);
I= [frame_start:N,1:frame_start-1];
receivedA2B(:,1)=receivedA2B1(I',1);
receivedA2B(:,2)=receivedA2B1(I',2);
receivedA2B(:,3)=receivedA2B1(I',3);
receivedA2B(:,4)=receivedA2B1(I',4);
%oarf_stop(card); %not good, since it does a reset
%sleep(0.01);
#%%----------Node B to A transmission---------%%
% oarf_send_frame(card,signalB2A,n_bit);
% %keyboard
% sleep(0.01);
% receivedB2A=oarf_get_frame(card);
% %oarf_stop(card); %not good, since it does a reset
# %% ------- Do the A to B channel estimation ------- %%
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:,meas)=vec(fblock);
endfor
HA2B=repmat(conj(Da2b_T),Niter,Nantb).*Da2b_R(:,:,meas);
phasesA2B=unwrap(angle(HA2B));
if(mean(var(phasesA2B))>0.5)
disp("The phases of your estimates from A to B are a bit high (larger than 0.5 rad.), something is wrong.");
endif
chanestsA2B(:,:,meas)=reshape(diag(repmat(Da2b_T,Niter,Nantb)'*Da2b_R(:,:,meas))/size(Da2b_T,1),301,Nantb);
#fchanestsA2B=zeros(512,Nantb);
#for i=1:Nantb
# fchanestsA2B(:,i)=[0; chanestsA2B([1:150],i,meas); zeros(210,1); chanestsA2B(151:301,i,meas)];
#endfor
fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)];
tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
%% ------- Do the B to A channel estimation ------- %%
% for i=0:119;
% ifblock=receivedB2A(i*640+[1:640],indA);
% ifblock(1:128,:)=[];
% fblock=fft(ifblock);
% fblock(1,:)=[];
% fblock(151:360,:)=[];
% Db2a_R((Niter-1)*120+i+1,:,meas)=fblock.';
% endfor
% HB2A=conj(repmat(Db2a_T,Niter,1)).*repmat(Db2a_R(:,:,meas),1,Nantb);
% phasesB2A=unwrap(angle(HB2A));
% if(mean(var(phasesB2A))>0.5)
% disp("The phases of your estimates from B to A are a bit high (larger than 0.5 rad.), something is wrong.");
% endif
% if (chanest_full)
% chanestsB2A(:,:,meas)=zeros(301,Nantb);
% inds=repmat([1:Nantb]',1,301);
% for ci=1:301;
% data=Db2a_T(:,ci+[0:Nantb-1]*301);
% rec=Db2a_R(:,ci,meas);
% chanestsB2A(ci,:,meas)=(inv(data'*data)*data'*rec).';
% endfor
% else
% chanestsB2A(:,:,meas)=reshape(diag(repmat(Db2a_T,Niter,1)'*repmat(Db2a_R(:,:,meas),1,Nantb)/(Niter*60)),301,Nantb);
% end
#fchanestsB2A=zeros(512,Nantb);
#for i=1:Nantb
# fchanestsB2A(:,i)=[0; chanestsB2A([1:150],i); zeros(210,1); chanestsB2A(151:301,i)];
#endfor
%fchanestsB2A(:,:,meas) = [zeros(1,Nantb); chanestsB2A([1:150],:,meas); zeros(210,Nantb); chanestsB2A(151:301,:,meas)];
% tchanestsB2A(:,:,meas)=ifft(fchanestsB2A(:,:,meas));
end
%% -- Some plotting code -- %% (you can uncomment what you see fit)
received = receivedA2B;
phases = phasesA2B;
tchanests = [tchanestsA2B(:,:,end)];% , tchanestsB2A(:,:,end)];
fchanests = [fchanestsA2B(:,:,end)];% , fchanestsB2A(:,:,end)];
clf
figure(1)
for i=1:4
subplot(220+i);plot(20*log10(abs(fftshift(fft(received(:,i))))));
endfor
figure(2)
t=[0:512-1]/512*1e-2;
plot(t,20*log10(abs(tchanests)))
xlabel('time')
ylabel('|h|')
legend('SigGEN->Antenna1','SigGEN->Antenna2','SigGEN->Antenna3','SigGEN->Antenna4');
figure(4)
plot(20*log10(abs(fchanests)));
ylim([40 100])
xlabel('freq')
ylabel('|h|')
legend('SigGEN->Antenna1','SigGEN->Antenna2','SigGEN->Antenna3','SigGEN->Antenna4');
i=1
if (i==0)
figure(3)
wndw = 50;
for i=1:5:Nantb*301 %# sliding window size
phamean = filter(ones(wndw,1)/wndw, 1, phases(:,i)); %# moving average
plot(phamean(wndw:end),'LineWidth',2);
title(['subcarrier ' num2str(i)]);
xlabel('time')
ylabel('phase')
ylim([-pi pi])
drawnow;
pause(0.1)
endfor
phavar=var(phases);
plotphavar=[];
for i=0:Nantb-1
plotphavar=[plotphavar; phavar([1:301]+i*301)];
endfor
plot([1:150 362:512],plotphavar,'o');
%ylim([0 pi])
xlabel('subcarrier')
ylabel('phase variance')
end
endif
%else
% if(LSBSWITCH_FLAG) error("You have to unset the LSB switch flag (LSBSWITCH_FLAG) in initparams.m.\n")
% else error("You have to run init.params.m first!")
% endif
%endif
File diff suppressed because one or more lines are too long
-79
View File
@@ -1,79 +0,0 @@
clear all
Nmeas=1
rx_spec
for meas=1:Nmeas
close all
receivedA2B1=oarf_get_frame(card);
initial_sync
N=76800;
indA=[1 0 0 0];
indB=[1 2 3 4];
Nanta=length(indA);
Nantb=length(indB);
fchan=zeros(512,Nantb);
tchan=fchan;
frame_start=abs(frame_start)
I= [frame_start:N,1:frame_start-1];
receivedA2B=receivedA2B1(I',:);
%load where2_v1_final.mat
load filesave0811.mat
Nofs=3840; % The offset in samples between the downlink and uplink sequences. It must be a multiple of 640, 3840 samples is 0.5 ms.
maskA2B=kron(ones(1,N/(2*Nofs)),[ones(1,Nofs) zeros(1,Nofs)])';
datamaskA2B=diag(kron(ones(1,N/(2*Nofs)),[ones(1,Nofs/640) zeros(1,Nofs/640)]));
signalA2B=s2;
Da2b_T=datamaskA2B*data;
%tmps=s2;
Niter=1
Da2b_R=zeros(Niter*120,Nantb*301);
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:)=vec(fblock);
endfor
HA2B=repmat(conj(Da2b_T),1,Nantb).*Da2b_R;
phasesA2B=unwrap(angle(HA2B));
chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb);
fchanestsA2B=zeros(512,Nantb);
for i=1:Nantb
fchanestsA2B(:,i)=[0; chanestsA2B([1:150],i); zeros(210,1); chanestsA2B(151:301,i)];
endfor
tchanestsA2B=ifft(fchanestsA2B);
fchan=fchanestsA2B+fchan;
end %% Nmeas
siglevel0_dB=10*log10(sum(abs((receivedA2B(:,1)-mean(receivedA2B(:,1))).^2))/length(receivedA2B(:,1)));
siglevel1_dB=10*log10(sum(abs((receivedA2B(:,2)-mean(receivedA2B(:,2))).^2))/length(receivedA2B(:,2)));
siglevel2_dB=10*log10(sum(abs((receivedA2B(:,3)-mean(receivedA2B(:,3))).^2))/length(receivedA2B(:,3)));
siglevel3_dB=10*log10(sum(abs((receivedA2B(:,4)-mean(receivedA2B(:,4))).^2))/length(receivedA2B(:,4)));
fprintf("SigLevels : %2.2f dB,%2.2f dB,%2.2f dB,%2.2f dB\n",siglevel0_dB,siglevel1_dB,siglevel2_dB,siglevel3_dB);
received = receivedA2B;
fchanests = [fchan(:,:)/Nmeas];
tchanests = ifft((fchan));
plots
-46
View File
@@ -1,46 +0,0 @@
%
% PURPOSE : channel estimation using least square method
%
% ARGUMENTS :
%
% m_sym_T : transmitted symbol, d_N_f x d_N_ofdm x d_N_ant_act x d_N_meas
% m_sym_R : received symbol, d_N_f x d_N_ofdm x d_N_ant_act x d_N_meas
% d_N_meas : number of measurements
%
% OUTPUTS :
%
% m_H_est : estimation of sub-channels, d_N_antR x d_N_antT x d_N_f x d_N_meas
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "runmeas_full_duplex" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function m_H_est = f_ch_est(m_sym_T, m_sym_R)
%% ** initialisation **
[d_N_f,d_N_OFDM,d_N_antT,d_N_meas] = size(m_sym_T);
d_N_antR = size(m_sym_R,3);
m_H_est = zeros(d_N_antR,d_N_antT,d_N_f,d_N_meas);
%% ** estimate the subband channel for each measurement and antenna **
for d_n_meas = 1:d_N_meas
for d_n_f = 1:d_N_f
m_y = reshape(m_sym_R(d_n_f,:,:,d_n_meas),d_N_OFDM,d_N_antR).'; % squeeze: problem for antenna number = 1 case
m_s = reshape(m_sym_T(d_n_f,:,:,d_n_meas),d_N_OFDM,d_N_antT).';
m_H_est(:,:,d_n_f,d_n_meas) = m_y*m_s'/(m_s*m_s'); % LS channel estimation
end
end
end
-18
View File
@@ -1,18 +0,0 @@
function m_sig_T = f_ofdm_mod(m_sym_T, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf, d_amp)
d_N_ant_act = sum(v_active_rf);
%** mapping useful data to favorable carriers **
m_sym_T_ext = zeros(d_N_FFT,d_N_OFDM,d_N_ant_act);
m_sym_T_ext(2:151,:,:) = m_sym_T(1:150,:,:);
m_sym_T_ext(362:512,:,:) = m_sym_T(151:301,:,:);
%** ifft **
m_sig_T_ = sqrt(d_N_FFT)*ifft(m_sym_T_ext,d_N_FFT,1);
%** add cyclic prefix **
m_sig_T_ = [m_sig_T_(end-d_N_CP+1:end,:,:); m_sig_T_];
d_L = (d_N_FFT+d_N_CP)*d_N_OFDM;
m_sig_T = floor(reshape(m_sig_T_,d_L,d_N_ant_act)*d_amp);
end
-46
View File
@@ -1,46 +0,0 @@
%
% PURPOSE : OFDM Receiver
%
% ARGUMENTS :
%
% m_sig_R : received signal with dimension ((d_N_FFT+d_N_CP)*d_N_ofdm) x d_N
% d_N_FFT : total carrier number
% d_N_CP : extented cyclic prefix
% d_N_OFDM : OFDM symbol number per frame
% v_active_rf : active RF antenna indicator
%
% OUTPUTS :
%
% m_sym_R : transmitted signal before IFFT with dimension d_N_f x d_N_ofdm x d_N_ant_act
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "genrandpskseq" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function m_sym_R = f_ofdm_rx(m_sig_R, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf)
d_N_ant_act = sum(v_active_rf);
m_sig_R_eff = m_sig_R(:,find(v_active_rf));
m_sig_R_f = reshape(m_sig_R_eff,(d_N_FFT+d_N_CP),d_N_OFDM,d_N_ant_act);
%** delete the CP **
m_sig_R_noCP = m_sig_R_f(d_N_CP+1:end,:,:);
%** fft **
m_sym_R_fft = 1/sqrt(d_N_FFT)*fft(m_sig_R_noCP,d_N_FFT,1);
%m_sym_R_fft = fft(m_sig_R_noCP,d_N_FFT,1);
m_sym_R = m_sym_R_fft([2:151 362:512],:,:);
end
-59
View File
@@ -1,59 +0,0 @@
%
% PURPOSE : OFDM Transmitter
%
% ARGUMENTS :
%
% d_M : modulation order
% d_N_f : carrier number carrying data
% d_N_FFT : total carrier number
% d_N_CP : extented cyclic prefix
% d_N_OFDM : OFDM symbol number per frame
% v_active_rf : active RF antenna indicator
% d_amp : amplitude
%
% OUTPUTS :
%
% m_sym_T : transmitted signal before IFFT with dimension d_N_f x d_N_OFDM x d_N_ant_act
% m_sig_T : OFDM signal with dimension ((d_N_FFT+d_N_CP)*d_N_OFDM) x d_N_ant
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "genrandpskseq" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function [m_sym_T, m_sig_T] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf, d_amp)
d_N_ant_act = sum(v_active_rf);
%** constellation table **
v_MPSK = exp(sqrt(-1)*([1:d_M]*2*pi/d_M+pi/d_M));
%** transmitted symbol **
%v_state = [1;2;3;4];
%rand("state",v_state);
m_sym_T = v_MPSK(ceil(rand(d_N_f, d_N_OFDM, d_N_ant_act)*d_M));
%** mapping useful data to favorable carriers **
m_sym_T_ext = zeros(d_N_FFT,d_N_OFDM,d_N_ant_act);
m_sym_T_ext(2:151,:,:) = m_sym_T(1:150,:,:);
m_sym_T_ext(362:512,:,:) = m_sym_T(151:301,:,:);
%** ifft **
m_sig_T_ = sqrt(d_N_FFT)*ifft(m_sym_T_ext,d_N_FFT,1);
%** add cyclic prefix **
m_sig_T_ = [m_sig_T_(end-d_N_CP+1:end,:,:); m_sig_T_];
d_L = (d_N_FFT+d_N_CP)*d_N_OFDM;
m_sig_T = floor(reshape(m_sig_T_,d_L,d_N_ant_act)*d_amp);
end
-53
View File
@@ -1,53 +0,0 @@
%
% PURPOSE : TLS solution for AX = B based on alternative projection
%
% ARGUMENTS :
%
% A : observation of A
% B : observation of B
%
% OUTPUTS :
%
% X : TLS solution for X
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Mai-05-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - none.
%
%**********************************************************************************************
function [X_est A_est B_est] = f_tls_ap(A,B)
%** initlisation **
e_new = 0;
e_old = 1e14;
e_thr = 1e-5; %error threshold: what if the error cannot fall down under the error threshold
X_est = eye(size(A,2));
A_est = A;
%** alternative projection **
while(abs(e_new-e_old)>e_thr)
e_old = e_new;
% optimise X_est
X_est = (A_est'*A_est)\A_est'*B;
%optimise A_est
A_est = B*X_est'/(X_est*X_est');
e_new = norm(A_est*X_est-B)^2+norm(A_est-A)^2;
end
B_est = A_est*X_est;
end
-46
View File
@@ -1,46 +0,0 @@
%
% PURPOSE : TLS solution for AX = B based on SVD assuming X is diagonal
%
% ARGUMENTS :
%
% A : observation of A
% B : observation of B
%
% OUTPUTS :
%
% X : TLS solution for X (Diagonal)
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - I. Markovsky and S. V. Huffel, “Overview of total least-squares methods,” Signal Processing, vol. 87, pp.
% 2283–2302, 2007
%
%**********************************************************************************************
function [X_est A_est B_est] = f_tls_diag(A,B)
d_N = size(A,2);
X_est = zeros(d_N);
A_est = zeros(size(A));
B_est = zeros(size(B));
err_est = zeros(d_N);
for d_n = 1:d_N
[X_est(d_n,d_n) A_est(:,d_n) B_est(:,d_n)] = f_tls_svd(A(:,d_n),B(:,d_n));
end
%method 2: LS solution
% for d_n = 1:d_N
% X_est(d_n,d_n) = (A(:,d_n).'*A(:,d_n))\A(:,d_n).'*B(:,d_n);
% end
-49
View File
@@ -1,49 +0,0 @@
%
% PURPOSE : TLS solution for AX = B based on SVD
%
% ARGUMENTS :
%
% A : observation of A
% B : observation of B
%
% OUTPUTS :
%
% X : TLS solution for X
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - I. Markovsky and S. V. Huffel, “Overview of total least-squares methods,” Signal Processing, vol. 87, pp.
% 2283–2302, 2007
%
%**********************************************************************************************
function [X_est A_est B_est]= f_tls_svd(A,B)
C = [A B];
n = size(A,2);
d = size(B,2);
[U S V] = svd(C,0);
V12 = V(1:n,n+1:end);
V22 = V(n+1:end,n+1:end);
S1 = S(1:n,1:n);
Z12 = zeros(n,d);
Z22 = zeros(d);
Z21 = zeros(d,n);
X_est = - V12/V22;
C_est = U*[S1 Z12;Z21 Z22]*V';
A_est = C_est(:,1:n);
B_est = C_est(:,n+1:end);
% delta_C = -U*diag([zeros(n,1);diag(S(n+1:end,n+1:end))])*V';
% delta_C = [A_est-A B_est-B]; %same as the previous calculation
% err = norm(delta_C,'fro')^2/norm(C,'fro')^2;:w
end
-161
View File
@@ -1,161 +0,0 @@
%
% SCRIPT ID : s_beamforming
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : perform beamforming based on TDD calibration
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 script creation v0.1
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the script "beamforming" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
%% -------- initilisation --------
d_M = 4; % modulation order, e.g. 4 means QPSK
%** frequency **
d_fc = 1907600000;
d_delta_f = 15000;
d_N_f = 301; % carrier number carrying data
d_N_FFT = 512; % total carrier number
d_N_CP = 128; % extented cyclic prefix
%** time **
d_N_OFDM = 60; % number of ofdm symbol per half frame
d_N_meas = 1; % measuement number
%** space **
d_N_antA = 4; % antenna number at site a
d_N_antB = 4; % antenna number at site b
v_active_rfA = [1 1 1 1];
v_active_rfB = [1 0 0 0];
v_indA = find(v_active_rfA); % active antenna index at site a
v_indB = find(v_active_rfB); % active antenna index at site b
d_N_antA_act = length(v_indA);
d_N_antB_act = length(v_indB);
%** amplitude **
d_amp = pow2(12.5)-1;
%% -------- load F --------
o_result = load('result/4a_l45_t10b.mat');
m_F_full = o_result.m_F0;
m_F_diag = o_result.m_F2;
%% -------- channel measurement --------
s_run_meas;
%% -------- signal precoding --------
v_MPSK = exp(sqrt(-1)*([1:d_M]*2*pi/d_M+pi/d_M));
m_sym_TA = v_MPSK(ceil(rand(d_N_f, d_N_OFDM*2)*d_M));
m_sym_TA_ideal = zeros(d_N_f,d_N_OFDM*2,d_N_antA_act);
for d_f = 1:d_N_f
%** ideal case **
v_H_A2B_ideal = squeeze(m_H_est_A2B(:,:,d_f));
v_P_ideal = v_H_A2B_ideal'/norm(v_H_A2B_ideal);
m_sym_TA_ideal(d_f,:,:) = (v_P_ideal*m_sym_TA(d_f,:)).';
%** identity matrix **
v_H_A2B_iden = squeeze(m_H_est_B2A(:,:,d_f)).';
v_P_iden = v_H_A2B_iden'/norm(v_H_A2B_iden);
m_sym_TA_iden(d_f,:,:) = (v_P_iden*m_sym_TA(d_f,:)).';
%** diagonal calibration **
v_H_A2B_diag = squeeze(m_H_est_B2A(:,:,d_f).')*squeeze(m_F_diag(:,:,2));
v_P_diag = v_H_A2B_diag'/norm(v_H_A2B_diag);
m_sym_TA_diag(d_f,:,:) = (v_P_diag*m_sym_TA(d_f,:)).';
%** full calibration **
v_H_A2B_full = squeeze(m_H_est_B2A(:,:,d_f).')*squeeze(m_F_diag(:,:,2));
v_P_full = v_H_A2B_full'/norm(v_H_A2B_full);
m_sym_TA_full(d_f,:,:) = (v_P_full*m_sym_TA(d_f,:)).';
end
%% -------- signal transmission --------
m_sig_TA_ideal = f_ofdm_mod(m_sym_TA_ideal,d_N_FFT,d_N_CP,d_N_OFDM*2,v_active_rfA,d_amp)*2;
m_sig_TA_iden = f_ofdm_mod(m_sym_TA_iden,d_N_FFT,d_N_CP,d_N_OFDM*2,v_active_rfA,d_amp)*2;
m_sig_TA_diag = f_ofdm_mod(m_sym_TA_diag,d_N_FFT,d_N_CP,d_N_OFDM*2,v_active_rfA,d_amp)*2;
m_sig_TA_full = f_ofdm_mod(m_sym_TA_full,d_N_FFT,d_N_CP,d_N_OFDM*2,v_active_rfA,d_amp)*2;
m_sig_TB = zeros((d_N_CP+d_N_FFT)*d_N_OFDM*2,d_N_antB);
oarf_send_frame(cardB,m_sig_TB,d_n_bit);
m_noise_RB_ = oarf_get_frame(cardB);
m_noise_RB = m_noise_RB_(1:d_N_OFDM*(d_N_FFT+d_N_CP),5:8);
m_n_sym_RB = f_ofdm_rx(m_noise_RB, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
m_sig_TB(:,:)=1+1i;
oarf_send_frame(cardB,m_sig_TB,d_n_bit);
oarf_send_frame(cardA,m_sig_TA_ideal,d_n_bit);
m_sig_RB_ideal_ = oarf_get_frame(cardB);
m_sig_RB_ideal = m_sig_RB_ideal_(1:d_N_OFDM*(d_N_FFT+d_N_CP),5:8);
m_sym_RB_ideal = f_ofdm_rx(m_sig_RB_ideal, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
oarf_send_frame(cardA,m_sig_TA_iden,d_n_bit);
m_sig_RB_iden_ = oarf_get_frame(cardB);
m_sig_RB_iden = m_sig_RB_iden_(1:d_N_OFDM*(d_N_FFT+d_N_CP),5:8);
m_sym_RB_iden = f_ofdm_rx(m_sig_RB_iden, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
oarf_send_frame(cardA,m_sig_TA_diag,d_n_bit);
m_sig_RB_diag_ = oarf_get_frame(cardB);
m_sig_RB_diag = m_sig_RB_diag_(1:d_N_OFDM*(d_N_FFT+d_N_CP),5:8);
m_sym_RB_diag = f_ofdm_rx(m_sig_RB_diag, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
oarf_send_frame(cardA,m_sig_TA_full,d_n_bit);
m_sig_RB_full_ = oarf_get_frame(cardB);
m_sig_RB_full = m_sig_RB_full_(1:d_N_OFDM*(d_N_FFT+d_N_CP),5:8);
m_sym_RB_full = f_ofdm_rx(m_sig_RB_full, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
%% -------- SNR measurement --------
%** noise measurment **
%v_P_n = mean(var(squeeze(m_n_sym_RB),0,2));
v_P_n = mean(var(squeeze(m_n_sym_RB),0,2));
%** SNR caculation
%v_P_s_ideal = zeros(301,1);
%for d_f=1:d_N_f
% v_H_A2B_ideal = squeeze(m_H_est_A2B(:,:,d_f));
% v_P_s_ideal(d_f) = norm(v_H_A2B_ideal)^2;
%end
%keyboard;
v_P_s_ideal = var(squeeze(m_sym_RB_ideal),0,2);
v_P_s_iden = var(squeeze(m_sym_RB_iden),0,2);
v_P_s_diag = var(squeeze(m_sym_RB_diag),0,2);
v_P_s_full = var(squeeze(m_sym_RB_full),0,2);
v_SNR_ideal_ = 10*log10((v_P_s_ideal-v_P_n)/v_P_n);
v_SNR_iden_ = 10*log10((v_P_s_iden-v_P_n)/v_P_n);
v_SNR_diag_ = 10*log10((v_P_s_diag-v_P_n)/v_P_n);
v_SNR_full_ = 10*log10((v_P_s_full-v_P_n)/v_P_n);
v_SNR_ideal = nan(d_N_f+1,1);
v_SNR_iden = nan(d_N_f+1,1);
v_SNR_diag = nan(d_N_f+1,1) ;
v_SNR_full = nan(d_N_f+1,1) ;
v_SNR_ideal([1:151 153:302]) = v_SNR_ideal_([151:301 1:150]);
v_SNR_iden([1:151 153:302]) = v_SNR_iden_([151:301 1:150]) ;
v_SNR_diag([1:151 153:302]) = v_SNR_diag_([151:301 1:150]) ;
v_SNR_full([1:151 153:302]) = v_SNR_full_([151:301 1:150]);
save('-v7','result/bf_gain_4x1_t3.mat','v_SNR_ideal','v_SNR_iden','v_SNR_diag','v_SNR_full');
%% -------- plot --------
v_f = d_fc-floor(d_N_f/2)*d_delta_f:d_delta_f:d_fc+ceil(d_N_f/2)*d_delta_f;
figure(5)
hold on
plot(v_f,v_SNR_ideal,'k-')
plot(v_f,v_SNR_iden,'m-.')
plot(v_f,v_SNR_diag,'r-')
plot(v_f,v_SNR_full,'b-')
hold off
ylim([30 40])
-127
View File
@@ -1,127 +0,0 @@
%
% SCRIPT ID : s_run_calib
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : channel calibration for MISO case
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-30-2014 X. JIANG 0.1 script creation v0.1
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the script "calibration" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
%% ** initilisation **
%---------- to change in experiement ---------
%s_init_params;
%clc
%clear all
close all
%d_N_f = 301; % carrier number carrying data
%d_N_meas = 10; % measuement number
%d_N_loc = 5; % Rx locations
%d_N_antM = 2; % max active antenna number for site a and site b
%----------------------------------------------
%% -------- System parameters --------
d_M = 4; % modulation order, e.g. 4 means QPSK
%** frequency **
d_N_f = 301; % carrier number carrying data
d_N_FFT = 512; % total carrier number
d_N_CP = 128; % extented cyclic prefix
%** time **
d_N_OFDM = 60; % number of ofdm symbol per half frame
d_N_meas = 10; % measuement number
%** space **
d_N_antA = 4; % antenna number at site a
d_N_antB = 4; % antenna number at site b
v_indA = find(v_active_rfA); % active antenna index at site a
v_indB = find(v_active_rfB); % active antenna index at site b
d_N_antA_act = length(v_indA);
d_N_antB_act = length(v_indB);
%** amplitude **
d_amp = pow2(12.5)-1; % to see how to be used??
%% -------- calibration parameters -------
d_N_loc = 45; % Rx locations
d_N_antM = max(sum(v_active_rfA),sum(v_active_rfB)); % max active antenna number for site a and site b
%% -------- initialisation ----------------
m_H_A2B = zeros(d_N_antM,d_N_meas*d_N_loc, d_N_f); % d_N_antA x (d_N_meas*d_N_loc) x d_N_f
m_H_B2A = zeros(d_N_antM,d_N_meas*d_N_loc, d_N_f); % d_N_antA x (d_N_meas*d_N_loc) x d_N_f
m_F0 = zeros(d_N_antM,d_N_antM,d_N_f);
m_F1 = zeros(d_N_antM,d_N_antM,d_N_f);
%% ** collect the measurement data from different locations **
for d_loc = 1:d_N_loc
% run measurement, note: uncomment "clear all"
s_run_meas;
% --- the following part is dedicated to A2B MISO -----
m_H_A2Bi = permute(squeeze(m_H_est_A2B),[1 3 2]);
m_H_B2Ai = permute(squeeze(m_H_est_B2A),[1 3 2]);
% -----------------------------------------------------
m_H_A2B(:,(d_loc-1)*d_N_meas+1:d_loc*d_N_meas,:) = m_H_A2Bi;
m_H_B2A(:,(d_loc-1)*d_N_meas+1:d_loc*d_N_meas,:) = m_H_B2Ai;
%keyboard;
disp('Please move the antenna to another location and press any key to continue');
% pause
pause(5);
end
save('-v7','result/4a_l45_t10d.mat','m_H_A2B','m_H_B2A');
%save('-v7','result/2c_l15_t2a.mat','m_H_A2B','m_H_B2A');
%% ** calibration **
for d_f = 1:d_N_f
[m_F0(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A(:,:,d_f).',m_H_A2B(:,:,d_f).'); % solve the TLS problem using SVD method
[m_F1(:,:,d_f),m_A1_est,m_B0_est] = f_tls_ap(m_H_B2A(:,:,d_f).',m_H_A2B(:,:,d_f).'); % solve the TLS problem using Alternative Projection method
end
%% ** plot **
figure(10)
hold on;
for d_f=1:size(m_F0,3);
m_F= m_F0(:,:,d_f);
plot(diag(m_F),'bo')
plot(diag(m_F,1),'k+')
plot(diag(m_F,2),'rx')
plot(diag(m_F,3),'g*')
plot(diag(m_F,-1),'y+')
plot(diag(m_F,-2),'mx')
plot(diag(m_F,-3),'c*')
end
hold off;
title('F0');
axis([-2 2 -2 2])
grid on
figure(11)
hold on;
for d_f=1:size(m_F1,3);
m_F= m_F1(:,:,d_f);
plot(diag(m_F),'bo')
plot(diag(m_F,1),'k+')
plot(diag(m_F,2),'rx')
plot(diag(m_F,3),'g*')
plot(diag(m_F,-1),'y+')
plot(diag(m_F,-2),'mx')
plot(diag(m_F,-3),'c*')
end
hold off;
title('F1');
axis([-2 2 -2 2])
grid on
-115
View File
@@ -1,115 +0,0 @@
close all
%clear all
d_N_f = 301; % carrier number carrying data
d_N_meas = 10;
d_file_name = 'result/4a_l45_t10a.mat';
o_result = load(d_file_name);
m_H_B2A = o_result.m_H_B2A;
m_H_A2B = o_result.m_H_A2B;
d_N_loc = size(m_H_A2B,2)/d_N_meas;
m_F0 = zeros(size(m_H_B2A,1));
m_F1 = zeros(size(m_H_B2A,1));
m_F2 = zeros(size(m_H_B2A,1));
%% ** post processing **
% ** normalisation **
for d_l = 1:d_N_loc
temp = (d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas;
d_norm_fac = mean(mean(mean(abs(m_H_B2A(:,temp,:)))));
m_H_B2A(:,temp,:) = m_H_B2A(:,temp,:)/d_norm_fac;
m_H_A2B(:,temp,:) = m_H_A2B(:,temp,:)/d_norm_fac;
end
% ** average **
d_var_thr = 0.03;
m_H_A2B_ = [];
m_H_B2A_ = [];
for d_l = 1:d_N_loc
% d_var_l = max(var(squeeze(m_H_A2B(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,1)).'));
d_var_l = max(var(m_H_A2B(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,1).'));
d_mean_l = mean(mean(abs(m_H_A2B(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,1).')));
if d_var_l/d_mean_l < d_var_thr
% m_H_A2B_ = [m_H_A2B_ mean(m_H_A2B(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,:),2)];
% m_H_B2A_ = [m_H_B2A_ mean(m_H_B2A(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,:),2)];
m_H_A2B_ = [m_H_A2B_ m_H_A2B(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,:)];
m_H_B2A_ = [m_H_B2A_ m_H_B2A(:,(d_l-1)*d_N_meas+1:(d_l-1)*d_N_meas+d_N_meas,:)];
end
end
%keyboard;
% % ** no processing **
% m_H_B2A_ = m_H_B2A;
% m_H_A2B_ = m_H_A2B;
%% ** calibration **
% temp = 1:15;
for d_f = 1:d_N_f
[m_F0(:,:,d_f),m_A0_est,m_B0_est] = f_tls_svd(m_H_B2A_(:,:,d_f).',m_H_A2B_(:,:,d_f).');
% [m_F0(:,:,d_f),m_A0_est,m_B0_est,d_err0] = f_tls_svd(m_H_B2A_(:,temp,d_f).',m_H_A2B_(:,temp,d_f).');
% [m_F1(:,:,d_f),m_A1_est,m_B1_est d_err1] = f_tls_ap(m_H_B2A_(:,:,d_f).',m_H_A2B_(:,:,d_f).');
[m_F2(:,:,d_f),m_A2_est,m_B2_est] = f_tls_diag(m_H_B2A_(:,:,d_f).',m_H_A2B_(:,:,d_f).');
end
save('-v7','-append',d_file_name,'m_F0','m_F2');
%% ** plot **
h10 = figure(10);
hold on;
for d_f=1:d_N_f
m_F= m_F0(:,:,d_f);
plot(diag(m_F),'bo')
plot(diag(m_F,1),'k+')
plot(diag(m_F,-1),'y+')
plot(diag(m_F,2),'rx')
plot(diag(m_F,-2),'mx')
plot(diag(m_F,3),'g*')
plot(diag(m_F,-3),'c*')
end
hold off;
title('F0');
% axis([-0.1 0.1 -0.1 0.1])
axis([-2 2 -2 2])
% axis([-0.3 0.3 -0.3 0.3])
grid on
% saveas(h10,'results\F_svd_2c_g20_0_t1','fig');
% print('-depsc','results\F_svd_2c_g20_0_t1.eps')
%
% h11=figure(11);
% hold on;
% for d_f=1:d_N_f
% m_F= m_F1(:,:,d_f);
% plot(diag(m_F),'bo')
% plot(diag(m_F,1),'k+')
% plot(diag(m_F,-1),'y+')
% plot(diag(m_F,2),'rx')
% plot(diag(m_F,-2),'mx')
% plot(diag(m_F,3),'g*')
% plot(diag(m_F,-3),'c*')
% end
% hold off;
% axis([-0.3 0.3 -0.3 0.3])
% % axis([-2 2 -2 2])
% grid on
% saveas(h11,'results\F_ap_2c_g20_0_t2','fig');
% print('-depsc','results\F_ap_2c_g20_0_t2.eps')
%
% h12=figure(12);
% hold on;
% for d_f=1:d_N_f
% m_F= m_F2(:,:,d_f);
% plot(diag(m_F),'bo')
% % plot(diag(m_F,1),'k+')
% % plot(diag(m_F,-1),'k+')
% % plot(diag(m_F,2),'rx')
% % plot(diag(m_F,-2),'rx')
% % plot(diag(m_F,3),'g*')
% % plot(diag(m_F,-3),'g*')
% end
% hold off;
% title('F2');
% axis([-2 2 -2 2])
% grid on
% saveas(h12,'results\F_diag_2c_g20_0_t2','fig');
% print('-depsc','results\F_diag_2c_g20_0_t2.eps')
-56
View File
@@ -1,56 +0,0 @@
clear all
close all
addpath([getenv('OPENAIR_TARGETS') '/ARCH/EXMIMO/USERSPACE/OCTAVE']);
addpath([getenv('OPENAIR_DIR') '/cmake_targets/lte_build_oai/build']);
%% -------- ExpressMIMO2 configuration --------
limeparms;
cardA = 0;
cardB = 1;
v_active_rfA = [1 1 1 1];
v_active_rfB = [1 0 0 0];
fc = 1907600000; %3500000000; %fc = 859.5e6; %fc = 2660000000;
freq_rxA = fc*v_active_rfA;
freq_txA = freq_rxA; %+1.92e6;
freq_rxB = fc*v_active_rfB;
freq_txB = freq_rxB; %+1.92e6;
tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB; %we need the LSB switching for the woduplex script, otherwise we don't receive anything
rx_gainA = 10*v_active_rfA;%[0 0 0 3];
tx_gainA = 10*v_active_rfA;%[20 20 20 20]
rx_gainB = 10*v_active_rfB;
tx_gainB = 10*v_active_rfB;
syncmodeA = SYNCMODE_MASTER;
syncmodeB = SYNCMODE_SLAVE;
eNB_flag = 0;
resampling_factorA = [2 2 2 2];%2*v_active_rfA;
resampling_factorB = [2 2 2 2];%2*v_active_rfB;
rf_modeA = (TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * v_active_rfA;
rf_rxdcA = rf_rxdc*v_active_rfA;
rf_vcocalA = rf_vcocal_19G*v_active_rfA;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rffe_rxg_lowA = 31*v_active_rfA;
rffe_rxg_finalA = 63*v_active_rfA;
rffe_bandA = B19G_TDD*v_active_rfA;
autocal_modeA = v_active_rfA;
oarf_stop(cardA);
sleep(0.1);
oarf_config_exmimo(cardA,freq_rxA,freq_txA,tdd_config,syncmodeA,rx_gainA,tx_gainA,eNB_flag,rf_modeA,rf_rxdcA,rf_local,rf_vcocalA,rffe_rxg_lowA,rffe_rxg_finalA,rffe_bandA,autocal_modeA,resampling_factorA);
rf_modeB = (TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * v_active_rfB;
rf_rxdcB = rf_rxdc*v_active_rfB;
rf_vcocalB = rf_vcocal_19G*v_active_rfB;
rffe_rxg_lowB = 31*v_active_rfB;
rffe_rxg_finalB = 63*v_active_rfB;
rffe_bandB = B19G_TDD*v_active_rfB;
autocal_modeB = v_active_rfB;
oarf_stop(cardB);
sleep(0.1);
oarf_config_exmimo(cardB,freq_rxB,freq_txB,tdd_config,syncmodeB,rx_gainB,tx_gainB,eNB_flag,rf_modeB,rf_rxdcB,rf_local,rf_vcocalB,rffe_rxg_lowB,rffe_rxg_finalB,rffe_bandB,autocal_modeB,resampling_factorB);
d_n_bit = 16;
-139
View File
@@ -1,139 +0,0 @@
%
% SCRIPT ID : s_run_meas
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : full transmission and receive train for TDD reciprocity calibration
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 script creation v0.1
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the script "run_full_duplex" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
%% ** initialisation **
%% ------------- to change in experiment ------------
%clc
close all
%clear all
%
%% ----------------------------------------------------
m_sym_TA = zeros(d_N_f,d_N_OFDM,length(v_indA),d_N_meas);
m_sym_TB = zeros(d_N_f,d_N_OFDM,length(v_indB),d_N_meas);
m_sym_RA = zeros(d_N_f,d_N_OFDM,length(v_indA),d_N_meas);
m_sym_RB = zeros(d_N_f,d_N_OFDM,length(v_indB),d_N_meas);
m_sym_TA_ = zeros(d_N_f,d_N_OFDM,length(v_indA));
m_sig_TA = zeros((d_N_CP+d_N_FFT)*d_N_OFDM*2,d_N_antA);
m_sig_TB = zeros((d_N_CP+d_N_FFT)*d_N_OFDM*2,d_N_antB);
for d_n_meas = 1:d_N_meas
%% -------- tx --------
%** tx of site A **
[m_sym_TA_(:,:,:,d_n_meas), m_sig_TA_] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfA, d_amp);
for d_a = 1:d_N_antA_act
d_N_a = d_N_OFDM/d_N_antA_act;
d_N_b = d_N_OFDM*(d_N_FFT+d_N_CP)/d_N_antA_act;
m_sig_TA(d_N_b*(d_a-1)+1:d_N_b*d_a,v_indA(d_a)) = m_sig_TA_(d_N_b*(d_a-1)+1:d_N_b*d_a,d_a);
m_sym_TA(:,d_N_a*(d_a-1)+1:d_N_a*d_a,d_a,d_n_meas) = m_sym_TA_(:,d_N_a*(d_a-1)+1:d_N_a*d_a,d_a,d_n_meas);
end
m_sig_TA(1:end/2,v_indA)= m_sig_TA(1:end/2,v_indA)*2; %affect the LSB to 0 to set on Tx mode
m_sig_TA(end/2+1:end,v_indA)= 1+1i; %affect the LSB to 1 to set on Rx mode
%** tx of site B **
[m_sym_TB(:,:,:,d_n_meas), m_sig_TB_] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB, d_amp);
m_sig_TB(1:end/2,v_indB)=1+1i;
m_sig_TB(end/2+1:end,v_indB)= m_sig_TB_*2;
%** Transmission from A to B **
oarf_send_frame(cardA,m_sig_TA,d_n_bit);
%** Transmission from B to A **
oarf_send_frame(cardB,m_sig_TB,d_n_bit);
%sleep(0.1);
m_sig_R = oarf_get_frame(-2);
m_sig_RA = m_sig_R(d_N_OFDM*(d_N_FFT+d_N_CP)+1:d_N_OFDM*(d_N_FFT+d_N_CP)*2,1:d_N_antA);
m_sig_RB = m_sig_R(1:d_N_OFDM*(d_N_FFT+d_N_CP),d_N_antA+1:d_N_antA+d_N_antB);
%% -------- rx --------
m_sym_RB(:,:,:,d_n_meas) = f_ofdm_rx(m_sig_RB, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
m_sym_RA(:,:,:,d_n_meas) = f_ofdm_rx(m_sig_RA, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfA);
%keyboard;
end
%** channel estimation **
m_H_est_A2B = f_ch_est(m_sym_TA, m_sym_RB); %dimension: d_N_antR x d_N_antT x d_N_f x d_N_meas
m_H_est_B2A = f_ch_est(m_sym_TB, m_sym_RA);
%% -------- plot --------
%** channel estimation in frequency domain **
m_H_A2B_draw = squeeze(m_H_est_A2B(1,:,:,end)).';
m_H_B2A_draw = squeeze(m_H_est_B2A(:,1,:,end)).';
figure(1)
subplot(2,1,1)
plot(real(m_sig_RB(1:40,v_indB)),'b-');
hold on
plot(real(m_sig_RB(end-80+1:end-40,v_indB)),'g-')
hold on
plot(real(m_sig_RB(end-40+1:end,v_indB)),'r-')
title('m_sig_RB')
subplot(2,1,2)
plot(real(m_sig_RA(:,v_indA)),'-');
title('m_sig_RA')
figure(2)
subplot(2,2,1)
plot(20*log10(abs(m_H_A2B_draw)),'-');
title('|h| vs. freq (A2B)')
xlabel('freq')
ylabel('|h|')
ylim([0 100])
subplot(2,2,2)
plot(20*log10(abs(m_H_B2A_draw)),'-');
title('|h| vs. freq (B2A)')
xlabel('freq')
ylabel('|h|')
ylim([0 100])
subplot(2,2,3)
plot(angle(m_H_A2B_draw),'-');
title('angle(h) vs. freq (A2B)')
xlabel('freq')
ylabel('angle(h)')
subplot(2,2,4)
plot(angle(m_H_B2A_draw),'-');
title('angle(h) vs. freq (B2A)')
xlabel('freq')
ylabel('angle(h)')
%v_color = ['b*','g*','r*','c*'];
figure(3)
for d_a = 1:d_N_antA_act
subplot(2,2,d_a);
plot(m_sym_RA(1,:,d_a,1),'*');
title(strcat('m sym RA',num2str(d_a)));
end
figure(4)
for d_a = 1:d_N_antA_act
subplot(2,2,d_a);
plot(m_sym_RB(1,d_N_OFDM/d_N_antA_act*(d_a-1)+1:d_N_OFDM/d_N_antA_act*d_a,1,1),'*');
hold on;
title(strcat('m sym RB',num2str(d_a)));
end
-37
View File
@@ -1,37 +0,0 @@
function [F, HA]=alterproj(CHB2A,CHA2B, s, N, Nl, Nt)
for l=1:Nl
YA(:,((l-1)*Nt+1):(l*Nt))=squeeze(CHB2A{l}(s,:,:));
YB(:,((l-1)*Nt+1):(l*Nt))=squeeze(CHA2B{l}(s,:,:));
end
HA=zeros(N,Nl);
for l=1:Nl
for t=1:Nt
HA(:,l)=HA(:,l)+YA(:,t+(l-1)*Nt);
end
HA(:,l)=HA(:,l)/Nt;
end
GA=kron(HA,ones(1,Nt));
F=YB*GA'*inv(GA*GA');
oldobj=1e14;
newobj=norm(YB-F*GA)^2+norm(YA-GA)^2;
while(oldobj-newobj>1e-10)
oldobj=newobj;
FI=repmat([F; eye(N)],Nt,1);
YBA=reshape([YB; YA],2*N*Nt,Nl);
FIFI=FI'*FI;
if(cond(FIFI)>30)
warning(['The cond. number in HA est is ' num2str(cond(FIFI))])
end
HA=inv(FIFI)*FI'*YBA;
GA=kron(HA,ones(1,Nt));
GAGA=GA*GA';
if(cond(GAGA)>30)
warning(['The cond. number in F est. is ' num2str(cond(GAGA))])
end
F=YB*GA'*inv(GAGA);
newobj=norm(YB-F*GA)^2+norm(YA-GA)^2;
end
end
-108
View File
@@ -1,108 +0,0 @@
% do some beamforming
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
signalB2A_prec_full=zeros(N,4);
signalB2A_prec_diag=zeros(N,4);
Da2b_R=zeros(Niter*120,Nantb*301);
Db2a_R=zeros(Niter*120,Nanta*301);
%%----------Node A to B transmission---------%%
for i=1:4
if(active_rfA(i))
[Da2b_T, tmps]=genrandpskseq(N,M,amp);
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
else
signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
end
end
oarf_send_frame(card,signalA2B,n_bit);
%keyboard
sleep(0.01);
receivedA2B=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
sleep(0.01);
%% ------- Do the A to B channel estimation ------- %%
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R(i+1,:)=vec(fblock);
end
chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb);
%fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)];
%tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
%% calculate beamformer based on chanestA2B
for i=1:301
YA=chanestsA2B(i,:).';
F=Fs(:,:,i);
Fd=Fds(:,:,i);
BFs(:,i) = conj(F*YA)./norm(F*YA);
BDs(:,i) = conj(Fd*YA)./norm(Fd*YA);
end
%% generate normal and beamformed signals
[seqf, tmps]=genrandpskseq(N,M,amp);
for i=1:size(seqf,1)
% precoding
for j=1:size(seqf,2)
seqf_prec_full(:,i,j)=BFs(:,j)*seqf(i,j);
seqf_prec_diag(:,i,j)=BDs(:,j)*seqf(i,j);
end
end
tmps_prec_diag = ofdm_mod(seqf_prec_full,amp);
tmps_prec_full = ofdm_mod(seqf_prec_diag,amp);
%%
for i=1:4
if(active_rfB(i))
signalB2A(:,i)=floor(tmps/sqrt(3))*2; %make sure LSB is 0 (switch=tx)
signalB2A_prec_full(:,i)=tmps_prec_full(i-1,:)*2; %make sure LSB is 0 (switch=tx)
signalB2A_prec_diag(:,i)=tmps_prec_diag(i-1,:)*2; %make sure LSB is 0 (switch=tx)
else
signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
signalB2A_prec_full(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
signalB2A_prec_diag(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
end
end
%% send normal signal
P_tx = 10*log10(sum(mean(abs(signalB2A(:,2:4)).^2)))
oarf_send_frame(card,signalB2A,n_bit);
%keyboard
sleep(0.01);
receivedB2A=oarf_get_frame(card);
sleep(0.01);
% measure SNR
P_rx = 10*log10(mean(abs(receivedB2A(:,1)).^2))
%% send beamformed DL signal
P_tx_prec_diag = 10*log10(sum(mean(abs(signalB2A_prec_diag(:,2:4)).^2)))
oarf_send_frame(card,signalB2A_prec_diag,n_bit);
%keyboard
sleep(0.01);
receivedB2A_prec_diag=oarf_get_frame(card);
sleep(0.01);
% measure SNR
P_rx_prec_diag = 10*log10(mean(abs(receivedB2A_prec_diag(:,1)).^2))
%% send beamformed DL signal
P_tx_prec_full = 10*log10(sum(mean(abs(signalB2A_prec_full(:,2:4)).^2)))
oarf_send_frame(card,signalB2A_prec_full,n_bit);
%keyboard
sleep(0.01);
receivedB2A_prec_full=oarf_get_frame(card);
sleep(0.01);
% measure SNR
P_rx_prec_full = 10*log10(mean(abs(receivedB2A_prec_full(:,1)).^2))
figure(10)
bar([P_tx P_tx_prec_diag P_tx_prec_full; P_rx P_rx_prec_diag P_rx_prec_full]);
legend('normal','beamformed F diag', 'beamformed F full')
ylim([0 60])
drawnow
-46
View File
@@ -1,46 +0,0 @@
initparams;
N_loc = 3; %check
CHA2B = {}; %this should be a cell array
CHB2A = {}; %this should be a cell array
% run measurements for all location
for loc = 1:N_loc
runmeas_woduplex;
% alternatively load the measurements from file for testing
% now you should have chanestA2B, fchanestA2B, tchanestA2B, chanestB2A,
% fchanestB2A, tchanestB2A
CHA2B{loc} = chanestsA2B; %to check
CHB2A{loc} = chanestsB2A; %to check
disp('Please move the antenna to another location and press key when finished')
pause
end
%% calculate full F matrix
Fs = zeros(Nantb,Nantb,301);
for s=1:301
[F, HA]=alterproj(CHB2A,CHA2B, s, Nantb, N_loc, Nmeas);
Fs(:,:,s)=F;
%HAs{s}=HA;
end
%% calculate the diag F matrix based on last position
Fds = zeros(Nantb,Nantb,301);
for s=1:301
CHA = squeeze(chanestsA2B(s,:,:));
CHB = squeeze(chanestsB2A(s,:,:));
Fds(:,:,s)=diag(diag(CHB*CHA')./diag(CHA*CHA'));
end
%% plot F
figure(1)
clf
hold on;
for s=1:size(Fs,3);
F=Fs(:,:,s);
plot(diag(F),'bo')
plot(diag(F,1),'r+')
plot(diag(F,2),'gx')
end
%axis([-1 1 -1 1])
hold off;
@@ -1,44 +0,0 @@
# % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se
function [carrierdata, s]=genorthqpskseq(Ns,N,amp)
if(N!=512*150)
error('The sequence length must be 76800.');
endif
s = zeros(N,Ns);
H=1; for k=1:log2(128) H=[H H; H -H]; end; H=H(:,1:120);
i=1; while(i<size(H,1)) h=H(i,:); inds=find(h*H'!=0); H(inds,:)=[]; H=[h; H]; i=i+1; end
Hc=H+sqrt(-1)*H;
if(sum(Hc*Hc'-240*eye(8))>0) error("The code is not orhtogonal\n"); endif
carrierdata=zeros(120,Ns*301);
inds=1:8;
ind=8;
for i=1:301
for k=1:Ns
carrierdata(:,i+(k-1)*301)=Hc(inds(ind),:)';
inds(ind)=[];
ind=ind-1;
if(ind==0)
inds=1:8;
ind=8;
endif
endfor
endfor
for k=1:Ns
frstgroup=(k-1)*301+[1:150]; # The first group of OFDM carriers
sndgroup=(k-1)*301+[151:301]; # The second group of OFDM carriers
for i=0:119
fblock=[0 carrierdata(i+1,frstgroup) zeros(1,210) carrierdata(i+1,sndgroup)];
ifblock=ifft(fblock,512)*sqrt(512);
block = [ifblock(end-127:end) ifblock]; # Cycl. prefix
s([1:640]+i*640,k)=floor(amp*block);
endfor
endfor
endfunction
@@ -1,29 +0,0 @@
% Author: Mirsad Cirkic
% Organisation: Eurecom (and Linkoping University)
% E-mail: mirsad.cirkic@liu.se
function [carrierdata, s]=genrandpskseq(N,M,amp)
if(mod(N,640)~=0)
error('The sequence length must be divisible with 640.');
end
s = zeros(N,1);
MPSK=exp(sqrt(-1)*([1:M]*2*pi/M+pi/M));
% OFDM sequence with 512 FFT using randomly
% generated 4-QAM and 128 cyclic prefix
carrierdata=zeros(120,301);
for i=0:(N/640-1)
datablock=MPSK(ceil(rand(301,1)*M));
for j=1:301
carrierdata(i+1,j)=datablock(j);
end
fblock=[0 datablock(1:150) zeros(1,210) datablock(151:301)];
ifblock=ifft(fblock,512)*sqrt(512);;
% Adding cycl. prefix making the block of 640 elements
block = [ifblock(end-127:end) ifblock];
s([1:640]+i*640)=floor(amp*block);
end
end
-60
View File
@@ -1,60 +0,0 @@
# % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se
addpath([getenv('OPENAIR_TARGETS') '/ARCH/EXMIMO/USERSPACE/OCTAVE']);
clear all
close all
paramsinitialized=false;
limeparms;
rx_gain=[0 0 0 0];
tx_gain=[20 20 20 20];
eNB_flag = 0;
card = 0;
Ntrx=4;
dual_tx=0;
active_rfA=[0 0 0 1];
% active_rfB=[1 1 1 0];
active_rfB=[0 1 1 0];
active_rf=active_rfA | active_rfB;
if(active_rfA*active_rfB'!=0) error("The A and B transceive chains must be orthogonal./n") endif
%fc = 2660000000;
fc = 1912600000; %1907600000;
%fc = 859.5e6;
autocal_mode=active_rf;
resampling_factor = [2 2 2 2];
%rf_mode=(RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1) * active_rf;
%rf_mode=(TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM) * active_rf;
% we have to enable both DMA transfers so that the switching signal in the LSB of the TX buffer gets set
rf_mode=(TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * active_rf;
tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB; %we also need the LSB switching for the woduplex script, otherwise we don't receive anything
%tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB;
syncmode = SYNCMODE_FREE;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rf_vcocal=rf_vcocal_19G*active_rf;
rffe_rxg_low = 31*active_rf;
rffe_rxg_final = 63*active_rf;
rffe_band = B19G_TDD*active_rf;
rf_rxdc = rf_rxdc*active_rf;
freq_rx = fc*active_rf;
freq_tx = freq_rx; %+1.92e6;
oarf_stop(card);
sleep(0.1);
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode,resampling_factor);
autocal_mode=0*active_rf; % Autocalibration is only needed the first time we conf. exmimo
amp = pow2(12.5)-1;
n_bit = 16;
%chanest_full = 1;
chanest_full = 1;
paramsinitialized=true;
-49
View File
@@ -1,49 +0,0 @@
# % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se
%clear
paramsinitialized=false;
limeparms;
rxgain=10;
txgain=25;
eNB_flag = 0;
card = 0;
Ntrx=4;
dual_tx=0;
active_rfA=[1 0 0 0];
active_rfB=[0 1 1 0];
active_rf=active_rfA+active_rfB;
if(active_rfA*active_rfB'!=0) error("The A and B transceive chains must be orthogonal./n") endif
%fc = 2660000000;
fc = 1912600000; %1907600000;
%fc = 859.5e6;
%rf_mode=(RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAByp+RFBBLNA1) * active_rf;
autocal_mode=active_rf;
rf_mode=(TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM) * active_rf;
tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_TESTTX; LSBSWITCH_FLAG=false;
%tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB; LSBSWITCH_FLAG=true;
syncmode = SYNCMODE_FREE;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rf_vcocal=rf_vcocal_19G*active_rf;
rffe_rxg_low = 61*active_rf;
rffe_rxg_final = 61*active_rf;
rffe_band = B19G_TDD*active_rf;
rf_rxdc = rf_rxdc*active_rf;
freq_rx = fc*active_rf;
freq_tx = freq_rx; %+1.92e6;
tx_gain = txgain*active_rf;
rx_gain = rxgain*active_rf;
%rx_gain = [10 10 30 0];
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode);
autocal_mode=0*active_rf; % Autocalibration is only needed the first time we conf. exmimo
amp = pow2(14)-1;
n_bit = 16;
paramsinitialized=true;
-13
View File
@@ -1,13 +0,0 @@
function sigt = ofdm_mod(sigf,amp)
[Nant,Nsymb,Nsub] = size(sigf);
sigt = zeros(Nant,Nsymb*640);
for i=1:Nsymb
symbol=squeeze(sigf(:,i,:));
% insert zero subcarriers
symbol=cat(2,zeros(Nant,1),symbol(:,1:150),zeros(Nant,210),symbol(:,151:301));
% ofdm modulation
symbol_t=ifft(symbol,512,2);
% Adding cycl. prefix making the block of 640 elements
symbol_cp = cat(2,symbol_t(:,end-127:end), symbol_t);
sigt(:,(1:640)+(i-1)*640)=floor(amp*symbol_cp);
end
-1
View File
@@ -1 +0,0 @@
old project by Misard and Florian
@@ -1,253 +0,0 @@
% Author: Mirsad Cirkic, Florian Kaltenberger
% Organisation: Eurecom (and Linkoping University)
% E-mail: mirsad.cirkic@liu.se
if(paramsinitialized)
disp(['\n\n------------\nThis code is, so far, only written for single runs. Multiple ' ...
'runs will overwrite the previous measurement data, i.e., the ' ...
'data structures are not defined for multiple runs. You will need to ' ...
'add code in order to save the intermediate measurements and the ' ...
'corresponding timestamps.\n------------'])
N=76800;
M=4;
indA=find(active_rfA==1);
indB=find(active_rfB==1);
Nanta=length(indA);
Nantb=length(indB);
if(Nanta~=1)
error('Node A can only have one antenna active\n');
end
Niter=1;
if(Niter~=1)
error('We should only use one get_frame at each run.\n');
end
Nmeas = 5;
%% ------- Prepare the signals for A2B ---------- %%
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
ia=1; ib=1;
Db2a_T=[];
for i=1:4
if(indA(ia)==i)
[Da2b_T, tmps]=genrandpskseq(N,M,amp);
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
if(length(indA)> ia) ia=ia+1; end
end
% if(indB(ib)==i)
% % This part could be improved by creating fully orthogonal sequences
% [tmpd, tmps]=genrandpskseq(N,M,amp);
% signalB2A(:,i)=tmps*2;
% signalA2B(:,i)=repmat(1+1j,76800,1);
% Db2a_T=[Db2a_T tmpd];
% if(length(indB)> ib) ib=ib+1; end
% end
end
%%------------Prepare the signals for B2A---------------%%
for i=1:4
if(indB(ib)==i)
[tmpd, tmps]=genrandpskseq(N,M,amp);
signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
Db2a_T=[Db2a_T tmpd];
if(length(indB)> ib) ib=ib+1; end
end
end
if (~chanest_full)
signalB2A(1:38400,3)=0;
signalB2A(38401:end,2)=0;
Db2a_T(1:60,302:end) = 0;
Db2a_T(61:end,1:301) = 0;
end
Da2b_R=zeros(Niter*120,Nantb*301,Nmeas);
Db2a_R=zeros(Niter*120,Nanta*301,Nmeas);
chanestsA2B=zeros(301,Nantb,Nmeas);
tchanestsA2B=zeros(512,Nantb,Nmeas);
fchanestsA2B=zeros(512,Nantb,Nmeas);
chanestsB2A=zeros(301,Nantb,Nmeas);
tchanestsB2A=zeros(512,Nantb,Nmeas);
fchanestsB2A=zeros(512,Nantb,Nmeas);
for meas=1:Nmeas
%% ------- Node A to B transmission ------- %%
oarf_send_frame(card,signalA2B,n_bit);
receivedA2B=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
sleep(0.01);
%%----------Node B to A transmission---------%%
oarf_send_frame(card,signalB2A,n_bit);
receivedB2A=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
%keyboard;
%% ------- Do the A to B channel estimation ------- %%
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:,meas)=vec(fblock);
end
HA2B=repmat(conj(Da2b_T),Niter,Nantb).*Da2b_R(:,:,meas);
phasesA2B=unwrap(angle(HA2B));
if(mean(var(phasesA2B))>0.5)
disp('The phases of your estimates from A to B are a bit high (larger than 0.5 rad.), something is wrong.');
end
chanestsA2B(:,:,meas)=reshape(diag(repmat(Da2b_T,Niter,Nantb)'*Da2b_R(:,:,meas))/size(Da2b_T,1),301,Nantb);
%fchanestsA2B=zeros(512,Nantb);
%for i=1:Nantb
% fchanestsA2B(:,i)=[0; chanestsA2B([1:150],i,meas); zeros(210,1); chanestsA2B(151:301,i,meas)];
%end
fchanestsA2B(:,:,meas)=[zeros(1,Nantb); chanestsA2B([1:150],:,meas); zeros(210,Nantb); chanestsA2B(151:301,:,meas)];
tchanestsA2B(:,:,meas)=ifft(fchanestsA2B(:,:,meas));
%% ------- Do the B to A channel estimation ------- %%
for i=0:119;
ifblock=receivedB2A(i*640+[1:640],indA);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Db2a_R((Niter-1)*120+i+1,:,meas)=fblock.';
end
HB2A=conj(repmat(Db2a_T,Niter,1)).*repmat(Db2a_R(:,:,meas),1,Nantb);
phasesB2A=unwrap(angle(HB2A));
%if(mean(var(phasesB2A))>0.5)
% disp('The phases of your estimates from B to A are a bit high (larger than 0.5 rad.), something is wrong.');
%end
if (chanest_full)
chanestsB2A(:,:,meas)=zeros(301,Nantb);
inds=repmat([1:Nantb]',1,301);
for ci=1:301;
data=Db2a_T(:,ci+[0:Nantb-1]*301);
rec=Db2a_R(:,ci,meas);
chanestsB2A(ci,:,meas)=(inv(data'*data)*data'*rec).';
end
else
chanestsB2A(:,:,meas)=reshape(diag(repmat(Db2a_T,Niter,1)'*repmat(Db2a_R(:,:,meas),1,Nantb)/(Niter*60)),301,Nantb);
end
%fchanestsB2A=zeros(512,Nantb);
%for i=1:Nantb
% fchanestsB2A(:,i)=[0; chanestsB2A([1:150],i); zeros(210,1); chanestsB2A(151:301,i)];
%end
fchanestsB2A(:,:,meas) = [zeros(1,Nantb); chanestsB2A([1:150],:,meas); zeros(210,Nantb); chanestsB2A(151:301,:,meas)];
tchanestsB2A(:,:,meas)=ifft(fchanestsB2A(:,:,meas));
end % Nmeas
%% estimate the noise
no_signal=repmat(1+1j,76800,4);
oarf_send_frame(card,no_signal,n_bit);
sleep(0.01);
noise_received=oarf_get_frame(card);
% estimate noise in frequency domain
noise_f = zeros(120,301,4);
for i=0:119;
ifblock=noise_received(i*640+[1:640],:);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
%noise_f(i+1,:,:)=fblock;
end
%% -- Some plotting code -- %% (you can uncomment what you see fit)
received = [receivedA2B(:,indB) receivedB2A(:,indA)];
phases = phasesB2A;
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
fchanests = [chanestsA2B(:,:,end), chanestsB2A(:,:,end)];
clf
figure(1)
for i=1:size(received,2);
subplot(220+i);
plot(20*log10(abs(fftshift(fft(received(:,i))))));
ylim([20 140])
end
figure(2)
%t=[0:512-1]/512*1e-2;
%plot(t,20*log10(abs(tchanests)))
plot(20*log10(abs(tchanests)))
xlabel('time')
ylabel('|h|')
if Nantb==3
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
else
legend('A->B1','A->B2','B1->A','B2->A');
end
figure(3)
plot(20*log10(abs(fchanests)));
hold on
plot(squeeze(10*log10(mean(abs(noise_f(:,:,[indB indA])).^2,1))),'.');
hold off
ylim([40 100])
xlabel('freq')
ylabel('|h|')
if Nantb==3
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A','Noise B1','Noise B2','Noise B3','Noise A');
else
legend('A->B1','A->B2','B1->A','B2->A','Noise B1','Noise B2','Noise A');
end
if (0)
figure(4)
wndw = 50;
for i=1:5:Nantb*301 %# sliding window size
phamean = filter(ones(wndw,1)/wndw, 1, phases(:,i)); %# moving average
plot(phamean(wndw:end),'LineWidth',2);
title(['subcarrier ' num2str(i)]);
xlabel('time')
ylabel('phase')
ylim([-pi pi])
drawnow;
pause(0.1)
end
phavar=var(phases);
plotphavar=[];
for i=0:Nantb-1
plotphavar=[plotphavar; phavar([1:301]+i*301)];
end
plot([1:150 362:512],plotphavar,'o');
%ylim([0 pi])
xlabel('subcarrier')
ylabel('phase variance')
end
%% estimate F matrix assuming it is diagonal for sanity checking
Fhatloc = zeros(Nmeas,301,Nantb);
for t=1:Nmeas
for s=1:301
ya=chanestsB2A(s,:,t);
yb=chanestsA2B(s,:,t);
Fhatloc(t,s,:)=(yb.*conj(ya))./(ya.*conj(ya));
end
end
figure(5)
plot_style={'rx','go','bs'};
hold off
for n=1:Nantb
plot((squeeze(Fhatloc(:,:,n))),plot_style{n})
hold on
end
axis([-2 2 -2 2])
%disp(squeeze(mean(Fhatloc,2)));
drawnow;
else
error('You have to run init.params.m first!')
end
@@ -1,254 +0,0 @@
% Author: Mirsad Cirkic, Florian Kaltenberger
% Organisation: Eurecom (and Linkoping University)
% E-mail: mirsad.cirkic@liu.se
if(paramsinitialized)
disp(['\n\n------------\nThis code is, so far, only written for single runs. Multiple ' ...
'runs will overwrite the previous measurement data, i.e., the ' ...
'data structures are not defined for multiple runs. You will need to ' ...
'add code in order to save the intermediate measurements and the ' ...
'corresponding timestamps.\n------------'])
N=76800;
M=4;
Ntaps=8;
indA=find(active_rfA==1);
indB=find(active_rfB==1);
Nanta=length(indA);
Nantb=length(indB);
if(Nanta~=1)
error('Node A can only have one antenna active\n');
end
Niter=1;
if(Niter~=1)
error('We should only use one get_frame at each run.\n');
end
Nmeas = 10;
%% ------- Prepare the signals for A2B ---------- %%
signalA2B=zeros(N,4,Nmeas);
signalB2A=zeros(N,4,Nmeas);
Da2b_T=[];
Db2a_T=[];
for meas=1:Nmeas
ia=1; ib=1;
Dtmp=[];
for i=1:4
if(indA(ia)==i)
[tmpd, tmps]=genrandpskseq(N,M,amp);
signalA2B(:,i,meas)=tmps*2; %make sure LSB is 0 (switch=tx)
signalB2A(:,i,meas)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
Dtmp=[Dtmp tmpd];
if(length(indA)> ia) ia=ia+1; end
end
% if(indB(ib)==i)
% % This part could be improved by creating fully orthogonal sequences
% [tmpd, tmps]=genrandpskseq(N,M,amp);
% signalB2A(:,i)=tmps*2;
% signalA2B(:,i)=repmat(1+1j,76800,1);
% Db2a_T=[Db2a_T tmpd];
% if(length(indB)> ib) ib=ib+1; end
% end
end
Da2b_T=[Da2b_T; Dtmp];
%%------------Prepare the signals for B2A---------------%%
Dtmp=[];
for i=1:4
if(indB(ib)==i)
[tmpd, tmps]=genrandpskseq(N,M,amp);
signalB2A(:,i,meas)=tmps*2; %make sure LSB is 0 (switch=tx)
signalA2B(:,i,meas)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
Dtmp=[Dtmp tmpd];
if(length(indB)> ib) ib=ib+1; end
end
end
Db2a_T=[Db2a_T; Dtmp];
end
Da2b_R=zeros(Nmeas*120,Nantb*301);
Db2a_R=zeros(Nmeas*120,Nanta*301);
for meas=1:Nmeas
%% ------- Node A to B transmission ------- %%
oarf_send_frame(card,squeeze(signalA2B(:,:,meas)),n_bit);
%keyboard
sleep(0.01);
receivedA2B=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
sleep(0.01);
%%----------Node B to A transmission---------%%
oarf_send_frame(card,squeeze(signalB2A(:,:,meas)),n_bit);
%keyboard
sleep(0.01);
receivedB2A=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
%% ------- Do the A to B signal post preparation ------- %%
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((meas-1)*120+i+1,:)=vec(fblock);
end
%% ------- Do the B to A signal post preparation ------- %%
for i=0:119;
ifblock=receivedB2A(i*640+[1:640],indA);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Db2a_R((meas-1)*120+i+1,:)=fblock.';
end
end
%% estimate the noise
no_signal=repmat(1+1j,76800,4);
oarf_send_frame(card,no_signal,n_bit);
sleep(0.01);
noise_received=oarf_get_frame(card);
% estimate noise in frequency domain
noise_f = zeros(120,301,4);
for i=0:119;
ifblock=noise_received(i*640+[1:640],:);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
noise_f(i+1,:,:)=fblock;
end
%% ------- Do the A to B channel estimation ------- %%
HA2B=repmat(conj(Da2b_T),1,Nantb).*Da2b_R;
phasesA2B=mod(angle(HA2B),2*pi);
if(mean(var(phasesA2B))>0.5)
disp('The phases of your estimates from A to B are a bit high (larger than 0.5 rad.), something is wrong.');
end
DA2B=repmat(Da2b_T,1,Nantb);
chanestsA2B=reshape(diag(DA2B'*Da2b_R)./diag(DA2B'*DA2B),301,Nantb);
fchanestsA2B=[zeros(1,Nantb); chanestsA2B([1:150],:); zeros(210,Nantb); chanestsA2B(151:301,:)];
tchanestsA2B=ifft(fchanestsA2B);
%% ------- Do the B to A channel estimation ------- %%
if (chanest_full)
HB2A=zeros(120*Nmeas/10,301,Nantb);
for t=1:120*Nmeas/10
for ci=1:301;
data=Db2a_T((t-1)*10+1:t*10,ci+[0:Nantb-1]*301);
rec=Db2a_R((t-1)*10+1:t*10,ci);
HB2A(t,ci,:)=(inv(data'*data)*data'*rec).';
end
end
phasesB2A=mod(angle(HB2A),2*pi);
phasesB2A=reshape(phasesB2A,[],301*Nantb);
if(mean(var(phasesB2A))>0.5)
disp('The phases of your estimates from B to A are a bit high (larger than 0.5 rad.), something is wrong.');
end
chanestsB2A=zeros(301,Nantb);
for ci=1:301;
data=Db2a_T(:,ci+[0:Nantb-1]*301);
rec=Db2a_R(:,ci);
chanestsB2A(ci,:)=(inv(data'*data)*data'*rec).';
end
else
chanestsB2A=reshape(diag(Db2a_T'*repmat(Db2a_R,1,Nantb)/(Nmeas*60)),301,Nantb);
end
%fchanestsB2A=zeros(512,Nantb);
%for i=1:Nantb
% fchanestsB2A(:,i)=[0; chanestsB2A([1:150],i); zeros(210,1); chanestsB2A(151:301,i)];
%end
fchanestsB2A = [zeros(1,Nantb); chanestsB2A([1:150],:); zeros(210,Nantb); chanestsB2A(151:301,:)];
tchanestsB2A=ifft(fchanestsB2A);
%% -- Some plotting code -- %% (you can uncomment what you see fit)
received = [receivedA2B(:,indB) receivedB2A(:,indA)];
phases = phasesB2A;
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
fchanests = [chanestsA2B(:,:,end), chanestsB2A(:,:,end)];
clf
figure(1)
for i=1:size(received,2)
subplot(220+i);
plot(20*log10(abs(fftshift(fft(received(:,i))))));
ylim([20 140])
end
figure(2)
t=[0:512-1]/512*1e-2;
plot(t,20*log10(abs(tchanests)))
xlabel('time')
ylabel('|h|')
if Nantb==3
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
else
legend('A->B1','A->B2','B1->A','B2->A');
end
figure(3)
plot(20*log10(abs(fchanests)));
hold on
plot(squeeze(10*log10(mean(abs(noise_f(:,:,[indB indA])).^2,1))),'.');
hold off
ylim([40 100])
xlabel('freq')
ylabel('|h|')
if Nantb==3
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A','Noise B1','Noise B2','Noise B3','Noise A');
else
legend('A->B1','A->B2','B1->A','B2->A','Noise B1','Noise B2','Noise A');
end
if (0)
figure(4)
wndw = 50;
for i=1:5:Nantb*301 %# sliding window size
phamean = filter(ones(wndw,1)/wndw, 1, phases(:,i)); %# moving average
plot(phamean(wndw:end),'LineWidth',2);
title(['subcarrier ' num2str(i)]);
xlabel('time')
ylabel('phase')
ylim([-pi pi])
drawnow;
pause(0.1)
end
phavar=var(phases);
plotphavar=[];
for i=0:Nantb-1
plotphavar=[plotphavar; phavar([1:301]+i*301)];
end
plot([1:150 362:512],plotphavar,'o');
%ylim([0 pi])
xlabel('subcarrier')
ylabel('phase variance')
end
%% estimate F matrix assuming it is diagonal for sanity checking
Fhatloc = zeros(301,Nantb);
for s=1:301
ya=chanestsB2A(s,:);
yb=chanestsA2B(s,:);
Fhatloc(s,:)=(yb.*conj(ya))./(ya.*conj(ya));
end
figure(5)
plot_style={'rx','go','bs'};
hold off
for n=1:Nantb
plot((squeeze(Fhatloc(:,n))),plot_style{n})
hold on
end
axis([-2 2 -2 2])
%disp(squeeze(mean(Fhatloc,1)));
drawnow
else
error('You have to run init.params.m first!')
end
-254
View File
@@ -1,254 +0,0 @@
% Author: Mirsad Cirkic, Florian Kaltenberger
% Organisation: Eurecom (and Linkoping University)
% E-mail: mirsad.cirkic@liu.se
if(paramsinitialized)
disp(['\n\n------------\nThis code is, so far, only written for single runs. Multiple ' ...
'runs will overwrite the previous measurement data, i.e., the ' ...
'data structures are not defined for multiple runs. You will need to ' ...
'add code in order to save the intermediate measurements and the ' ...
'corresponding timestamps.\n------------'])
N=76800;
M=4;
indA=find(active_rfA==1);
indB=find(active_rfB==1);
Nanta=length(indA);
Nantb=length(indB);
%if(Nanta~=1)
% error('Node A can only have one antenna active\n');
%end
Niter=1;
if(Niter~=1)
error('We should only use one get_frame at each run.\n');
end
Nmeas = 10;
%% ------- Prepare the signals for A2B ---------- %%
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
ia=1; ib=1;
Da2b_T=[];
Db2a_T=[];
for i=1:4
if(indA(ia)==i)
[tmpd, tmps]=genrandpskseq(N,M,amp);
signalA2B(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
%signalB2A(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
Da2b_T = [Da2b_T tmpd];
if(length(indA)> ia) ia=ia+1; end
end
% if(indB(ib)==i)
% % This part could be improved by creating fully orthogonal sequences
% [tmpd, tmps]=genrandpskseq(N,M,amp);
% signalB2A(:,i)=tmps*2;
% signalA2B(:,i)=repmat(1+1j,76800,1);
% Db2a_T=[Db2a_T tmpd];
% if(length(indB)> ib) ib=ib+1; end
% end
end
%%------------Prepare the signals for B2A---------------%%
for i=1:4
if(indB(ib)==i)
[tmpd, tmps]=genrandpskseq(N,M,amp);
signalB2A(:,i)=tmps*2; %make sure LSB is 0 (switch=tx)
%signalA2B(:,i)=repmat(1+1j,76800,1); %make sure LSB is 1 (switch=rx)
Db2a_T=[Db2a_T tmpd];
if(length(indB)> ib) ib=ib+1; end
end
end
if (~chanest_full)
signalB2A(1:38400,3)=0;
signalB2A(38401:end,2)=0;
Db2a_T(1:60,302:end) = 0;
Db2a_T(61:end,1:301) = 0;
end
Da2b_R=zeros(Niter*120,Nantb*301,Nmeas);
Db2a_R=zeros(Niter*120,Nanta*301,Nmeas);
chanestsA2B=zeros(301,Nanta,Nantb,Nmeas);
tchanestsA2B=zeros(512,Nanta,Nantb,Nmeas);
fchanestsA2B=zeros(512,Nanta,Nantb,Nmeas);
chanestsB2A=zeros(301,Nanta,Nantb,Nmeas);
tchanestsB2A=zeros(512,Nanta,Nantb,Nmeas);
fchanestsB2A=zeros(512,Nanta,Nantb,Nmeas);
for meas=1:Nmeas
%% ------- Node A to B transmission ------- %%
oarf_send_frame(card,signalA2B,n_bit);
%keyboard
sleep(0.01);
receivedA2B=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
sleep(0.01);
%%----------Node B to A transmission---------%%
oarf_send_frame(card,signalB2A,n_bit);
%keyboard
sleep(0.01);
receivedB2A=oarf_get_frame(card);
%oarf_stop(card); %not good, since it does a reset
%% ------- Do the A to B channel estimation ------- %%
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:,meas)=vec(fblock);
end
if (chanest_full)
for ci=1:301;
data=Da2b_T(:,ci+[0:Nanta-1]*301);
rec=Da2b_R(:,ci+[0:Nantb-1]*301,meas);
chanestsA2B(ci,:,:,meas)=(inv(data'*data)*data'*rec).';
end
else
chanestsA2B(:,:,meas)=reshape(diag(repmat(Da2b_T,Niter,Nantb)'*Da2b_R(:,:,meas))/size(Da2b_T,1),301,Nantb);
end
fchanestsA2B(:,:,:,meas)=[zeros(1,Nanta,Nantb); chanestsA2B([1:150],:,:,meas); zeros(210,Nanta,Nantb); chanestsA2B(151:301,:,:,meas)];
tchanestsA2B(:,:,:,meas)=ifft(fchanestsA2B(:,:,:,meas));
%% ------- Do the B to A channel estimation ------- %%
for i=0:119;
ifblock=receivedB2A(i*640+[1:640],indA);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Db2a_R((Niter-1)*120+i+1,:,meas)=vec(fblock);
end
if (chanest_full)
for ci=1:301;
data=Db2a_T(:,ci+[0:Nantb-1]*301);
rec=Db2a_R(:,ci+[0:Nanta-1]*301,meas);
chanestsB2A(ci,:,:,meas)=(inv(data'*data)*data'*rec).';
end
else
chanestsB2A(:,:,meas)=reshape(diag(repmat(Db2a_T,Niter,1)'*repmat(Db2a_R(:,:,meas),1,Nantb)/(Niter*60)),301,Nantb);
end
fchanestsB2A(:,:,:,meas) = [zeros(1,Nanta,Nantb); chanestsB2A([1:150],:,:,meas); zeros(210,Nanta,Nantb); chanestsB2A(151:301,:,:,meas)];
tchanestsB2A(:,:,:,meas)=ifft(fchanestsB2A(:,:,:,meas));
end
%% -- Some plotting code -- %% (you can uncomment what you see fit)
received = [receivedB2A(:,indA) receivedA2B(:,indB)];
tchanests = [tchanestsA2B(:,:,end), tchanestsB2A(:,:,end)];
fchanests = [fchanestsA2B(:,:,end), fchanestsB2A(:,:,end)];
clf
if (0)
figure(1)
for i=1:size(received,2);
subplot(220+i);
plot(20*log10(abs(fftshift(fft(received(:,i))))));
ylim([20 140])
end
end
figure(2)
t=[0:512-1]/512*1e-2;
plot(t,20*log10(abs(tchanests)))
xlabel('time')
ylabel('|h|')
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
%legend('A->B1','A->B2','B1->A','B2->A');
figure(3)
plot(20*log10(abs(fchanests)));
ylim([40 100])
xlabel('freq')
ylabel('|h|')
legend('A->B1','A->B2','A->B3','B1->A','B2->A','B3->A');
%legend('A->B1','A->B2','B1->A','B2->A');
if (0)
figure(4)
wndw = 50;
for i=1:5:Nantb*301 %# sliding window size
phamean = filter(ones(wndw,1)/wndw, 1, phases(:,i)); %# moving average
plot(phamean(wndw:end),'LineWidth',2);
title(['subcarrier ' num2str(i)]);
xlabel('time')
ylabel('phase')
ylim([-pi pi])
drawnow;
pause(0.1)
end
phavar=var(phases);
plotphavar=[];
for i=0:Nantb-1
plotphavar=[plotphavar; phavar([1:301]+i*301)];
end
plot([1:150 362:512],plotphavar,'o');
%ylim([0 pi])
xlabel('subcarrier')
ylabel('phase variance')
end
figure(4);
for t=1
i=1;
for m=1:Nanta
for n=1:Nantb
subplot(Nanta,Nantb,i);
plot(20*log10(abs(fchanestsB2A(:,m,n,t))))
hold on
plot(20*log10(abs(fchanestsA2B(:,m,n,t))),'r')
ylim([0 80])
i=i+1;
end
end
end
figure(5)
for t=1
for m=1:Nanta
subplot(2,4,m);
Rb2a_comp = repmat(chanestsB2A(:,m,m,t)',120,1).*Db2a_R(:,(m-1)*301+(1:301),t);
plot(Rb2a_comp(:),'x');
subplot(2,4,4+m);
Ra2b_comp = repmat(chanestsA2B(:,m,m,t)',120,1).*Da2b_R(:,(m-1)*301+(1:301),t);
plot(Ra2b_comp(:),'rx');
end
end
if (0)
%% estimate F matrix assuming it is diagonal for sanity checking
Fhatloc = zeros(Nmeas,301,Nanta,Nantb);
for t=1:Nmeas
for s=1:301
for m=1:Nanta
for n=1:Nantb
ya=chanestsB2A(s,m,n,t);
yb=chanestsA2B(s,m,n,t);
Fhatloc(t,s,m,n)=(yb.*conj(ya))./(ya.*conj(ya));
end
end
end
end
figure(5)
plot_style={'rx','go','bs','kd'};
hold off
for m=1:Nanta
for n=1:Nantb
plot((squeeze(Fhatloc(:,:,m,n))),plot_style{m+(n-1)*2})
hold on
end
end
axis([-2 2 -2 2])
%disp(squeeze(mean(Fhatloc,2)));
end
else
error('You have to run init.params.m first!')
end
@@ -1,155 +0,0 @@
# % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se
if(paramsinitialized && LSBSWITCH_FLAG)
disp(["\n\n------------\nThis code is, so far, only written for single runs. Multiple " ...
"runs will overwrite the previous measurement data, i.e., the " ...
"data structures are not defined for multiple runs. You will need to " ...
"add code in order to save the intermediate measurements and the " ...
"corresponding timestamps.\n------------"])
N=76800;
M=4;
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
indA=find(active_rfA==1);
indB=find(active_rfB==1);
Nanta=length(indA);
Nantb=length(indB);
Niter=1;
Nofs=3840; % The offset in samples between the downlink and uplink sequences. It must be a multiple of 640, 3840 samples is 0.5 ms.
if(mod(Nofs,640)!=0) error("blabla") endif
if(Nanta!=1) error("Node A can only have one antenna active\n"); endif
if(Niter!=1) error("We should only use one get_frame at each run.\n"); endif
# %% ------- Prepare the signals for both A2B and B2A ------- %
maskA2B=kron(ones(1,N/(2*Nofs)),[ones(1,Nofs) zeros(1,Nofs)])';
maskB2A=ones(N,1)-maskA2B;
datamaskA2B=diag(kron(ones(1,N/(2*Nofs)),[ones(1,Nofs/640) zeros(1,Nofs/640)]));
datamaskB2A=eye(N/640)-datamaskA2B;
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
ia=1; ib=1;
Db2a_T=[];
for i=1:4
if(indA(ia)==i)
[tmpd, tmps]=generqpskseq(N,M,amp);
Da2b_T=datamaskA2B*tmpd;
signalA2B(:,i)=tmps*4.*maskA2B+maskB2A*sqrt(-1); %Added maskB2A to set the LSB correctly. The factor 4 there should make a 2 bit shift. Don't know if that is correct
if(length(indA)> ia) ia=ia+1; endif
endif
if(indB(ib)==i)
% This part could be improved by creating fully orthogonal sequences
[tmpd, tmps]=generqpskseq(N,M,amp);
signalB2A(:,i)=tmps*4.*maskB2A+maskA2B*sqrt(-1); %Added maskA2B to set the LSB correctly. The factor 4 there should make a 2 bit shift. Don't know if that is correct.
Db2a_T=[Db2a_T datamaskB2A*tmpd];
if(length(indB)> ib) ib=ib+1; endif
endif
endfor
signal = signalA2B+signalB2A;
# %% ------- Node B and A duplex transmission/reception ------- %%
rf_mode_current = rf_mode + (DMAMODE_TX+TXEN+DMAMODE_RX+RXEN)*active_rf;
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode_current,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode);
oarf_send_frame(card,signal,n_bit);
received=oarf_get_frame(card);
oarf_stop(card);
receivedA2B=received.*repmat(maskA2B,1,4);
receivedB2A=received.*repmat(maskB2A,1,4);
# %% ------- Do the A to B channel estimation ------- %%
Da2b_R=zeros(Niter*120,Nantb*301);
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:)=vec(fblock);
endfor
HA2B=repmat(conj(Da2b_T),1,Nantb).*Da2b_R;
phasesA2B=unwrap(angle(HA2B));
if(mean(var(phasesA2B))>0.5)
disp("The phases of your estimates are a bit high (larger than 0.5 rad.), something is wrong.");
endif
chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb);
fchanestsA2B=zeros(512,Nantb);
for i=1:Nantb
fchanestsA2B(:,i)=[0; chanestsA2B([1:150],i); zeros(210,1); chanestsA2B(151:301,i)];
endfor
tchanestsA2B=ifft(fchanestsA2B);
%% ------- Do the B to A channel estimation ------- %%
Db2a_R=zeros(Niter*120,Nanta*301);
for i=0:119;
ifblock=receivedB2A(i*640+[1:640],indA);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Db2a_R((Niter-1)*120+i+1,:)=fblock.';
endfor
HB2A=conj(repmat(Db2a_T,Niter,1)).*repmat(Db2a_R,1,Nantb);
phasesB2A=unwrap(angle(HB2A));
if(mean(var(phasesB2A))>0.5)
disp("The phases of your estimates are a bit high (larger than 0.5 rad.), something is wrong.");
endif
chanestsB2A=reshape(diag(repmat(Db2a_T,Niter,1)'*repmat(Db2a_R,1,Nantb)/(Niter*120)),301,Nantb);
# %% -- Some plotting code -- %% (you can uncomment what you see fit)
# clf
# figure(1)
# for i=1:4
# subplot(220+i);plot(20*log10(abs(fftshift(fft(receivedA2B(:,i))))));
# endfor
# figure(2)
# t=[0:512-1]/512*1e-2;
# plot(t,abs(tchanests))
# xlabel('time')
# ylabel('|h|')
# figure(3)
# % wndw = 50;
# % for i=1:5:Nantb*301 %# sliding window size
# % phamean = filter(ones(wndw,1)/wndw, 1, phases(:,i)); %# moving average
# % plot(phamean(wndw:end),'LineWidth',2);
# % title(['subcarrier ' num2str(i)]);
# % xlabel('time')
# % ylabel('phase')
# % ylim([-pi pi])
# % drawnow;
# % pause(0.1)
# % endfor
# phavar=var(phases);
# plotphavar=[];
# for i=0:Nantb-1
# plotphavar=[plotphavar; phavar([1:301]+i*301)];
# endfor
# plot([1:150 362:512],plotphavar,'o');
# %ylim([0 pi])
# xlabel('subcarrier')
# ylabel('phase variance')
# figure(4)
# plot(20*log10(abs(fchanests))), ylim([40 100])
# %end
# fprintf(' done\n')
# for i=0:(Nantb-1)
# fchanests(:,i+1)=[0; chanests(301*i+[1:150]); zeros(210,1); chanests(301*i+[151:301])];
# endfor
# tchanests=ifft(fchanests);
else
if(!LSBSWITCH_FLAG) error("You have to set the LSB switch flag (LSBSWITCH_FLAG) in initparams.m.\n")
else error("You have to run init.params.m first!")
endif
endif
@@ -1,157 +0,0 @@
# % Author: Mirsad Cirkic
# % Organisation: Eurecom (and Linkoping University)
# % E-mail: mirsad.cirkic@liu.se
if(paramsinitialized && ~LSBSWITCH_FLAG)
disp(["\n\n------------\nThis code is, so far, only written for single runs. Multiple " ...
"runs will overwrite the previous measurement data, i.e., the " ...
"data structures are not defined for multiple runs. You will need to " ...
"add code in order to save the intermediate measurements and the " ...
"corresponding timestamps.\n------------"])
N=76800;
M=4;
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
indA=find(active_rfA==1);
indB=find(active_rfB==1);
Nanta=length(indA);
Nantb=length(indB);
#%i f(Nanta!=1) error("Node A can only have one antenna active\n"); endif
Niter=1;
if(Niter!=1) error("We should only use one get_frame at each \
run.\n");
endif
# %% ------- Prepare the signals for both A2B and B2A ------- %%
signalA2B=zeros(N,4);
signalB2A=zeros(N,4);
ia=1; ib=1;
Db2a_T=[];
for i=1:4
if(indA(ia)==i)
[Da2b_T, tmps]=generqpskseq(N,M,amp);
%tmps(1024:2048) = 0;
signalA2B(:,i)=tmps;
if(length(indA)> ia) ia=ia+1; endif
endif
if(indB(ib)==i)
% This part could be improved by creating fully orthogonal sequences
[tmpd, tmps]=generqpskseq(N,M,amp);
%tmps(1024:2048) = 0;
signalB2A(:,i)=tmps;
Db2a_T=[Db2a_T tmpd];
if(length(indB)> ib) ib=ib+1; endif
endif
endfor
# %% ------- Node B to A transmission ------- %%
rf_mode_current = rf_mode + (DMAMODE_TX+TXEN)*active_rfB +(DMAMODE_RX+RXEN)*active_rfA;
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode_current,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode);
oarf_send_frame(card,signalB2A,n_bit);
#% keyboard
receivedB2A=oarf_get_frame(card);
oarf_stop(card);
# %% ------- Node A to B transmission ------- %%
rf_mode_current = rf_mode + (DMAMODE_TX+TXEN)*active_rfA +(DMAMODE_RX+RXEN)*active_rfB;
oarf_config_exmimo(card, freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNB_flag,rf_mode_current,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal_mode);
oarf_send_frame(card,signalA2B,n_bit);
%keyboard
receivedA2B=oarf_get_frame(card);
oarf_stop(card);
# %% ------- Do the A to B channel estimation ------- %%
Da2b_R=zeros(Niter*120,Nantb*301);
for i=0:119;
ifblock=receivedA2B(i*640+[1:640],indB);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Da2b_R((Niter-1)*120+i+1,:)=vec(fblock);
endfor
HA2B=repmat(conj(Da2b_T),1,Nantb).*Da2b_R;
phasesA2B=unwrap(angle(HA2B));
if(mean(var(phasesA2B))>0.5)
disp("The phases of your estimates are a bit high (larger than 0.5 rad.), something is wrong.");
endif
chanestsA2B=reshape(diag(repmat(Da2b_T,1,Nantb)'*Da2b_R)/size(Da2b_T,1),301,Nantb);
fchanestsA2B=zeros(512,Nantb);
for i=1:Nantb
fchanestsA2B(:,i)=[0; chanestsA2B([1:150],i); zeros(210,1); chanestsA2B(151:301,i)];
endfor
tchanestsA2B=ifft(fchanestsA2B);
%% ------- Do the B to A channel estimation ------- %%
Db2a_R=zeros(Niter*120,Nanta*301);
for i=0:119;
ifblock=receivedB2A(i*640+[1:640],indA);
ifblock(1:128,:)=[];
fblock=fft(ifblock);
fblock(1,:)=[];
fblock(151:360,:)=[];
Db2a_R((Niter-1)*120+i+1,:)=fblock.';
Db2a_R((Niter-1)*120+i+1,:)=fblock.';
endfor
HB2A=conj(repmat(Db2a_T,Niter,1)).*repmat(Db2a_R,1,Nantb);
phasesB2A=unwrap(angle(HB2A));
if(mean(var(phasesB2A))>0.5)
disp("The phases of your estimates are a bit high (larger than 0.5 rad.), something is wrong.");
endif
chanestsB2A=reshape(diag(repmat(Db2a_T,Niter,1)'*repmat(Db2a_R,1,Nantb)/(Niter*120)),301,Nantb);
# %% -- Some plotting code -- %% (you can uncomment what you see fit)
# clf
# figure(1)
# for i=1:4
# subplot(220+i);plot(20*log10(abs(fftshift(fft(receivedA2B(:,i))))));
# endfor
# figure(2)
# t=[0:512-1]/512*1e-2;
# plot(t,abs(tchanests))
# xlabel('time')
# ylabel('|h|')
# figure(3)
# % wndw = 50;
# % for i=1:5:Nantb*301 %# sliding window size
# % phamean = filter(ones(wndw,1)/wndw, 1, phases(:,i)); %# moving average
# % plot(phamean(wndw:end),'LineWidth',2);
# % title(['subcarrier ' num2str(i)]);
# % xlabel('time')
# % ylabel('phase')
# % ylim([-pi pi])
# % drawnow;
# % pause(0.1)
# % endfor
# phavar=var(phases);
# plotphavar=[];
# for i=0:Nantb-1
# plotphavar=[plotphavar; phavar([1:301]+i*301)];
# endfor
# plot([1:150 362:512],plotphavar,'o');
# %ylim([0 pi])
# xlabel('subcarrier')
# ylabel('phase variance')
# figure(4)
# plot(20*log10(abs(fchanests))), ylim([40 100])
# %end
# fprintf(' done\n')
# for i=0:(Nantb-1)
# fchanests(:,i+1)=[0; chanests(301*i+[1:150]); zeros(210,1); chanests(301*i+[151:301])];
# endfor
# tchanests=ifft(fchanests);
else
if(LSBSWITCH_FLAG) error("You have to unset the LSB switch flag (LSBSWITCH_FLAG) in initparams.m.\n")
else error("You have to run init.params.m first!")
endif
endif
@@ -1,45 +0,0 @@
% PURPOSE : channel estimation using least square method
%% ARGUMENTS :
%
% m_sym_T : transmitted symbol, d_N_f x d_N_ofdm x d_N_ant_act x d_N_meas
% m_sym_R : received symbol, d_N_f x d_N_ofdm x d_N_ant_act x d_N_meas
% d_N_meas : number of measurements
%
% OUTPUTS :
%
% m_H_est : estimation of sub-channels, d_N_antR x d_N_antT x d_N_f x d_N_meas
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "runmeas_full_duplex" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function m_H_est = f_ch_est(m_sym_T, m_sym_R)
%% ** initialisation **
[d_N_f,d_N_OFDM,d_N_antT,d_N_meas] = size(m_sym_T);
d_N_antR = size(m_sym_R,3);
m_H_est = zeros(d_N_antR,d_N_antT,d_N_f,d_N_meas);
%% ** estimate the subband channel for each measurement and antenna **
for d_n_meas = 1:d_N_meas
for d_n_f = 1:d_N_f
m_y = reshape(m_sym_R(d_n_f,:,:,d_n_meas),d_N_OFDM,d_N_antR).'; % squeeze: problem for antenna number = 1 case
m_s = reshape(m_sym_T(d_n_f,:,:,d_n_meas),d_N_OFDM,d_N_antT).';
m_H_est(:,:,d_n_f,d_n_meas) = m_y*m_s'/(m_s*m_s'); % LS channel estimation
end
end
end
@@ -1,46 +0,0 @@
%
% PURPOSE : OFDM Receiver
%
% ARGUMENTS :
%
% m_sig_R : received signal with dimension ((d_N_FFT+d_N_CP)*d_N_ofdm) x d_N
% d_N_FFT : total carrier number
% d_N_CP : extented cyclic prefix
% d_N_OFDM : OFDM symbol number per frame
% v_active_rf : active RF antenna indicator
%
% OUTPUTS :
%
% m_sym_R : transmitted signal before IFFT with dimension d_N_f x d_N_ofdm x d_N_ant_act
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "genrandpskseq" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function m_sym_R = f_ofdm_rx(m_sig_R, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf)
d_N_ant_act = sum(v_active_rf);
m_sig_R_eff = m_sig_R(:,find(v_active_rf));
m_sig_R_f = reshape(m_sig_R_eff,(d_N_FFT+d_N_CP),d_N_OFDM,d_N_ant_act);
%** delete the CP **
m_sig_R_noCP = m_sig_R_f(d_N_CP+1:end,:,:);
%** fft **
m_sym_R_fft = 1/sqrt(d_N_FFT)*fft(m_sig_R_noCP,d_N_FFT,1);
%m_sym_R_fft = fft(m_sig_R_noCP,d_N_FFT,1);
m_sym_R = m_sym_R_fft([363:512 2:151],:,:);
end
@@ -1,59 +0,0 @@
%
% PURPOSE : OFDM Transmitter
%
% ARGUMENTS :
%
% d_M : modulation order
% d_N_f : carrier number carrying data
% d_N_FFT : total carrier number
% d_N_CP : extented cyclic prefix
% d_N_OFDM : OFDM symbol number per frame
% v_active_rf : active RF antenna indicator
% d_amp : amplitude
%
% OUTPUTS :
%
% m_sym_T : transmitted signal before IFFT with dimension d_N_f x d_N_OFDM x d_N_ant_act
% m_sig_T : OFDM signal with dimension ((d_N_FFT+d_N_CP)*d_N_OFDM) x d_N_ant
%
%**********************************************************************************************
% EURECOM - All rights reserved
%
% AUTHOR : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% Apr-29-2014 X. JIANG 0.1 creation of code
%
% REFERENCES/NOTES/COMMENTS :
%
% - Based on the function "genrandpskseq" created by Mirsad Cirkic, Florian Kaltenberger.
%
%**********************************************************************************************
function [m_sym_T, m_sig_T] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rf, d_amp)
d_N_ant_act = sum(v_active_rf);
%** constellation table **
v_MPSK = exp(sqrt(-1)*([1:d_M]*2*pi/d_M+pi/d_M));
%** transmitted symbol **
%v_state = [1;2;3;4];
%rand("state",v_state);
m_sym_T = v_MPSK(ceil(rand(d_N_f, d_N_OFDM, d_N_ant_act)*d_M));
%** mapping useful data to favorable carriers **
m_sym_T_ext = zeros(d_N_FFT,d_N_OFDM,d_N_ant_act);
m_sym_T_ext(2:151,:,:) = m_sym_T(151:300,:,:);
m_sym_T_ext(363:512,:,:) = m_sym_T(1:150,:,:);
%** ifft **
m_sig_T_ = sqrt(d_N_FFT)*ifft(m_sym_T_ext,d_N_FFT,1);
%** add cyclic prefix **
m_sig_T_ = [m_sig_T_(end-d_N_CP+1:end,:,:); m_sig_T_];
d_L = (d_N_FFT+d_N_CP)*d_N_OFDM;
m_sig_T = floor(reshape(m_sig_T_,d_L,d_N_ant_act)*d_amp);
end
-110
View File
@@ -1,110 +0,0 @@
%
% SCRIPT ID : s_H_est
%
% PROJECT NAME : TDD Recoprocity
%
% PURPOSE : full transmission and receive train for calibration channel estimation
%
%**********************************************************************************************
% Eurecom - All rights reserved
%
% AUTHOR(s) : Xiwen JIANG, Florian Kaltenberger
%
% DEVELOPMENT HISTORY :
%
% Date Name(s) Version Description
% ----------- ------------- ------- ------------------------------------------------------
% May-11-2015 X. JIANG 0.1 script creation v0.1
%
% REFERENCES/NOTES/COMMENTS :
%
%**********************************************************************************************
%% ** initialisation **
clc
close all
clear all
s_init_params;
d_M = 4; % modulation order, e.g. 4 means QPSK
%%** frequency **
d_N_f = 300; % carrier number carrying data
d_N_FFT = 512; % total carrier number
d_N_CP = 128; % extented cyclic prefix
%%** time **
d_N_OFDM = 120; % number of ofdm symbol per frame
d_N_meas = 10; % measuement number
%%** antenna **
d_N_antA = 4; % antenna number at site a
d_N_antB = 4; % antenna number at site b
v_indA = find(v_active_rfA); % active antenna index at site a
v_indB = find(v_active_rfB); % active antenna index at site b
d_amp = pow2(12);
%% ----------------------------------------------------
m_sym_TA = zeros(d_N_f,d_N_OFDM,length(v_indA),d_N_meas);
m_sym_TB = zeros(d_N_f,d_N_OFDM,length(v_indA),d_N_meas);
m_sym_RB = zeros(d_N_f,d_N_OFDM,length(v_indB),d_N_meas);
m_sig_TA = zeros((d_N_CP+d_N_FFT)*d_N_OFDM,d_N_antA);
m_sig_TB = zeros((d_N_CP+d_N_FFT)*d_N_OFDM,d_N_antB);
%** simulation**
for d_n_meas = 1:d_N_meas
%% -------- tx --------
%** tx of site A **
[m_sym_TA(:,:,:,d_n_meas), m_sig_TA_] = f_ofdm_tx(d_M, d_N_f, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfA, d_amp);
%% -------- channel --------
%** Transmission from A to B **
m_sig_TA(:,v_indA)= m_sig_TA_*2; %affect the LSB to 0 to set on Tx mode
m_sig_TB(:,v_indB)= 1+1i*ones(size(m_sig_TB,1),length(v_indB)); %affect the LSB to 1 to set on Rx mode
oarf_send_frame(cardB,m_sig_TB,d_n_bit);
oarf_send_frame(cardA,m_sig_TA,d_n_bit);
m_sig_R = oarf_get_frame(cardA);
m_sig_RB = m_sig_R(1:d_N_OFDM*(d_N_FFT+d_N_CP),d_N_antA+1:d_N_antA+d_N_antB);
sleep(0.1);
%% -------- rx --------
m_sym_RB(:,:,:,d_n_meas) = f_ofdm_rx(m_sig_RB, d_N_FFT, d_N_CP, d_N_OFDM, v_active_rfB);
end
%keyboard;
%** channel estimation **
m_H_est_A2B_f = f_ch_est(m_sym_TA, m_sym_RB); %dimension: d_N_antR x d_N_antT x d_N_f x d_N_meas
m_H_est_A2B_ = zeros(length(v_indB),length(v_indA),d_N_FFT,d_N_meas);
m_H_est_A2B_(:,:,[2:151 363:512],:) = m_H_est_A2B_f(:,:,[151:300 1:150],:);
m_H_est_A2B_t = ifft(m_H_est_A2B_,[],3);
%% -------- plot --------
%** channel estimation in frequency domain **
m_H_A2B_draw_f = squeeze(m_H_est_A2B_f(1,:,:,1)).';
m_H_A2B_draw_t = squeeze(m_H_est_A2B_t(1,:,:,1)).';
figure(1)
plot(real(m_sig_RB(1:1000,v_indB)),'b-');
title('received signal at site B (time domain)')
figure(2)
plot(m_sym_RB(100,:,1,1),'*')
title('Demodulated symboles at site B')
figure(3)
plot(abs(m_H_A2B_draw_t))
title('Impulse Response')
figure(4)
subplot(2,1,1)
plot(20*log10(abs(m_H_A2B_draw_f)),'-');
title('|h| vs. freq (A2B)')
xlabel('freq')
ylabel('|h|')
ylim([0 100])
subplot(2,1,2)
plot(angle(m_H_A2B_draw_f),'-');
title('angle(h) vs. freq (A2B)')
xlabel('freq')
ylabel('angle(h)')
@@ -1,57 +0,0 @@
clear all
close all
addpath([getenv('OPENAIR_TARGETS') '/ARCH/EXMIMO/USERSPACE/OCTAVE']);
%% -------- ExpressMIMO2 configuration --------
limeparms;
cardA = 0;
cardB = 1;
v_active_rfA = [1 0 0 0];
v_active_rfB = [1 0 0 0];
fc = 1907600000; %3500000000; %fc = 859.5e6; %fc = 2660000000;
freq_rxA = fc*v_active_rfA;
freq_txA = freq_rxA; %+1.92e6;
freq_rxB = fc*v_active_rfB;
freq_txB = freq_rxB; %+1.92e6;
tdd_config = DUPLEXMODE_FDD+TXRXSWITCH_LSB; %we need the LSB switching for the woduplex script, otherwise we don't receive anything
rx_gainA = 10*v_active_rfA;%[0 0 0 3];
tx_gainA = 10*v_active_rfA;%[20 20 20 20]
rx_gainB = 10*v_active_rfB;
tx_gainB = 10*v_active_rfB;
syncmodeA = SYNCMODE_MASTER;
syncmodeB = SYNCMODE_SLAVE;
eNB_flag = 0;
resampling_factorA = [2 2 2 2];%2*v_active_rfA;
resampling_factorB = [2 2 2 2];%2*v_active_rfB;
rf_modeA = (TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * v_active_rfA;
rf_rxdcA = rf_rxdc*v_active_rfA;
rf_vcocalA = rf_vcocal_19G*v_active_rfA;
rf_local = [8254744 8255063 8257340 8257340]; %eNB2tx 1.9GHz
rffe_rxg_lowA = 31*v_active_rfA;
rffe_rxg_finalA = 63*v_active_rfA;
rffe_bandA = B19G_TDD*v_active_rfA;
autocal_modeA = v_active_rfA;
oarf_stop(cardA);
%oarf_stop_without_reset(cardA);
sleep(0.1);
oarf_config_exmimo(cardA,freq_rxA,freq_txA,tdd_config,syncmodeA,rx_gainA,tx_gainA,eNB_flag,rf_modeA,rf_rxdcA,rf_local,rf_vcocalA,rffe_rxg_lowA,rffe_rxg_finalA,rffe_bandA,autocal_modeA,resampling_factorA);
rf_modeB = (TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM+DMAMODE_TX+TXEN+DMAMODE_RX+RXEN) * v_active_rfB;
rf_rxdcB = rf_rxdc*v_active_rfB;
rf_vcocalB = rf_vcocal_19G*v_active_rfB;
rffe_rxg_lowB = 31*v_active_rfB;
rffe_rxg_finalB = 63*v_active_rfB;
rffe_bandB = B19G_TDD*v_active_rfB;
autocal_modeB = v_active_rfB;
oarf_stop(cardB);
%oarf_stop_without_reset(cardB);
sleep(0.1);
oarf_config_exmimo(cardB,freq_rxB,freq_txB,tdd_config,syncmodeB,rx_gainB,tx_gainB,eNB_flag,rf_modeB,rf_rxdcB,rf_local,rf_vcocalB,rffe_rxg_lowB,rffe_rxg_finalB,rffe_bandB,autocal_modeB,resampling_factorB);
d_n_bit = 16;