summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-09-06 00:08:17 +0200
committerVadim Yanitskiy <axilirator@gmail.com>2019-09-07 17:03:02 +0200
commitdea80c5863589219be4a691c600cc06ac24e849e (patch)
treed54bdec06740a431d931d79b21cf0dd00699f3c9
parent7a530d141a2dc1dafbede05203d637e70432c785 (diff)
PCU_Tests_RAW.ttcn: initial version of component RAW_PCU_BTS_CTfixeria/pcu
The purpose of RAW_PCU_BTS_CT is to emulate the BTS by sending TDMA frame clock and RTS (Ready To Send) indications, so that we can build new test cases on top of it, and move both osmo-bts-virtual and virt_phy out of the scope of IUT. == Current state - After creation, the component starts a listening UNIX socket and waits for a connection from OsmoPCU. - As soon as OsmoPCU is connected, we wait for the TXT.ind with its version, and respond with INFO.ind (SI13). - After sending the INFO.ind, we start TDMA clock timer that triggers transmission of TIME.ind messages at the beginning of every MAC block. == What's missing? - Sending of RTS indications for free DL blocks. - We may need to handle OsmoPCU disconnection. Change-Id: I63a23abebab88fd5318eb4d907d6028e7c38e9a3
-rw-r--r--pcu/PCU_Tests_RAW.ttcn99
1 files changed, 99 insertions, 0 deletions
diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
index dcd1f96..20db95f 100644
--- a/pcu/PCU_Tests_RAW.ttcn
+++ b/pcu/PCU_Tests_RAW.ttcn
@@ -477,6 +477,104 @@ testcase TC_ta_init_prach() runs on RAW_Test_CT {
}
}
+type component RAW_PCU_ClckGen_CT {
+ /* TDMA frame clock generator. One TDMA frame is 4.615 ms long */
+ timer T_TDMAClock := 4.615 / 1000.0;
+ var integer fn := 0;
+
+ port PCUIF_CODEC_PT PCU;
+}
+
+private function f_clck_gen_ct_handler(integer bts_nr, integer pcu_conn_id)
+runs on RAW_PCU_ClckGen_CT {
+ while (true) {
+ /* We don't really need to send every frame to OsmoPCU, because
+ * it omits frame numbers not starting at a MAC block. */
+ var integer fn13 := fn mod 13;
+ if (fn13 == 0 or fn13 == 4 or fn13 == 8) {
+ // log("Sending clock indication fn=", fn);
+ PCU.send(valueof(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_TIME_IND(bts_nr, fn))));
+ }
+
+ /* TDMA hyperframe period is (2048 * 51 * 26) frames */
+ fn := (fn + 1) mod (2048 * 51 * 26);
+
+ /* (Re)start TDMA clock timer and wait */
+ T_TDMAClock.start;
+ T_TDMAClock.timeout;
+ }
+}
+
+type enumerated pcu_if_state {
+ /* Server started, waiting for connection from the BTS */
+ PCU_IF_ST_INIT,
+ /* The BTS is connected and wants TIME.ind / RTS.ind from us */
+ PCU_IF_ST_CONNECTED
+}
+
+type component RAW_PCU_BTS_CT {
+ /* TDMA clock generator */
+ var RAW_PCU_ClckGen_CT vc_CLCK_GEN;
+
+ /* PCU interface (UNIX domain socket) */
+ var pcu_if_state g_pcu_conn_state := PCU_IF_ST_INIT;
+ var ConnectionId g_pcu_conn_id := -1;
+ port PCUIF_CODEC_PT PCU;
+}
+
+private function f_bts_ct_handler(integer bts_nr, charstring pcu_sock_path)
+runs on RAW_PCU_BTS_CT {
+ var PCUIF_send_data pcu_sd_msg;
+ var PCUIF_Message pcu_msg;
+
+ /* Port mappings */
+ map(self:PCU, system:PCU);
+
+ /* Init the Unix Domain Socket */
+ log("Init PCU interface on '" & pcu_sock_path & "'");
+ g_pcu_conn_id := f_pcuif_listen(PCU, pcu_sock_path);
+ PCU.receive(UD_connected:?);
+
+ /* Init TDMA clock generator (so we can stop and start it) */
+ vc_CLCK_GEN := RAW_PCU_ClckGen_CT.create("ClckGen-" & int2str(bts_nr)) alive;
+ map(vc_CLCK_GEN:PCU, system:PCU);
+
+ alt {
+ /* Wait for PCU_VERSION and return INFO_IND */
+ [g_pcu_conn_state == PCU_IF_ST_INIT] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))) {
+ log("OsmoPCU is now connected, sending INFO.ind");
+ g_pcu_conn_state := PCU_IF_ST_CONNECTED;
+
+ /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
+ PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_INFO_IND(
+ bts_nr := bts_nr, nsei := mp_nsconfig.nsei,
+ nsvci := mp_nsconfig.nsvci, bvci := mp_gb_cfg.bvci,
+ local_port := mp_nsconfig.remote_udp_port,
+ remote_port := mp_nsconfig.local_udp_port,
+ remote_ip := f_inet_haddr(mp_nsconfig.local_ip))));
+
+ /* Start feeding clock to the PCU */
+ vc_CLCK_GEN.start(f_clck_gen_ct_handler(bts_nr, g_pcu_conn_id));
+ repeat;
+ }
+ [] PCU.receive(PCUIF_send_data:?) -> value pcu_sd_msg {
+ log("Rx unexpected PCU message: ", pcu_sd_msg);
+ repeat;
+ }
+ }
+}
+
+testcase TC_bts_ct_tuwat() runs on RAW_Test_CT {
+ var RAW_PCU_BTS_CT vc_EUSE;
+
+ /* Init NS codec (emulate SGSN) */
+ f_init_ns_codec();
+
+ vc_EUSE := RAW_PCU_BTS_CT.create("BTS-" & testcasename());
+ vc_EUSE.start(f_bts_ct_handler(0, mp_pcu_sock_path));
+ vc_EUSE.done;
+}
+
control {
execute( TC_ns_reset() );
execute( TC_ns_reset_retrans() );
@@ -491,6 +589,7 @@ control {
/* Timing Advance tests (see GSM TS 43.064, section 6) */
execute( TC_ta_init_prach() );
+ execute( TC_bts_ct_tuwat() );
}