From 8c74cbbf5a7534f6aa2d28a30a4b6bff7fe8067b Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 4 May 2021 15:26:56 +0200 Subject: [PATCH] sgsn: Introduce test TC_rim_eutran_to_geran GTP_Templates.ttcn new templates use BssgpCellId, hence it depends on Osmocom_Gb_Types.ttcn. Related: SYS#5314 Change-Id: I9dcf6ee2dc55bc6aba178eca30080233254f025e --- deps/Makefile | 11 +- ggsn_tests/gen_links.sh | 10 +- library/GTP_Emulation.ttcn | 20 +- library/GTP_Templates.ttcn | 425 +++++++++++++++++++++++++++++++++++++ pgw/gen_links.sh | 10 +- sgsn/SGSN_Tests.ttcn | 118 +++++++++- sgsn/osmo-sgsn.cfg | 3 + 7 files changed, 580 insertions(+), 17 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 8dc2a829c..3d49a68de 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -15,6 +15,7 @@ ECLIPSEGITHUB:=https://github.com/eclipse ECLIPSEGIT2:=https://git.eclipse.org/r/titan +ECLIPSEGITLAB:=https://gitlab.eclipse.org/eclipse/titan OSMOGITHUB:=https://github.com/osmocom OSMOGIT:=git://git.osmocom.org @@ -51,7 +52,6 @@ ECLIPSEGIT2_REPOS= titan.ProtocolEmulations.M3UA \ titan.ProtocolModules.SUA \ titan.ProtocolModules.SDP \ titan.ProtocolModules.BSSAPP_v7.3.0 \ - titan.ProtocolModules.GTP_v13.5.0 \ titan.ProtocolModules.GTPv2_v13.7.0 \ titan.ProtocolModules.ISUP_Q.762 \ titan.ProtocolModules.LLC_v7.1.0 \ @@ -61,6 +61,8 @@ ECLIPSEGIT2_REPOS= titan.ProtocolEmulations.M3UA \ titan.ProtocolModules.SGsAP_13.2.0 \ titan.ProtocolModules.SNDCP_v7.0.0 +ECLIPSEGITLAB_REPOS= titan.ProtocolModules.GTP_v13.5.0 + OSMOGITHUB_REPOS= titan.TestPorts.SCTPasp \ titan.TestPorts.MTP3asp \ titan.TestPorts.UDPasp \ @@ -73,7 +75,7 @@ OSMOGIT_REPOS= titan.ProtocolModules.MAP \ titan.TestPorts.AF_PACKET \ osmo-uecups -ALL_REPOS=$(ECLIPSEGITHUB_REPOS) $(ECLIPSEGIT2_REPOS) $(OSMOGITHUB_REPOS) $(OSMOGIT_REPOS) +ALL_REPOS=$(ECLIPSEGITHUB_REPOS) $(ECLIPSEGIT2_REPOS) $(ECLIPSEGITLAB_REPOS) $(OSMOGITHUB_REPOS) $(OSMOGIT_REPOS) # Tag names from 'git-describe --tags'; if not available, a commit hash may be used instead. # Do not put references to branches here, except for local testing: this breaks the caching @@ -87,7 +89,7 @@ titan.ProtocolModules.BSSGP_v13.0.0_commit= e97d92a8b66bec399babea52f593771b76cb titan.ProtocolModules.BSSMAP_commit= 24f967b2f77bfdd2e6eabf1e82fa76239095f772 titan.ProtocolModules.DNS_commit= R.7.B titan.ProtocolModules.GRE_commit= R.2.A-5-g654c446 -titan.ProtocolModules.GTP_v13.5.0_commit= R.2.A-5-ge120ace +titan.ProtocolModules.GTP_v13.5.0_commit= 54219599037626c675610d3a44433d01af264fbb titan.ProtocolModules.GTPv2_v13.7.0_commit= R.2.A-5-g85cb124 titan.ProtocolModules.ICMP_commit= e49d9fb9f7de637b4bf4803dc6b6e911a8661640 titan.ProtocolModules.ICMPv6_commit= 46f4d9b6e1e3c794294a92588401a81e4881dd27 @@ -187,6 +189,9 @@ $(foreach dir,$(ECLIPSEGITHUB_REPOS), \ $(foreach dir,$(ECLIPSEGIT2_REPOS), \ $(eval $(call GIT_template,$(dir),$(ECLIPSEGIT2)))) +$(foreach dir,$(ECLIPSEGITLAB_REPOS), \ + $(eval $(call GIT_template,$(dir),$(ECLIPSEGITLAB)))) + $(foreach dir,$(OSMOGITHUB_REPOS), \ $(eval $(call GIT_template,$(dir),$(OSMOGITHUB)))) diff --git a/ggsn_tests/gen_links.sh b/ggsn_tests/gen_links.sh index 1b54e9dd5..f9bae1cea 100755 --- a/ggsn_tests/gen_links.sh +++ b/ggsn_tests/gen_links.sh @@ -44,9 +44,17 @@ DIR=$BASEDIR/titan.TestPorts.TELNETasp/src FILES="TELNETasp_PT.cc TELNETasp_PT.hh TELNETasp_PortType.ttcn" gen_links $DIR $FILES +DIR=$BASEDIR/titan.ProtocolModules.NS_v7.3.0/src +FILES="NS_Types.ttcn" +gen_links $DIR $FILES + +DIR=$BASEDIR/titan.ProtocolModules.BSSGP_v13.0.0/src +FILES="BSSGP_EncDec.cc BSSGP_Types.ttcn" +gen_links $DIR $FILES + DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn PAP_Types.ttcn " -FILES+="GTP_CodecPort.ttcn GTP_CodecPort_CtrlFunct.ttcn GTP_CodecPort_CtrlFunctDef.cc GTP_Templates.ttcn " +FILES+="GTP_CodecPort.ttcn GTP_CodecPort_CtrlFunct.ttcn GTP_CodecPort_CtrlFunctDef.cc GTP_Templates.ttcn Osmocom_Gb_Types.ttcn " FILES+="Osmocom_VTY_Functions.ttcn " gen_links $DIR $FILES diff --git a/library/GTP_Emulation.ttcn b/library/GTP_Emulation.ttcn index 43c034b8f..b67e828c3 100644 --- a/library/GTP_Emulation.ttcn +++ b/library/GTP_Emulation.ttcn @@ -43,6 +43,7 @@ type component GTP_Emulation_CT { /* Communication with Clients */ port GTPEM_PT CLIENT; port GTPEM_PROC_PT CLIENT_PROC; + port GTPEM_PT CLIENT_DEFAULT; /* Configuration by the user */ var GtpEmulationCfg g_gtp_cfg; @@ -199,11 +200,16 @@ function main(GtpEmulationCfg cfg) runs on GTP_Emulation_CT { vc_conn := f_comp_by_teid(g1c_ud.gtpc.teid); CLIENT.send(g1c_ud) to vc_conn; } else { - /* Send to all clients */ - var integer i; - for (i := 0; i < sizeof(TidTable); i := i+1) { - if (isbound(TidTable[i].teid) and TidTable[i].teid == teid) { - CLIENT.send(g1c_ud) to TidTable[i].vc_conn; + /* Check if a default port is set: */ + if (CLIENT_DEFAULT.checkstate("Connected")) { + CLIENT_DEFAULT.send(g1c_ud); + } else { + /* Send to all clients */ + var integer i; + for (i := 0; i < sizeof(TidTable); i := i+1) { + if (isbound(TidTable[i].teid) and TidTable[i].teid == teid) { + CLIENT.send(g1c_ud) to TidTable[i].vc_conn; + } } } } @@ -220,7 +226,9 @@ function main(GtpEmulationCfg cfg) runs on GTP_Emulation_CT { [] CLIENT.receive(Gtp1uUnitdata:?) -> value g1u_ud sender vc_conn { GTPU.send(g1u_ud); } - + [] CLIENT_DEFAULT.receive(Gtp1cUnitdata:?) -> value g1c_ud sender vc_conn { + GTPC.send(g1c_ud); + } [] CLIENT_PROC.getcall(GTPEM_register_imsi:{?}) -> param(imsi) sender vc_conn { f_imsi_tbl_add(imsi, vc_conn); diff --git a/library/GTP_Templates.ttcn b/library/GTP_Templates.ttcn index aa4275947..1bd56e129 100644 --- a/library/GTP_Templates.ttcn +++ b/library/GTP_Templates.ttcn @@ -17,6 +17,7 @@ module GTP_Templates { import from GTPU_Types all; import from GTP_CodecPort all; import from IPCP_Types all; + import from Osmocom_Gb_Types all; // BssgpCellId /* Table 38 of 3GPP TS 29.060 */ type enumerated GTP_Cause { @@ -30,6 +31,28 @@ module GTP_Templates { /* FIXME */ }; + private function f_oct_or_wc(template integer inp, integer len) return template octetstring { + if (istemplatekind(inp, "omit")) { + return omit; + } else if (istemplatekind(inp, "*")) { + return *; + } else if (istemplatekind(inp, "?")) { + return ?; + } + return int2oct(valueof(inp), len); + } + + private function f_hex_or_wc(template integer inp, integer len) return template hexstring { + if (istemplatekind(inp, "omit")) { + return omit; + } else if (istemplatekind(inp, "*")) { + return *; + } else if (istemplatekind(inp, "?")) { + return ?; + } + return int2hex(valueof(inp), len); + } + /* generalized GTP-C receive template */ template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := { /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an @@ -612,6 +635,408 @@ module GTP_Templates { } + /* GTP-C RIM */ + + template (value) RIM_Application_Identity_GTPC ts_GTPC_RIM_Application_Identity(OCT1 app_id) := { + iEI := '4B'O, + ext := '1'B, + lengthIndicator := { + length1 := 1 + }, + rIMApplicationIdentity := app_id + } + /* 3GPP TS 48.018 11.3.62 */ + template (value) RIM_Sequence_Number_GTPC ts_GTPC_RIM_Sequence_Number(integer seq) := { + iEI := '4C'O, + ext := '1'B, + lengthIndicator := { + length1 := 4 + }, + rIMSequenceNumber := int2oct(seq, 4) + } + template (value) RIM_PDU_Indications_GTPC ts_GTPC_RIM_PDU_Indications(boolean ack, BIT3 type_ext) := { + iEI := '4F'O, + ext := '1'B, + lengthIndicator := { + length1 := 1 + }, + ack := bool2bit(ack), + pDU_Type_Extension := type_ext, + reserved := '0000'B + } + /* 3GPP TS 48.018 11.3.67 */ + template (value) RIM_Protocol_Version_Number_GTPC ts_GTPC_RIM_Protocol_Version_Number(integer ver) := { + iEI := '55'O, + ext := '1'B, + lengthIndicator := { + length1 := 1 + }, + rIMProtocolVersionNumber := int2oct(ver, 1) + } + function tr_GTPC_Cell_Identifier_V(template BssgpCellId cid) return template Cell_Identifier_V_GTPC { + var template Cell_Identifier_V_GTPC ret := { + mccDigit1 := ?, + mccDigit2 := ?, + mccDigit3 := ?, + mncDigit3 := ?, + mncDigit1 := ?, + mncDigit2 := ?, + lac := ?, + rac := ?, + cI_value := ? + } + if (istemplatekind(cid, "omit")) { + return omit; + } else if (istemplatekind(cid, "*")) { + return *; + } else if (istemplatekind(cid, "?")) { + return ?; + } + if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) { + if (isvalue(cid.ra_id.lai.mcc_mnc)) { + ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0]; + ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1]; + ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2]; + ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3]; + ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4]; + ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; + } + if (isvalue(cid.ra_id.lai.lac)) { + ret.lac := f_oct_or_wc(cid.ra_id.lai.lac, 2); + } + } + if (isvalue(cid) and isvalue(cid.ra_id)) { + ret.rac := f_oct_or_wc(cid.ra_id.rac, 1); + } + if (isvalue(cid)) { + ret.cI_value := f_oct_or_wc(cid.cell_id, 2); + } + return ret; + } + template (value) Cell_Identifier_V_GTPC ts_GTPC_Cell_Identifier_V(BssgpCellId cid) := { + mccDigit1 := cid.ra_id.lai.mcc_mnc[0], + mccDigit2 := cid.ra_id.lai.mcc_mnc[1], + mccDigit3 := cid.ra_id.lai.mcc_mnc[2], + mncDigit3 := cid.ra_id.lai.mcc_mnc[3], + mncDigit1 := cid.ra_id.lai.mcc_mnc[4], + mncDigit2 := cid.ra_id.lai.mcc_mnc[5], + lac := int2oct(cid.ra_id.lai.lac, 2), + rac := int2oct(cid.ra_id.rac, 1), + cI_value := int2oct(cid.cell_id, 2) + } + template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_cid(BssgpCellId cid) := { + cell_Identifier := ts_GTPC_Cell_Identifier_V(cid) + } + function tr_GTPC_ENB_Identifier(template BssgpCellId cid, template integer tac, template octetstring gnbid) return template ENB_Identifier { + var template ENB_Identifier ret := { + mccDigit1 := ?, + mccDigit2 := ?, + mccDigit3 := ?, + mncDigit3 := ?, + mncDigit1 := ?, + mncDigit2 := ?, + tAC := ?, + globalENB_ID := ? + } + if (istemplatekind(cid, "omit") and istemplatekind(tac, "omit") and istemplatekind(gnbid, "omit")) { + return omit; + } else if (istemplatekind(cid, "*") and istemplatekind(tac, "*") and istemplatekind(gnbid, "*")) { + return *; + } else if (istemplatekind(cid, "?") and istemplatekind(tac, "?") and istemplatekind(gnbid, "?")) { + return ?; + } + if (isvalue(cid) and isvalue(cid.ra_id) and isvalue(cid.ra_id.lai)) { + if (isvalue(cid.ra_id.lai.mcc_mnc)) { + ret.mccDigit1 := cid.ra_id.lai.mcc_mnc[0]; + ret.mccDigit2 := cid.ra_id.lai.mcc_mnc[1]; + ret.mccDigit3 := cid.ra_id.lai.mcc_mnc[2]; + ret.mncDigit3 := cid.ra_id.lai.mcc_mnc[3]; + ret.mncDigit1 := cid.ra_id.lai.mcc_mnc[4]; + ret.mncDigit2 := cid.ra_id.lai.mcc_mnc[5]; + } + } + if (isvalue(tac)) { + ret.tAC := int2oct(valueof(tac), 2); + } + if (isvalue(gnbid)) { + ret.globalENB_ID := gnbid; + } + + return ret; + } + template (value) ENB_Identifier ts_GTPC_ENB_Identifier(BssgpCellId cid, integer tac, octetstring gnbid) := { + mccDigit1 := cid.ra_id.lai.mcc_mnc[0], + mccDigit2 := cid.ra_id.lai.mcc_mnc[1], + mccDigit3 := cid.ra_id.lai.mcc_mnc[2], + mncDigit3 := cid.ra_id.lai.mcc_mnc[3], + mncDigit1 := cid.ra_id.lai.mcc_mnc[4], + mncDigit2 := cid.ra_id.lai.mcc_mnc[5], + tAC := int2oct(tac, 2), + globalENB_ID := gnbid + } + template RIM_Routing_Address_GTPC t_GTPC_RIM_Routing_Address_enbid(BssgpCellId cid, integer tac, octetstring gnbid) := { + eNB_Identifier := ts_GTPC_ENB_Identifier(cid, tac, gnbid) + } + template RIM_Routing_Information_GTPC + tr_GTPC_RIM_Routing_Information(HEX1 addr_discr, template RIM_Routing_Address_GTPC addr) := { + iEI := '54'O, + ext := '1'B, + lengthIndicator := { + length1 := ? + }, + rIMRoutingAddressDiscriminator := addr_discr, + spare := '0'H, + rIM_Routing_Address := addr + } + template (value) RIM_Routing_Information_GTPC + ts_GTPC_RIM_Routing_Information(HEX1 addr_discr, template (value) RIM_Routing_Address_GTPC addr) := { + iEI := '54'O, + ext := '1'B, + lengthIndicator := { + length1 := 0 /* overwritten */ + }, + rIMRoutingAddressDiscriminator := addr_discr, + spare := '0'H, + rIM_Routing_Address := addr + } + /* 3GPP TS 48.018 11.3.63.1.1 */ + template RAN_Information_Request_Application_Container_NACC_GTPC + tr_GTPC_RAN_Information_Request_Application_Container_NACC(template BssgpCellId cid) := { + iEI := '4D'O, + ext := '1'B, + lengthIndicator := { + length1 := ? + }, + reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid) + } + template (value) RAN_Information_Request_Application_Container_NACC_GTPC + ts_GTPC_RAN_Information_Request_Application_Container_NACC(BssgpCellId cid) := { + iEI := '4D'O, + ext := '1'B, + lengthIndicator := { + length1 := 0 /* overwritten */ + }, + reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid) + } + /* 3GPP TS 48.018 11.3.63.1 */ + template RAN_Information_Request_Application_Container_GTPC + tru_GTPC_RAN_Information_Request_Application_Container_NACC(template BssgpCellId cid) := { + nacc := tr_GTPC_RAN_Information_Request_Application_Container_NACC(cid) + } + template (value) RAN_Information_Request_Application_Container_GTPC + tsu_GTPC_RAN_Information_Request_Application_Container_NACC(BssgpCellId cid) := { + nacc := ts_GTPC_RAN_Information_Request_Application_Container_NACC(cid) + } + /* 3GPP TS 48.018 11.3.63.2.1 */ + template RAN_Information_Application_Container_NACC_GTPC + tr_GTPC_RAN_Information_Application_Container_NACC(template BssgpCellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := { + iEI := '4E'O, + ext := '1'B, + lengthIndicator := { + length1 := ? + }, + reporting_Cell_Identifier := tr_GTPC_Cell_Identifier_V(cid), + typeBit := bool2bit(psi_type), + number_of_SI_PSI := int2bit(si_psi_num, 7), + sI_PSI := si_psi + } + template (value) RAN_Information_Application_Container_NACC_GTPC + ts_GTPC_RAN_Information_Application_Container_NACC(BssgpCellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := { + iEI := '4E'O, + ext := '1'B, + lengthIndicator := { + length1 := 0 /* overwritten */ + }, + reporting_Cell_Identifier := ts_GTPC_Cell_Identifier_V(cid), + typeBit := bool2bit(psi_type), + number_of_SI_PSI := int2bit(si_psi_num, 7), + sI_PSI := si_psi + } + + /* RAN_Information_Request */ + template (value) RAN_Information_Request_RIM_Container_GTPC + ts_GTPC_RAN_Information_Request_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id, + template (value) RIM_Sequence_Number_GTPC seq, + template (value) RIM_PDU_Indications_GTPC ind, + template (omit) RIM_Protocol_Version_Number_GTPC ver := omit, + template (omit) RAN_Information_Request_Application_Container_GTPC app_cont := omit, + template (omit) SON_TransferApplicationIdentity son_app_id := omit) := { + iEI := '57'O, + ext := '1'B, + lengthIndicator := { + length1 := 0 /* overwritten */ + }, + rIM_Application_Identity := app_id, + rIM_Sequence_Number := seq, + rIM_PDU_Indications := ind, + rIM_Protocol_Version_Number := ver, + application_Container := app_cont, + sON_TransferApplicationIdentity := son_app_id + } + template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC + ts_GTPC_RAN_Information_Request(template (value) RIM_Routing_Information_GTPC dest, + template (value) RIM_Routing_Information_GTPC src, + template (value) RAN_Information_Request_RIM_Container_GTPC cont) := { + bssgpPduType := '71'O, + destination_Cell_Identifier := dest, + source_Cell_Identifier := src, + rIM_Container := cont + } + template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO_REQ(template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC pdu) := { + type_gtpc := '90'O, + lengthf := 0, /* FIXME */ + rANTransparentContainerField := { + pDU_BSSGP_RAN_INFORMATION_REQUEST := pdu + } + } + + /* RAN_Information */ + template ApplContainer_or_ApplErrContainer_NACC_GTPC + tru_GTPC_ApplContainer_NACC(BssgpCellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := { + application_Container := tr_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi) + } + template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC + tsu_GTPC_ApplContainer_NACC(BssgpCellId cid, boolean psi_type, integer si_psi_num, octetstring si_psi) := { + application_Container := ts_GTPC_RAN_Information_Application_Container_NACC(cid, psi_type, si_psi_num, si_psi) + } + template ApplContainer_or_ApplErrContainer_GTPC + tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(template ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := { + nacc := cont + } + template (value) ApplContainer_or_ApplErrContainer_GTPC + tsu_GTPC_ApplContainer_or_ApplErrContainer_NACC(template (value) ApplContainer_or_ApplErrContainer_NACC_GTPC cont) := { + nacc := cont + } + template RAN_Information_RIM_Container_GTPC + tr_GTPC_RAN_Information_RIM_Container(template RIM_Application_Identity_GTPC app_id, + template RIM_Sequence_Number_GTPC seq, + template RIM_PDU_Indications_GTPC ind, + template RIM_Protocol_Version_Number_GTPC ver := omit, + template ApplContainer_or_ApplErrContainer_GTPC app_cont := omit, + template SON_TransferApplicationIdentity son_app_id := omit) := { + iEI := '58'O, + ext := '1'B, + lengthIndicator := { + length1 := ? + }, + rIM_Application_Identity := app_id, + rIM_Sequence_Number := seq, + rIM_PDU_Indications := ind, + rIM_Protocol_Version_Number := ver, + applContainer_or_ApplErrContainer := app_cont, + sON_TransferApplicationIdentity := son_app_id + } + template (value) RAN_Information_RIM_Container_GTPC + ts_GTPC_RAN_Information_RIM_Container(template (value) RIM_Application_Identity_GTPC app_id, + template (value) RIM_Sequence_Number_GTPC seq, + template (value) RIM_PDU_Indications_GTPC ind, + template (omit) RIM_Protocol_Version_Number_GTPC ver := omit, + template (omit) ApplContainer_or_ApplErrContainer_GTPC app_cont := omit, + template (omit) SON_TransferApplicationIdentity son_app_id := omit) := { + iEI := '58'O, + ext := '1'B, + lengthIndicator := { + length1 := 0 /* overwritten */ + }, + rIM_Application_Identity := app_id, + rIM_Sequence_Number := seq, + rIM_PDU_Indications := ind, + rIM_Protocol_Version_Number := ver, + applContainer_or_ApplErrContainer := app_cont, + sON_TransferApplicationIdentity := son_app_id + } + template PDU_BSSGP_RAN_INFORMATION_GTPC + tr_GTPC_RAN_Information(template RIM_Routing_Information_GTPC dest, + template RIM_Routing_Information_GTPC src, + template RAN_Information_RIM_Container_GTPC cont) := { + bssgpPduType := '70'O, + destination_Cell_Identifier := dest, + source_Cell_Identifier := src, + rIM_Container := cont + } + template (value) PDU_BSSGP_RAN_INFORMATION_GTPC + ts_GTPC_RAN_Information(template (value) RIM_Routing_Information_GTPC dest, + template (value) RIM_Routing_Information_GTPC src, + template (value) RAN_Information_RIM_Container_GTPC cont) := { + bssgpPduType := '70'O, + destination_Cell_Identifier := dest, + source_Cell_Identifier := src, + rIM_Container := cont + } + template RANTransparentContainer tr_RANTransparentContainer_RAN_INFO(template PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := { + type_gtpc := '90'O, + lengthf := ?, + rANTransparentContainerField := { + pDU_BSSGP_RAN_INFORMATION := pdu + } + } + template (value) RANTransparentContainer ts_RANTransparentContainer_RAN_INFO(template (value) PDU_BSSGP_RAN_INFORMATION_GTPC pdu) := { + type_gtpc := '90'O, + lengthf := 0, /* overwritten */ + rANTransparentContainerField := { + pDU_BSSGP_RAN_INFORMATION := pdu + } + } + + template RANTransparentContainer tr_RANTransparentContainer(template RANTransparentContainerField rANTransparentContainerField) := { + type_gtpc := '90'O, + lengthf := ?, + rANTransparentContainerField := rANTransparentContainerField + } + template (value) RANTransparentContainer ts_RANTransparentContainer(template (value) RANTransparentContainerField rANTransparentContainerField) := { + type_gtpc := '90'O, + lengthf := 0, /* overwritten */ + rANTransparentContainerField := rANTransparentContainerField + } + template GTPC_PDUs tr_RANInfoRelay(template RANTransparentContainer transparentContainer) := { + ranInformationRelay := { + transparentContainer := transparentContainer, + rIM_RoutingAddress := *, + rIM_RoutingAddress_Discriminator := *, + private_extension_gtpc := * + } + } + template (value) GTPC_PDUs ts_RANInfoRelay(template (value) RANTransparentContainer transparentContainer) := { + ranInformationRelay := { + transparentContainer := transparentContainer, + rIM_RoutingAddress := omit, + rIM_RoutingAddress_Discriminator := omit, + private_extension_gtpc := omit + } + } + template Gtp1cUnitdata + tr_GTPC_RANInfoRelay(template GtpPeer peer, + template RANTransparentContainer transparentContainer) := { + peer := peer, + gtpc := tr_GTP1C_PDU(rANInformationRelay, '00000000'O, tr_RANInfoRelay(transparentContainer)) + } + template (value) Gtp1cUnitdata + ts_GTPC_RANInfoRelay(template (value) GtpPeer peer, + template (value) RANTransparentContainer transparentContainer) := { + peer := peer, + gtpc := ts_GTP1C_PDU(rANInformationRelay, '00000000'O, valueof(ts_RANInfoRelay(transparentContainer)), 0) + } + + + template RAN_Information_Request_RIM_Container_GTPC + tr_GTPC_RAN_Information_Request_RIM_Container(template RIM_Application_Identity_GTPC app_id := ?, + template RIM_Sequence_Number_GTPC seq := ?, + template RIM_PDU_Indications_GTPC ind := ?, + template RIM_Protocol_Version_Number_GTPC ver := *, + template RAN_Information_Request_Application_Container_GTPC app_cont := *, + template SON_TransferApplicationIdentity son_app_id := *) := { + iEI := '57'O, + ext := '1'B, + lengthIndicator := { + length1 := ? + }, + rIM_Application_Identity := app_id, + rIM_Sequence_Number := seq, + rIM_PDU_Indications := ind, + rIM_Protocol_Version_Number := ver, + application_Container := app_cont, + sON_TransferApplicationIdentity := son_app_id + } /* GTP-U */ diff --git a/pgw/gen_links.sh b/pgw/gen_links.sh index a0f128114..b061fea5a 100755 --- a/pgw/gen_links.sh +++ b/pgw/gen_links.sh @@ -32,6 +32,14 @@ DIR=$BASEDIR/titan.ProtocolModules.UDP/src FILES="UDP_EncDec.cc UDP_Types.ttcn" gen_links $DIR $FILES +DIR=$BASEDIR/titan.ProtocolModules.NS_v7.3.0/src +FILES="NS_Types.ttcn" +gen_links $DIR $FILES + +DIR=$BASEDIR/titan.ProtocolModules.BSSGP_v13.0.0/src +FILES="BSSGP_EncDec.cc BSSGP_Types.ttcn" +gen_links $DIR $FILES + DIR=$BASEDIR/titan.ProtocolModules.GTP_v13.5.0/src FILES="GTPC_EncDec.cc GTPC_Types.ttcn GTPU_EncDec.cc GTPU_Types.ttcn" gen_links $DIR $FILES @@ -50,7 +58,7 @@ gen_links $DIR $FILES DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn PAP_Types.ttcn " -FILES+="GTP_CodecPort.ttcn GTP_CodecPort_CtrlFunct.ttcn GTP_CodecPort_CtrlFunctDef.cc GTP_Templates.ttcn " +FILES+="GTP_CodecPort.ttcn GTP_CodecPort_CtrlFunct.ttcn GTP_CodecPort_CtrlFunctDef.cc GTP_Templates.ttcn Osmocom_Gb_Types.ttcn " FILES+="GTPv2_PrivateExtensions.ttcn GTPv2_Templates.ttcn " FILES+="GTPv2_CodecPort.ttcn GTPv2_CodecPort_CtrlFunctDef.cc GTPv2_CodecPort_CtrlFunct.ttcn GTPv2_Emulation.ttcn " FILES+="DNS_Helpers.ttcn " diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn index dded39032..d760e5821 100644 --- a/sgsn/SGSN_Tests.ttcn +++ b/sgsn/SGSN_Tests.ttcn @@ -66,6 +66,7 @@ modulepar { integer mp_hlr_port := 4222; charstring mp_ggsn_ip := "127.0.0.103"; integer mp_echo_interval := 5; /* in seconds. Only used in test enabling g_use_echo */ + charstring mp_sgsn_gtp_ip := "127.0.0.10"; NSConfigurations mp_nsconfig := { { @@ -179,6 +180,7 @@ type component test_CT { /* used by RIM related test */ port BSSGP_PT RIM[NUM_GB]; + port GTPEM_PT GTPC; var GTP_Emulation_CT vc_GTP; @@ -225,6 +227,12 @@ type record BSSGP_ConnHdlrPars { SCCP_PAR_Address sccp_addr_peer optional }; +/* Passed in RAN-INFO message from emulated neighbor using RIM */ +const octetstring si1_default := '198fb100000000000000000000000000007900002b'O; +const octetstring si3_default := '1b753000f110236ec9033c2747407900003c0b2b2b'O; +const octetstring si13_default := '009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O; +const octetstring si_default := si1_default & si3_default & si13_default; + private function f_cellid_to_RAI(in BssgpCellId cell_id) return RoutingAreaIdentificationV { /* mcc_mnc is encoded as of 24.008 10.5.5.15 */ var BcdMccMnc mcc_mnc := cell_id.ra_id.lai.mcc_mnc; @@ -3207,16 +3215,11 @@ testcase TC_bssgp_rim_single_report() runs on test_CT { /* Now also emulate also the response as well and send it back on GB interface #1. Expect the result on * GB interface #0 */ - var octetstring si1 := '198fb100000000000000000000000000007900002b'O; - var octetstring si3 := '1b753000f110236ec9033c2747407900003c0b2b2b'O; - var octetstring si13 := '009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O; - var octetstring si := si1 & si3 & si13; - res_cont := ts_RAN_Information_RIM_Container(ts_RIM_Application_Identity(RIM_APP_ID_NACC), ts_RIM_Sequence_Number(2), ts_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP), ts_RIM_Protocol_Version_Number(1), - tsu_ApplContainer_or_ApplErrContainer_NACC(tsu_ApplContainer_NACC(g_gb[0].cfg.bvc[0].cell_id, false, 3, si)), + tsu_ApplContainer_or_ApplErrContainer_NACC(tsu_ApplContainer_NACC(g_gb[0].cfg.bvc[0].cell_id, false, 3, si_default)), omit); bssgp_rim_pdu := ts_PDU_BSSGP_RAN_INFORMATION(ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr), ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, dst_addr), @@ -3242,6 +3245,108 @@ testcase TC_bssgp_rim_single_report() runs on test_CT { f_cleanup(); } +testcase TC_rim_eutran_to_geran() runs on test_CT { + var BSSGP_ConnHdlr vc_conn; + f_init(); + /* connect RIM related port */ + connect(vc_GTP:CLIENT_DEFAULT, self:GTPC); + + var GtpPeer peer := { + connId := 1, + remName := mp_sgsn_gtp_ip, + remPort := GTP1C_PORT + } + + var template (value) RIM_Routing_Address_GTPC gtpc_dst_addr, gtpc_src_addr; + var template (value) RAN_Information_Request_RIM_Container_GTPC gtpc_rim_req_cont; + var template (value) PDU_BSSGP_RAN_INFORMATION_REQUEST_GTPC gtpc_bssgp_cont; + var template (value) Gtp1cUnitdata gtpc_pdu; + + gtpc_dst_addr := t_GTPC_RIM_Routing_Address_cid(g_gb[1].cfg.bvc[0].cell_id); + gtpc_src_addr := t_GTPC_RIM_Routing_Address_enbid(g_gb[1].cfg.bvc[0].cell_id, tac := 3, gnbid := '12345678123456'O); + + gtpc_rim_req_cont := ts_GTPC_RAN_Information_Request_RIM_Container(ts_GTPC_RIM_Application_Identity(RIM_APP_ID_NACC), + ts_GTPC_RIM_Sequence_Number(1), + ts_GTPC_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP), + ts_GTPC_RIM_Protocol_Version_Number(1), + tsu_GTPC_RAN_Information_Request_Application_Container_NACC(g_gb[1].cfg.bvc[0].cell_id), + omit); + gtpc_bssgp_cont := ts_GTPC_RAN_Information_Request(ts_GTPC_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, gtpc_dst_addr), + ts_GTPC_RIM_Routing_Information(RIM_ADDR_EUTRAN_NODEB_ID, gtpc_src_addr), + gtpc_rim_req_cont); + gtpc_pdu := ts_GTPC_RANInfoRelay(peer, ts_RANTransparentContainer_RAN_INFO_REQ(gtpc_bssgp_cont)); + GTPC.send(gtpc_pdu); + + var template RIM_Routing_Address bssgp_dst_addr, bssgp_src_addr; + var template PDU_BSSGP bssgp_rim_pdu_expect; + bssgp_dst_addr := t_RIM_Routing_Address_cid(g_gb[1].cfg.bvc[0].cell_id); + bssgp_src_addr := t_RIM_Routing_Address_enbid(g_gb[1].cfg.bvc[0].cell_id, tac := 3, gnbid := '12345678123456'O); + bssgp_rim_pdu_expect := tr_RAN_INFORMATION_REQUEST(tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, bssgp_dst_addr), + tr_RIM_Routing_Information(RIM_ADDR_EUTRAN_NODEB_ID, bssgp_src_addr), + tr_RAN_Information_Request_RIM_Container); + timer T := 2.0; + T.start; + alt { + [] RIM[1].receive(bssgp_rim_pdu_expect) { + setverdict(pass); + T.stop; + } + [] RIM[1].receive { + setverdict(fail, "Unexpected BSSGP RIM PDU received"); + } + [] T.timeout { + setverdict(fail, "No BSSGP RIM PDU received"); + mtc.stop; + } + } + + /* Now also emulate also the response as well and send it back on GB + interface #1. Expect the result on * GTPC */ + var template RAN_Information_RIM_Container res_cont; + var template PDU_BSSGP bssgp_rim_pdu; + res_cont := ts_RAN_Information_RIM_Container(ts_RIM_Application_Identity(RIM_APP_ID_NACC), + ts_RIM_Sequence_Number(2), + ts_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP), + ts_RIM_Protocol_Version_Number(1), + tsu_ApplContainer_or_ApplErrContainer_NACC(tsu_ApplContainer_NACC(g_gb[1].cfg.bvc[0].cell_id, false, 3, si_default)), + omit); + bssgp_rim_pdu := ts_PDU_BSSGP_RAN_INFORMATION(ts_RIM_Routing_Information(RIM_ADDR_EUTRAN_NODEB_ID, bssgp_src_addr), + ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, bssgp_dst_addr), + res_cont); + RIM[1].send(bssgp_rim_pdu); + + var template RAN_Information_RIM_Container_GTPC rim_cont; + var template PDU_BSSGP_RAN_INFORMATION_GTPC gtpc_bssgp_cont_ack; + var template Gtp1cUnitdata gtpc_pdu_exp; + rim_cont := tr_GTPC_RAN_Information_RIM_Container(ts_GTPC_RIM_Application_Identity(RIM_APP_ID_NACC), + ts_GTPC_RIM_Sequence_Number(2), + ts_GTPC_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP), + ts_GTPC_RIM_Protocol_Version_Number(1), + tru_GTPC_ApplContainer_or_ApplErrContainer_NACC(tru_GTPC_ApplContainer_NACC(g_gb[1].cfg.bvc[0].cell_id, false, 3, si_default)), + omit); + gtpc_bssgp_cont_ack := tr_GTPC_RAN_Information(tr_GTPC_RIM_Routing_Information(RIM_ADDR_EUTRAN_NODEB_ID, gtpc_src_addr), + tr_GTPC_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, gtpc_dst_addr), + rim_cont); + gtpc_pdu_exp := tr_GTPC_RANInfoRelay(peer, tr_RANTransparentContainer_RAN_INFO(gtpc_bssgp_cont_ack)); + + T.start; + alt { + [] GTPC.receive(gtpc_pdu_exp) { + setverdict(pass); + T.stop; + } + [] GTPC.receive { + setverdict(fail, "Unexpected GTPC RIM PDU received"); + } + [] T.timeout { + setverdict(fail, "No GTPC RIM PDU received"); + mtc.stop; + } + } + + f_cleanup(); +} + /* Test if the SGSN routes traffic to new cell after the MS attached to it */ private function f_TC_cell_change_different_rai_ci_attach(charstring id) runs on BSSGP_ConnHdlr { var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip)); @@ -3436,6 +3541,7 @@ control { execute( TC_paging_ps() ); execute( TC_bssgp_rim_single_report() ); + execute( TC_rim_eutran_to_geran() ); execute( TC_cell_change_different_rai_ci_attach() ); execute( TC_cell_change_different_rai_ci_data() ); diff --git a/sgsn/osmo-sgsn.cfg b/sgsn/osmo-sgsn.cfg index 082a353a1..79410078c 100644 --- a/sgsn/osmo-sgsn.cfg +++ b/sgsn/osmo-sgsn.cfg @@ -101,3 +101,6 @@ sgsn timer t3397 8 no compression rfc1144 no compression v42bis + mme test-mme0 + gtp remote-ip 127.0.0.103 + gtp ran-info-relay 262 42 3