Hi.
Attached is a small patch which replaces direct call to comp128 from libosmocore to
auth api call. This will help to remove comp128 from libosmocore public api and to
use other auth functions in openbsc in future.
--
best regards,
Max, http://fairwaves.ru
This patch adds a function bts_update_agch_max_queue_length()
to compute a limit of the AGCH queue. This is based on the idea,
that the AGCH queue has a limited drain rate and that CHANNEL
REQUESTs must be answered within a certain time frame, given
by the minimum value of T3126 (see GSM 04.08). When the AGCH queue
reaches that limit, the last message would be delivered in time if
there were no other delays involved (which is not the case).
The calculation is based on the ratio of the number RACH slots and
CCCH blocks per time:
Lmax = (T + 2*S) / R_RACH * R_CCCH
where
T3126_min = (T + 2*S) / R_RACH
R_RACH is the RACH slot rate (e.g. RACHs per multiframe)
R_CCCH is the CCCH block rate (same time base like R_RACH)
The value depends control_channel_desc.ccch_conf and
rach_control.tx_integer (both from SYSINFO_TYPE_3) and should
therefore by called at least each time after one of these is changed.
For this reason, a signal callback is registered under
SS_GLOBAL/S_NEW_SYSINFO which invokes bts_update_agch_max_queue_length().
Based-On: "bts: Calculate length of agch queue" by Ivan Kluchnikov
<kluchnikovi(a)gmail.com>
---
include/osmo-bts/bts.h | 1 +
include/osmo-bts/gsm_data.h | 1 +
src/common/bts.c | 86 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 49ef617..ec061e8 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -26,6 +26,7 @@ void bts_setup_slot(struct gsm_bts_trx_ts *slot, uint8_t comb);
int bts_agch_enqueue(struct gsm_bts *bts, struct msgb *msg);
struct msgb *bts_agch_dequeue(struct gsm_bts *bts);
+void bts_update_agch_max_queue_length(struct gsm_bts *bts);
int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt,
int is_ag_res);
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index aee56a9..ea3fa5e 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -50,6 +50,7 @@ struct gsm_bts_role_bts {
uint8_t max_ta;
struct llist_head agch_queue;
int agch_queue_length;
+ int agch_max_queue_length;
struct paging_state *paging_state;
char *bsc_oml_host;
unsigned int rtp_jitter_buf_ms;
diff --git a/src/common/bts.c b/src/common/bts.c
index 7bbf587..2a6c1bd 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -42,6 +42,7 @@
#include <osmo-bts/bts_model.h>
#include <osmo-bts/rsl.h>
#include <osmo-bts/oml.h>
+#include <osmo-bts/signal.h>
struct gsm_network bts_gsmnet = {
@@ -51,11 +52,32 @@ struct gsm_network bts_gsmnet = {
void *tall_bts_ctx;
+/* Table 3.1 TS 04.08: Values of parameter S */
+static const uint8_t tx_integer[] = {
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 25, 32, 50,
+};
+
+static const uint8_t s_values[][2] = {
+ { 55, 41 }, { 76, 52 }, { 109, 58 }, { 163, 86 }, { 217, 115 },
+};
+
+static int bts_signal_cbfn(unsigned int subsys, unsigned int signal,
+ void *hdlr_data, void *signal_data)
+{
+ if (subsys == SS_GLOBAL && signal == S_NEW_SYSINFO) {
+ struct gsm_bts *bts = signal_data;
+
+ bts_update_agch_max_queue_length(bts);
+ }
+ return 0;
+}
+
int bts_init(struct gsm_bts *bts)
{
struct gsm_bts_role_bts *btsb;
struct gsm_bts_trx *trx;
int rc;
+ static int initialized = 0;
/* add to list of BTSs */
llist_add_tail(&bts->list, &bts_gsmnet.bts_list);
@@ -110,6 +132,11 @@ int bts_init(struct gsm_bts *bts)
bts_gsmnet.num_bts++;
+ if (!initialized) {
+ osmo_signal_register_handler(SS_GLOBAL, bts_signal_cbfn, NULL);
+ initialized = 1;
+ }
+
return rc;
}
@@ -209,11 +236,68 @@ int lchan_init_lapdm(struct gsm_lchan *lchan)
return 0;
}
+#define CCCH_RACH_RATIO_COMBINED256 (256*1/9)
+#define CCCH_RACH_RATIO_SEPARATE256 (256*10/55)
+
+void bts_update_agch_max_queue_length(struct gsm_bts *bts)
+{
+ struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
+ struct gsm48_system_information_type_3 *si3;
+ int T, S, ccch_rach_ratio256, i;
+ int T_group = 0;
+ int ccch_comb = 0;
+ int old_max_length = btsb->agch_max_queue_length;
+
+ if (!(bts->si_valid & (1<<SYSINFO_TYPE_3)))
+ return;
+
+ si3 = GSM_BTS_SI(bts, SYSINFO_TYPE_3);
+
+ if (si3->control_channel_desc.ccch_conf == 1)
+ ccch_comb = 1;
+
+ /*
+ * The calculation is based on the ratio of the number RACH slots and
+ * CCCH blocks per time:
+ * Lmax = (T + 2*S) / R_RACH * R_CCCH
+ * where
+ * T3126_min = (T + 2*S) / R_RACH, as defined in GSM 04.08, 11.1.1
+ * R_RACH is the RACH slot rate (e.g. RACHs per multiframe)
+ * R_CCCH is the CCCH block rate (same time base like R_RACH)
+ * S and T are defined in GSM 04.08, 3.3.1.1.2
+ * The ratio is mainly influenced by the downlink only channels
+ * (BCCH, FCCH, SCH, CBCH) that can not used for CCCH.
+ * An estimation with an error of < 10% is used:
+ * ~ 1/9 if CCCH is combined with SDCCH, and
+ * ~ 1/5.5 otherwise.
+ */
+ ccch_rach_ratio256 = ccch_comb ?
+ CCCH_RACH_RATIO_COMBINED256 :
+ CCCH_RACH_RATIO_SEPARATE256;
+
+ T = si3->rach_control.tx_integer;
+ for (i = 0; i < 15; i++) {
+ if (tx_integer[i] == T) {
+ T_group = i % 5;
+ break;
+ }
+ }
+ S = s_values[T_group][ccch_comb];
+
+ btsb->agch_max_queue_length = (T + 2 * S) * ccch_rach_ratio256 / 256;
+
+ if (btsb->agch_max_queue_length != old_max_length)
+ LOGP(DRSL, LOGL_INFO, "Updated AGCH max queue length to %d, "
+ "T = %d, S = %d, CCCH/RACH = %d%%, AG_BLK_RES = %d\n",
+ btsb->agch_max_queue_length,
+ T, S, ccch_rach_ratio256 * 100 / 256,
+ si3->control_channel_desc.bs_ag_blks_res);
+}
+
int bts_agch_enqueue(struct gsm_bts *bts, struct msgb *msg)
{
struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
- /* FIXME: implement max queue length */
msgb_enqueue(&btsb->agch_queue, msg);
btsb->agch_queue_length++;
--
1.7.9.5
Hi All.
It's time Again!
This is the announcement for the next Osmocom Berlin meeting.
Tomorrow, 8pm @ CCC Berlin, Marienstr. 11, 10117 Berlin
There is no formal presentation scheduled for this meeting.
If you are interested to show up, feel free to do so. There is no
registration required. The meeting is free as in "free beer", despite
no actual free beer being around.
I am looking forward to see you there!
regards.
Philipp
SQLite uses DELETE journaling mode by default. It became a problem on a
real-world, actively used network (several hundred subscribers, several
thousands SMS per day). Some location updates and SMS delivery marks
were not getting written because database file was locked:
2013-12-13_07:26:10.10665 <0002> gsm_subscriber.c:362 Subscriber 334020422525672 ATTACHED LAC=3
2013-12-13_07:26:10.10668 <000d> db.c:170 DBI: 5: database is locked
2013-12-13_07:26:10.10865 <000d> db.c:969 Failed to update Subscriber (by IMSI).
Switching to WAL mode fixed the problem.
WAL journaling mode is persistent; it stays in effect after closing and
reopening the database. WAL mode database requires SQLite >= 3.7.0.
All credit belongs Ivan Kluchnikov who diagnosed and fixed this issue.
---
openbsc/src/libmsc/db.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index e720c78..3a989d4 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -232,11 +232,18 @@ static int db_configure(void)
dbi_result result;
result = dbi_conn_query(conn,
+ "PRAGMA journal_mode = WAL");
+ if (!result)
+ LOGP(DDB, LOGL_NOTICE, "Warning: failed to set journal_mode = WAL.\n");
+ else
+ dbi_result_free(result);
+
+ result = dbi_conn_query(conn,
"PRAGMA synchronous = FULL");
if (!result)
return -EINVAL;
-
dbi_result_free(result);
+
return 0;
}
--
1.7.7.5 (Apple Git-26)