Commit Graph

357 Commits

Author SHA1 Message Date
Jacob Erlbeck 8e323b39f9 edge: Set the EGPRS window parameters
Currently the GPRS parameters are used, which is ok for the WS but
not for the SNS.

This commit uses RLC_EGPRS_SNS and RLC_EGPRS_MIN_WS for the window
configuration.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:13 +01:00
Jacob Erlbeck 869449cdd0 edge: Move EGPRS setup from setup_tbf to tbf_alloc_ul_tbf
Currently the EGPRS mode is enabled in setup_tbf depending on the
values of egprs_ms_class and bts->egprs_enabled (both must be != 0).
This makes it difficult to set different values (like window
parameters) depending on the direction.

This commit moved the initialisation part to tbf_alloc_ul_tbf und
just leaves the setting of the ms_class to setup_tbf.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:13 +01:00
Jacob Erlbeck a3a567e765 rlc: Add constructor to window classes
Currently the gprs_rlc_dl_window and gprs_rlc_ul_window do not have
constructors, but need to get initialized explicitly.

This commit adds constructors to both classes and removes explicit
external initialization code.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:12 +01:00
Jacob Erlbeck e8f5fe5255 tbf: Refactor parts of extract_tlli into set_tlli_from_ul
Currently gprs_rlcmac_tbf::extract_tlli takes care of decoding and
the TBF update. These are really different things and doing the
decoding in extract_tlli makes EGPRS support more complex.

This commit moves the TBF state related part into a new method
gprs_rlcmac_tbf::set_tlli_from_ul.

Sponsored-by: On-Waves ehf
2015-12-16 19:37:49 +01:00
Jacob Erlbeck 5265f59525 edge: Enable EGPRS if configured and egprs_ms_class present
Enable the TBF to use EGPRS if the bts->egprs_enabled config variable
has been set via the VTY "egprs" command and if the MS has signaled a
EGPRS multislot class.

Tell the MS to use EGPRS if the condition above holds.

Note that this will cause the MS to use EGPRS RLC block formats for
further messages which are not yet understood by the PCU.

Sponsored-by: On-Waves ehf
2015-12-15 15:19:42 +01:00
Jacob Erlbeck 86b6f05d19 edge: Support EGPRS multislot class handling in tbf_alloc
Add an egprs_ms_class argument to the allocation functions and
set/pass it where necessary.

Sponsored-by: On-Waves ehf
2015-12-15 15:17:51 +01:00
Jacob Erlbeck 5643f35fb4 edge: Add m_egprs_enabled and related methods to TBF
Add the following methods to gprs_rlcmac_tbf:
  - is_egprs_enabled
  - enable_egprs
  - disable_egprs

Also show the value of the flag in name() by displaying "EGPRS" if
it is set.

Sponsored-by: On-Waves ehf
2015-12-15 15:17:51 +01:00
Jacob Erlbeck 76d767cbe8 edge: Support EGPRS in packet uplink assignment message
Currently the Encoding::write_packet_uplink_assignment method only
supports the GPRS variant of the message.

This commit adds the missing EGPRS variant to the encoder.

Sponsored-by: On-Waves ehf
2015-11-30 12:20:36 +01:00
Jacob Erlbeck 7c8d39a67b poll: Count failed procedures
When a timeout has occured several times, the procedures handled by
poll_timeout are aborted. This happens when the number of repetitions
exceed N3105. Currently only the timeouts themselves are counted.

This commits adds counters that are incremented if a procedure has
really failed.

New counter:
- rlc.ass.failed:   Count failing UL and DL assigments via PACCH
- rlc.ack.failed:   Count failing DL Ack/Nack requests

Sponsored-by: On-Waves ehf
2015-09-07 14:10:35 +02:00
Jacob Erlbeck 91ff7d1864 tbf: Refactor reuse_tbf into releasing and DL TBF establishment
Currently reuse_tbf (partly) resets the old DL TBF and uses its PACCH
to establish a new DL TBF. The method can not be used with UL TBFs.

This commit replaces the reuse_tbf method into a
gprs_rlcmac_dl_tbf:release method which triggers the TBF's timer
based deletion (so that the TFI is still reserved for some time) and
a gprs_rlcmac_tbf::establish_dl_tbf_on_pacch which can establish DL
TBFs on existing PACCHs of either DL or UL TBFs.

Sponsored-by: On-Waves ehf
2015-09-01 11:49:04 +02:00
Jacob Erlbeck 9659d59307 tbf: Keep the old MS object alive in extract_tlli
Currently when a second MS object has been created for an MS, because
the TLLI was not known yet, the will be detected in
gprs_rlcmac_tbf::extract_tlli and the two objects will be merged by
update_ms. But when the dl_tbf is moved from the old to the new
(second) MS object, the old MS object can get idle and be removed
before the object are merged. This can cause LLC frame loss when the
MS object is deleted immediately after getting idle (no timeout
configured).

This commit adds a guard to keep the MS object until extract_tlli has
been executed.

Sponsored-by: On-Waves ehf
2015-09-01 11:48:26 +02:00
Jacob Erlbeck cf6ae9d12f Revert "tbf: Do not kill DL TBF on Packet Resource Request"
This reverts commit e91bd3babd.

That commit seems to cause hanging DL TBFs when there was a RACH
based UL TBF establishment while it that TBF is active. This could be
caused by the use of a different PDCH for the SBA.

Conflicts:
	tests/tbf/TbfTest.cpp
	tests/tbf/TbfTest.err
2015-09-01 11:48:25 +02:00
Jacob Erlbeck 16d29c7da4 tbf: Add logging for polling
This commit adds the relevant frame number to the "poll timeout"
logging message. In addition, logging is added to the places where
poll_fn gets set.

The goal is to track down the source for frequent "poll timeout"
messages.

Sponsored-by: On-Waves ehf
2015-08-28 12:23:07 +02:00
Jacob Erlbeck b6b3c7eb27 tbf: Use explicit initialisations in constructor (Coverity)
Currently when allocating tbf_alloc_ul_tbf or tbf_alloc_dl_tbf
objects, the allocated memory area is pre-initialised by talloc_zero
before the C++ constructors are called. This is not recognised by
Coverity, since there is no talloc model file yet. Thus Coverity
complains about missing initialisers.

On the other hand, it is still planned to convert the TBF classes
into real C++ ones. So instead of silencing Coverity directly, this
is an opportunity to do it the C++ way.

This commit adds initialisers and initialisation code for all
members that relied on talloc_zero. The corresponding calls to
talloc_zero are replaced by calls to talloc to give ASAN/valgrind
a chance to detect future initialisation errors. Some initialisation
code is also moved from setup_tbf to the constructors, notably the
initialisation of the bts pointer.

Fixes: Coverity CID 1320604, 1320605, 1320606

Sponsored-by: On-Waves ehf
2015-08-28 12:07:14 +02:00
Jacob Erlbeck 6835cead8c ms: Store references to replaced TBFs in the MS object
Currently when calling GprsMs::attach_tbf and a TBF of the same
direction already exists, the old TBF gets detached from the MS
object.

Therefore that TBF object loses access to that MS object including
for instance TLLI and IMSI.

This leads to failing DL TBF reuses, since the downlink assigment
cannot be sent on the PACCH later on because that must be sent on the
old DL TBF which ms() is NULL and the new DL TBF cannot be retrieved.

This commit fixes this bug by changing the GprsMs implementation to
keep a list of replaced (old) TBFs. TBFs are only removed when they
are being detached explicitely (see tbf_free and set_ms).

Addresses:
tbf.cpp:741 We have a schedule for downlink assignment at uplink
TBF(TFI=1 TLLI=0xf35a680e DIR=UL STATE=RELEASING), but there is no
downlink TBF

Sponsored-by: On-Waves ehf
2015-08-24 12:23:50 +02:00
Jacob Erlbeck 444bc82081 tbf: Use C++/talloc magic to support TBF constructors/destructors
The TBF object are currently created by using talloc_zero/talloc_free
directly from plain functions. Therefore C++ constructors and destructors
are not called. So the only initialisation that is done is setting
every member to 0. Non POD members do not have their constructors
called either, which makes it impossible to use the current LListHead
class for real members when the LListHead::m_back member has to be set.

This commit changes the TBF allocation functions to call the
corresponding C++ constructor after the call to talloc_zero and to
register the C++ destructor with the talloc context, so that is is
called before talloc_free actually frees the memory.

With this change, non-POD members and custom
constructors/desctructors can be used with gprs_rlcmac_tbf,
gprs_rlcmac_dl_tbf, and gprs_rlcmac_ul_tbf.

Note that this change is only a single step of the plan to turn the
TBF classes into real C++ classes.

Sponsored-by: On-Waves ehf
2015-08-24 12:23:50 +02:00
Jacob Erlbeck e91bd3babd tbf: Do not kill DL TBF on Packet Resource Request
Currently all active TBF of an MS are killed if a Packet Resource
Request is received from the MS. In general this happens after a RACH
request. This does not happen after a resource request that has been
included into a Downlink Ack/Nack.

Sometimes an UL TBF is requested by an MS via RACH while a DL TBF is
running for instance to send a TCP Ack. This can happen, if a former
request via PACCH did not work.

This commit removes the killing of the DL TBF from
gprs_rlcmac_pdch::rcv_resource_request().

Sponsored-by: On-Waves ehf
2015-08-21 19:02:18 +02:00
Jacob Erlbeck 537b149828 tbf: Fix typos in log messages concerning UL/DL
The TBF in create_dl_ass can be of any direction. The text in
rcv_resource_request uses DL instead of UL.

Sponsored-by: On-Waves ehf
2015-08-21 18:59:14 +02:00
Jacob Erlbeck 2b349b5d33 ms: Move MS information merging to GprsMS
Currently the merging of the meta information (MS class, IMSI) takes
place in gprs_rlcmac_tbf::merge_and_clear_ms(). This makes it
difficult to merge the internal state and does not directly relate to
TBFs anyway.

This commit moves this into a new method GprsMs::merge_old_ms.

Sponsored-by: On-Waves ehf
2015-08-18 11:55:03 +02:00
Jacob Erlbeck 28c40b1757 tbf: Clean old MS objects if they have the same TLLI
Currently if an MS retries to access the PCU by using RACH and if
there is already an entry for that MS, a duplicated MS object
referring to the same TLLI is created. This is caused by blindly
setting the TLLI without querying the MS storage to avoid
inconsitencies.

This leads to several entries in the MS storage that are assigned to
the same TLLI. If that happens, 'show ms all' can display multiple
entries with the same TLLI (note that an MS object can belong to
several TLLIs, so there might be an intersection that is not visible
in the list) or 'show tbf all' can show entries with MS_CLASS == 0 in
some cases.

This commit changes update_ms() to merge and clean up old entries
that belong to the given TLLI if they exist. Some data (like the MS
class) is copied to the new MS object.

Note that TBF belonging to the old MS object are deleted immediately
if they have not registered a timer.

Sponsored-by: On-Waves ehf
2015-08-17 16:23:01 +02:00
Jacob Erlbeck 3a10dbd564 tbf: Put the TFI->TBF mapping into the PDCH objects
Currently the TBFs are registered in a TFI indexed array within the TRX
objects. TBFs can be searched globally by TFI and TRX number. This
conflicts with the use of the same TFI for different TBF on different
PDCH. This use case requires the specification of the PDCH as
additional search dimension.

This commit moves the TFI index TBF arrays into the PDCH objects. The
related methods are updated accordingly.

Ticket: #1793
Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck 5879c6493f tbf: Move TFI selection into alloc_algorithm
Currently the TFI and the TRX have to be determined before the actual TBF
allocation function is called, passing TFI and TRX number as
parameters. This does fit to TFI reuse for different slots, since
this were tightly coupled with the slot selection.

This commit just moves the TFI selection into the alloc_algorithm
functions. The tfi parameter is removed from the the TFI alloc
functions. The trx parameter is changed into use_trx to optionally
limit the trx selection (same semantics like in tfi_find_free).

Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck c91c18e6ef tbf: Add Poll Timeout counters
This commits adds three poll timeout counters

  - RLC Assign Timeout
  - RLC Ack Timeout
  - RLC Release Timeout

to help diagnosing to cause for these events. There seems to be an
increased rate of these when a PDCH is shared by multiple TBFs.

Sponsored-by: On-Waves ehf
2015-07-07 09:33:29 +02:00
Jacob Erlbeck e0c734dcfe Revert "tbf: Add GprsMs* argument to update() and use it in reuse_tbf"
This reverts commit 2272a83a13b57ea7e99fe96ac76e4ad892e19e90.

The modification is no longer needed, since the call to update has
been removed from reuse_tbf().

Conflicts:
	src/tbf_dl.cpp

Sponsored-by: On-Waves ehf
2015-07-03 15:58:45 +02:00
Jacob Erlbeck 617c7127f4 ms: Get the set of slots currently active
This commits adds methods to GprsMs and gprs_rlcmac_tbf to retrieve
the slots that are actively used.

Sponsored-by: On-Waves ehf
2015-07-03 15:37:16 +02:00
Jacob Erlbeck 9380f5d218 tbf: Add GprsMs* argument to update() and use it in reuse_tbf
Since set_ms() is caled on the new DL TBF, the old DL TBF loses the
reference to the MS object. This will lead to a segfault, when
update() is called in reuse_tbf().

This commit adds an optional GprsMs* parameter to update() and uses it
for the slot allocation.

This fixes a TbfTest crash that would otherwise occur after applying
the next commit.

Sponsored-by: On-Waves ehf
2015-07-03 15:30:26 +02:00
Jacob Erlbeck ccc34e4d30 tbf: Maintain the number of TBF per PDCH
Currently the PDCH object do not know anything about the TBFs using
them. To make the slot allocation load dependant, at least some
numbers are required.

This commit adds TBF counters (one per direction) and the related methods
attach_tbf, detach_tbf, and num_tbfs to gprs_rlcmac_pdch.

Sponsored-by: On-Waves ehf
2015-07-03 13:17:22 +02:00
Jacob Erlbeck cb1b494c89 tbf: Add BTS::ms_alloc method
Currently the code that creates the MS objects with tbf.cpp is
duplicated.

This commit moves the corresponding code into a new method. Since
there is no TLLI available there, the GprsMsStorage::create_ms method
has been refactored into two variants: one with TLLI/direction and
one without.

Sponsored-by: On-Waves ehf
2015-06-29 11:43:17 +02:00
Jacob Erlbeck 6d86628e5b tbf: Always create an MS object on TBF allocation
Currently the MS object are created when the TLLI gets known.
Therefore some information (TA, MS class) must be stored in the TBF
itself and is copied to the MS object later on. This would get even
more complex, if the allocation algorithms were extended based on
this scheme.

This commit ensures, that an MS object will always be created on TBF
allocation, even if the TLLI is not yet known. These 'anonymous'
objects are still managed by the MS storage. To avoid dangling
entries without a TLLI there (which cannnot be retrieved anyway), the
timer in the MS objects is not started after all TBF have been
detached, so that they get deleted immediately in that case.

Note that an MS object can still be removed (e.g. by replacement)
from an existing TBF, so tbf->ms() can be NULL.

Ticket: #1794
Sponsored-by: On-Waves ehf
2015-06-29 10:53:32 +02:00
Jacob Erlbeck e2e004e7a9 tbf: Pass the MS object around instead of old_tbf
Currently the old TBF (either uplink or downlink) is passed around at
TBF allocation mainly to get information about the MS. To implement
more complex allocation algorithms, the MS object itself will be
needed anyway.

This commit replaces the old_tbf arguments by MS object arguments.

Sponsored-by: On-Waves ehf
2015-06-29 10:53:32 +02:00
Jacob Erlbeck ace7b570a0 tbf: Remove update_tlli method
This method does not do anything anymore, it's functionality has been
taken over by update_ms.

This commit removes gprs_rlcmac_tbf::update_tlli completely.

Sponsored-by: On-Waves ehf
2015-06-29 10:53:32 +02:00
Jacob Erlbeck 7bf9f49728 tbf: Check for NULL in name() (Coverity)
The gprs_rlcmac_tbf::name() method is generally used to generate log
messages. To avoid the need for an explicit NULL check for the tbf
and to get a consistent text if it is NULL, this commit adds a
NULL check to the method itself so that it can be called with this ==
NULL.

Fixes: Coverity CID 1304680, 1304681
Sponsored-by: On-Waves ehf
2015-06-11 13:13:55 +02:00
Jacob Erlbeck a700dd9e11 tbf: Move the current CS field to GprsMs
Currently the current CS value is stored in the cs field of
gprs_rlcmac_tbf and initialised when it is used the first time.

This commit adds separate fields for UL and DL CS values to the
GprsMs class and provides corresponding getter methods for GprsMs and
gprs_rlcmac_tbf.

Ticket: #1739
Sponsored-by: On-Waves ehf
2015-06-08 09:39:25 +02:00
Jacob Erlbeck befc760f86 tbf: Store MS class in GprsMs objects
The ms_class value is a property of the MS and thus belongs to the
GprsMs class. Nevertheless the MS object is created after the TLLI
gets known, so the value still has to be stored in the TBF initially.

This commit add the ms_class value to the GprsMs class and introduces
TBF accessor functions which either access that object or, if that is
not available, the value stored locally.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-06-08 09:38:49 +02:00
Jacob Erlbeck 489a2b35d8 tbf: Move the LLC queue to GprsMs
Currently the enqueued DL LLC messages which have not yet passed to
RLC/MAC encoding are eventually copied from one TBF to the next one
(see gprs_rlcmac_dl_tbf::reuse_tbf). Since the enqueued LLC messages
are related to a specific MS, they should be stored at that layer.

This commit moves the gprs_llc_queue object to GprsMs and changes the
TBF's accessor methods accordingly. The LLC copying code is removed
from gprs_rlcmac_dl_tbf::reuse_tbf().

Sponsored-by: On-Waves ehf
2015-06-08 09:38:44 +02:00
Jacob Erlbeck 6dbe822062 llc: Separate LLC queue handling from gprs_llc
Currently the gprs_llc class handles both LLC queueing and the
partition into smaller pieces for RLC/MAC encapsulation. This hinders
the separation of TBF and MS related data, since LLC queueing belongs
to the MS related code while the RLC/MAC encoding/decoding belongs to
the TBF layer.

This commits takes the LLC queueing related methods and members and
puts them into a new class gprs_llc_queue. It puts the queueing
object into gprs_rlcmac_tbf and adds accessor functions. The
implementation in tbf.cpp and tbf_dl.cpp is adapted accordingly.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-06-08 09:35:11 +02:00
Jacob Erlbeck a098c19b55 tbf: Set MS timeout
This commit sets the MS timeout when the MS object is created. The
value is taken from the ms_idle_sec field in gprs_rlcmac_bts which
can be changed by the VTY commands shown below.

The following VTY commands are added to the config-pcu node:

- ms-idle-time <1-7200>      Set the timeout in seconds
- no ms-idle-time            Disable the timeout

Another timer that is related is T3314 (Ready Timer, default 44s, GSM
24.008, 11.2.2) which requires the SGSN to use paging after its
expiry. Longer timeouts can help if adaptive coding scheme selection
is used (not yet implemented). On the other hand, measurement values
(TA, signal quality) can get invalid after some time, especially with
a moving MS. So a value slightly above T3314 is probably a good value
to start with.

Sponsored-by: On-Waves ehf
2015-05-28 17:40:15 +02:00
Jacob Erlbeck 9200ce6019 tbf: Store the timing advance (TA) value in the GprsMs object
The TA value rather relates to an MS and not to a single TBF. So all
TBFs share the same TA value. Currently the TA value is stored per
TBF and eventually copied from an old TBF to a new one. It is in
general only passed with an RACH request when the TLLI and thus the
MS is not yet known.

This commit adds a TA member to the GprsMs class and uses that one
when the TBF is associated to an MS object. Since the TBF is not
always associated with an MS object (after RACH or when it has been
replaced by another TBF), the TA value is still stored in each TBF
and that value is used as long as no MS object is being associated.

Sponsored-by: On-Waves ehf
2015-05-28 13:58:23 +02:00
Jacob Erlbeck d3eac2867a tbf: Remove TBF chaining (m_new_tbf and m_old_tbf)
Currently a new TBF is chained to an existing older one, either of
the other direction (active or releasing) or of the same direction
(releasing). This does not work properly work if and uplink and a
downlink TBF are being established at the same time while an old TBF
is being released. In that case, one of them is thrown away and the
pending procedure is cancelled.

The chaining is no longer necessary since the GprsMs objects have
been introduced which keep track of the active TBFs.

This commit removes the TBF members m_new_tbf and m_old_tbf and the
related methods and code paths.

Note that a new TBF can replace an older TBF entry of the same
direction within an MS object when it is associated with an MS (e.g.
by TLLI or because it is assigned via another, already associated
TBF). In that case, the old TBF is no longer associated with an MS
object.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-28 12:29:43 +02:00
Jacob Erlbeck 71e55118f5 tbf: Remove IMSI handling from trigger_dl_ass
Currently the BTS::trigger_dl_ass() method assigns the IMSI to the MS
object. This should be (and is already) done earlier where the MS
object is retrieved/created.

This commit removes the corresponding code along with the 'imsi'
parameter from trigger_dl_ass.

Sponsored-by: On-Waves ehf
2015-05-28 12:29:42 +02:00
Jacob Erlbeck b0e5eaf59a tbf: Move IMSI to MS object
Currently the IMSI is stored in the TBFs. Since it directly refers to
an MS, it should rather be stored in an MS object.

This patch move the m_imsi field from gprs_rlcmac_tbf to GprsMs,
changes gprs_rlcmac_tbf::imsi() to get the IMSI from the associated
MS object, and adds getter and setter to GprsMs. Before changing the
IMSI of the associated MS object, assign_imsi() checks if there is
already another MS object with the same IMSI and eventually resets
the IMSI of that one. So using update_ms() and assign_imsi() ensures
that there are not two MS object entries is the storage with the
same TLLI or the same IMSI.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-28 12:28:40 +02:00
Jacob Erlbeck 0e50ce6145 tbf: Always call set_tlli/confirm_tlli in update_ms
Currently the m_tlli member in GprsMs is set by the constructor,
circumventing the TLLI confirmation mechanism.

This commit replaces the get_or_create_ms() method by a create_ms()
method which takes the TLLI and the direction (UL or DL) as
parameters to select either set_tlli() or confirm_tlli(). The MS
object is instantiated with TLLI = 0, and therefore GprsMs::tlli() is
extended to return the DL TLLI if both of the other TLLI are not set.

Note that create_ms() will not check whether an MS object with a
matching TLLI is already stored in the list, so it should only be
called after a corresponding get_ms() in general.

Sponsored-by: On-Waves ehf
2015-05-27 13:30:01 +02:00
Jacob Erlbeck 767193e20b tbf: Remove the TLLI from the TBFs
Currently the TLLI is stored in each TBF. Since each MS is now
represented by a GprsMs object which takes care of TLLI updating,
and each TBF that has been associated with an TLLI also contains a
reference to a GprsMs object, per TBF TLLI handling is no longer
needed. Keeping all TBF m_tlli members up to date is complex and
doesn't currently work correctly in all circumstances.

This commit removes m_tlli and related members from the TBF class and
the tbf_by_tlli functions from the BTS class.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-27 13:29:59 +02:00
Jacob Erlbeck be0cbc1b7e tbf: Explicitly pass the direction to update_ms()
The type of the TBF update_ms() is being called on does not always
reflect whether the TLLI has been signaled by the MS or the SGSN.

This commit adds an additional parameter to tell the method, in which
direction the TLLI has been passed.

Sponsored-by: On-Waves ehf
2015-05-21 17:11:14 +02:00
Jacob Erlbeck 87597358cf tbf: Get the TLLI from the MS object
Since the synchronisation of the TBF's concerning the TLLIs has been
removed in 'Support new and old TLLI's', gprs_rlcmac_tbf::tlli() can
return the old TLLI which is probably different to ms()->tlli() in
that case. This can lead to a wrong TLLI being used in BSSGP messages.

This commit modifies the TBF's tlli() method to get the current TLLI
from the MS object.

Sponsored-by: On-Waves ehf
2015-05-21 17:10:49 +02:00
Jacob Erlbeck 9399046729 ms: Support new and old TLLIs
According to the specification (GSM 04.08/24.008, 4.7.1.5) after a
new P-TMSI has been assigned, the old P-TMSI must be kept basically
until it has been used by both sides. Since the TLLI will be derived
from the P-TMSI, the old TLLI must also be kept until the new TLLI
has been used by both MS and SGSN.

This commit modifies the TLLI handling of GprsMs accordingly.
set_tlli() is only used with TLLIs derived from MS messages,
confirm_tlli() is used with TLLIs derived from messages received from
the SGSN. tlli() returns the value set by the MS. check_tlli()
matches each of the TLLI used by either MS or SGSN as well as the old
TLLI until it has been confirmed.

Sponsored-by: On-Waves ehf
2015-05-21 17:10:42 +02:00
Jacob Erlbeck e43460b50f ms: Integrate the MS storage
Use the MS storage to find a MS object for a given TLLI instead of
searching the TBF lists. The TBFs are then taken from the MS object,
if one has been found. If all TBF might be temporarily detached from
the MS object, a GprsMs::Guard is added to prevent the deletion of
the object, in case another TBF gets attached later on in the scope.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-20 11:36:12 +02:00
Jacob Erlbeck fecece0e59 tbf: Add MS object management to TBF code
This commit adds MS object creation and cleanup to the TBF related
code. MS objects are created when a TBF that has been "anonymous" so
far gets associated with a TLLI. When a TBF is replaced by another,
the old TBF is detached and the new one is attached to the MS. When
all TBFs have been detached, the MS object gets deleted.

The TBF related code should not call attach_tbf/detach_tbf directly
but use set_ms instead to make sure, that the references are updated
properly. GprsMs::detach_tbf also calls set_ms(NULL) on the detached
TBF object.

The MS object is not really used yet, the focus is still on object
creation, TBF association, and cleanup.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-20 11:31:07 +02:00
Jacob Erlbeck c0c580c414 vty: Fix warnings about undeclared functions
This commit adds missing includes to pcu_vty.c and fixes the
llist_head type (missing struct keyword) used by tbf_print_vty_info.

Sponsored-by: On-Waves ehf
2015-05-04 09:58:34 +02:00
Jacob Erlbeck d0261b72de tbf: Force ACK after the last DL LCC frame has been received
If the protocol layers above LLC (e.g. TCP) need an acknowledgement
to continue, it can take up to 400ms (single TS) until the MS is
polled for Ack/Nack which it can use to request an uplink TBF
quickly. The 400ms result from requesting an DL Ack/Nack every 20 RLC
blocks until all pending LLC frames have been sent.

Especially TCP's slow start mechanism can lead to a high delay at the
start of the connection, since the sender will eventually stop after
having sent the first packets (up to 4 (RFC2581) or 10 (RFC6928)).

This commit modifies append_data() to (re-)start
a timer every time it handles an LLC packet and to request an
Ack/Nack every time it expires. So if the server ceases to send IP
packets, the MS is polled in the assumption, that the server is
waiting for an ACK.

The following VTY commands are added (pcu node):

 - queue idle-ack-delay <1-65535>  timeout in centiseconds
 - no queue idle-ack-delay         disable this feature (default)

A sensible value is 10 (100ms) that at gave promising results when
testing locally.

Sponsored-by: On-Waves ehf
2015-04-02 18:14:08 +02:00
Jacob Erlbeck 3bed5d11d2 tbf: Implement delayed release of a downlink TBF
Currently a DL TBF is immediately closed, when the LLC queue is
drained. This will lead to a new DL assignment if data is received
afterwards. In addition, it is not possible to keep the PACCH open
to poll the MS for UL establishment requests there.

GSM 44.060, 9.3.1a suggests to delay the release of an inactive TBF
for some time (max 5s).

This commit mainly changes create_new_bsn() to send LLC dummy
commands as filler if no LLC data is available until keep_open()
returns false. The keep_open() functions returns true unless a
configurable time has passed after the LLC data store drained. By
default, that time is not set which causes keep_open() to always
return false, so that delayed release is effectively disabled.

The following VTY commands are added:
  - dl-tbf-idle-time <1-5000>    to set the delay in ms
  - no dl-tbf-idle-time          to disable delayed release

Ticket: #556
Sponsored-by: On-Waves ehf
2015-03-25 12:32:35 +01:00
Jacob Erlbeck 005ee7f862 tbf: Add frames_since_last_poll method
This functions calculates the number of frames that have passed since
the last DL poll (RRBP flag set) has been sent. It returns a value
less than zero (fn_now - fn_sched) if the block has been scheduled but
not yet sent.

If the function is called before the first data block has been sent
it will return -1.

If the function is called before the first DL poll is sent, it
returns the number of frames since the first data block has been
sent.

Sponsored-by: On-Waves ehf
2015-03-25 12:12:27 +01:00
Jacob Erlbeck 1842c921b3 tbf: Reduce m_new_tbf logging messages
Currently tbf->m_new_tbf may point to itself if no new TBF is
assigned. But this leads to additional logging messages, since the
code in set_new_tbf and tbf_free assumes, that a real new TBF is
assigned and generates log messages accordingly.

This commit adds checks to avoid those messages in the above case.

Sponsored-by: On-Waves ehf
2015-03-06 19:28:08 +01:00
Jacob Erlbeck adcdf150a6 tbf: Add name() method and put the buf into the tbf
Currently tbf_name() must not be used twice in a printf statement
with different TBFs, since the same baffer will be used for each.

This commit puts the text buffer into struct gprs_rlcmac_tbf to avoid
this problem.

Sponsored-by: On-Waves ehf
2015-03-06 19:25:53 +01:00
Jacob Erlbeck 08fe76a893 tbf: Fix dangling m_new_tbf pointer
Currently if a 'new' TBF is freed before the 'old' one (where
old_tbf->m_new_tbf == new_tbf), the old_tbf->m_new_tbf is not cleared
and can be accessed later on. This can lead to inconsistencies or
segmentation faults.

This commit adds m_old_tbf which points back from new_tbf to old_pdf.
m_new_tbf and m_old_tbf are either both set to NULL or one is the
reverse pointer of the other (tbf->m_new_tbf->m_old_tbf == tbf and
tbf->m_old_tbf->m_new_tbf == tbf). It extends set_new_tbf and
tbf_free to update the pointee accordingly.

The TBF test is extended to check this invariant at several places.

Sponsored-by: On-Waves ehf
2015-02-23 15:10:20 +01:00
Holger Hans Peter Freyther f5c97476de tbf: Fix dereference before null check
m_new_tbf might be NULL. Assign was_releasing _after_ we have
done the NULL check.

Related: Coverity CID#1238847
2014-12-26 18:32:00 +01:00
Daniel Willmann e481815583 tbf,bts: Keep track of new TBF for dl/ul assignment in m_new_tbf
There are a couple of possibilities where one TBF is used to assign a
new one:

1. Assign a DL TBF from a UL TBF
2. Assign a UL TBF from a DL TBF
3. Assign a DL TBF from a DL TBF which is in wait-release state (T3193 is
   running)

In these cases the assignment is sent on the existing TBF and triggers
the assignement of the new TBF (with different TFI/direction).

The current code detects these situations by looking at dl/ul_ass_state
and then chosing the TBF with the opposite direction (DL/UL) that has
the same TLLI. This does not work in the case 3 above where a new DL TBF
is triggered for a DL TBF. The current code reuses the old TBF (and
TFI), but this violates the spec.

This patch introduces a m_new_tbf member which is set to the new TBF to
be assigned. When receiving a control ack the code looks up the
n_new_tbf member of the tbf that requested the control ack and completes
the ul/dl assignment. If the old TBF was in the wait release state
(T3193 is running) it is released.

From 3GPP TS 04.60 9.3.2.6:
"""
If the network has received the PACKET DOWNLINK ACK/NACK message with
the Final Ack Indicator bit set to '1' and has new data to transmit for
the mobile station, the network may establish a new downlink TBF for the
mobile station by sending the PACKET DOWNLINK ASSIGNMENT or PACKET
TIMESLOT RECONFIGURE message with the Control Ack bit set to '1' on
PACCH. In case the network establishes a new downlink TBF for the mobile
station, the network shall stop timer T3193.
"""

reuse_tbf() is modified to allocate a new TBF with a new TFI and trigger
a dl assignment for that TBF on the old TBF. All pending data is moved
to the new TBF.

Ticket: SYS#382
Sponsored-by: On-Waves ehf
2014-09-10 19:04:46 +02:00
Daniel Willmann 08e57c8366 tbf: Include TBF state in tbf_name output
Sponsored-by: On-Waves ehf
2014-08-15 18:28:45 +02:00
Daniel Willmann ca102af92b tbf: Split out UL/DL TBF methods into separate files
tbf_ul.cpp for UL TBF methods
tbf_dl.cpp for DL TBF methods

This commit contains no code changes.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-12 19:24:49 +02:00
Daniel Willmann eb100244b0 tbf, bts: Use tbf set_state method instead of tbf_new_state function
All the function did was add debug output and call the set_state method.
Move the debugging into the method and remove the function.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-08 14:15:24 +02:00
Daniel Willmann 418a4230e0 tbf, gprs_rlcmac_meas: Move the DL bandwidth variables to the DL TBF
The bandwidth calculation as well as loss report is only done for DL TBF
so move everything related to that in there.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-08 14:15:24 +02:00
Daniel Willmann cf706b0775 tbf: Make llc_dequeue a method of DL TBF
llc_dequeue is only used in DL TBF to send the data from the BSSGP to
the MS.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-08 14:15:24 +02:00
Daniel Willmann e2732e2f59 tbf: Make snd_ul_ud() and assemble_forward_llc() methods of UL TBF
They are only called for UL TBF.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-08 14:15:24 +02:00
Daniel Willmann 7e994e392d tbf, ...: Make the fields in the dl/ul struct member variables
There is no need for the union/struct anymore. Make the variable members
of the UL/DL class.

As a result gprs_rlc_dl_window gets a reset() method because
memset(&dir.dl, 0, sizeof(dir.dl)) doesn't work anymore in reuse_tbf().

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:05 +02:00
Daniel Willmann 350f64d9e2 tbf: Move UL TBF methods from base class into UL TBF
The methods create_ul_ack(), rcv_data_block_acknowledged(),
maybe_schedule_uplink_acknack() are only used for UL TBFs so make them
methods of that class instead of the base class.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:05 +02:00
Daniel Willmann b2886f1a0d tbf: Split UL and DL TBFs up in create_dl_ass()
Explicitly use UL and DL TBFs where they are needed.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:05 +02:00
Daniel Willmann 6a16e0c092 tbf: Use DL/UL TBFs in poll_timeout codepaths that deal only with one type
Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:04 +02:00
Daniel Willmann 3016888ee0 tbf, gprs_bssgp_pcu: Move some methods to DL TBF
These methods are only used on DL TBFs and can be moved to the subclass.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:04 +02:00
Daniel Willmann 532a4b54f5 bts: Change parameter in BTS::trigger_dl_ass() to DL TBF
This method is always called with a DL TBF as argument so make it clear.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:04 +02:00
Daniel Willmann b8f260176e tbf: Make create_new_bsn and create_dl_acked_block a method of DL TBF
These functions are only used for DL TBFs so move them.
sched_select_downlink() in src/gprs_rlcmac_sched.cpp now needs to deal
with DL TBFs instead of the base class.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-08-07 13:03:10 +02:00
Daniel Willmann 6c813fc9bc bts, tbf: Make rcvd_dl_ack a method of the DL TBF
This method is only userul for DL TBFs so move it. As a result
gprs_rlcmac_pdch::rcv_control_ack needs to work with dl_tbfs.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-08-07 13:03:10 +02:00
Daniel Willmann 538ac5b574 tbf: Make append_data a function of DL TBFs
This function is only used in DL TBFs (called by handle).

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-08-07 13:03:09 +02:00
Daniel Willmann 2354402b7a tbf: Make tbf_lookup_dl() return and handle() use a dl_tbf
These two functions only deal with DL TBFs so make it clear

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-08-07 13:03:09 +02:00
Daniel Willmann 1b3864fc47 tbf: Use plain old data structure (PODS) for llist management
The PODS struct has a back pointer to access the actual object.
llist_pods_for_each_entry traverses the list of struct llist_pods and
makes the entry available (through the back pointer).

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-30 18:27:30 +02:00
Daniel Willmann 48aa0b0d99 bts, tbf: Split alloc_tbf function into separate UL and DL versions
UL and DL tbfs are used in very separate parts and are not the same
thing so split the alloc function and use the UL/DL version throughout
the code.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-22 12:36:31 +02:00
Daniel Willmann 0d12a2fa89 bts, tbf: Change the TBF return type of functions to the ul/dl version
Many functions only ever deal with or return a UL or a DL TBF.
Explicitly change the type to reflect which TBF is used where.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-22 12:36:13 +02:00
Daniel Willmann 078bb713e1 tbf: Add ul and dl TBF types and allocate them in tbf_alloc()
Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-16 19:03:36 +02:00
Daniel Willmann b59d61b4b4 bts, tbf: Separate functions for dl/ul tbf_by_tlli lookup
In the future we want to separate ul and dl tbf into different
classes that inherit from a common base.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-03 15:36:46 +02:00
Daniel Willmann 17a1d5e162 gprs_rlcmac_pdch: Get rid of ul/dl_tbf
The current code keeps a reference to all tbfs in the bts and another
reference in the pdch. This allows for the possibility of both lists to
go out of sync.

This patch removes the pdch-specific list of ul and dl tbfs and uses the
lists in the bts to lookup tbfs everywhere.

Performance for going through the global list is not an issue yet. We
can optimize this later and in a better way.

Sponsored-by: On-Waves ehf
2014-06-04 17:17:45 +02:00
Daniel Willmann cf1fae7f38 tbf: Re-send dl assignment if we can upgrade to multislot
The current code would only ever assign one PDCH for the initial
assignment (from CCCH). Only if reuse_tbf is called the algorithm would
actually use multiple DL PDCHs if possible.

This patch introduced a tbf attribute upgrade_to_multislot that is set
if we have multiple PDCH configured, and support multislot assignment,
but can only assign a single PDCH (alloc_algorithm_b, parameter single
is set). In this case after the assignment completes (and the MS is
listening on a PDCH) we resend a DL assignment though the PACCH and this
time we can assign multiple timeslots.
2014-05-30 18:23:17 +02:00
Daniel Willmann 73191a443f tbf/bts, encoding: Keep track of WAIT_RELEASE state for DL assignment
The current code does not properly distinguish between DL assignments to
reuse a tbf (after it was put in state WAIT_RELEASE) and DL assignments
for an active tbf to change the allocation of the PDCH timeslots.

This patch introduces a new variable was_releasing which remembers if
trigger_dl_ass() was called with a tbf in state WAIT_RELEASE. In that
case we have to set the CONTROL_ACK field in the download assignment.

This should allow us to send DL assignments to change PDCH TS allocation
of a tbf before we enter FLOW state.
2014-05-30 18:21:00 +02:00
Daniel Willmann fc03bbe078 tbf/bts: Rename tbf->snd_dl_ack to tbf->rcvd_dl_ack
This function is called to act upon a received DL ACK packet so this
name makes more sense.
2014-05-30 18:19:06 +02:00
Holger Hans Peter Freyther e5109ba1f0 tbf: Change the log area to RLCMACDL so we see it in a DL trace 2014-01-16 10:11:22 +01:00
Holger Hans Peter Freyther 3d0cc2f97d tbf: Make finding use-after-free more easy and set to NULL or return
Make finding use-after-free more easy by setting things to NULL
or simply return after tbf_free(this) has been called.
2014-01-16 10:09:42 +01:00
Holger Hans Peter Freyther a004799699 tbf: Use past-tense and call it created_ts 2014-01-16 10:07:20 +01:00
Daniel Willmann 80367aae17 tbf: Save a timestamp at tbf allocation and print it in the VTY 2014-01-15 17:41:45 +01:00
Daniel Willmann 772415fd8a pcu_vty: Add a command to print info about all TBFs 2014-01-15 17:41:45 +01:00
Daniel Willmann afa72f5210 tbf: Add a function to output tbf info to VTY 2014-01-15 17:41:44 +01:00
Daniel Willmann 3ce011f44f rlc: Rename state() to show_state() to better reflect its function
show_state() is only used for debugging output to make the v(b) array
human readable.
2014-01-15 15:23:35 +01:00
Daniel Willmann 146514e180 rlc/tbf: Move v_b into DL window
Move functions resend_needed(), mark_for_resend(), update(),
move_window(), state(), count_unacked() out of v_b directly into the UL
window and provide a function get_state in v_b to access the v_b
elements.
2014-01-15 15:23:21 +01:00
Daniel Willmann 55844795be rlc/tbf: Add function receive_bsn that updates v_r, v_q, v_n
We don't need to expose the mecanics of updating the variables to the
outside.
2014-01-15 15:23:21 +01:00
Daniel Willmann 7c3751b10b rlc/tbf: Move v_n into gprs_rlc_ul_window and adapt the tests
v_n is part of the UL window handling so move it inside the ul_window
2014-01-15 15:23:21 +01:00
Holger Hans Peter Freyther 4af30533f0 alloc/tests: Create an allocation test for various scenarious
The allocation in the TBF/BTS code is quite complex. In parts this
is due the assignment and requests occuring under differen circumstances.
Attempt to re-create the commono scenarios.

Remove the bogus msclass check in gprs_rlcmac_tbf::update as the
allocation code will check the ms class anyway.
2014-01-15 10:39:07 +01:00
Holger Hans Peter Freyther 8f399de135 tbf: Kill the tsc member as it duplicates data
We can just use first_ts and the trx/pdch to extract this information.
Avoid duplication of data.
2014-01-15 10:34:09 +01:00
Holger Hans Peter Freyther ba26368040 tbf: Fix typo and call it same 2014-01-15 10:33:56 +01:00
Daniel Willmann 9c623892f5 llc: Calculate the average queuing delay of the LLC queues
Use a formula like it is used with TCP. This can help to make
decisions about if frames should be dropped or not at the time
we enqueue them.

This code will store two timeval structs in fron the of the
actual data and compute the average at the time of the dequeue.
2013-12-25 14:55:04 +01:00
Holger Hans Peter Freyther 550bb88a9e llc: Count the number of frames queued inside the LLC queue 2013-12-18 12:11:27 +01:00
Daniel Willmann 6f7cb2cb4f decoding: Use 'I' and 'R' in rbb array for DL
We want to match up rbb decoding and encoding so it helps to use the
same chars.
2013-12-12 11:03:50 +01:00
Holger Hans Peter Freyther 3cbf9e040c rlc: Make the RLC types only operate on the BSN
The code has an internal optimization to only use window_size
space. This means that the caller needed to know that only half
of the size was used. Change the API to work on the BSN and do
the mapping internally. The compiler should have plenty of
opportunity to propagate the constant(s) but this has not been
verified.
2013-12-04 21:01:02 +01:00
Holger Hans Peter Freyther 3c95776805 tbf: Separate the handling for rh->si and call in case of re-transmission
In case of a retransmission ack the window again..
2013-12-04 13:51:43 +01:00
Holger Hans Peter Freyther 7a5f3c2153 tbf/sched: We pick the _last_ entry, rotate the lists
We always pick the _last_ entry from the lists. Let's rotate
so we make it a bit more fair.
2013-11-26 21:00:52 +01:00
Holger Hans Peter Freyther 7f3e662b34 tbf/rlc: Move raising of V(Q) into the ul window code 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther cbb00ebd04 rlc/tbf: Move the code to raise V(R) into the ul_window handling 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther 423dd2286b tbf/rlc: Move the putting of a block into the rlc code 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther 4c06d9155c tbf: Move the extraction of the TLLI into a separate method 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther c15d5cc230 tbf/rlc: Remove the side-effect from the loop. 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther 9977e1545a tbf: Reduce complexity and deal with only one way of assignment
The normal mode of the PCU doesn't really work right now. There
is no place to have certain kind of features that are not built
and not unit-tested.
2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther 6ab5b24be4 tbf/rlc: Move the check if something is in the window out. 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther 270f7fce1d tbf/rlc: Move the v_n handling into a dedicated object 2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther f1593b7c49 tbf/rlc: Big change and move the window handling out to the rlc
The send and receive window is now managed by an external object.
There are some issues that can only be solved with C++11 but it
is progres and removes some of the spaghetti code. For GPRS the
sns and ws is hardcoded. Move that into the window code.
2013-11-26 21:00:51 +01:00
Holger Hans Peter Freyther ab6cd921e3 tbf: Update the legend and mention invalid as well
We should not see it but the legend should be complete.
2013-11-26 20:57:42 +01:00
Holger Hans Peter Freyther 9c5539d46d tbf/rlc: Move the counting of unacked frames into the RLC V_B class
Whenwe receive a final ack we assume that all the unacked frames
have been acked now. Move the counting to V_B and now the caller
can remove the BSN and the "lost" variable which has always been
zero.
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther 86dc355a33 tbf: Split the handling of DL ACK/NACK into two separate parts
Split the handling of the final ack and the handling of frames
that is moving frames.
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther bc15570651 tbf/rlc: Change the code and generate the entire state in the V_B 2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther e358ff8fa4 tbf/rlc: Move the moving of V(A) into the V_B code
Move the code that moves the V_B to the first not acked frame. Return
how many indexes the V_B was moved and update the V_A in the caller.
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther df6b4f52e0 tbf/rlc: Move the parsing of RBB to Decoding, move window marking out
Move the parsing of the bitbmap out of the TBF code into Decoding.
Move the updating of the V_B into the V_B class. Add some comments
about handling the mod_sns, mod_sns_half parameters by using template
code.
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther 9eb8ace260 tbf: Fix the indention of this routine 2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther 12c039cdb2 debug_diagram: Remove the special debug_diagram compilation mode
This approach is somehow flawed. We need/want to debug problems on
systems with real traffic and re-compiling it with debug_diagram
is not an option. All internal logging needs to be expressive enough
so we can understand what is going on (e.g. create a script to
post-process the output).
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther a6ba67cb3a tbf: Simplify the create_dl_acked_block into two parts
Separate the resend from creating a new block. It shows that the
first_fin_ack is always set to FALSE for re-sending. This might
not be what we want.
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther 8b16ae30fe tbf/rlc: Move the marking of frames for resend into the v_b 2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther c03e38291a tbf: Move the check if the window is stalled to a separate method 2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther 1577779526 rlc/tbf: Move the loop into the gprs_rlc_v_b class 2013-11-26 20:57:19 +01:00
Holger Hans Peter Freyther ef93bdb19b tbf: Count how often we re-start a BSN in the send routine
There appears to be a scheduling issue. Even without any NACKs
we are re-transmitting a lot of frames. It might be because of
this.
2013-11-24 00:01:50 +01:00
Holger Hans Peter Freyther 64b49bc3ce tbf: Always increase the tx_counter when we transmit a frame
In case the ACK could not be scheduled we were not increasing the
tx_counter. Change the code flow to always increase the tx_counter
after we have created a frame.
2013-11-23 23:16:07 +01:00
Holger Hans Peter Freyther b18aedcc50 tbf: Make the ws and sns number "private" (they should also be const) 2013-11-23 16:27:50 +01:00
Holger Hans Peter Freyther 321f3c3104 rlc: Move the ack state array into a separate class that can be tested 2013-11-23 16:19:17 +01:00
Holger Hans Peter Freyther 092478f294 rlc: Count nacked frames in the statistics too 2013-11-23 01:01:19 +01:00
Holger Hans Peter Freyther 58db60c68e rlc: Start to move things out of the tbf into the rlc
Add remarks of possible broken behavior inside the tbf
routines. Move the preparation (and init) into the new
rlc.cpp file.
2013-11-19 21:26:43 +01:00
Daniel Willmann c3d5325fc8 tbf: The memory regions overlap so memmove should be used 2013-11-19 21:26:43 +01:00
Holger Hans Peter Freyther c70aae4697 rlc: Count the window stalls on the RLC level 2013-11-19 17:09:37 +01:00
Holger Hans Peter Freyther e5dc2a0ac5 rlc: Pass the gprs_rlc_data to the assemble function for assembly 2013-11-13 20:17:06 +01:00
Holger Hans Peter Freyther 796270bf83 rlc: Put a block and the length into a separate object
This will ease passing things around.
2013-11-13 20:05:00 +01:00
Holger Hans Peter Freyther 9241fd0957 rlc: Begin to move the rlc block handling into a separate object
The secret of gprs_rlc will be the manipulation of the blocks for
the current window. We might add the window handling in this class
as well.
2013-11-13 19:51:55 +01:00
Holger Hans Peter Freyther e9429b5d3e rlc: Count the sent and resent RLC blocks 2013-11-13 19:36:57 +01:00
Holger Hans Peter Freyther 55cf994c29 tbf: Re-use the code that is re-using the tbf
Address the fixme and re-use the code. Fix the counting in the
final ack case and provide a log message in the other case. Prefix
it with the tbf name
2013-11-13 18:15:45 +01:00
Holger Hans Peter Freyther b1302b083e llc: Move the decision if a frame has expired into the LLC
This way the generation of the expiry information and the check
is at the same place. This should make reading the code more easy.
2013-11-13 17:16:28 +01:00
Holger Hans Peter Freyther e23102602c llc: Move some more secrets from the TBF into the LLC
Introduce a method to append data to a TBF and then reset the
read pointer when the frame has been sent.
2013-11-13 17:08:07 +01:00
Holger Hans Peter Freyther b3d5ee2934 bts: Count the number of llc frames that were "scheduled" to be sent
This does not mean that they have been successfully transferred
to the SGSN/MS but at least that they have reached a certain point
in the message flow.
2013-11-13 16:43:26 +01:00
Holger Hans Peter Freyther 51e093bd1c llc: Use timeradd and timercmp and fix for < 1s PDU llc timeouts 2013-11-13 15:35:45 +01:00
Holger Hans Peter Freyther fce431cf3a llc: Move the timeout calculation into the TBF 2013-11-13 15:17:12 +01:00
Holger Hans Peter Freyther aa35ba7584 tbf: Count how often we re-use a TBF that was already being deactivated 2013-11-13 15:02:50 +01:00
Holger Hans Peter Freyther 857281f7ff llc: Remove one of the two variants to put data into the frame 2013-11-13 14:58:19 +01:00
Holger Hans Peter Freyther a6e47c7f54 llc: Add another warning for me to take a look 2013-11-11 20:08:35 +01:00
Holger Hans Peter Freyther 5697b4ccfa tbf: Make sure that tfi is signed so we can make a < 0 check
For the failure check we need this variable to be < 0.

Fixes: Coverity CID 1107941
2013-11-11 16:22:39 +01:00
Holger Hans Peter Freyther acb5427bda llc: Move all direct accesses to the frame into the llc structure
Add some todo items where we could add assertions now that I see
the constraints and invariants of this code.
2013-11-07 08:15:58 +01:00
Holger Hans Peter Freyther b7840466ce tbf: Split create_dl_acked_block into two methods
The method was more than 300 hundred lines of code. Split the
selection of the index and the creation of the dl_msg.
2013-11-07 07:50:26 +01:00
Holger Hans Peter Freyther a1da251c10 tbf: Move the tbf_handle and tbf_append_data into the class 2013-11-07 07:32:51 +01:00
Holger Hans Peter Freyther 096f6f9f39 llc: Move the llc code out of the tbf.cpp into a new dedicated one 2013-11-07 07:21:06 +01:00
Holger Hans Peter Freyther 758dc12c9f llc: First routines moved from the TBF into the LLC 2013-11-07 07:16:21 +01:00
Holger Hans Peter Freyther 28e5378b55 llc: Begin creating a LLC class and move counts into it.
Begin to move state of the LLC into a separate object. This will
allow to make side-effects more clear and kill some code duplication.
2013-11-06 20:23:56 +01:00
Holger Hans Peter Freyther 9948514086 tbf: Move the tx part into the tbf as it accesses internal data 2013-11-06 20:15:11 +01:00
Holger Hans Peter Freyther 77e05971b4 tbf: Move the llc handling into the tbf (from the bts)
This will be moved to a LLC class in the future but after this
we can make the sns/ws private now and have little to update
outside the tbf.
2013-11-06 19:16:43 +01:00
Holger Hans Peter Freyther bc1626e5de tbf: Update the timing advance for the new tlli based on the old one 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther b809866be5 tbf: Learn and propagate the TLLI changes due a new P-TMSI
During a routing area update a new P-TMSI was assigned. During
the PACKET CONTROL ACK on the DL we notice the change of TLLI
but didn't propagate this. This means that a Routing Area Update
Complete was only sent after a new RACH request.

Addresses:
<0007> gprs_rlcmac_meas.cpp:103 UL RSSI of TLLI=0x88661bc6: -67 dBm
<0002> bts.cpp:945 Got ACK, but UL TBF is gone TLLI=0xe512eba3
<0007> gprs_rlcmac_meas.cpp:158 DL packet loss of IMSI=274080000004765 / TLLI=0xe512eba3: 0%
<0002> tbf.cpp:668 TBF TFI=0 TLLI=0x88661bc6 T3169 timeout during transsmission
<0002> tbf.cpp:690 - Assignment was on PACCH
<0002> tbf.cpp:694 - No uplink data received yet
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 5464c9baf2 tbf: Have one imsi field and assign it through a function
Have one IMSI field per TBF and assign through a function call.
The IMSI should be used to look-up the TBF on the SGSN->PCU
direction.
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 34f6e5ebe6 tbf: Make tfi private and update the code
All logging code that used tbf->tfi is now using tbf_name to
print the the TBF. External code is now using tfi() which is
inlined and should result in the same code being generated as
before (+debug code that can be stripped).
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 474685e26e tbf: Make the tlli "private" and update the updating code
Now all updates to the tlli/tlli_valid are in one place. If we
implement the policy to update the matching/linked TBF we can
now to do it in a single place. Add a todo item for that as I
am waiting for feedback from the mailinglist.
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther bd449f57a7 tbf: Create tbf_name and use it in log statements
This is like gsm_lchan_name and should be used in log statements.
This way we can easily change the information that is printed and
we know how to search things. The other part is that direct use
of tfi/tlli is removed which will allow us to make them private
and at the same time start to resolve the "tlli" updated in many
places.

Not old log statements are changed yet. This will done whenever
a bad log statement is seen on the console...
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther ec80f82824 tbf: Remove the trx_no field from the tbf, go through the trx object 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther fc498c9e7b tbf: Go through the trx to get the ARFCN 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 875fc895a8 bts: Further logging improvements for TFI/TLLI output 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 8d0e489484 tbf: Log the TFI and TLLI so we can try to figure out more from logs
<0002> tbf.cpp:444 Poll timeout for DL TBF=0
<0002> tbf.cpp:513 - Timeout for polling PACKET DOWNLINK ACK.
<0002> tbf.cpp:688 - Assignment was on PACCH
<0002> tbf.cpp:694 - Downlink ACK was received
<0008> gprs_bssgp_pcu.cpp:154 LLC [SGSN -> PCU] = TLLI: 0xd6942c78 IMSI: 274080000004765 len: 506
<0002> bts.cpp:974 PACKET DOWNLINK ACK with unknown FN=2213128 TFI=0 (TRX 0 TS 6)
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 15bb1a2a51 misc: Change the logging for the tbf and what to log
TLLIs got printed as TBF. Fix that but also rename things to
TFI. The TFI is not required to be unique per BTS but it is
the indicator we use right now.
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 90b87ea5e6 misc: Fix typo.. resource in english only has one 's' 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 1997787c52 llc: Count timedout and silently dropped frames
A DL tbf can be discarded and then the already queued LLCs will
be silently dropped. Count this event.
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 158776411b bts: Provide the first set of counters 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 61a0a04d26 tbf: Move gprs_rlcmac_send_data_block_acknowledged into tbf
We can now remove the gprs_rlcmac_data as the code has been
moved into the tbf, pdch and bts.
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 3dc56a3b34 tbf: Move gprs_rlcmac_send_packet_uplink_assignment into the tbf 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther ae03f22199 tbf: Move gprs_rlcmac_send_packet_uplink_assignment to the tbf
Again the function was called send but didn't do any sending
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 22b31190cb tbf: Fix typo in thecomment 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 46bcb8d59d tbf: Move gprs_rlcmac_send_uplink_ack into the tbf
The method was called send but didn't send anything. Move
it to the tbf
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 2db7e7e7db tbf: Move gprs_rlcmac_send_packet_downlink_assignment into the tbf
This method was called _send_packet_ but actually didn't do any
sending at all. It just formated the right assignment. I replaced
tbf-> with nothing.
2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 24c1a5ba29 bts: Move gprs_rlcmac_trigger_downlink_assignment into BTS 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 42de18f347 debug_dl_ass_idle: Remove the feature as it is obviously broken
strncpy takes three arguments but only two are given. This feature
would also only work if there is one tbf at a time.
2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther d9262b3b55 tbf: Move gprs_rlcmac_poll_timeout into the tbf
Move the gprs_rlcmac_poll_timeout method into the tbf class and
gprs_rlcmac_downlink_assignment into the BTS.
2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 70ddde6929 tbf/bts: Move the tfi_find_free into the bts 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther f63cabd931 tbf/pdch/bts: Move the tbf look-up by tfi into the BTS 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 6673005215 tbf: Fix typo in the debug message 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 782f6ddf99 tbf: Add todo item tht could help improving debugging 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 86300bbeea tbf: Move the timer routine into the class
The timer is used for various timeouts and there is still external
client code that is calling it. In a perfect world the client code
would indicate that an event has happened and the internal timer
will be stopped. The best compromise is the "stop_t3191" method. It
allows to add semantic verification that the timer has been running.
2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther af8094d799 tbf: Move the handle tineout into the tbf class 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther aa9c326d7e tbf: Move the updating of the data into the tbf class 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther d11290b90b pdch/tbf: Move gprs_rlcmac_rcv_data_block_acknowledged into the pdch
Move the method into the PDCH. Extract the finding of TLLI into a
new class called Decoding. Move the assemble and forward LLC frames
into the TBF as it is poking in the internals of the TBF.
2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther b65e08a7be misc: Remove the bts parameter from calls that take a tbf
Mark some of the tbf manipulation that is burried in the data
sending routine.. that it should be moved around.
2013-10-30 21:24:10 +01:00
Holger Hans Peter Freyther 1702f102af tbf: First round of removing llc handling from the rlcmac_data
The code in gprs_rlcmac_data should ask the TBF for help in packing
the frames but it really shouldn't poke in the internals of the
tbf structure. This is very bad capsuling and has plenty of copy
and paste.

At the same thime this will be the most dangerous refactoring of
the code base.
2013-10-30 21:24:10 +01:00
Holger Hans Peter Freyther 34bd8bdf30 bts/tbf: Move the lists into the BTS and do the look-up from the BTS
The list belongs to the BTS. This makes cleaning this up more easy
and establishes a hierachy of resources that start from the BTS. The
debug_diagram code is now broken.
2013-10-30 21:24:10 +01:00
Holger Hans Peter Freyther 9f0c1d216a tbf: Keep a pointer from the tbf to the BTS
This is preparing the next commits and will ease working with
the debug_diagram when the global lists are killed. It will
simplify the APIin the long run.
2013-10-30 21:24:10 +01:00
Holger Hans Peter Freyther 111614a994 ta: Create TimingAdvance class and make it belong to the BTS
This allows us to easily flush the state in case a PCU/BTS
connection is lost.
2013-10-30 21:24:10 +01:00
Holger Hans Peter Freyther 67ed34eedb bts: Move struct gprs_rlcmac_bts and other structs into a bts.h
Begin to make the BTS a real C++ object with real responsibilities.
The biggest issue will be the pcu_vty.c that might not like C++
at all.
2013-10-30 21:20:45 +01:00
Holger Hans Peter Freyther 1b33361bab bts: Remove the global state from the tbf 2013-10-30 21:20:45 +01:00
Holger Hans Peter Freyther 344ff48756 bts: Remove the global state gprs_rlcmac_trigger_downlink_assignment
Remove the global state from gprs_rlcmac_trigger_downlink_assignment
and walk up to the pcu_l1_if.cpp where I find the timeout handling
that should be part of the SBA and TBF functionality. In terms of
hierachies things start to be more clear.

There should be the BTS object. That holds the SBA and TBF Controllers
that can allocate TBFs and SBAs and will handle the timeout polling
for a BTS.
2013-10-30 21:20:44 +01:00
Holger Hans Peter Freyther 173a240a7e bts: Remove global state and the usage of the gprs_rlcmac_bts
Global state makes mocking/writing tests more difficult. Continue
by removing direct usage of the bts and adding it as pointer to
the function calls (showing the true dependencies of the functions)
2013-10-30 21:20:44 +01:00
Holger Hans Peter Freyther 743bafa50c alloc: Introduce a backpointer from the tbf to the trx and simplify code
Kill all the level of indirections where one needs to have the BTS
the TBF to find the TRX.
2013-10-30 14:45:57 +01:00
Holger Hans Peter Freyther 96efa70a9e alloc: Call it trx_no and not trx as it is not trx object 2013-10-30 14:45:57 +01:00
Holger Hans Peter Freyther 1c344e2668 tbf: Prepare to make thing things private in the tbf, start with the state
There really shouldn't be too many callers of state. Instead the
tbf should dispatch depending on the internal state. For now
introduce state_is and state_is_not accessor functions so we can
start to see who is using the internal state.
2013-10-28 12:54:09 +04:00
Holger Hans Peter Freyther 7380babdba tbf: Move the tbf_timer_cb into the tbf class
Introduce the first instance method for printing out diagonistic
about itself and create a jump function for it.
2013-10-28 12:53:49 +04:00
Holger Hans Peter Freyther 455613076a tbf: Move many routines related to the tbf from gprs_rlcmac to tbf.c 2013-10-28 12:52:59 +04:00
Holger Hans Peter Freyther 4f6a4e5d6d tbf: Add another variant of the free_all now by pdch 2013-10-28 12:52:33 +04:00
Holger Hans Peter Freyther 964ddb6aa0 tbf: Move the code to close all timeslots into the tbf class
Move the code out of the sysmocom_socket (as this is only required
to talk to our hardware) and into the TBF class that actually knows
what a TBF is.
2013-10-28 12:52:15 +04:00
Holger Hans Peter Freyther 8692128365 tbf: Move the alloc_ul_tbf into tbf.c and change signature
Add the bts parameter to the method list. This would be a static
method of the class (in case the TBF would be a class)
2013-10-18 15:17:43 +04:00