aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs_ms.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-06-16Add header type 1 support for EGPRS uplinkAravind Sirsikar1-2/+2
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-03-04tbf: Fix copy and paste in the set_mode routineHolger Hans Peter Freyther1-1/+1
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-04Revert "Refactor coding scheme assignment code"Holger Hans Peter Freyther1-33/+32
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 22d7e75e1f160e5337140d9f3dcb2679b621b646.
2016-02-25Refactor coding scheme assignment codeMax1-32/+33
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-08ms: Fix GprsMs::current_cs_dl()Jacob Erlbeck1-1/+1
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-08ms: Add current_pacch_slots methodJacob Erlbeck1-0/+26
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-08edge: Fix initial coding scheme selectionJacob Erlbeck1-12/+17
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-01edge: Replace integer cs by GprsCodingSchemeJacob Erlbeck1-56/+162
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-01tbf: Replace static casts by calls to as_ul_tbf/as_dl_tbfJacob Erlbeck1-2/+2
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
2015-11-30edge: Get EGPRS multislot classJacob Erlbeck1-0/+13
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-08-24ms: Store references to replaced TBFs in the MS objectJacob Erlbeck1-6/+26
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-21tbf: Move pending LLC frames when merging MS objectsJacob Erlbeck1-0/+2
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-18ms: Move MS information merging to GprsMSJacob Erlbeck1-0/+14
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-14ms: Set default CoDel interval to 4sJacob Erlbeck1-1/+1
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-14tbf: Handle TLLI change on DLJacob Erlbeck1-0/+14
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-07-21llc: Use CoDel to drop packages from the LLC queueJacob Erlbeck1-1/+17
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-16ms: Add is_idle() method to GprsMs::GuardJacob Erlbeck1-0/+8
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-03ms: Get the set of slots currently activeJacob Erlbeck1-0/+26
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-03ms: Add support for slot reservationJacob Erlbeck1-3/+34
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-03ms: Add tbf() method to get the TBF based on the directionJacob Erlbeck1-0/+9
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-03ms: Add first_common_ts method to GprsMsJacob Erlbeck1-0/+11
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-06-29tbf: Always create an MS object on TBF allocationJacob Erlbeck1-1/+1
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-22ms: Reduce DL CS level if only a few LLC bytes are leftJacob Erlbeck1-0/+33
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-22ms: Store the NACK rate in the MS objectJacob Erlbeck1-1/+4
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-22l1: Store measurement values sent by the MSJacob Erlbeck1-0/+17
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-22ms: Add UL CS selection based on L1 link qualityJacob Erlbeck1-8/+40
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-22ms: Store the L1 measurement values in the MS objectsJacob Erlbeck1-0/+12
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-11ms: Fix timer start condition (Coverity)Jacob Erlbeck1-1/+1
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-11ms: Add missing initialiser for m_delay (Coverity)Jacob Erlbeck1-1/+2
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-08ms: Add support for maximum CS valuesJacob Erlbeck1-2/+11
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-08ms: Add blocking period for CS upgradeJacob Erlbeck1-6/+30
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-08tbf: Add adaptive DL CS adjustmentJacob Erlbeck1-0/+36
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-08tbf: Move the current CS field to GprsMsJacob Erlbeck1-0/+12
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-08ms: Add back pointer to BTSJacob Erlbeck1-2/+3
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-08tbf: Store MS class in GprsMs objectsJacob Erlbeck1-0/+13
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-08tbf: Move the LLC queue to GprsMsJacob Erlbeck1-0/+2
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-05-28ms: Add timerJacob Erlbeck1-5/+52
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-28tbf: Store the timing advance (TA) value in the GprsMs objectJacob Erlbeck1-0/+13
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-28tbf: Move IMSI to MS objectJacob Erlbeck1-0/+27
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-21ms: Support new and old TLLIsJacob Erlbeck1-2/+44
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-20ms: Add MS storage classJacob Erlbeck1-1/+2
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-20tbf: Add MS object management to TBF codeJacob Erlbeck1-0/+13
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-20ms: Add GprsMs class to hold per-MS informationJacob Erlbeck1-0/+182
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