summaryrefslogtreecommitdiffstats
path: root/src/target/trx_toolkit/burst_gen.py
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-03-21 13:46:34 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-04-04 17:14:26 +0000
commit55afe0072b435a0d9abc2db934ec9f17d4fb07dd (patch)
tree4024840f040ee162659d1ef404e7707cbbee1212 /src/target/trx_toolkit/burst_gen.py
parent9d90d1907b9d1013a07ef7a9c187f16bc29129fb (diff)
trx_toolkit: Add cmdline arg to set bind addr
Previous hardcoded default of 0.0.0.0 was inappropiate in some scenarios, as it sets the SRC addr of the packets sent through the socket based on the routing. For instance, if iface IF1 has assigned two IP addresses A and B, A being the first addr of the interface, and osmo-bts-trx is configured with "osmotrx ip local A" and "osmotrx ip remote B", the following happens: CMD POWER OFF src=A:5801 dst=B:5701 RSP POWER OFF src=A:5701 dst=A:5701 <-- A is assigned as src addr. But osmo-bts-trx is waiting for packets from B:5701, and the packet is dropped with ICMP Unreachable. If addr binding is forced in fake_trx to B, then everthing's fine. Let's extend the UDPLink in order to allow manual, but optional setting of bind address, and add a corresponding cmdline argument to all executables. Change-Id: I7be18fef40967fb7551f4115f22cbbd9cdb0840d
Diffstat (limited to 'src/target/trx_toolkit/burst_gen.py')
-rwxr-xr-xsrc/target/trx_toolkit/burst_gen.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/target/trx_toolkit/burst_gen.py b/src/target/trx_toolkit/burst_gen.py
index 4bc036ea..d83f1378 100755
--- a/src/target/trx_toolkit/burst_gen.py
+++ b/src/target/trx_toolkit/burst_gen.py
@@ -39,6 +39,7 @@ from data_msg import *
class Application:
# Application variables
remote_addr = "127.0.0.1"
+ bind_addr = "0.0.0.0"
base_port = 5700
conn_mode = "TRX"
output_file = None
@@ -70,11 +71,11 @@ class Application:
def run(self):
# Init DATA interface with TRX or L1
if self.conn_mode == "TRX":
- self.data_if = DATAInterface(self.remote_addr,
- self.base_port + 2, self.base_port + 102)
+ self.data_if = DATAInterface(self.remote_addr, self.base_port + 2,
+ self.bind_addr, self.base_port + 102)
elif self.conn_mode == "L1":
- self.data_if = DATAInterface(self.remote_addr,
- self.base_port + 102, self.base_port + 2)
+ self.data_if = DATAInterface(self.remote_addr, self.base_port + 102,
+ self.bind_addr, self.base_port + 2)
# Init random burst generator
burst_gen = RandBurstGen()
@@ -149,6 +150,7 @@ class Application:
" -o --output-file Write bursts to a capture file\n" \
" -m --conn-mode Send bursts to: TRX (default) / L1\n" \
" -r --remote-addr Set remote address (default %s)\n" \
+ " -b --bind-addr Set local address (default %s)\n" \
" -p --base-port Set base port number (default %d)\n\n"
s += " Burst generation\n" \
@@ -161,7 +163,7 @@ class Application:
" --toa Set ToA in symbols (default random)\n" \
" --toa256 Set ToA in 1/256 symbol periods\n"
- print(s % (self.remote_addr, self.base_port))
+ print(s % (self.remote_addr, self.bind_addr, self.base_port))
if msg is not None:
print(msg)
@@ -169,12 +171,13 @@ class Application:
def parse_argv(self):
try:
opts, args = getopt.getopt(sys.argv[1:],
- "o:m:r:p:b:c:f:t:h",
+ "o:m:r:b:p:b:c:f:t:h",
[
"help",
"output-file="
"conn-mode=",
"remote-addr=",
+ "bind-addr=",
"base-port=",
"burst-type=",
"burst-count=",
@@ -200,6 +203,8 @@ class Application:
self.conn_mode = v
elif o in ("-r", "--remote-addr"):
self.remote_addr = v
+ elif o in ("-b", "--bind-addr"):
+ self.bind_addr = v
elif o in ("-p", "--base-port"):
self.base_port = int(v)