Commit Graph

163 Commits

Author SHA1 Message Date
Alexander Couzens 5c3783b7e8 gprs_bssgp_pcu: explicit allocate & initialize bssgp_nsi instance
The instance bssgp_nsi is a global instance to be used by all
NS related functions. Previous the PCU allocated and initialized
the bssgp_nsi instance when (re-)connecting and freeing on disconnect.
The problem of the implicit initialisation is gprs_ns_vty_init(bssgp_nsi).
All vty init functions must be called before the configuration is read,
otherwise a previous vty written configuration is invalid.
Furthermore the vty modifications to the `ns` object were lost when the PCU has to
reconnect to the SGSN.

Fixes: OS#4024
Change-Id: I2aa53ea54e9352577f6280ad7b9d1d9da9f57eaf
2019-06-07 01:17:53 +02:00
Alexander Couzens eb64d43922 gprs_bssgp_pcu: make gprs_bssgp_ns_cb public
rename the function sgsn_ns_cb -> gprs_bssgp_ns_cb.
To allow writing and reading the same configuration, the pcu needs to register
all vty commands before reading the configuration. This callback
is required to register NS based vty commands

Related: OS#4024
Change-Id: I440c0df2e32fe22bf43288c00bb4aa3a0c6a3a51
2019-05-25 05:56:32 +02:00
Max 136ebccc5e MCS: use value_string for conversion
Change-Id: I212ebb892ab162821633974d5a6c7e315d308370
2019-03-19 18:27:49 +01:00
Max 51754b6f35 MCS: move HeaderType enum outside of class definition
Move functions which compute number of blocks or bits depending on
header type and corresponding enum outside of GprsCodingScheme
class. This will allows us to use standard libosmocore value_sting
functions in upcoming patches for IA Rest Octet encoding/decoding.

Change-Id: Id0873f85e1f16a72e17e7fbc4ad76b194917067f
2019-03-19 18:27:06 +01:00
Harald Welte 57d3515abd Optionally Use the NS Sub-Network-Service (SNS) on Gb
This change add support for the recently-introduced GPRS Gb interface
auto-configuration using the NS IP Sub-Network Service (SNS) procedures.

It requires a Change-Id I84786c3b43a8ae34ef3b3ba84b33c90042d234ea of
libosmocore.

Related: OS#3372
Depends: I84786c3b43a8ae34ef3b3ba84b33c90042d234ea (libosmcore)
Change-Id: I256b40ac592d3b6e75dd581bf7b9512f69b11e83
2019-02-26 13:23:24 +01:00
Harald Welte b26854c276 Mark gprs_ns_reconnect() as static (not used outside of C file)
Change-Id: I95138adedacdc2d953284cff57f79ecb33616f0f
2019-02-26 11:11:51 +00:00
Stefan Sperling 3df1532e97 check bssgp_tlv_parse() return code in gprs_bssgp_pcu_rcvmsg()
The return code from bssgp_tlv_parse() was not checked for a parsing
error. In case of a parsing error the stored return code could have
been overwritten later in this function.

Explicitly check for a parsing error, log corresponding packets,
and return an "invalid mandatory information" error status to
the sender. To avoid loops, do not respond with an error status
to STATUS PDUs.

Change-Id: I56e10a97cda7fd2d40bc7b4b2e6202f97772e1b3
Related: OS#3178
2018-06-25 13:02:06 +02:00
Pau Espin 74906224ca gprs_bssgp_pcu.cpp: Comment unused function parse_ra_cap
Commit 741d25cb6f commented the only user
of the function but forgot to comment too the function itself.

Change-Id: I8b291b45aaedfb0421cd28c0d9e24cefa5547b09
2018-03-17 01:43:14 +01:00
Neels Hofmeyr bdc55fad62 implement support for 3-digit MNC with leading zeros
Receive the mnc_3_digits flag from the PCU interface.

Bump the PCU interface to 9.
This is one part of the three identical pcuif_proto.h patches:
- I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts)
- I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu)
- I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc)

Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
         Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore)

Change-Id: I787fed84a7b613158a5618dd5cffafe4e4927234
2018-03-11 00:47:14 +01:00
Max 6dc90b8c86 Move PDCH-related functions into separate files
The PDCH class and corresponding functions are rather self-contained and
independent from BTS implementation. Let's move them into separate file
to make bts.cpp more manageable. As additional benefit it allow us to
somewhat untangle all the different cross-dependent includes.

Change-Id: Ie05e25361e6741a81b024679f9675c98d4923683
Related: OS#1539
2018-02-19 17:41:24 +01:00
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 ef784e4e9e Remove unused includes and forward declarations
Change-Id: I59da04edd1b8ff965bbfbe00ccae1f7c9b6e5301
2017-12-18 22:05:22 +00:00
Philipp Maier 4c9ec22546 gb: allow only packets from a specific SGSN
Each PCU has a specifically assigned SGSN, which may send
packets to the PCU. Ensure that no one else except the
configured SGSN can send packets to the PCU.

Change-Id: Ic2009039fab7cf0fba916556239747ae5b410366
Depends: libosmocore Ifeb201d9006eec275a46708007ff342cdfc14e45
2017-10-24 10:50:17 +00:00
Harald Welte 05d7b5dd59 BSSGP: Improve logging of received messages
We now differentiate clearly between messages that

a) we don't expect based on our reading of the spec
b) we have not implemented yet (but should)
c) we do not even know of

Also, unify the log string formats and provide BVCI whenever possible.

Change-Id: Ie32f5771d49960547ec5d7611f96a74facc1b035
2017-07-29 10:21:24 +02:00
Max 2813f931dd BSSGP: Use libosmocore for BVC-RESET
Implement proper BVC RESET procedure by using libosmocore code to handle
BVCI reset and initiate PTP BVC reset if necessary.

Requires I9bf8f4dd784ccddbb9926492a85fff3293a0e913 in libosmocore.
Related: OS#1638
Change-Id: I718c949759688cb34ce6bcbb3da2092fcdfa6989
2017-07-28 17:42:45 +00:00
Harald Welte 49b78229ca use tlvp_val16be() rather than manual pointer-cast + ntohs()
Change-Id: Ib77cb703bb1710da396db3a939700515b5c20235
2017-06-11 11:40:19 +02:00
Harald Welte 356ac618f1 Fix format string error (string needs %s)
In a49475b5a8 we introduce the use of
bssgp_pdu_str() and change from printing the numeric code to the
stringified version of the message code.  However, the format string
was not updated accordingly :/

Change-Id: I7173b692fb1f222aab44cd4f44a482038d0f51dc
Fixes: Coverity CID 169684
2017-05-25 19:05:32 +02:00
Max a49475b5a8 Print human-readable BSSGP PDU type
Change-Id: Ief4b5ce4e4020edaf771eaa24f4382ec368dd18c
2017-05-23 17:53:38 +02:00
Alexander Couzens ccde5c9557 remove pcu own bitvector implementation
The osmocore bitvec is exact the same, but use a pointer instead of
a reference.

Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7
2017-05-15 12:46:33 +00:00
Neels Hofmeyr a01e2ee177 logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*
In libosmocore, my patch was merged to master a bit too soon. To accomodate the
request for naming that matches the general "LOG" prefix instead of "LOGGING",
a fixup was committed to libosmocore. Adjust for that.

Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067
The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93

Change-Id: I4db4a668f2be07f3d55f848d38d1b490d8a7a685
2017-02-23 18:11:44 +01:00
Neels Hofmeyr 4ae5406959 logging: use central filter and ctx consts from libosmocore
Change-Id: I7b41a5a26527864177c63403ad171d2987f0ff6a
Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067
2017-02-17 17:23:36 +01:00
Jacob Erlbeck 7f28c97fcc edge: Support all coding schemes for BSSGP flow control
Currently the MCS schemes are not supported when the leak rate is
being computed. This leads to a lower value for the leak rate, thus
limiting the throughput to GPRS-like ranges.

Use the payload size reported by GprsCodingScheme instead.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:40 +01:00
Jacob Erlbeck 741d25cb6f bssgp: Ignore downlink BSSGP RA Cap IE
That IE may contain inaccurate or completely bogus data.

This commit disables the parsing.

Note that this should be replaced by a config option.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 4a07a3be11 edge: Get EGPRS MS class from downlink BSSGP
In case there is no MS object present that matches a DL UNITDATA,
the EGPRS class is currently assumed to be 0, since the Radio
Access Capabilities IE is not fully decoded if present.

This commit uses the CSN.1 decoder to parse the IE and uses the
same functions like the uplink related code does to get the GPRS
and EGPRS multislot classes.

Remove the old parse_ra_cap_ms_class function.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:36 +01:00
Jacob Erlbeck acf66fb456 Revert "bssgp: Add hand-coded extended RA Cap parser"
Just keep this for later reference, since a CSN.1 decoder based
implementation will be used.

This reverts commit b37ab36bb14d2d2c1363fbe521cd19984d0c3d4c.
2016-02-08 00:45:36 +01:00
Jacob Erlbeck a35122c496 bssgp: Add hand-coded extended RA Cap parser
Add an extended parse_ra_cap function based on the existing
parse_ra_cap_ms_class which also parses up to the EGPRS related
fields.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:36 +01:00
Jacob Erlbeck c362df25a2 pcu: Fix memory corruption bugs (ASAN)
ASAN has found improper deletion of objects. These only occur
on shutdown but makes it impossible to run the test cases with
full ASAN support.

This commit fixes some of them and deactivates the freeing of the_pcu.bctx
which may cause a corruption in BTS::~BTS() later on.

Note that the latter is only a work-aound and should be fixed
properly. It will leak bctx objects, but this is currently not
critical, since gprs_bssgp_destroy is only called once, immediately
before a call to exit().

Ticket: OW#1572
Sponsored-by: On-Waves ehf
2016-02-01 13:56:32 +01:00
Jacob Erlbeck 14e00f8f66 edge: Extend gprs_rlcmac_dl_tbf::handle by egprs_ms_class
The multislot (MS) class and the EGPRS MS class can also be passed
via BSSGP in an MS Radio Access Capability element which can
optionally be contained in a DL-UNITDATA PDU. While this case is fully
supported for GPRS, the EGPRS MS class in BSSGP messages is ignored.

This commit extends gprs_rlcmac_dl_tbf::handle to pass the EGPRS MS
class, too.

Note, that the EGPRS class is not yet taken from the CSN.1 RA
capability and is always set to 0. Note also, that append_data
still uses ms_class only.

Sponsored-by: On-Waves ehf
2015-12-15 15:19:42 +01:00
Jacob Erlbeck 2db0f08e08 bssgp: Use measured leak rate for flow control
The leak rate sent to the SGSN does not reflect the current CS level,
lost frames, and control message overhead. So the SGSN cannot do
proper queue control under non-optimal conditions.

This commit computes the leak rate for the last flow control interval
by computing the maximum theoretical leak rate and basically
substracting control blocks, nacked blocks, and reduced block sizes
due to CS downgrade. By using this approach, the value will by more
stable on low load, where the value will tend to be near the value
derived from the configuration. On full load the transmitted value is
completely derived from the measurements.

Note that the MS default values are no adapted to the adapted BVC
leak rate, since a single MS which has a lower link quality would
otherwise be reducing the rate of another MS with good radio
conditions, which would not make much sense if they did not share any
PDCH.

Sponsored-by: On-Waves ehf
2015-09-11 11:52:02 +02:00
Jacob Erlbeck ebebad1c92 ns: Reconnect NSVC after timeout
Currently the signal S_NS_ALIVE_EXP emitted by the NS layer if the
alive check has timed out too often is ignored. This prevents the PCU
from reconnecting to the SGSN if it has not been accessible for some
time.

This commit modifies nsvc_signal_cb to reset the NSCV if
S_NS_ALIVE_EXP is sent, so that the PCU continues to send NS RESET
message if that happened.

Sponsored-by: On-Waves ehf
2015-08-17 16:29:34 +02:00
Jacob Erlbeck 6eed1911fd bssgp: Fix leak rate computation CS value
Currently the initial_cs_dl value is used to compute the maximum leak
rate. This can be too low if adaptive CS selection is used.

This commit changes gprs_bssgp_tx_fc_bvc to derive the max CS level
from the configuration.

Sponsored-by: On-Waves ehf
2015-07-21 19:22:36 +02:00
Jacob Erlbeck 7f79f0d332 bssgp: Adapt flowcontrol MS default to current alloc algorithm
Currently the values Bmax/R default MS are computed under the
assumption than min(4, N_PDCH) DL slots are allocated for an MS, even
if multislot assignment is not enabled.

This commit changes the computation to assume 1 DL slot if algorithm
A is selected or the dynamic algorithm is used and has disabled
multislot assigment due to high load.

Sponsored-by: On-Waves ehf
2015-07-17 12:06:19 +02:00
Jacob Erlbeck 1e50a3dade llc: Make timeval arguments const
Some struct timeval pointer arguments do not have the const qualifier,
albeit the methods do not write to the structures. The next commit
will change related pointers to const, so this commit provides the
required constness.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 0ae4313800 bssgp: Calculate the avg_delay_ms in 32bit only (Coverity)
Currently the delay_sum is stored in 64 to avoid overflow errors.
But only the result of tv_sec * 1000 is casted to 64 bit, resulting
in an overflow if the accumulated queue delay reached 25 days (which
will not happen in practice, unless there are >200k LLC messages with
a max of 10s delay each in the queue). If that were the case, the
only impact would be a wrong number in a log message and in the BSSGP
FLOW CONTROL message.

This commit changes the calculations so that they are done in 32 bit
only, rather than to do the calculation in 64 bit properly.

Fixes: Coverity CID 1298705
Sponsored-by: On-Waves ehf
2015-06-11 13:13:55 +02:00
Jacob Erlbeck 09fdf6622a bssgp: Handle btcx == NULL in gprs_bssgp_pcu_rx_sign (Coverity)
Currently it is assumed, that btcx is non-NULL. The btcx is only used
to obtain the BVCI in some log messages.

This commit changes that by using -1 as shown BVCI value.

Fixes: Coverity CID 1040961
Sponsored-by: On-Waves ehf
2015-06-11 13:13:55 +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 6eeb7c7e74 bssgp: Increment BSSGP flow control tag value
Currently the tag value in FLOW CONTROL BVC messages is always 1.

This commit changes the implementation to increment that value with
each of the FLOW CONTROL BVC messages that is sent to the SGSN.

Sponsored-by: On-Waves ehf
2015-05-06 15:26:08 +02:00
Jacob Erlbeck 6e4ccec6c4 bssgp: Compute and transmit queue delay
The specification 28.018,  allows to transmit the average LLC downlink
queueing delay in FLOW CONTROL BVC messages (BVC Measurement IE, see
GSM 28.018, 10.4.4 and 11.3.7).

This commit extends gprs_bssgp_pcu.cpp to compute the average delay
time between two subsequent FLOW CONTROL BVC messages. The average is
implemented as an arithmetic average without any weighting.

Ticket: OW#1432
Sponsored-by: On-Waves ehf
2015-05-06 15:22:57 +02:00
Jacob Erlbeck 0288cdb0a8 bssgp: Add VTY command to Limit the bucket size by time
Currently the bucket size is by default being computed based on the
leak rate and the expected life time of LLC frames. The latter is
either taken from 'queue lifetime' (if given) or a fixed value is
used. Using 'queue lifetime' has the drawback that it sets a 'hard'
limit, since frames will be dropped if they stay in the queue
for a longer time.

This commit adds a VTY command to specifically set the time used for
the computation of the bucket size advertised to the SGSN. It does
not affect the PCUs queue handling in any way. If the bucket time is
not set (or if the 'no' command has been used), the old behaviour
(see above) is applied.

The following VTY commands are added (config-pcu node):

- flow-control bucket-time <1-65534>  Sets the time in centisecs
- no flow-control bucket-time         Don't use this time

Ticket: OW#1432
Sponsored-by: On-Waves ehf
2015-05-06 15:22:33 +02:00
Jacob Erlbeck 3d62fc55d8 bssgp: Compute BVC bucket size and leak rate
Currently the PDCH assignment and coding scheme does not influence
the values transmitted by the FLOW-CONTROL-BVC messages.

This commit adds the computation of those values. If the leak rate is
not given explicitly, it is derived from the number of PDCH and the
allowed coding scheme. If the BVC bucket size is not given
explicitly, it is derived from the leak rate and the maximum buffer time.
The latter is taken from the 'queue lifetime' command (or 10s if this
has not been used). The MS default bucket size is set to 50% of the
BVC bucket size. The MS default rate computation assumes, that each MS
only supports up to 4 time slots for GPRS RX.

Sponsored-by: On-Waves ehf
2015-05-06 15:20:43 +02:00
Jacob Erlbeck 87d7341fbe bssgp: Make BVC bucket size / leak rate configurable
Currently the FLOW-CONTROL_BVC message contains fixed values: The tag
is 1, the BVC bucket size is 6MB, the BVC bucket leak rate is
820kbit/s, the MS bucket size is 50kB, and the MS leak rate is
50kbit/s.

This commit makes the BVC parameters configurable and adds the
following VTY commands:

- flow-control force-bvc-bucket-size <1-6553500>
- no flow-control force-bvc-bucket-size
- flow-control force-bvc-leak-rate <1-6553500>
- no flow-control force-bvc-leak-rate
- flow-control force-ms-bucket-size <1-6553500>
- no flow-control force-ms-bucket-size
- flow-control force-ms-leak-rate <1-6553500>
- no flow-control force-ms-leak-rate

The 'no' variants restore the default behaviour.

Sponsored-by: On-Waves ehf
2015-05-06 15:20:35 +02:00
Jacob Erlbeck 39645b824a bssgp: Handle BSSGP STATUS messages
Currently incoming BSSGP STATUS messages are just logged and apart
from that ignored. Since it is possible that the gbproxy can
eventually send both valid replies (from the primary SGSN) and
STATUS(unknown BVCI) messages (from the secondary SGSN). Since the
PCU assumes in this case that the BVC has been successfully reset and
unblocked, it will not send a BVC RESET message after receiving an
NS_UNBLOCK.

This commit changes gprs_bssgp_pcu_rcvmsg to pass BSSGP STATUS
messages to bssgp_rcvmsg() which will in turn call bssgp_prim_cb()
with primitive NM_STATUS. Then the BVC RESET or UNBLOCK procedure
will be started if the IE in the message matches and the PCU assumes
that the BVC should have been successfully reset and unblocked
respectively while the STATUS message tells otherwise.

Note that bssgp_rcvmsg() from libosmocore is otherwise used for the
SGSN side only, albeit it generally just decodes messages, does basic
protocol handling and eventually invokes PRIM indications. The only
exception here is the handling of BVC RESET, which is implemented
specifically for the SGSN.

Ticket: OW#1414
Sponsored-by: On-Waves ehf
2015-03-17 10:44:07 +01:00
Jacob Erlbeck 1e96af6325 bssgp: Set blocking and reset timer to 30s
Currently the timer T1 and T2 are hard-coded to 1s which is pretty
low in consideration of a possible high latency connection to the
SGSN.

This commit introduces macros for the timer values and sets them to
30s.

Sponsored-by: On-Waves ehf
2015-03-17 10:43:42 +01: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 6d8884de49 Always exit and don't try to recover
The current code tries to recover from dropped connections and resets the
pcu state so it can keep running. However, this never worked correctly
which is why the -e option is used. This option exits the pcu as soon as
the internal state needs to be reset.

This patch removes this option and makes this behaviour default.

Ticket: SYS#390
Sponsored-by: On-Waves ehf
2014-06-15 19:28:51 +02:00
Holger Hans Peter Freyther d26318e4a7 misc: Fix coverity warning about indention
So we had one intended line inside the if for "SMS VALUE" and
at the same time one line with "SMS VALUE" at the same indention.
Assume it is copy and paste and remove the line. Currently we
are only parsing the ms_class so this change should not have any
semantic change.

Fixes: Coverity CID 1058761
2013-11-11 20:28:29 +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 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 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 17c31ce173 tbf: Begin to add some structure to the tbf code
The TBF should use the IMSI to identify a block flow but all
handling is spread across the entire code. Start to clean this
up by moving relevant code into the tbf file. Afterwards one
can clean up and add more internal structure.
2013-10-18 15:15:49 +04:00
Holger Hans Peter Freyther d6bd91e4e5 tfi: The tfi_alloc doesn't allocate anything, rename the function
Call things by what they do and this function doesn't allocate
anything but it is searching for the first unallocated tbf index.
2013-10-02 18:08:31 +04:00
Holger Hans Peter Freyther 416ce69550 bssgp: Add callback UNITDATA.DL messaes with the data 2013-09-04 21:28:53 +04:00
Holger Hans Peter Freyther c0f1644c88 bssgp: Add callbacks for certain BSSGP events
Add a callback called when Unblock Ack is received. This can be
used by a supervisor or the emulation test.
2013-09-04 21:28:53 +04:00
Holger Hans Peter Freyther e8d9a5fa54 bssgp: Return the gprs_bssgp_pcu instance from create/connect
This can be used to install handlers/testcases to register
callbacks and other data.
2013-09-04 21:28:53 +04:00
Holger Hans Peter Freyther b67a8a348a rlcmac: Reduce the depedency on the global gprs_rlcmac_bts variable
For mocking/unit-testing/emulation (and a dual trx-systems) having
global state is quite bad. Cut back on the usage of the global
struct gprs_rlcmac_bts. It also makes the complexity of certain
routines more clear.
2013-09-04 21:28:53 +04:00
Holger Hans Peter Freyther 90d5df4ae7 bssgp: These routines are not public API.. make them static for now 2013-09-04 21:28:53 +04:00
Holger Hans Peter Freyther a9744debd9 bssgp: Re-indent the switch/case statement 2013-09-04 21:28:53 +04:00
Holger Hans Peter Freyther 421fe79e39 bssgp: The method creates and the connects.. reflect that in the name
Call things by what they do. This method is creating and then connecting
a BSSGP..
2013-08-02 13:39:30 +04:00
Holger Hans Peter Freyther 98fe945a0d misc: Move the parsing of the ms_class from RA Capabilities to a method
Decrease the number of lines of a single method by splitting things up.
The fewer lines of code, branches and side-effects in a method, the easier
it will be to understand. The other benefit is that one can start creating
unit tests for the some parts of the code.
2013-07-30 12:23:25 +04:00
Holger Hans Peter Freyther 249c7e9431 bssgp: Remove commented out code that is currently not used. 2013-07-30 12:22:51 +04:00
Holger Hans Peter Freyther 40bd0c4b57 bssgp: Reset the BVC and NSVC state in the destroy routine
This might explain the issue of the BVCI > 1 not being unblocked
as the internal state has not been re-set when destroying the bssgp.
2013-07-30 12:22:12 +04:00
Holger Hans Peter Freyther 4b984b14a3 misc: Move the nsvc_unblocked into the struct osmo_pcu 2013-07-30 12:21:16 +04:00
Holger Hans Peter Freyther ed70cb733c misc: Move the bvc_timer into the struct osmo_pcu
This continues with the previous changes to reduce the global state.
2013-07-30 12:20:41 +04:00
Holger Hans Peter Freyther d8157c07df misc: Remove the unused sgsn pointer from the compilation unit 2013-07-30 12:20:15 +04:00
Holger Hans Peter Freyther 90692f93cf misc: Move the struct bssgp_bvc_ctx into the struct osmo_pcu 2013-07-30 12:19:40 +04:00
Holger Hans Peter Freyther 90f08efe58 misc: Introduce a struct osmo_pcu and move things into it.
One of the issues with not properly re-setting everything is that
due the global state it is not clear which variables belong together
and how long it exists. Begin with creating a osmo_pcu and moving
things into this class.

Think of an organic cell, this commit is introducing the cell wall
around it... and defines what is inside and what is outside of it.
2013-07-30 12:18:45 +04:00
Holger Hans Peter Freyther a30f47613a misc: Add an option exit/quit when the BSSGP is supposed to be destroyed
The PCU does not properly re-set the state when the connection to the
BTS is lost (and the SGSN potentially is re-started during that). This
results in the BSSGP BVCI > 1 remaining blocked and no data will be
accepted by the SGSN.

Add the '-e' option and exit the PCU when the BSSGP/NS are getting
destroyed.
2013-07-27 22:15:04 +02:00
Holger Hans Peter Freyther 51c57045e5 misc: Remove if (timer_pending) stop_timer idiom from the code
osmo_timer_del is an idempotent operation. There is no requirement
to check if it is running. If you don't want a timer to run, delete
it. Maybe one should have called the method _unschedule, _cancel to
make this more clear.
2013-07-27 22:14:45 +02:00
Andreas Eversberg a004e6a823 Added timing advance support for up and downlink TBFs
The timing advance of any TBF is stored when it ends. Whenever a new TBF
with the same TLLI is created (downlink TBF), the stored TA is recalled.

This algorithm assumes that the mobile does not move too fast during
transfer. Also the mobile must start a connection in order to get correct
initial timing advance.

This algorithm does not implement the timing advance procedure as defined
in TS 04.60. To implement the standard timing advance procedure, the BTS
must decode RACH on certain bursts, the mobile is expected to send them.
This requires much more complexity to a transceiver like USRP/UmTRX or
Calypso BTS.

The algorithm was tested at TA >= 8 and works quite well.
2013-05-13 16:45:21 +02:00
Andreas Eversberg 050ace2fb4 Introduce new file for various measurements
The measurements include:
- DL bandwidth usage
- DL packet loss rate
- DL measurements by mobile
- UL measurements by BTS

In order to receive DL measurements from mobile, it must be enabled via
system information message at BSC.
2013-03-17 17:16:44 +01:00
Harald Welte 30a73d8544 PCU: respect the PCU-side "local port" as configured via L1 IF
This makes sure that the UDP local port of the Gb link is actually
set to what is configured via OML from OpenBSC.
2013-03-10 08:57:03 +00:00
Andreas Eversberg 71cce91a76 Use PCU's talloc context to allocate libosmogb instances
This is usefull to identifiy memory leaks while using libosmogb.
2013-01-16 13:50:42 +01:00
Andreas Eversberg 273a222d7f Fixed memory leaks caused by not freeing bitvector
Especially each data message from SGSN caused two memory leaks, which
resulted in increasing memory usage while receiving date from SGSN.
2013-01-16 09:19:22 +01:00
Andreas Eversberg 02d7cd2ac2 Get rid of allocating first timeslot at tfi_alloc
This simpliefies the allocation process.

tfi_alloc is responsible to allocate a TFI, not a time slot.

The first time slot available depends on multislot class and on other
ongoing TBF (concurrent TBFs), so it is part of the allocation
algorithm to select it.
2013-01-15 08:59:34 +01:00
Harald Welte de5253a20f make sure to register NS protocol to the VTY
Without calling gprs_ns_vty_init(), the NS specific VTY commands are not
activated.
2013-01-11 09:45:17 +01:00
Andreas Eversberg 8c3680dcc9 Added paging PS support by Ivan Kluchnikov
Original code: c7e7f6868b
(The code was committed earlier, but got lost somehow.)

I added IMSI, so the paging request is sent in correct paging group.
Also I excluded rest octets from pseudo length.

It is tested and it work.
2012-12-18 10:03:34 +01:00
Andreas Eversberg 00950743d7 Use seperate function to parse IMSI from BSSGP message 2012-12-18 10:03:24 +01:00
Andreas Eversberg f7adfdebe9 Fix: Removed potential double free bug when receiving NS messages 2012-12-18 10:01:27 +01:00
Ivan Kluchnikov 9eb552b239 Merge branch 'jolly'
Conflicts:
	src/gprs_bssgp_pcu.cpp
	src/gprs_rlcmac.cpp
	src/gprs_rlcmac_data.cpp
	src/gprs_rlcmac_sched.cpp
2012-10-05 18:17:57 +04:00
Andreas Eversberg a3c12fb6c5 Fix: Cleanly open and close NS instance 2012-09-28 22:46:33 +02:00
Andreas Eversberg a9be1547b1 Use PCH confirm from BTS to start downlink packet flow
Since we don't know when the IMM.ASS message is sent on it's paging group
on PCH, we will wait for confirm from BTS and start packet flow then.
2012-09-27 09:23:24 +02:00
Andreas Eversberg 80be275710 Fix: Dump correct NSVCI value at debug line 2012-09-27 09:21:17 +02:00
Andreas Eversberg 514491d726 Fix: Correctly interpret MCC, MNC, CELL ID from BTS 2012-09-23 06:42:07 +02:00
Andreas Eversberg cd8a83a42c Statefull reset and unblock BVCs and sending flow control messages
The flow control interval can be set via VTY.
2012-09-23 06:41:21 +02:00
Andreas Eversberg 14db19ed11 Adding flags for debugging assignment and polling timeout 2012-08-06 15:03:03 +02:00
Andreas Eversberg 08e93cdc3f Use final_ack_sent and contention_resolution_done to define ongoing UL TBF
Both flags can be used to determine wether assignment must be sent on PCH
or on AGCH. Before contention resolution is done, mobile will ignore
downlink assinment. When final uplink acknowledge was sent, the mobile
will go back to PCH after reception of akcnowledge.
2012-07-26 08:13:06 +02:00
Andreas Eversberg ba1cd9bbc2 Fixed two issues found by clang, pointed out by Holger 2012-07-25 09:14:09 +02:00
Holger Freyther 1115f5972c misc: Fix typos in the comments
ressource -> resorce
2012-07-24 11:20:02 +02:00
Andreas Eversberg 7f5352c17b Fix: gprs_rlcmac_trigger_downlink_assignment() selects correct channel
In order to select correct channel (PCH or PACCH), a tbf pointer is set
in case of PACCH. The tbf pointer points to TBF whose PACCH is used.
2012-07-23 18:25:43 +02:00
Andreas Eversberg 24131bf55b Add check of lifetime of LLC frame
If lifetime expires of queued LLC frames, they are discarded. The number
of discarded frames and the sum of their octets are reported to SGSN
via LLC-DISCARDED message.

The lifetime can be overridden via VTY. The value can be centi-seconds
or "infinite".
2012-07-21 11:09:58 +02:00
Andreas Eversberg 06f96cd5a7 Added missing TA value assignment 2012-07-15 07:12:36 +02:00
Andreas Eversberg 592e04ab6d multislot: Rework of handling control channel / polling
In order to send control blocks to MS and receive control blocks from MS
(polling), it is required to select one timeslot that the MS must be
able to send and receive. The allocation algorithm must take care of
selecting that slot.
2012-07-15 06:25:37 +02:00
Andreas Eversberg 51ab134fa8 Added parsing of multislot class inside BSSGP PDU 2012-07-13 14:52:50 +02:00
Andreas Eversberg b0c7ea72c8 Changed data structures for TBF and PDCH instances, to allow multislot
The new data structure is required to define slot/TFI assigment for MS
with multislot capability.

Now there are two lists for TBFs: uplink and downlink. It is possible to
have different TBFs with same TFI in the same direction, as long as they
are assigned on different timeslots.

See tbf.txt for description.

Note: This does not implement any multislot support. It defines the new
data structure. Currently only the first slot is assigned.
2012-07-13 14:46:03 +02:00
Ivan Kluchnikov df72c89e4b Removed unnecessary test for tbf. 2012-07-13 16:00:02 +04:00
Andreas Eversberg b8695f290a Removed obsolete if-condition 2012-07-13 13:48:45 +02:00
Ivan Kluchnikov ef7f28cc7f Merge branch 'jolly_new'
Merge is based on jolly_new branch with two modifications.
1. Modified PCU L1 interface.
pcu_l1_if.cpp - common functions for tx and rx messages on L1 interface.
sysmo_sock.cpp - SYSMO-PCU socket functions.
openbts_sock.cpp - OpenBTS-PCU socket functions.
pcuif_proto.h - L1 interface's primitives.
2. Modified encoding of RLC/MAC Control messages, now we use structures and encode_gsm_rlcmac_downlink() function for encode control blocks (without  hand-coding).
2012-07-12 14:49:15 +04:00
Andreas Eversberg e13fa2d569 Send downlink IMMEDIATE ASSIGNMENT on PCH and not on AGCH
The IMSI is used to define paging group on which it is sent.

This is tested with MS that requires correct paging group.
2012-07-09 17:10:44 +02:00
Andreas Eversberg 0e4030982f Restructured debugging levels to get better overview of TBFs/processes
Only when using LOGL_DEBUG, every detailled information is displayed.

When using LOGL_INFO, a summary of the process is displayed.

When using LOGL_NOTICE, only errors and warnings like timeouts
or invalid received informations are displayed.

When using LOGL_ERROR, only local error like software errorss are
displayed.
2012-07-06 11:04:57 +02:00
Andreas Eversberg 3e372d57ed Cleanup of BSSGP code.
The hack for resetting BSSGP instance is removed and now performed
whenever the NS state changes to UNBLOCKED.

The BSSGP instance is now created only once, as it should be.

Received STATUS messages are ignored as they should be.

The creation and destruction of BSSGP/NS instances is now handled by
layer 1 interface alone.
2012-07-06 09:28:15 +02:00