Commit Graph

225 Commits

Author SHA1 Message Date
Jacob Erlbeck 1c68abaffa tbf/test: Attach TLLI and MS objects to TBFs
Currently the DL TBF's TLLI are not set. This will have to change in
the future, when the m_new_tbf chaining is replaced by the usage of MS
object to group TBFs.

This commit just calls update_ms() on newly created TBFs. This
changes many of the lines written to stderr due to the TLLI change,
but doesn't change other aspects or messages beside creating and
destroying MS objects.

Sponsored-by: On-Waves ehf
2015-05-28 12:29:43 +02:00
Jacob Erlbeck 7b9f825ae8 ms: Use the IMSI to retrieve the MS object
This commit extends get_ms() to really compare the IMSI if it has
been given. Matching by TLLI has a higher precedence than matching by
IMSI.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-28 12:29:40 +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 9a2845d491 tbf/test: Fix IMSI creation
Currently the generated IMSI contains blanks due to a missing '0'
flag in the corresponding snprintf statement. In addition, the buffer
is effectively limited to 15 bytes which is shorter than the
generated character sequence, such that the last character of the
IMSI is removed.

This patch fixes both issues. Since snprintf itself will add a
terminating \0 character, the whole buffer can be passed to snprintf.

Sponsored-by: On-Waves ehf
2015-05-27 13:30:01 +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 4f459799e3 tbf: Just pass the MS object in reuse_tbf
Currently the MS will be searched based on the TLLI in resue_tbf().
Since the MS object is already known in the TBF when the TLLI is set,
it can just be passed to the new TBF.

This commit removes the call to update_ms() and just adds
new_tbf->set_ms(ms()) which will also work as expected if ms() == NULL.

Sponsored-by: On-Waves ehf
2015-05-21 17:11:40 +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 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 90de3a7ffe tbf: Send BSSGP LLC discarded on TBI exhaustion
Currently the PCU silently discard LLC frames from the SGSN if a
DL TBF cannot be allocated.

This commit changes tbf_new_dl_assignment and reuse_tbf to send an
LLC discarded message to the SGSN in this case.

Ticket: #607
Sponsored-by: On-Waves ehf
2015-04-09 19:24:47 +02:00
Jacob Erlbeck d58b711eec tbf/test: Add test for DL TBF exhaustion
This test calls gprs_rlcmac_dl_tbf::handle() with varying TLLI and
IMSI until the function fails.

Sponsored-by: On-Waves ehf
2015-04-09 19:24:00 +02:00
Jacob Erlbeck 502bd1feea tbf: Poll MS on idle DL TBFs
If an MS wants to open a new UL TBF, it can either use (P)RACH or
request one in a Ack/Nack message for a DL TBF (PACCH). When a TBF
becomes idle (LCC queue is empty but the TBF is kept open), there
aren't any Ack/Nack requests that can be used by the MS to ask for an
UL TBF, therefore it has to use the RACH. This leads to many RACH
requests even for a single HTTP transaction, so it takes some time to
retrieve even a simple web page.

This commit modifies the scheduler to regularly send Ack/Nack
requests on idle DL TBFs. It does so by extending the priority based
scheduling algorithm to have 5 priority levels (highest priority
first):

  - Control block is pending
  - High age (100%) threshold reached (-> request Ack/Nack)
  - Data is waiting or there are pending Nacks
  - Low age (200ms) threshold reached (-> request Ack/Nack)
  - Pending Nacks that have been resent already
  - None of the above (-> send DL dummy control block)

The 'age' refers to the time since since the last control block has
been sent on the TBF. This high age threshold is set to
dl-tbf-idle-time or to 50% of T3190 (whichever is smaller), aiming
for at least a poll (and TBF shutdown) after the TBF has expired and
to safely prevent expiry of T3190. So if dl-tbf-idle-time > 200ms,
there will be a poll every 200ms and a final poll after
dl-tbf-idle-time. On high load, the interval between polls can get
higher, but the 'high age' poll should be in place.

This commit implements the scheduling with respect to GSM 44.060,
9.3.1a ("Delayed release of downlink TBF").

Ticket: #556
Sponsored-by: On-Waves ehf
2015-03-25 12:34:38 +01:00
Jacob Erlbeck 2cbe80b53e tbf/test: Add test for delayed release
This tests checks the implementation of the delayed release of an
downlink TBF.

Ticket: #556
Sponsored-by: On-Waves ehf
2015-03-25 12:34:34 +01:00
Jacob Erlbeck c495209122 tbf: Use put_frame in append_data if the TBF has no data
Currently if append_data() is used when there is no LLC data in the DL TBF,
it will either call reuse_tbf() which in turn will call put_frame(),
or it will append the LLC message to the queue, even if the queue and
the frame buffer are empty. This only happens with the test case so
far, but this would change when idle DL TBFs are kept open for some
time. It results in empty LLC message being sent to the MS (see log
below).

This commit changes append_data to check for this case and to
eventually use put_frame() instead of appending the LLC data to the
queue.

Addresses:
  TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=FLOW) downlink (V(A)==0 ..
  V(S)==0)
  - Sending new block at BSN 0
  -- Chunk with length 0 is less than remaining space (20): add length
    header to to delimit LLC frame
  Complete DL frame for TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=FLOW)len=0
  - Dequeue next LLC for TBF(TFI=0 TLLI=0x00000000 DIR=DL STATE=FLOW)
    (len=200)

Sponsored-by: On-Waves ehf
2015-03-25 12:12:29 +01:00
Jacob Erlbeck 2493c660e9 tbf/test: Fix fn/block_nr in test_tbf_final_ack
Currently fn and block_nr are not incremented correctly. In addition,
the comments around the sending of blocks are not accurate either.

This commit introduces the send_rlc_block helper function which takes
care of the increments, updates the comments to reflect what is
really happening, and adds assertion to verify at least some aspects
of what is now stated in the comments.

Sponsored-by: On-Waves ehf
2015-03-25 12:10:48 +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
Jacob Erlbeck 5e9f40d3d9 tbf/test: Modify test to create a dangling TBF pointer
When new_tbf is freed before dl_tbf in test_tbf_final_ack, dl_tbf
still contains a pointer to it in m_new_tbf.

This patch changes the test to accept a test mode parameter and runs
it twice which a different order of tbf_free in each run. Consistency
checks are added, to check for a danglilng m_new_tbf pointer in both
cases.

Sponsored-by: On-Waves ehf
2015-02-23 15:07:06 +01:00
Daniel Willmann 07e39302ec tests/tbf: Commit TbfTest.err *with* whitespace "errors"
Otherwise the diff and hence the test will fail...
2014-09-19 12:01:39 +02:00
Daniel Willmann 0f58af6627 tests/tbf: Use correct function to enqueue llc data
The test called the llc enqueue() function directly which didn't take
care of prepending the tv values for the timeout to the data.

Now the test uses dl_tbf.append() which takes care of prepending the tv
values. With this patch make distcheck on jenkins should no longer fail
with "Discarding LLC PDU because lifetime limit reached." messages.
2014-09-19 11:57:21 +02:00
Daniel Willmann 510d7d36ed tests/tbf: Test for final ack issue
Ticket: SYS#382
Sponsored-by: On-Waves ehf
2014-09-10 19:19:58 +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 341689d6c5 TbfTest: Make logging more verbose
Sponsored-by: On-Waves ehf
2014-08-15 18:28:45 +02: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