From dc440717cdc3a0a0eba1884a2989dc5a289bd3f0 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Tue, 10 Nov 2015 02:37:09 +0100 Subject: [PATCH] added fixes for controlling bandrich UE remotely --- cmake_targets/autotests/test_case_list.xml | 38 +++--- .../tools/configure_cots_bandrich_ue.py | 118 ++++++++++++++++++ cmake_targets/autotests/tools/search_repl.py | 32 +++++ .../autotests/tools/wdial.bandrich.conf | 36 ++++++ cmake_targets/tools/build_helper | 5 +- 5 files changed, 212 insertions(+), 17 deletions(-) create mode 100644 cmake_targets/autotests/tools/configure_cots_bandrich_ue.py create mode 100644 cmake_targets/autotests/tools/search_repl.py create mode 100644 cmake_targets/autotests/tools/wdial.bandrich.conf diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 906bee963a..0163918520 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1,11 +1,11 @@ -stevens calisson nano +stevens calisson amerique /mnt/sradio/TEST_RESULTS https://gitlab.eurecom.fr/oai/openairinterface5g.git https://gitlab.eurecom.fr/oai/openair-cn.git feature-34-test_framework - develop + feature-17-test_framework oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* ltebox* @@ -750,20 +750,24 @@ calisson stevens - nano + amerique oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* ltebox* - 300 + 60 /tmp targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code 1 - targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf mobile_country_code 2 - targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf mobile_network_code 9 + targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf mobile_country_code 208 + targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf mobile_network_code 92 + targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.remote.conf tracking_area_code 1 + targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.remote.conf mobile_country_code 208 + targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.remote.conf mobile_network_code 92 + targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.remote.conf mme_ip_address ({ipv4="192.168.12.26";ipv6="192:168:30::17";active="yes";preference="ipv4";}) $OPENAIR_DIR/cmake_targets/build_oai --eNB -w USRP $OPENAIR_DIR/cmake_targets/lte_build_oai/build/lte-softmodem - - iperf + -O $OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.remote.conf + iperf -s @@ -776,17 +780,19 @@ --eNB -w USRP - $OPENAIR_DIR/cmake_targets/lte_build_oai/build/lte-softmodem + $OPENAIR_DIR/cmake_targets/autotests/tools/configure_cots_bandrich_ue --stop-ue ; $OPENAIR_DIR/cmake_targets/autotests/tools/configure_cots_bandrich_ue --start-ue - iperf + ping 192.172.0.1 /tmp - BUILD/EPC/epc.local.enb.conf.in MCC 7 - BUILD/EPC/epc.local.enb.conf.in MNC 8 - BUILD/EPC/epc.local.enb.conf.in TAC 9 + BUILD/EPC/epc.local.enb.conf.in MCC 208 + BUILD/EPC/epc.local.enb.conf.in MNC 92 + BUILD/EPC/epc.local.enb.conf.in TAC 1 + BUILD/EPC/epc.local.enb.conf.in PGW_INTERFACE_NAME_FOR_SGI eth1 + BUILD/EPC/epc.local.enb.conf.in PGW_IPV4_ADDRESS_FOR_SGI 192.168.12.82/24 SCRIPTS/build_epc -c -l SCRIPTS/build_hss @@ -794,11 +800,11 @@ - SCRITPTS/run_epc -l + /opt/ltebox/tools/stop_ltebox ; /opt/ltebox/tools/start_ltebox - SCRIPTS/run_hss -l + /opt/hss_sim0609/starthss - iperf + iperf -s diff --git a/cmake_targets/autotests/tools/configure_cots_bandrich_ue.py b/cmake_targets/autotests/tools/configure_cots_bandrich_ue.py new file mode 100644 index 0000000000..6408ef5aee --- /dev/null +++ b/cmake_targets/autotests/tools/configure_cots_bandrich_ue.py @@ -0,0 +1,118 @@ +import time +import serial +import os +from pyroute2 import IPRoute +import sys +import re +import threading +import signal +import traceback + +# configure the serial connections (the parameters differs on the device you are connecting to) +serial_port = '/dev/ttyUSB2' +bandrich_ppd_config = '$OPENAIR_DIR/cmake_targets/autotests/tools/wdial.bandrich.conf' + +exit_flag=0 + +def signal_handler(signal, frame): + print('You pressed Ctrl+C!') + print('Resetting the UE to detached state') + timeout=10 + exit_flag=1 + send_command('AT+CGATT=0' , 'OK' , timeout) + sys.exit(0) + +signal.signal(signal.SIGINT, signal_handler) + +ser = serial.Serial( + port=serial_port, + #baudrate=9600, + #parity=serial.PARITY_ODD, + #stopbits=serial.STOPBITS_TWO, + #bytesize=serial.EIGHTBITS +) + +#ser.open() +#ser.isOpen() + +class pppThread (threading.Thread): + def __init__(self, threadID, name, counter): + threading.Thread.__init__(self) + self.threadID = threadID + self.name = name + self.counter = counter + def run(self): + print "Starting " + self.name + #Here we keep running pppd thread in indefinite loop as this script terminates sometimes + #while 1: + while 1: + time.sleep(5) #Hard coded, do not reduce this number! + print "Starting wvdial now..." + print 'exit_flag = ' + str(exit_flag) + send_command('AT+CGATT=1','OK', 300) + os.system('wvdial -C ' + bandrich_ppd_config + '' ) + if exit_flag == 1: + print "Exit flag set to true. Exiting pppThread now" + print "Terminating wvdial now..." + +def send_command (cmd, response, timeout): + count=0 + sleep_duration = 1 + while count <= timeout: + ser.write (cmd + '\r\n') + out = '' + time.sleep(sleep_duration) + count = count + sleep_duration + while ser.inWaiting() > 0: + out += ser.read(1) + print 'out = <' + out + '> response = <' + response + '> \n' + if re.search(response, out): + break + + + +def start_ue () : + #print 'Enter your commands below.\r\nInsert "exit" to leave the application.' + timeout=60 #timeout in seconds + send_command('AT', 'OK' , timeout) + send_command('AT+CGATT=0' , 'OK' , timeout) + send_command('AT+CGATT=1','OK', 300) + #os.system('wvdial -C ' + bandrich_ppd_config + ' &' ) + + thread_ppp = pppThread(1, "ppp_thread", 1) + thread_ppp.start() + + iface='ppp0' + + while 1: + time.sleep ( 2) + #Now we check if ppp0 interface is up and running + try: + if exit_flag == 1: + break + ip = IPRoute() + idx = ip.link_lookup(ifname=iface)[0] + os.system ('route add 192.172.0.1 ppp0') + break + except Exception, e: + error = ' Interface ' + iface + 'does not exist...' + error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e) + error = error + traceback.format_exc() + print error + + thread_ppp.join() + +def stop_ue(): + timeout=60 + os.system('killall wvdial') + send_command('AT', 'OK' , timeout) + send_command('AT+CGATT=0' , 'OK' , timeout) + +for arg in sys.argv[1:]: + if arg == '--start-ue' : + start_ue() + elif arg == '--stop-ue' : + stop_ue() + else : + print " Script called with wrong arguments, arg = " + arg + sys.exit() diff --git a/cmake_targets/autotests/tools/search_repl.py b/cmake_targets/autotests/tools/search_repl.py new file mode 100644 index 0000000000..9c49bcc4e5 --- /dev/null +++ b/cmake_targets/autotests/tools/search_repl.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +import sys +import re + +#Arg 1 name of file +#Arg 2 keyword +#arg 3 replacement text +#Note that these should be seperated by spaces +if len(sys.argv) != 4: + print "search_repl.py: Wrong number of arguments. This program needs 3 arguments" + sys.exit() +filename = sys.argv[1] +keyword = sys.argv[2] +replacement_text = sys.argv[3] + +file = open(filename, 'r') +string = file.read() +file.close() + + +if keyword == 'mme_ip_address': + #string = (re.sub(r"mme_ip_address\s*=\s*\([^\$]+)\)\s*;\s*", r"<% tex \1 %>", t, re.M) + replacement_text = keyword + ' = ' + replacement_text + ' ; ' + string = re.sub(r"mme_ip_address\s*=\s*\(([^\$]+?)\)\s*;", replacement_text, string, re.M) +else : + replacement_text = keyword + ' = \" ' + replacement_text + '\" ; ' + string = re.sub(r"%s\s*=\s*\"([^\$]+?)\"\s*;" % keyword , replacement_text, string, re.M) + +file = open(filename, 'w') +file.write(string) +file.close() + diff --git a/cmake_targets/autotests/tools/wdial.bandrich.conf b/cmake_targets/autotests/tools/wdial.bandrich.conf new file mode 100644 index 0000000000..e1b64568f9 --- /dev/null +++ b/cmake_targets/autotests/tools/wdial.bandrich.conf @@ -0,0 +1,36 @@ +[Dialer Defaults] +Modem = /dev/ttyUSB0 +ISDN = off +Modem Type = Analog Modem +Baud = 9600 +Init = ATZ +Init2 = AT+CPIN? +Init3 = AT+CGREG? +Init4 = AT+COPS? +Init5 = AT+CSQ +Init6 = +Init7 = AT+CGATT=1 +Init8 = +Init9 = +Phone = *99***1# +Phone1 = +Phone2 = +Phone3 = +Phone4 = +Dial Prefix = +Dial Attempts = 1 +Dial Command = ATM1L3DT +Ask Password = off +Password = '' +Username = ImaginLab +Auto Reconnect = off +Abort on Busy = off +Carrier Check = on +Check Def Route = on +Abort on No Dialtone = on +Stupid Mode = on +Idle Seconds = 0 +Auto DNS = on +;Minimize = off +;Dock = off +;Do NOT edit this file by hand! diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index d45f0fedbc..d58d7018ed 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -256,7 +256,9 @@ check_install_oai_software() { python \ subversion \ xmlstarlet \ - python-pip + python-pip \ + pydb \ + wvdial $SUDO update-alternatives --set liblapack.so /usr/lib/atlas-base/atlas/liblapack.so if [ `lsb_release -rs` = '12.04' ] ; then install_nettle_from_source @@ -265,6 +267,7 @@ check_install_oai_software() { $SUDO apt-get install -y libgnutls-dev nettle-dev nettle-bin fi $SUDO pip install paramiko + $SUDO pip install pyroute2 install_asn1c_from_source }