Commit 91967123 authored by Kirill Smelkov's avatar Kirill Smelkov

amari.drb: Start tracking current bitrate in per-cell UE transmission state

We will need to know current cell DL/UL bitrate for multicell BitSync in
the next patches.
parent 26a82c6e
......@@ -231,6 +231,7 @@ class _UCtx: # UE transmission state on particular cell
__slots__ = (
'tx',
'retx',
'bitrate',
'rank',
'xl_use_avg',
)
......@@ -267,8 +268,10 @@ def add(s, ue_stats, stats, init=False):
uc.tx = cell['%s_tx' % s.dir] # in transport blocks
uc.retx = cell['%s_retx' % s.dir] # ----//----
uc.bitrate = cell['%s_bitrate' % s.dir] # bits/s
assert uc.tx >= 0, uc.tx
assert uc.retx >= 0, uc.retx
assert uc.bitrate >= 0, uc.bitrate
uc.rank = cell['ri'] if s.use_ri else 1
uc.xl_use_avg = scell['%s_use_avg' % s.dir]
......@@ -305,10 +308,14 @@ def add(s, ue_stats, stats, init=False):
u.qtx_bytes[qci] = u.qtx_bytes.get(qci,0) + etx_bytes
# debug
if 0 and s.dir == 'dl' and (etx_bytes != 0 or uc.tx != 0 or uc.retx != 0) and qci==9:
if 0 and \
s.dir == 'dl' and ( \
etx_bytes != 0 or \
uc.tx != 0 or uc.retx != 0 or uc.bitrate != 0 \
) and qci==9:
sfnx = ((t // tti) / 10) % 1024 # = SFN.subframe
_debug('% 4.1f ue%s %s .%d: etx_total_bytes: %d +%5d tx: %2d retx: %d ri: %d bitrate: %d' % \
(sfnx, ue_id, s.dir, qci, etx_total_bytes, etx_bytes, uc.tx, uc.retx, uc.rank, cell['%s_bitrate' % s.dir]))
(sfnx, ue_id, s.dir, qci, etx_total_bytes, etx_bytes, uc.tx, uc.retx, uc.rank, uc.bitrate))
# gc non-live erabs
for erab_id in set(ue.erab_flows.keys()):
......
......@@ -37,7 +37,7 @@ class Etx:
# UE represents one entry about an UE in ue_get[stats].ue_list .
class UE:
def __init__(ue, ue_id, tx, retx, *etxv, ri=1):
def __init__(ue, ue_id, tx, retx, *etxv, ri=1, bitrate=None):
for _ in etxv:
assert isinstance(_, Etx)
ue.ue_id = ue_id
......@@ -45,6 +45,7 @@ class UE:
ue.retx = retx
ue.etxv = etxv
ue.ri = ri
ue.bitrate = bitrate if bitrate is not None else tx*1000
# tSampler provides testing environment for _Sampler.
#
......@@ -104,6 +105,7 @@ class _tUEstats:
'ri': ue.ri,
'zz_tx': ue.tx,
'zz_retx': ue.retx,
'zz_bitrate': ue.bitrate,
}
],
'erab_list': erab_list,
......@@ -149,10 +151,11 @@ def S(tx_bytes, tx_time_tti):
# UCtx is shortcut to create _UCtx.
def UCtx(tx, rank, xl_use_avg):
def UCtx(tx, bitrate, rank, xl_use_avg):
uc = _UCtx()
uc.tx = tx
uc.retx = 0
uc.bitrate = bitrate
uc.rank = rank
uc.xl_use_avg = xl_use_avg
return uc
......@@ -372,11 +375,10 @@ def test_BitSync():
txv_out = []
xv_out = []
bitsync = _BitSync()
for x, (tx_bytes, tx) in enumerate(txv_in):
for bitrate, (tx_bytes, tx) in enumerate(txv_in):
u = _Utx()
u.qtx_bytes = None # bitsync itself does not use .qtx_bytes
u.cutx = {1: UCtx(tx, 1, 0.1)}
u.qtx_bytes = x # XXX hack - see ^^^
u.cutx = {1: UCtx(tx, bitrate, 1, 0.1)}
_ = bitsync.next(10*tti, tx_bytes, u)
for (δt, tx_bytes, u_) in _:
assert δt == 10*tti
......@@ -385,7 +387,7 @@ def test_BitSync():
uc_ = u_.cutx[1]
assert uc_.retx == 0
txv_out.append((tx_bytes, uc_.tx))
xv_out .append(u_.qtx_bytes)
xv_out .append(uc_.bitrate)
_ = bitsync.finish()
for (δt, tx_bytes, u_) in _:
......@@ -395,7 +397,7 @@ def test_BitSync():
uc_ = u_.cutx[1]
assert uc_.retx == 0
txv_out.append((tx_bytes, uc_.tx))
xv_out .append(u_.qtx_bytes)
xv_out .append(uc_.bitrate)
xv_out = ''.join(chr(ord('a')+_) for _ in xv_out)
assert xv_out == 'abcdefghijklmnopqrstuvwxyz'[:len(txv_in)]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment