Commit Graph

51 Commits

Author SHA1 Message Date
Vadim Yanitskiy cbd3d76df9 fake_trx/burst_fwd.py: drop useless set_slot() method
Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
2018-02-28 22:33:35 +07:00
Vadim Yanitskiy 7881fd6001 fake_trx/data_msg.py: use a single unified constructor
There are no message specific initialization parts, excepting
the header specific fields setting. Let's us a common constructor,
dropping custom fields from its arguments.

Change-Id: I13a3e4b2f6a1f443ebe7d809df62736e3c43f56f
2018-02-28 15:18:16 +07:00
Vadim Yanitskiy d93c1debb0 fake_trx/data_dump.py: fix python3 compatibility
There is no 'file' type in Python3 anymore, so let's reverse the
condition in DATADumpFile constructor. Also, the tag definition
was incorrect: both '\x01' and b'\x01' aren't the same.

Change-Id: Ib00c7f0bd5871fcfce931a4bfa501ae5bf797c45
2018-02-28 15:08:58 +07:00
Vadim Yanitskiy 77492b7926 fake_trx/data_msg.py: fix python3 compatibility in tests
In Python3 a range has it's own type, so its comparasion with
a list is incorrect. Let's explicitly convert both bit ranges
to lists in the bit conversation tests.

Change-Id: I98c40d3d63cbcdc3e5dc840ebf8d7310c5c08e56
2018-02-28 02:47:54 +07:00
Vadim Yanitskiy f35413691d fake_trx/burst_fwd.py: use DATAMSG transformation API
As the DATAMSG classes were introduced, let's use them.
This approach abstracts one from dealing with raw bytes.

Also, now BurstForwarder randomizes both RSSI and ToA values,
as this feature is supported from-the-box by the DATAMSG_TRX2L1.

Change-Id: Ib15018eab749150e244914dab4b6e433ce0c9209
2018-02-27 07:08:47 +07:00
Vadim Yanitskiy 615faadcfb fake_trx/data_msg.py: implement message transformation API
This change introduces two new methods, which allow to perform
L12TRX <-> TRX2L1 message type transformations.

Change-Id: Ic99cf74baa1864bf20a8fc0fc025604bc160084c
2018-02-27 06:49:07 +07:00
Vadim Yanitskiy 24e30142aa fake_trx/udp_link.py: set SO_REUSEADDR socket option
Setting this option allows one to reuse existing connections,
for example, by injecting CTRL commands or DATA bursts into
existing connections between fake_trx.py and trxcon.

Change-Id: I0882c76affa9a668a12d10967081054d2b666ed1
2018-02-27 04:57:58 +07:00
Vadim Yanitskiy 23446011af fake_trx/udp_link.py: drop useless UDPLink.loop() API
So far, this API is not used anywhere. Let's drop it.

Change-Id: I87ea2436f0b6bbeb62fe17700af48a048be143bb
2018-02-27 04:50:28 +07:00
Vadim Yanitskiy e5480d2c2b fake_trx/udp_link.py: close socket in destructor
Previously it was required to call the UDPLink.shutdown() method
manually in order to close a socket. Let's do this automatically
using the destructor of UDPLink.

Change-Id: I59c3dc61ec58cd9effeb789947d28fd602ca91f4
2018-02-27 04:40:28 +07:00
Harald Welte 05ea7248f8 trxcon|fake_trx: change default TRX port number to 6700
In order to avoid clashes with OsmoTRX, which may be also
running on the same host, let's use a different port range
starting from 6700 by default.

This idea was introduced as a result of OS#2984.

Change-Id: I66b5f25aaba3b836448ed29839c39869b5622bed
Related: OS#2984
2018-02-23 17:02:20 +07:00
Vadim Yanitskiy 318f8b78aa fake_trx/data_dump.py: use 2 bytes to store message length
One byte may store a value in range [0x00, 0xff]. The maximal 0xff
value is 255 in dec, so a message length is limited to 255 bytes.
This is enough for GSM bursts, but not for EDGE.

Since this change, two bytes of header are used to store the
pending message length. All captures created before are not
supported anymore...

Change-Id: I5a69d5cf2914fe56b2f9acca6054c9470627f91e
2018-02-20 19:43:02 +07:00
Vadim Yanitskiy d406afd23e fake_trx/burst_send.py: implement DATA capture support
Previously, this tool was only able to read a hand-crafted text
file with bursts and send them via the DATA interface. This is
not so useful...

This change implements support of reading DATA capture files,
which can be generated e.g. by trx_sniff.py or burst_gen.py.
Both standart input (stdio) and text-files are not supported
anymore.

Usage example:

  ./burst_send.py -m L1 -i capture.bin --timeslot 2

Change-Id: I626662bd1897c874421ab5178970ec19325f8a47
2018-02-20 19:29:00 +07:00
Vadim Yanitskiy 711e2f256e fake_trx/burst_gen.py: add burst capture support
Now all generated bursts can be also written to a capture file,
using a new option called '--output-file'. If a file already
exists, bursts would be appended to the end. Otherwise a new
capture file is created.

Change-Id: I074ff7dbc4d6beecdecce20de9dade5939e707f2
2018-02-20 18:19:48 +07:00
Vadim Yanitskiy 3dfd6cbae5 fake_trx/trx_sniff.py: use DATADumpFile for capture writing
Since we have a separate class for DATA capture management now,
no need to implement the wheel - let's just use it!

Change-Id: I7c30bcea294ce7270bf905ae5420a06dbc2e46f1
2018-02-20 18:02:35 +07:00
Vadim Yanitskiy afd110a3b5 fake_trx: implement classes for DATA capture menagement
This change introduces the following classes:

  - DATADump - basic class, which contains methods to generate
    and parse the a message header, and some constants.

  - DATADumpFile - a child class, which contains methods to
    write and parse DATA messages from capture files.

Usage example:

  # Open a capture file
  ddf = DATADumpFile("capture.bin")

  # Parse the 10th message
  msg = ddf.parse_msg(10)
  msg.fn = 100
  msg.tn = 0

  # Append one to the end of the capture
  ddf.append_msg(msg)

Change-Id: I1b31183bd7bcca94de089847ee0b2f4ec88a7f1d
2018-02-20 17:48:29 +07:00
Vadim Yanitskiy 041bfc0b03 fake_trx/burst_send.py: handle both GSM and EDGE bursts
Previously, it was expected that burst length should be equal
to 148. Let's also handle EDGE bursts and use GSM constants.

Change-Id: Iab13dd06f175556137c5e25d2cbddb9bea403b09
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy 630cc5a367 fake_trx/burst_send.py: also handle RSSI and ToA values
Change-Id: Idb9a5ae4a8980a320f6e620c66add7c7393d3ecb
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy e3a23102b7 fake_trx/burst_gen.py: also handle RSSI and ToA values
Change-Id: I7c9441c1154c925dcb5c743e39445495233c123e
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy d273ebf611 fake_trx: use DATAMSG classes for DATA messages
The DATAMSG API, that was introduced and extended a few commits
before, provides all required methods to create, validate,
generate and parse DATA messages. Let's use it now.

Change-Id: Ibc99126dc05d873c1ba538a5f4e74866de563f56
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy 263ccef268 fake_trx/burst_gen.py: don't store RandBurstGen
No need to keep it as a class member.

Change-Id: I5bf5846c2b8fa1211cf5150545b9d001c17fa0eb
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy b84699096a fake_trx/burst_gen.py: check argv separately
Change-Id: I35b5475d3b6df6dc92a1981c693afb63df866c87
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy d9553faf62 fake_trx/data_msg.py: implement header description
This change introduces a new method for both types of messages
called 'desc_hdr', that generates human-readable header
description.

Examples:

  TRX -> L1: fn=571353 tn=1 rssi=-108 toa=-0.53
  L1 -> TRX: fn=1777477 tn=3 pwr=161

Change-Id: Iafe63e39ad68f4ff373ae098424d76ca9f83c8fc
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy 475ece7182 fake_trx/data_msg.py: handle bursts properly
One L1 -> TRX message carries one to be transmitted burst encoded
as regular bits (0 or 1). One TRX -> L1 message carries one
received burst encoded as unsigned soft-bits (0..254).

This shall be noted during message encoding and decoding process.
Also, we shall distinguish between GSM and EDGE bursts.

Change-Id: I909b7a4dc70e8c632987bde07f00281a6595c4cb
2018-01-29 04:19:01 +07:00
Vadim Yanitskiy 8c79e2ce6b fake_trx/data_msg.py: implement header randomization
This feature could be used by both burst_gen.py and burst_send.py.

Change-Id: I724e267382ff32ef1f964b1ee6cbe99069139867
2018-01-29 04:18:56 +07:00
Vadim Yanitskiy f10a8d4c92 fake_trx: implement classes for DATA messages
This change introduces three new classes:

  - DATAMSG - abstract class, defines common fields and methods
    for any message on DATA interface, e.g. frame and timeslot
    numbers, bit conversation methods, etc.

  - DATAMSG_L12TRX - a child of DATAMSG, defines a message
    coming from L1 to TRX.

  - DATAMSG_TRX2L1 - a child of DATAMSG, defines a message
    coming from TRX to L1.

Both child classes could be used to generate DATA messages from
known fields (i.e. fn, tn, etc.), and parse them back from
already encoded DATA messages.

Change-Id: Id1c72f0b18fb128acc74d0cd899fb7aab7bd8790
2018-01-29 04:14:34 +07:00
Vadim Yanitskiy 5da2ac7197 fake_trx: share and use common GSM constants
Previously there were multiple definitions of some common GSM
constants in different modules. Let's share them.

Change-Id: Id6cdfbc6e8688755a0df7e44daa512c9afa7dad2
2018-01-29 03:49:35 +07:00
Vadim Yanitskiy ab7eb390cb fake_trx: implement a new tool for TRX protocol sniffing
This change introduces a new tool, which could be used to sniff a
single connection between L1 and TRX in both directions, filter
captured bursts by direction, timeslot and/or frame number, and
finally write them to a binary file for further analysis.

Sniffing capability is based on Scapy framework, so it should
be installed in order to run this tool. Please also note,
that sniffing requires root access. For details, see:

https://github.com/secdev/scapy
https://scapy.readthedocs.io/en/latest/

Usage example:

  sudo ./trx_sniff --frame-count 30 --timeslot 2 -o /tmp/bursts

This command will capture 30 frames on timeslot number 2, and
write them to a binary file. The format of this file is based
on TLV (Tag Length Value), that wraps each burst:

  ... |-TAG (byte)-|-LEN (byte)-|-BURST (LEN bytes)-| ...

  TAG 0x01 - a message coming from L1 to TRX
  TAG 0x02 - a message coming from TRX to L1

Change-Id: I6e65e1d657574cc3e67bc7cdb1c01ef6bf08ecde
2018-01-21 02:13:47 +06:00
Vadim Yanitskiy 32462cfd62 fake_trx/burst_send.py: indicate actual burst source
Change-Id: I7e45996f4a7a2aacc962ff9b65107c6b04e7bf68
2018-01-20 16:44:19 +06:00
Vadim Yanitskiy af217395cc fake_trx: don't sent clock indications until POWERON
Change-Id: I86ccc9d26fc54e6511f74f858afdaebb2b284c19
2017-12-09 01:25:52 +07:00
Vadim Yanitskiy 26ecb9460e fake_trx/clck_gen.py: reset the clck_src when calling stop()
Change-Id: I1043f71a2cbe856a0cb605db8a7feab9defa6afd
2017-12-09 01:24:05 +07:00
Vadim Yanitskiy 05ff6b0667 fake_trx/clck_gen.py: send the first indication immediately
Change-Id: I0132dd939b02db357d248abf65c9116d6a1802d0
2017-12-09 01:22:24 +07:00
Vadim Yanitskiy 04aecc7f8d fake_trx: correct brief descriptions of files
Change-Id: Ie76fee4a567681a5380be90e5744621c2aa3e5f0
2017-11-21 18:39:11 +07:00
Vadim Yanitskiy eb56da3743 fake_trx: implement a new tool for burst sending
This change introduces a new tool for sending existing bursts from
file or standard input either to L1 (OsmoBTS or OsmocomBB) or to
TRX (OsmoTRX and GR-GSM TRX).

Change-Id: I2c542583252d31daac466e6c7837317fda8a7020
2017-11-21 18:25:48 +07:00
Vadim Yanitskiy 3a395740d3 fake_trx/burst_gen.py: remove unused import
Change-Id: I407877e2025663f706d1a2f93e6228770bfc253c
2017-11-21 17:42:51 +07:00
Vadim Yanitskiy 826c515f4e fake_trx/README: correct the branch name
Change-Id: I9d65580570d9bced65a7bcc95ca073ecc3e130e5
2017-11-21 17:42:19 +07:00
Vadim Yanitskiy be7825d983 fake_trx/ctrl_cmd.py: add help and basic command line options
Sometimes it's important to use different CTRL port, for example
when OsmoTRX is running at the same time. This change adds the
corresponding command line options and help message.

Change-Id: Ic6eeb69d9a1fc151eab2e63f3708e3d70e2e558b
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f28f0d343f fake_trx: whitespace fix
Change-Id: Iad2be36777e4a2454e181c856c7902574a4ab20c
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy a59edfbd40 fake_trx: separate DataInterface from burst_gen.py
Change-Id: I325cf2ae59ef8834c2ddfb67206eede44d1e0acf
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 1e9501671a fake_trx: add options to specify fn, tn and pwr
Change-Id: Ifd4f4864707596a69fece11218a4800b98551c31
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 539e9a1f18 fake_trx: add a new tool for burst generation
This change introduces a new tool named 'burst_gen.py'. One can
be used for sending GSM bursts either to L1 (OsmoBTS or OsmocomBB)
or to TRX (OsmoTRX and GR-GSM TRX). Currently it is only possible
to send random bursts of different types: NB, FB, SB, AB.

Change-Id: Ie14281222d29536b8690517e57af2a1007fcbc91
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy d497bc8288 fake_trx: add copyright message to clck_gen.py and ctrl_cmd.py
Change-Id: Ia79279dd9e85d131d66d790f1f3fd64fb1914f58
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 4fa6694006 fake_trx: don't send clock indications to mobile stations
Clock indications are only required for BTS, while MS can
obtain current frame number from messages on DATA interface.

Change-Id: Id2993847a3581cac0d355850ad09ceabc6116d3f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 538bea917b fake_trx: fix compatibility with Python 3
Change-Id: Idce0c631aa3fcd20092a3773558570e442b2fec8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 87e5f67f66 fake_trx: implement simple freq. filter
Change-Id: Ifbeaebeaf68a88c07a05b672502f503ab7b890f2
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b4da181c39 fake_trx: handle SETSLOT command from BB
Change-Id: I152486377ecd6777dbae7024e5d12cfdbcb17628
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 02996abeda fake_trx: implement power measurement emulation
This change introduces a new class named FakePM, which is intended
to generate pseudo-random power levels for base stations and noise
levels inactive frequencies.

Also, there is a new command in BB CTRL, which instructs transceiver
to perform a power measurement on requested frequency. As we work in
virtual Um-interface, a FakePM instance is used to provide some fake
power levels.

Change-Id: If48c12fd0b1ba10e1cf76559b359e17a1256617d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e39bb0f0d1 fake_trx/ctrl_if.py: allow adding custom params to response
Change-Id: I551bb425c25a5c978801d9e1e033b4ba352e259f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ef31f1bff2 fake_trx/ctrl_cmd.py: print response to stdout
Change-Id: Icdbb1802b81eddf42786fafcf96200a60db3cc24
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 798e2b148c fake_trx: fix copy-paste error
Change-Id: I9a6b294ad3501aa26d92667a995d08ca3be03da4
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy a692cacdfc fake_trx/burst_fwd.py: append two unused bytes at the end
Change-Id: I1d7ed076d93b37699520ee2a31c42c177f966865
2017-11-19 17:35:07 +07:00