This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/6766 fake_trx: separate DataInterface from burst_gen.py Change-Id: I325cf2ae59ef8834c2ddfb67206eede44d1e0acf --- M src/target/fake_trx/burst_gen.py A src/target/fake_trx/data_if.py 2 files changed, 108 insertions(+), 81 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/66/6766/1 diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py index fb50ea3..f8f924c 100755 --- a/src/target/fake_trx/burst_gen.py +++ b/src/target/fake_trx/burst_gen.py @@ -28,8 +28,8 @@ import select import sys -from udp_link import UDPLink from rand_burst_gen import RandBurstGen +from data_if import DATAInterface COPYRIGHT = \ "Copyright (C) 2017 by Vadim Yanitskiy <axilirator at gmail.com>\n" \ @@ -37,86 +37,6 @@ "<http://gnu.org/licenses/gpl.html>\n" \ "This is free software: you are free to change and redistribute it.\n" \ "There is NO WARRANTY, to the extent permitted by law.\n" - -class DATAInterface(UDPLink): - # GSM PHY definitions - GSM_HYPERFRAME = 2048 * 26 * 51 - - def send_l1_msg(self, burst, - tn = None, fn = None, rssi = None): - # Generate random timeslot index if not preset - if tn is None: - tn = random.randint(0, 7) - - # Generate random frame number if not preset - if fn is None: - fn = random.randint(0, self.GSM_HYPERFRAME) - - # Generate random RSSI if not preset - if rssi is None: - rssi = -random.randint(-75, -50) - - # Prepare a buffer for header and burst - buf = [] - - # Put timeslot index - buf.append(tn) - - # Put frame number - buf.append((fn >> 24) & 0xff) - buf.append((fn >> 16) & 0xff) - buf.append((fn >> 8) & 0xff) - buf.append((fn >> 0) & 0xff) - - # Put RSSI - buf.append(rssi) - - # HACK: put fake TOA value - buf += [0x00] * 2 - - # Put burst - buf += burst - - # Put two unused bytes - buf += [0x00] * 2 - - # Send message - self.send(bytearray(buf)) - - def send_trx_msg(self, burst, - tn = None, fn = None, pwr = None): - # Generate random timeslot index if not preset - if tn is None: - tn = random.randint(0, 7) - - # Generate random frame number if not preset - if fn is None: - fn = random.randint(0, self.GSM_HYPERFRAME) - - # Generate random power level if not preset - if pwr is None: - pwr = random.randint(0, 34) - - # Prepare a buffer for header and burst - buf = [] - - # Put timeslot index - buf.append(tn) - - # Put frame number - buf.append((fn >> 24) & 0xff) - buf.append((fn >> 16) & 0xff) - buf.append((fn >> 8) & 0xff) - buf.append((fn >> 0) & 0xff) - - # Put transmit power level - buf.append(pwr) - - # Put burst - buf += burst - - # Send message - self.send(bytearray(buf)) class Application: # Application variables diff --git a/src/target/fake_trx/data_if.py b/src/target/fake_trx/data_if.py new file mode 100644 index 0000000..315281c --- /dev/null +++ b/src/target/fake_trx/data_if.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- + +# Simple tool to send custom messages via TRX DATA interface, +# which may be also useful for fuzzing and testing +# +# (C) 2017 by Vadim Yanitskiy <axilirator at gmail.com> +# +# All Rights Reserved +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import random + +from udp_link import UDPLink + +class DATAInterface(UDPLink): + # GSM PHY definitions + GSM_HYPERFRAME = 2048 * 26 * 51 + + def send_l1_msg(self, burst, + tn = None, fn = None, rssi = None): + # Generate random timeslot index if not preset + if tn is None: + tn = random.randint(0, 7) + + # Generate random frame number if not preset + if fn is None: + fn = random.randint(0, self.GSM_HYPERFRAME) + + # Generate random RSSI if not preset + if rssi is None: + rssi = -random.randint(-75, -50) + + # Prepare a buffer for header and burst + buf = [] + + # Put timeslot index + buf.append(tn) + + # Put frame number + buf.append((fn >> 24) & 0xff) + buf.append((fn >> 16) & 0xff) + buf.append((fn >> 8) & 0xff) + buf.append((fn >> 0) & 0xff) + + # Put RSSI + buf.append(rssi) + + # HACK: put fake TOA value + buf += [0x00] * 2 + + # Put burst + buf += burst + + # Put two unused bytes + buf += [0x00] * 2 + + # Send message + self.send(bytearray(buf)) + + def send_trx_msg(self, burst, + tn = None, fn = None, pwr = None): + # Generate random timeslot index if not preset + if tn is None: + tn = random.randint(0, 7) + + # Generate random frame number if not preset + if fn is None: + fn = random.randint(0, self.GSM_HYPERFRAME) + + # Generate random power level if not preset + if pwr is None: + pwr = random.randint(0, 34) + + # Prepare a buffer for header and burst + buf = [] + + # Put timeslot index + buf.append(tn) + + # Put frame number + buf.append((fn >> 24) & 0xff) + buf.append((fn >> 16) & 0xff) + buf.append((fn >> 8) & 0xff) + buf.append((fn >> 0) & 0xff) + + # Put transmit power level + buf.append(pwr) + + # Put burst + buf += burst + + # Send message + self.send(bytearray(buf)) -- To view, visit https://gerrit.osmocom.org/6766 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I325cf2ae59ef8834c2ddfb67206eede44d1e0acf Gerrit-PatchSet: 1 Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>