This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/6581 sgsn: Add user plane GTP testing (GTP->Gb and Gb->GTP) Change-Id: Ifd62cca8cd9dbcffe4eac957db210ac13b8c633f --- M library/BSSGP_Emulation.ttcn M library/LLC_Templates.ttcn M sgsn/SGSN_Tests.ttcn 3 files changed, 139 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/81/6581/1 diff --git a/library/BSSGP_Emulation.ttcn b/library/BSSGP_Emulation.ttcn index 9a48918..c4628be 100644 --- a/library/BSSGP_Emulation.ttcn +++ b/library/BSSGP_Emulation.ttcn @@ -702,6 +702,15 @@ sndcp := omit } +template BssgpDecoded tr_BD_SNDCP(template BIT4 sapi, template PDU_SN sn) := { + bssgp := ?, + llc := tr_LLC_UI(?, sapi), + l3_mo := omit, + l3_mt := omit, + sndcp := sn +} + + } diff --git a/library/LLC_Templates.ttcn b/library/LLC_Templates.ttcn index 7bc4088..086207c 100644 --- a/library/LLC_Templates.ttcn +++ b/library/LLC_Templates.ttcn @@ -20,6 +20,12 @@ pM := bool2bit(protected) } +template (value) Control_field_U ts_LLC_CtrlU(BIT4 m_bits, BIT1 p_f) := { + mBits := m_bits, + pF := p_f, + format := '111'B +} + template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u, template boolean encrypted := ?, template boolean protected := ?) := { @@ -29,6 +35,14 @@ e := bool2bit_tmpl(encrypted), pM := bool2bit_tmpl(protected) } + +template Control_field_U tr_LLC_CtrlU(template BIT4 m_bits := ?, + template BIT1 p_f := ?) := { + mBits := m_bits, + pF := p_f, + format := '111'B +} + template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u, boolean encrypted := false, boolean protected := false) := { @@ -51,6 +65,19 @@ } } +template PDU_LLC tr_LLC_XID(template XID_Information xid, template BIT4 sapi := ?, + template BIT1 cr := ?, template BIT1 p_f := ?) := { + pDU_LLC_U := { + address_field := t_LLC_Addr(sapi, cr), + control_field := tr_LLC_CtrlU('1011'B, p_f), + information_field_U := { + xID := xid + }, + fCS := '000000'O /* provided by decoder if FCS OK */ + } +} + + const BIT4 c_LLC_SAPI_LLGMM := '0001'B; const BIT4 c_LLC_SAPI_TOM2 := '0010'B; const BIT4 c_LLC_SAPI_LL3 := '0011'B; diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn index a02d3a9..f41817f 100644 --- a/sgsn/SGSN_Tests.ttcn +++ b/sgsn/SGSN_Tests.ttcn @@ -2,6 +2,7 @@ import from General_Types all; import from Osmocom_Types all; +import from Native_Functions all; import from NS_Types all; import from NS_Emulation all; import from BSSGP_Types all; @@ -781,7 +782,7 @@ octetstring sgsn_ip_u optional }; -function f_pdp_ctx_act(PdpActPars apars) runs on BSSGP_ConnHdlr { +function f_pdp_ctx_act(inout PdpActPars apars) runs on BSSGP_ConnHdlr { var boolean exp_rej := ispresent(apars.exp_rej_cause); var Gtp1cUnitdata g_ud; @@ -795,6 +796,8 @@ apars.sgsn_tei_u := gtpc_rx.createPDPContextRequest.teidDataI.teidDataI; apars.sgsn_ip_c := gtpc_rx.createPDPContextRequest.sgsn_addr_signalling.addressf; apars.sgsn_ip_u := gtpc_rx.createPDPContextRequest.sgsn_addr_traffic.addressf; + f_gtp_register_teid(apars.ggsn_tei_c); + f_gtp_register_teid(apars.ggsn_tei_u); var OCT1 cause := int2oct(128, 1); GTP.send(ts_GTPC_CreatePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, cause, @@ -891,6 +894,85 @@ sgsn_ip_u := omit } +template (value) GtpPeer ts_GtpPeerU(octetstring ip) := { + connId := 1, + remName := f_inet_ntoa(ip), + remPort := GTP1U_PORT +} + +template (value) GtpPeer ts_GtpPeerC(octetstring ip) := { + connId := 1, + remName := f_inet_ntoa(ip), + remPort := GTP1C_PORT +} + +private function f_gtpu_send(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { + var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); + GTP.send(ts_GTP1U_GPDU(peer, 0 /*seq*/, apars.sgsn_tei_u, payload)); +} + +private altstep as_xid(PdpActPars apars) runs on BSSGP_ConnHdlr { + [] BSSGP.receive(tr_BD_LLC(tr_LLC_XID(?, apars.sapi))) { + repeat; + } +} + +template PDU_SN tr_SN_UD(template BIT4 nsapi, template octetstring payload) := { + pDU_SN_UNITDATA := { + nsapi := nsapi, + moreBit := ?, + snPduType := '1'B, + firstSegmentIndicator := ?, + spareBit := ?, + pcomp := ?, + dcomp := ?, + npduNumber := ?, + segmentNumber := ?, + npduNumberContinued := ?, + dataSegmentSnUnitdataPdu := payload + } +} + +/* simple case: single segment, no compression */ +template (value) PDU_SN ts_SN_UD(BIT4 nsapi, octetstring payload) := { + pDU_SN_UNITDATA := { + nsapi := nsapi, + moreBit := '0'B, + snPduType := '1'B, + firstSegmentIndicator := '1'B, + spareBit := '0'B, + pcomp := '0000'B, + dcomp := '0000'B, + npduNumber := '0000'B, + segmentNumber := '0000'B, + npduNumberContinued := '00'O, + dataSegmentSnUnitdataPdu := payload + } +} + +/* Transceive given 'payload' as MT message from GTP -> OsmoSGSN -> Gb */ +private function f_gtpu_xceive_mt(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { + /* Send PDU via GTP from our simulated GGSN to the SGSN */ + f_gtpu_send(apars, payload); + /* Expect PDU via BSSGP/LLC on simulated PCU from SGSN */ + alt { + [] as_xid(apars); + [] BSSGP.receive(tr_BD_SNDCP(apars.sapi, tr_SN_UD(apars.nsapi, payload))); + } +} + +private function f_gtpu_xceive_mo(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { + /* Send PDU via SNDCP/LLC/BSSGP/NS via simulated MS/PCU to the SGSN */ + var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); + var PDU_SN sndcp := valueof(ts_SN_UD(apars.nsapi, payload)); + BSSGP.send(ts_LLC_UI(enc_PDU_SN(sndcp), apars.sapi, '0'B, 0)); + f_gtpu_send(apars, payload); + /* Expect PDU via GTP from SGSN on simulated GGSN */ + alt { + [] GTP.receive(tr_GTPU_GPDU(peer, apars.ggsn_tei_u, payload)); + } +} + private function f_TC_attach_pdp_act(charstring id) runs on BSSGP_ConnHdlr { var PdpActPars apars := valueof(t_PdpActPars); @@ -932,6 +1014,25 @@ vc_conn.done; } +/* ATTACH + PDP CTX ACT + user plane traffic */ +private function f_TC_attach_pdp_act_user(charstring id) runs on BSSGP_ConnHdlr { + var PdpActPars apars := valueof(t_PdpActPars); + + /* first perform regular attach */ + f_TC_attach(id); + /* then activate PDP context */ + f_pdp_ctx_act(apars); + /* then transceive a downlink PDU */ + f_gtpu_xceive_mt(apars, '01020304'O); + f_gtpu_xceive_mo(apars, 'a1b2c3d4'O); +} +testcase TC_attach_pdp_act_user() runs on test_CT { + var BSSGP_ConnHdlr vc_conn; + f_init(); + vc_conn := f_start_handler(refers(f_TC_attach_pdp_act_user), testcasename(), g_gb[0], 19); + vc_conn.done; +} + control { @@ -952,6 +1053,7 @@ execute( TC_detach_poweroff() ); execute( TC_attach_pdp_act() ); execute( TC_pdp_act_unattached() ); + execute( TC_attach_pdp_act_user() ); } -- To view, visit https://gerrit.osmocom.org/6581 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifd62cca8cd9dbcffe4eac957db210ac13b8c633f Gerrit-PatchSet: 1 Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>