Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/11562


Change subject: WIP: bts: f_est_dchan: verify Chan Rqd originated by RACH 
arrives on RSL
......................................................................

WIP: bts: f_est_dchan: verify Chan Rqd originated by RACH arrives on RSL

Change-Id: I438fd3ee82d88498d928dbcc89ce9bd80d37ab64
---
M bts/BTS_Tests.ttcn
M library/RSL_Emulation.ttcn
M library/RSL_Types.ttcn
3 files changed, 76 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/62/11562/1

diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 5b073ef..0676214 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -1344,17 +1344,37 @@
        }
 }

+/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
+private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return 
GsmFrameNumber {
+       var GsmFrameNumber fn;
+       timer T := 8.0;
+
+       f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, 
g_pars.l1_pars.ms_power_level);
+       /* Send the actual RACH */
+       log("PESPIN: calling f_L1CTL_RACH ", ra);
+       fn := f_L1CTL_RACH(L1CTL, ra);
+       log("PESPIN: called with fn returned ", fn);
+       /* advertise to RSL Emulation that we expect to receive confirmation 
from RACH */
+       RSL.send(ts_RSLDC_ChanRqd(int2oct(ra,1), fn));
+       T.start;
+       alt {
+       [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, 
"Received CHAN-RQD from RACH REQ")}
+       [] T.timeout {
+               Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, 
log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
+               }
+       }
+       T.stop
+       return fn;
+}

 /* Establish dedicated channel: L1CTL + RSL side */
 private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr {
-       var GsmFrameNumber fn;
        var ImmediateAssignment imm_ass;
        var integer ra := 23;
+       var GsmFrameNumber fn;
 
-       f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, 
g_pars.l1_pars.ms_power_level);
-       fn := f_L1CTL_RACH(L1CTL, ra);
-       /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere 
*/
-       //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1)));
+       /* Send RACH request and wait for ChanReq */
+       fn := f_rach_req_wait_chan_rqd(ra);

        /* Activate channel on BTS side */
        f_rsl_chan_act(g_pars.chan_mode, encr_enable);
diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn
index cf02d00..24c9202 100644
--- a/library/RSL_Emulation.ttcn
+++ b/library/RSL_Emulation.ttcn
@@ -148,7 +148,7 @@
 runs on RSL_Emulation_CT return integer {
        var integer i;
        for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
-               if (ispresent(ConnectionTable[i].comp_ref) and
+               if (ispresent(ConnectionTable[i].comp_ref) and
                    ConnectionTable[i].comp_ref == comp_ref) {
                        return i;
                }
@@ -161,7 +161,7 @@
 runs on RSL_Emulation_CT return integer {
        var integer i;
        for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
-               if (ispresent(ConnectionTable[i].chan_nr) and
+               if (ispresent(ConnectionTable[i].chan_nr) and
                    ConnectionTable[i].chan_nr == chan_nr and 
ConnectionTable[i].trx_nr == trx_nr) {
                        return i;
                }
@@ -183,6 +183,24 @@
        return -1;
 }

+private function f_cid_by_ra_fn2(OCT1 ra, RSL_IE_FrameNumber fn)
+runs on RSL_Emulation_CT return integer {
+       var RSL_IE_FrameNumber ct_fn;
+       var integer i;
+       for (i := 0; i < sizeof(ConnectionTable); i := i+1) {
+               if (ispresent(ConnectionTable[i].ra) and
+                   ConnectionTable[i].ra == ra) {
+                       ct_fn := 
f_compute_RSL_IE_FrameNumber(ConnectionTable[i].ra_fn);
+                       log("PESPIN: matching ", fn, " with ", ct_fn)
+                       if (ct_fn == fn) {
+                               return i;
+                       }
+               }
+       }
+       log("No Dchan handler for ", ra, fn);
+       return -1;
+}
+
 /* create an ew client with given RA and FN */
 private function f_cid_create(OCT1 ra, GsmFrameNumber fn, RSL_DchanHdlr 
comp_ref)
 runs on RSL_Emulation_CT {
@@ -394,6 +412,23 @@
                                }
                        }
                }
+               [not bts_role] IPA_PT.receive(tr_RSL(tr_RSL_CHAN_RQD(?))) -> 
value rx_rsl {
+                       var RSL_IE_RequestRef req_ref;
+                       var OCT1 ra;
+                       var GsmFrameNumber fn;
+                       req_ref := rx_rsl.rsl.ies[1].body.req_ref;
+                       ra := req_ref.ra
+                       //fn := 23; //FIXME(req_ref.frame_nr);
+                       cid := f_cid_by_ra_fn2(req_ref.ra, req_ref.frame_nr);
+                       if (cid != -1) {
+                               //ConnectionTable[cid].chan_nr := 
rx_rsl.rsl.ies[0].body.chan_nr;
+                               CLIENT_PT.send(rx_rsl.rsl) to 
ConnectionTable[cid].comp_ref;
+                               f_cid_clear(cid);
+                       } else {
+                               log("Received CHAN-RQD from unknown RACH REQ", 
req_ref);
+                               CCHAN_PT.send(rx_rsl);
+                       }
+               }

                [bts_role] IPA_PT.receive(tr_RSL(tr_RSL_PAGING_CMD(?, ?))) -> 
value rx_rsl {
                        /* broadcast to all clients? */
@@ -446,6 +481,11 @@
                                                 ts_RSL_CHAN_RQD(chan_rqd.ra, 
chan_rqd.fn)));
                        }

+               [not bts_role] CLIENT_PT.receive(RSLDC_ChanRqd:?) -> value 
chan_rqd sender vc_conn {
+                       /* Store the knowledge that this sender has requested a 
certain RQ+time */
+                       f_cid_create(chan_rqd.ra, chan_rqd.fn, vc_conn);
+                       }
+
                [] CLIENT_PT.receive(tr_RSL_MsgType(?)) -> value rx_rsl_msg 
sender vc_conn {
                        /* forward to BSC */
                        cid := f_cid_by_comp_ref(vc_conn);
diff --git a/library/RSL_Types.ttcn b/library/RSL_Types.ttcn
index cd4ba58..1741c01 100644
--- a/library/RSL_Types.ttcn
+++ b/library/RSL_Types.ttcn
@@ -404,6 +404,15 @@
        }
        type RSL_IE_FrameNumber RSL_IE_StartingTime;

+       /* compute the expected request reference for given RA + FN */
+       function f_compute_RSL_IE_FrameNumber(GsmFrameNumber fn) return 
RSL_IE_FrameNumber {
+               var RSL_IE_FrameNumber frame_nr;
+               frame_nr.t1_p := (fn / 1326) mod 32;
+               frame_nr.t2 := fn mod 26;
+               frame_nr.t3 := fn mod 51;
+               return frame_nr
+       }
+
        /* 9.3.10 */
        type record RSL_IE_L1Info {
                uint5_t         ms_power_lvl,

--
To view, visit https://gerrit.osmocom.org/11562
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I438fd3ee82d88498d928dbcc89ce9bd80d37ab64
Gerrit-Change-Number: 11562
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to