Commit Graph

49 Commits

Author SHA1 Message Date
Max 1187a7719c Update header includes
Many files include unnecessary headers and don't include headers which
are actually used. Because of that combined with the fact that OsmoPCU
is a mixture of C and C++, it makes it hard to modularize code. Fix
this (using iwyu [1] tool):

* add missing headers
* remove unused headers

[1] https://include-what-you-use.org/

Related: OS#1539
Change-Id: I8c9f488a43b099c72b2d30d3245e7ba50872fc00
2018-02-19 08:43:46 +00:00
Max 1962136a33 Assert valid CS
The coding scheme converted to number make sense only if it's
valid. This is implicitly assumed by the code using this conversion as
non-zero value. Make those assumptions explicit with OSMO_ASSERT().

Change-Id: I8f62627b7b7b89dfa1b0d1a7e71b95b2c40fdffa
Fixes: CID70466
2017-09-08 12:51:03 +02:00
Minh-Quang Nguyen 1f18909335 EDGE: Fix UL link adaptation.
We have seen that UL MCS5- MCS9 link adaptation has not been implemented in current PCU implementation.
If the MS slowly moves far away from the BTS, the UL MCS will always stick at MCS9 no matter UL link quality values leading to poor data service experience.
The UL MCS is expected to adapt from MCS9 -> MCSx due to bad UL quality.

Below PCU traces indicate that UL MCS is quickly increasing to MCS9 (max MCS 9 was used in this test) and it never changes to other UL MCS due zero thresholds.

<0004> gprs_ms.cpp:670 MS (IMSI ): Link quality 23dB (23dB) left window [0, 0], modifying uplink CS level: MCS-6 -> MCS-7
<0004> gprs_ms.cpp:670 MS (IMSI 000): Link quality 23dB (23dB) left window [0, 0], modifying uplink CS level: MCS-7 -> MCS-8
<0004> gprs_ms.cpp:670 MS (IMSI 000): Link quality 23dB (23dB) left window [0, 0], modifying uplink CS level: MCS-8 -> MCS-9

Change-Id: I9272c337ad6399da4a47cc6e2736e25f24e099d8
2017-08-18 18:09:24 +00:00
sivasankari da7250ad2c Add counter at BTS level And statistics at TBF/MS level.
Adds spb counters at BTS level(show bts statistics).
Adds RLC/MAC downlink control msg at ms level(show ms imsi <imsi_val>).
Adds the number of coding schemes counter for UL at TBF level.

Change-Id: Icbe4ba95e34bea89ee36f532d099db68204b7c38
2016-12-22 14:09:04 +00:00
Max 9bbe1600cc Fix Timing Advance handling
* initialize with invalid TA instead of making assumption that phone is
  located within 550 meters (TA=0)
* only set valid TA

Change-Id: Idfc40ff0c11bdac13d9e28fbfa4e95dfc6b735b0
Related: OS#1526
2016-09-09 06:37:04 +00:00
Aravind Sirsikar e8ccafc63d Add Accessor functions for ARQ-II in EGPRS DL
Add accessor function in existing classes to support ARQ-II for
retransmission in EGPRS DL

Change-Id: Iefff956bf2dcfe8fb0b2f5a7a7a2122d5d555f9e
2016-07-13 13:50:04 +00:00
Aravind Sirsikar 99ab0a8fa0 Add header type 1 support for EGPRS uplink
Function is added to parse the EGPRS header type 1 in uplink tbf path.
along with configuration parameter updation to reflect max mcs in UL

Change-Id: I13c250e2e07377982ac3f29745f3cffd4088552a
Reviewed-on: https://gerrit.osmocom.org/270
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 14:32:07 +00:00
Holger Hans Peter Freyther fd263b0dfd tbf: Fix copy and paste in the set_mode routine
This is the second attempt to fix what looks like a copy and paste
issue. The code assigns m_current_cs_ul and then compares the _dl
variant, then assigns m_current_cs_ul with a default value. It seems
to indicate that _ul should be used.

Fixes: Coverity: CID 1351733
2016-03-04 18:26:43 +01:00
Holger Hans Peter Freyther 99db40ad2d Revert "Refactor coding scheme assignment code"
Roll-out the refactoring change. The code did not include the
necessary update to the test result and there are some concerns
about it in itself and the right approach would have been to
fix the copy and paste issue, then do the refactoring.

This reverts commit 22d7e75e1f.
2016-03-04 18:26:43 +01:00
Max 22d7e75e1f Refactor coding scheme assignment code
Previously this code used too much copy-paste of boilerplate code which
is error-prone and hard to read. Factor out actual (M)CS assignment into
separate function and use it for both DL and UL cases in respective
mode.

Fixes: Coverity: CID 1351733
2016-02-25 14:03:49 +01:00
Jacob Erlbeck 14e26cbca3 ms: Fix GprsMs::current_cs_dl()
Currently the queue length is overwritten by the remaining chunk
length, which should be added instead. This may result in a lower
CS/MCS value than expected.

Add the chunk length instead if the TBF is present.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:40 +01:00
Jacob Erlbeck 7c72acaa94 ms: Add current_pacch_slots method
The PACCH is specific to an MS and may change when a TBF is
established or removed (see TS 44.060, 8.1.1.2.2). For multislot
class type 2 phones, more than one timeslot may be used to transmit
RLC/MAC control messages.

Add a method that returns a set of TS which can be used for the
PACCH.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck 53bc1861c4 edge: Fix initial coding scheme selection
Currently the coding scheme gets reset when GprsMs::set_mode()
is called even if the mode did not change.

Make sure, that the CS is only reset, if it is not compliant to the
new mode.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:35 +01:00
Jacob Erlbeck cb7289094a edge: Replace integer cs by GprsCodingScheme
Currently the TBF and MS object use a plain integer value
(current_cs) to manage the coding scheme. This makes it difficult to
support the MCS schemes. GprsCodingScheme supports a partial ordering
of these values (CS and MCS) and provides safe increment and
decrement methods.

Use the GprsCodingScheme type instead of integer for cs fields and
variables. Add a 'mode' to GprsMs which can be set to either GPRS,
EGPRS, or EGPRS_GMSK which also set the initial values of
current_cs_ul/dl. Select the mode based on max_mcs_ul and max_mcs_dl.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:14 +01:00
Jacob Erlbeck aa9daa1b9d tbf: Replace static casts by calls to as_ul_tbf/as_dl_tbf
Currently casts from gprs_rlcmac_tbf to gprs_rlcmac_ul_tbf and
gprs_rlcmac_dl_tbf are done by using static_cast. This doesn't provide
protection against converting a gprs_rlcmac_ul_tbf pointer to a
gprs_rlcmac_dl_tbf pointer and vice versa.

This commit provides two functions as_ul_tbf and as_dl_tbf, that
behave similar like dynamic_cast but use the direction field instead
of RTTI.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:13 +01:00
Jacob Erlbeck c3c58046c7 edge: Get EGPRS multislot class
The EGPRS MS class ist contained in the MS_RA_capability information.
Its presence indicates, that the MS is able (and willing) to use
EGPRS.

This commit implements basic support for retrieving, storing, and
showing it in the VTY. The information is stored in the MS object.

Sponsored-by: On-Waves ehf
2015-11-30 12:20:36 +01: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 e0b21f41c2 tbf: Move pending LLC frames when merging MS objects
Currently the pending LLC packets are lost in some cases when MS
objects are merged, for instance after a RACH when there were 2 MS
object for the same MS (they get merged, when the TLLI is known for
both objects).

This patch modifies GprsMs::merge_old_ms to move all pending LLC
packets (if there are any) to the current MS object.

Sponsored-by: On-Waves ehf
2015-08-21 19:02:18 +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 1c3b8998bc ms: Set default CoDel interval to 4s
The current default interval is 2s which seems to be too short when
the DL TBF has to be established. This may cause freezing or really
slow TCP connections.

This commit increases the default value to 4s. When the
dl-tbf-idle-time is set, DL TBF are established less frequent, so
smaller values (like 2s or below) can be used to improve the average
latency when the load is high.

Sponsored-by: On-Waves ehf
2015-08-14 16:35:34 +02:00
Jacob Erlbeck ac28905082 tbf: Handle TLLI change on DL
When doing an RA Update the network can request to change the TLLI.
In this case, there can be 2 MS objects with different TLLI for a
single real MS. The first is associated with the old TLLI and the
IMSI, while the second is associated with the new TLLI and no IMSI if
it had been created for the uplink TBF. When the first message with
the new TLLI and the IMSI arrives from the network, the PCU is able
to detect this.

Currently this is not handled properly. The TBFs of the old MS object
are not cleaned up properly, keeping the old MS from being deleted.

This patch modifies gprs_rlcmac_dl_tbf::handle to check for this and
if neccessary to move an existing DL TBF and to clean up the old MS
object to ensure its deletion.

Sponsored-by: On-Waves ehf
2015-08-14 16:35:29 +02:00
Jacob Erlbeck d4ad731bae llc: Use CoDel to drop packages from the LLC queue
Currently packets are only dropped if they have reached their maximum
life time. This leads to LLC queues being constantly filled under
load, increasing the latency up to the maximum life time. This kind
of bufferbloat hinders TCP's congestion avoidance algorithms. To keep
the queues short, the CoDel active queue management algorithm can be
used.

This commit changes to llc_dequeue method to apply the CoDel
algorithm to selectively drop LLC frames before they passed to the
TBF layer to be encoded in BSNs. This feature is currently disabled
by default.

The CoDel state is managed per MS since the LLC queues are also kept
in the MS objects.

Note that there is still some buffering in the TBF objects, in the
worst case (CS4) 3.5kByte + LLC-MTU octets are stored there. The
resulting additional packet delay is not (yet) taken into account for
CoDel.

Also note that configuration changes are applied to new MS objects
only.

The following VTY commands are added to the 'pcu' node:

- queue codel           activates CoDel, the interval is selected by
                        the implementation
- queue codel interval <1-1000>
                        activates CoDel with a fixed interval given
                        in centiseconds (10ms-10s)
- no queue codel        deactivates CoDel

Which interval value to use is still an open issue. For high speed
links (e.g. Ethernet), CoDel suggests 100ms. For slower links, the
expected RTT is recommended. The current implementation uses a
default value of 2000ms.

Measurements:

Note that the following measurements depend on several other factors,
most notably the interaction with the SGSN's flow control. They are
just examples to give an idea how CoDel might influence some
parameters.

The measurements have been done with a single E71, first with a
running ping only (Idle), then with an additional TCP download
of a 360k file (Busy). The CoDel interval was set to 1s.

- Idle :
        ping ~400ms, avg queue delay 0ms, dropped 0
- Busy, No CoDel:
        ping ~6s, avg queue delay 4-6s,
        dropped  0, scheduled  948, duration 54s
- Busy, CoDel:
        ping 500-1500ms, avg queue delay ~600ms,
        dropped 77, scheduled 1040, duration 60s

More measurements with two MS downloading in parallel (two
independant measurements per case).

- Busy, No CoDel:
        dropped  0, scheduled 1883, duration 121s
        dropped 19, scheduled 2003, duration 133s
- Busy, CoDel:
        dropped 22, scheduled 1926, duration 116s
        dropped 22, scheduled 1955, duration 108s

Sponsored-by: On-Waves ehf
2015-07-21 19:22:36 +02:00
Jacob Erlbeck b2439bbb8a ms: Add is_idle() method to GprsMs::Guard
Currently there is no simple way to determine, whether the MS object
protected by a guard will continue to exist after the guard object is
destroyed.

This patch adds a is_idle() method that will return true if the MS
object is just kept by the guard from being idle. In that case, the
MS object would either be deleted or return true for
GprsMs::is_idle() after the guard's destruction, provided that no
TBF attachment took place in between.

Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +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 23f93a15ca ms: Add support for slot reservation
In contrast to the slots currently used by existing TBFs, the
reserved slots refer to the time slots that can be used for newly
allocated TBFs without causing conflicts (given that the first common
TS does not change). They correspond to the potential use of the
PDCHs and can be used to achieve a more uniform slot allocation.

This commit adds bit set based methods to GprsMs and gprs_rlcmac_trx
and a counter to gprs_rlcmac_pdch. The current TRX will also be
stored in the MS object.

Sponsored-by: On-Waves ehf
2015-07-03 15:37:16 +02:00
Jacob Erlbeck ac89a555fa ms: Add tbf() method to get the TBF based on the direction
To avoid the need for a switch or conditional statement when needing
a TBF from an MS object in direction independant code, this method
contains that case distinction. For additional flexibility, a
reverse() function is added to get the opposite direction.

Sponsored-by: On-Waves ehf
2015-07-03 13:17:22 +02:00
Jacob Erlbeck 699b8dca49 ms: Add first_common_ts method to GprsMs
This method gets the index (0 based) of first common time slot used
by the TBFs attach to it. It expects that all of them have the same
notion of this. If no TBF is attached, -1 will be returned.

Sponsored-by: On-Waves ehf
2015-07-03 13:17:22 +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 70b96aa232 ms: Reduce DL CS level if only a few LLC bytes are left
If just a few bytes are left to send to the MS, it makes sense to
reduce the coding scheme level to increase the throughput. This
has been shown by Chen and Goodman in their paper "Theoretical
Analysis of GPRS Throughput and Delay". See their throughput over C/I
measurement graphs (figures 4 and 5 in the paper) for details.

This commit implements a simplified CS downgrade feature for the
downlink. The coding scheme will be downgraded if there are only a
few octets are left to be send over the TBF (see the
downgrade-threshold command below) and the NACK rate is not low (the
CS will not get degraded on a high quality RF link). As an exception,
CS-3 will be degraded to CS-1, since CS-2 does not improve the
throughput in general when a few small packets are sent and the
signal fades slowly (see Chen/Goodman).

The following VTY command is added to the config-pcu node:

- cs downgrade-threshold <1-10000>
- cs no downgrade-threshold

to set the threshold of the number of remaining bytes to be RLC/MAC
encoded. The CS will only be reduced, if the number is below the
threshold. The 'no' command disables this feature completely. The
default value is 200 octets.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 04a108617a ms: Store the NACK rate in the MS object
Currently the NACK/unconfirmed ratio is already passed to the
corresponding MS object, but the value is not being stored there.

This commit adds a member and a getter method and include the values
into the output of the 'show ms' command.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 51b1151044 l1: Store measurement values sent by the MS
This commit extends the pcu_l1_meas structure by MS side measurement
values which are transmitted by PACKET DOWNLINK ACK/NACK and
PACKET RESOURCE REQUEST messages. The encoded values are remapped to
dB respectively % values. The values are stored in the corresponding
MS object (if there is one).

Note that the values are store as (rounded) integers, so some
different encodings are mapped to the same decoded value.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 94cde130ca ms: Add UL CS selection based on L1 link quality
Currently the UL CS values are set to the corresponding DL CS value,
eventually limited by a maximum value. This approach does not reflect
the general situation of the RF link between ME and BTS, which is
rather asymmetric e.g. due to a lower degree of TX efficiency of the
built-in antenna. This means, that UL and DL CS control should be
decoupled for better results.

This commit adds automatic UL CS selection based on the link quality
measurement parameter. Each coding scheme is mapped to a link quality
range. If the link quality value leaves that range, the current UL CS
value is increased/decreased accordingly. This value will be copied
when the next PACKET_UPLINK_ACK_NACK or PACKET_UPLINK_ASSIGMENT is
sent to the MS.

The following VTY command will be added to the config-pcu node:

-  cs link-quality-ranges cs1 <0-35> cs2 <0-35> <0-35>
          cs3 <0-35> <0-35> cs4 <0-35>

which sets the ranges for the four coding schemes. For instance the
example below reflects the current default values:

  cs link-quality-ranges cs1 6 cs2 5 8 cs3 7 13 cs4 12

set the following ranges, where the overlapping is used to configure
a hysteresis:

  CS1: -inf ..  6
  CS2:    5 ..  8
  CS3:    7 .. 13
  CS4:   12 .. inf

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck e4bcb62dbf ms: Store the L1 measurement values in the MS objects
This commits adds the GprsMs::update_l1_meas() and GprsMs::l1_meas()
methods to store and access the measurement values. The internal
state is updated depending on which values are actually set.

In addition, these values are shown in the output of the 'show ms
imsi|tlli' command.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 0808f68601 ms: Fix timer start condition (Coverity)
Currently the timer can be started even if m_ul_tbf is attached.

Replace m_dl_tbf by m_ul_tbf to only start the timer if _both_ TBF
are detached.

Fixes: Coverity CID 1304683
Sponsored-by: On-Waves ehf
2015-06-11 13:13:55 +02:00
Jacob Erlbeck 25db7c6116 ms: Add missing initialiser for m_delay (Coverity)
Set m_delay to 0 in the constructor to disable the timer feature by
default.

Fixes: Coverity CID 1304682
Sponsored-by: On-Waves ehf
2015-06-11 13:13:55 +02:00
Jacob Erlbeck b33e675e5a ms: Add support for maximum CS values
Currently the CS values can be increased to CS4 even when the "cs"
configuration command has been used with a lower value. The "cs"
command just sets the initial coding scheme, so other means are
needed to limit the selection. One approach is to use the CS flags
passed in SI, but these are currently ignored.

To make it possible to limit the CS selection by configuring the PCU,
this commit adds the following VTY commands to config-pcu:

- cs max <1-4>             Limit DL and UL CS to the given value
- cs max <1-4> <1-4>       Limit DL and UL CS separately (DL first)
- no cs max                Don't limit

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-06-08 09:41:07 +02:00
Jacob Erlbeck 8158ea7288 ms: Add blocking period for CS upgrade
Currently the CS level is immediately increased if the error rate
drops below the lower threshold. Since the measurement values are not
damped, this behaviour leads to a quick return to higher CS values
even under bad radio conditions. Since with GPRS RLC/MAC blocks
cannot be resent with another coding scheme, increasing the CS value
should be done carefully.

This commit adds a blocking period that only allows higher CS values
if all error rate measurements were below the LOW threshold for a
certain amount of time (currently fixed to 1s).

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-06-08 09:40:48 +02:00
Jacob Erlbeck 1751c62c98 tbf: Add adaptive DL CS adjustment
To cope with transmission failures due to bad radio conditions, a
different coding scheme with more redundance can be used.

This commit adds an implemenation that is based on the Ack/Nack
ratio per PACKET DOWNLINK ACK/NACK message received from the MS.

Basically the CS level is decreased, if the block error rate goes
above cs_adj_upper_limit (default 33%), and it is increased, if the
rate drops below cs_adj_lower_limit (default 10%). Only blocks that
have been encoded with the current CS are taken into account.

Note that this approach doesn't measure the MS->BTS conditions and
that the measurement values reported by the MS are not taken into
account.

Ticket: #1739
Sponsored-by: On-Waves ehf
2015-06-08 09:40:09 +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 17214bb06d ms: Add back pointer to BTS
Since more functionality will be moved to the GprsMs class, a pointer
to the current BTS object is added to allow access to configuration
data and other methods.

Sponsored-by: On-Waves ehf
2015-06-08 09:39:07 +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 d9e102472a ms: Add timer
Currently the MS object is immediately idle when all TBFs are
detached and if no guard is being used. Since the plan is to use the
MS objects to pass information from one TBF to the next one even
across the gap of some seconds of inactivity, a mechanism is needed
to keep the MS objects around for some time.

This commit extends the GprsMs class by a timer that keeps the MS
objects in non-idle state for some time after all TBFs have been
detached. The set_timeout method must be used with a non-zero value
to activate this feature.

Sponsored-by: On-Waves ehf
2015-05-28 16:38:16 +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 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 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 5367086175 ms: Add MS storage class
Currently the MS objects are contained in the TBF objects only. To
allow for an extended life time after the TBF objects have been freed
and to find them based on TLLI, a container for the MS objects is
needed.

This commit adds the container class and also adds the corresponding
m_list member to GprsMs. Further integration into the PCU code is not
yet done.

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 e04e0b0a20 ms: Add GprsMs class to hold per-MS information
Currently only TBF objects are used to handle the data flow between
the MS and the SGSN. MS specific data (e.g. pending LLC frames, TLLI)
is copied between successive TBFs. If all TBFs (uplink and downlink)
are idle for some time, all information about the MS is discarded in
the PCU. This makes the implementation of some features more
difficult, e.g. proper TLLI and timing advance handling,
connection based CS selection, and proper management of multiple TBF.

This commit adds the GprsMs class that is intended to hold
information directly related to the MS and to keep references to the
active TBFs.

The class is not yet integrated with the other PCU code. A GprsMs
object container and MS specific fields (TA, CS) will be added in
later commits.

Note that calling detach_tbf() can possibly delete the MS object
depending on the callback implementation.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-20 11:30:41 +02:00