// ***************************************************************************
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   Trademark 2010, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_10wk37
// * $Date: 2010-09-17 11:39:57 +0200 (Fri, 17 Sep 2010) $
// * $Rev: 3955 $
// ***************************************************************************

module NAS_TrackingArea
{
  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from CommonDefs all;
  import from Parameters all;
  import from EUTRA_Component all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_CellInfo all;
  import from EUTRA_ConfigurationSteps all;
  import from EUTRA_CommonProcedures all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_SRB_Templates all;
  import from EUTRA_SecurityFunctions all;
  import from EUTRA_SecuritySteps all;
  import from NAS_CommonTypeDefs all;
  import from NAS_CommonTemplates all;
  import from EUTRA_NASCommonFunctions all;
  import from EUTRA_NASCommonTemplates all;
  import from EUTRA_RRC_Templates all;
  import from EPS_NAS_TypeDefs all;
  import from EPS_NAS_MsgContainers all;
  import from EPS_NAS_Constants all;
  import from EPS_NAS_Templates all;
  import from EUTRA_AuxiliaryFunctions all;
  import from EUTRA_RRCSteps all;
  import from EUTRA_NASSteps all;
  import from UpperTesterFunctions all;
  import from EUTRA_ASP_SrbDefs all;
  import from EUTRA_Timing all;
  import from CommonIratDefs all;
  import from NAS_AuxiliaryDefsAndFunctions all;
  import from EUTRA_DRB_Templates all;
  import from EUTRA_LoopBack all;
  import from EUTRA_Paging all;
  import from CommonIP all;
  import from EUTRA_IRATFunctions all;

  group LocalTemplates {

  template NAS_UL_Message_Type cdr_TAU_Request_OldGutiPTMSISig(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                               NAS_KsiValue p_KsiValue,
                                                               template AdditionalUpdateType p_AdditionalUpdateType,
                                                               template (present) MobileIdentity p_OldGuti,
                                                               template PTMSI_Signature p_Sig)
    modifies cr_508_TAU_Request :=
  {
    tRACKING_AREA_UPDATE_REQUEST := {
      oldGuti := p_OldGuti,
      oldPtmsiSignature  := p_Sig
    }
  };
  
  template (value) NAS_DL_Message_Type cds_ATTACH_ACCEPT_T3412(NAS_AttDetValue_Type p_EpsAttachResultValue,
                                                               template (value) TrackingAreaIdList p_TaiList,
                                                               template (omit)  MobileIdentity p_Guti,
                                                               template (omit)  LocAreaId p_Lai,
                                                               template (omit)  MobileIdentity p_MSId,
                                                               template (omit)  EMM_Cause p_Cause,
                                                               template (omit) AdditionalUpdateResult p_AdditionalUpdateResult,
                                                               template (value) GPRS_Timer p_T3412)
    modifies cs_508_ATTACH_ACCEPT :=
  { /* @status    APPROVED */
    aTTACH_ACCEPT := {
      t3412                 := p_T3412
    }
  };

  template (value) NAS_DL_Message_Type cs_TAU_AcceptWithoutGuti ( NAS_AttDetValue_Type p_UpdateValue,
                                                                  template (omit) TrackingAreaIdList p_TaiList,
                                                                  template (value) EPS_BearerContextStatus p_EPSCtxtStatus,
                                                                  template (omit) LocAreaId p_LAI,
                                                                  template (omit) MobileIdentity p_MS_Id ) :=
  {
    tRACKING_AREA_UPDATE_ACCEPT := {
      securityHeaderType     := tsc_SHT_NoSecurityProtection,
      protocolDiscriminator  := tsc_PD_EMM,
      messageType            := tsc_MT_TauAccept,
      spareHalfOctet         := tsc_SpareHalfOctet,
      epsUpdateResult        := cs_EPS_UpdateResult(p_UpdateValue),
      t3412                  := omit,
      guti                   := omit,
      taiList                := p_TaiList,
      epsBearerContextStatus := p_EPSCtxtStatus,
      lai                    := p_LAI,
      msIdentity             := p_MS_Id,
      emmCause               := omit,
      t3402                  := omit,
      t3423                  := omit,
      equivalentPlmns        := omit,
      asmeNasKeySetId        := omit,
      emergencyNumberList    := omit,
      epsNetworkFeatureSupport := omit,    /* @sic R5s100135 sic@ */
      addUpdateResult        := omit       /* @sic R5s100135 sic@ */
    }
  };
  
  
  template (value) NAS_DL_Message_Type cds_TAU_Accept_T3412(NAS_AttDetValue_Type p_UpdateValue,
                                                            template (value) MobileIdentity p_Guti,
                                                            template (omit) TrackingAreaIdList p_TaiList,
                                                            template (value) EPS_BearerContextStatus p_EPSCtxtStatus,
                                                            template (omit) LocAreaId p_LAI,
                                                            template (omit) MobileIdentity p_MS_Id,
                                                            template (omit) AdditionalUpdateResult p_AdditionalUpdateResult,
                                                            template (value) GPRS_Timer p_T3412)
    modifies cs_508_TAU_Accept :=
  { /* @status    APPROVED */
    tRACKING_AREA_UPDATE_ACCEPT := {
      t3412                  := p_T3412

    }
  };

  template NAS_UL_Message_Type cdr_TAU_Request_OldandAdditionalGuti(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                                    NAS_KsiValue p_KsiValue,
                                                                    template AdditionalUpdateType p_AdditionalUpdateType,
                                                                    template (present) MobileIdentity p_OldGuti,
                                                                    template (present) MobileIdentity p_AdditionalGuti,
                                                                    template (omit) UERadioCapInfoUpdateNeeded  p_UeRadioCap)
    modifies cr_508_TAU_Request :=
  {
    tRACKING_AREA_UPDATE_REQUEST := {
      asmeNasKeySetId            := cr_NAS_KeySetIdentifier (p_KsiValue, tsc_NasKsi_NativeSecurityContext),
      epsUpdateType              := cr_EPS_UpdateType(tsc_EpsUpdate_NotActive, p_EpsUpdate_TypeValue),
      oldGuti                    := p_OldGuti,
      additionalGuti             := p_AdditionalGuti,
      drxParameter               := omit,
      ueRadioCapNeeded           := p_UeRadioCap
    }
  };

  template UL_CCCH_Message cdr_RRCConnectionRequest_NotSTMSI(template (present) EstablishmentCause p_EstablishmentCause)
    modifies cr_RRCConnectionRequest :=
  {
    message_ := {
      c1 := {
        rrcConnectionRequest := {
          criticalExtensions := {
            rrcConnectionRequest_r8 := {
              ue_Identity        :=
              {
                randomValue  := ? // This option was chosen, not the S-TMSI
              },
              establishmentCause := p_EstablishmentCause,
              spare              := ?
            }
          }
        }
      }
    }
  };

  template (value) UERadioCapInfoUpdateNeeded cs_UeRadioCap :=
  {
    iei := 'A'H,
    spare := '000'B,
    urcUpdate := '1'B
  };

  template NAS_UL_Message_Type cdr_TAU_Request_combinedupdating_IMSIattach(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                                         NAS_KsiValue p_KsiValue,
                                                                         template AdditionalUpdateType p_AdditionalUpdateType,
                                                                         template (value) MobileIdentity p_OldGuti,
                                                                         template (omit) LocAreaId p_LAI,
                                                                         NAS_PlmnId p_PlmnId,
                                                                         NAS_Tac    p_Tac)
  modifies cr_508_TAU_Request :=
{
   tRACKING_AREA_UPDATE_REQUEST := {
     oldGuti       := p_OldGuti,
     lastVisitedRegisteredTai   := cr_TAI(p_PlmnId, p_Tac),
     oldLai                     := p_LAI,
     tmsiStatus                 := cr_TMSI_Status('1'B)
   }
};

    template NAS_UL_Message_Type cdr_TAU_Request_combinedupdate_OldGuti_LAI_PTMSI(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                                            NAS_KsiValue p_KsiValue,
                                                                            template AdditionalUpdateType p_AdditionalUpdateType,
                                                                            template (present) MobileIdentity p_OldGuti,
                                                                            template LocAreaId p_LAI,
                                                                            template PTMSI_Signature p_Sig)
                                                                             
      modifies cr_508_TAU_Request :=
    {
       tRACKING_AREA_UPDATE_REQUEST := {
         oldGuti            := p_OldGuti,
         oldPtmsiSignature  := p_Sig,
         oldLai             := p_LAI,
         tmsiStatus         := omit,
         addUpdateType      := p_AdditionalUpdateType
       }
    };

    template NAS_UL_Message_Type cdr_ATTACH_REQUEST_WithImsiAndLAI(template (present) NAS_AttDetValue_Type p_AttachTypeValue,
                                                                   template AdditionalUpdateType p_AdditionalUpdateType,
                                                                   template (omit) LocAreaId p_LAI)
      modifies cr_508_ATTACH_REQUEST :=
    {
      aTTACH_REQUEST := {
    
        nasKeySetId              := cr_NAS_KeySetIdentifier(tsc_NasKsi_NoKey, ?),
        oldGutiOrImsi            := f_Imsi2MobileIdentity(px_IMSI_Def),
        oldPtmsiSignature        := omit,
        lastVisitedRegisteredTai := omit,
        oldLai                   := p_LAI,
        tmsiStatus               := omit,
        addUpdateType            := p_AdditionalUpdateType       /* @sic R5-103681 sic@ */
      }
    };

  template (value) NAS_DL_Message_Type cds_TAU_Accept_T3402(NAS_AttDetValue_Type p_UpdateValue,
                                                            template (value) MobileIdentity p_Guti,
                                                            template (omit) TrackingAreaIdList p_TaiList,
                                                            template (value) EPS_BearerContextStatus p_EPSCtxtStatus,
                                                            template (omit) LocAreaId p_LAI,
                                                            template (omit) MobileIdentity p_MS_Id,
                                                            template (omit) AdditionalUpdateResult p_AdditionalUpdateResult,
                                                            template (value) GPRS_Timer p_T3402)
    modifies cs_508_TAU_Accept :=
  {
    tRACKING_AREA_UPDATE_ACCEPT := {
       t3402                    := p_T3402
    }
  };

  template EPS_UpdateType cr_EPS_UpdateType_AnyActiveFlag(EPS_UpdateTypeValue p_EpsUpdateType) :=
  {
    activeFlag := ?,
    typeValue  := p_EpsUpdateType
  };


  template NAS_UL_Message_Type cdr_TAU_Request_AnyActiveFlag_OldGuti(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                         NAS_KsiValue p_KsiValue,
                                                         template AdditionalUpdateType p_AdditionalUpdateType,
                                                         template (present) MobileIdentity p_OldGuti,
                                                         template (present) TrackingAreaId p_LastTai)
    modifies cr_508_TAU_Request :=
    {
      tRACKING_AREA_UPDATE_REQUEST := {
        epsUpdateType              := cr_EPS_UpdateType_AnyActiveFlag(p_EpsUpdate_TypeValue),
        oldGuti := p_OldGuti,
        lastVisitedRegisteredTai := p_LastTai
      }
  };

  }// end of local_templates


  group LocalFunctions {

  /**
    * @desc Deactivate EPS bearer as needed for test 9.2.3.3.5
  */
  function fl_DeactivateEPSBearer(CellId_Type p_CellId) runs on EUTRA_PTC
  {
  const ProcedureTransactionIdentifier tsc_Eps_Ti := '00'O;
  var template (value) ESM_Cause v_EsmCause43 := cs_ESM_Cause_v ('00100100'B); // #36 regular deactivation


  // The SS sends DEACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST
  // [email discussion wit Lena@Qualcomm] Message does not exist use DEACTIVATE EPS BEARER CONTEXT REQUEST
    SRB.send(cas_SRB2_NasPdu_REQ(p_CellId,
               cs_TimingInfo_Now,
               cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                    cs_508_DeactivateEPSBearerCxtReq(tsc_EpsDedicatedBearerId,
                                             tsc_Eps_Ti,
                                             v_EsmCause43
                                             ))));

  // Check: Does the UE transmit a DEACTIVATE EPS BEARER CONTEXT ACCEPT?
  SRB.receive(car_SRB2_NasPdu_IND(p_CellId,
                cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                    cr_508_DeactivateEPSBearerCxtAccept(tsc_EpsDedicatedBearerId
                                                    ))));
  } // fl_DeactivateEPSBearer92335

  } // group LocalFunctions

  group TestcaseImplementations {

  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.1.1
  ///////////////////////////////////////////////////////////////////////////////
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.3.1.1
   * @status    APPROVED
   */
  function f_TC_9_2_3_1_1_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Network initiated detach procedure / re-attach required.

    // (1)
    // with { UE in state EMM-REGISTERED and EMM-IDLE mode}
    // ensure that {
    //   when { UE detects entering a new tracking area already included in the
    //          TAI list }
    //   then { UE does not send TRACKING AREA UPDATE REQUEST message }
    // }
    //
    // (2)
    // with { UE in state EMM-REGISTERED and EMM-IDLE mode}
    // ensure that {
    //   when { UE detects entering a new tracking area not included in the TAI
    //          list }
    //   then { UE sends TRACKING AREA UPDATE REQUEST message with 'EPS update
    //          type = TA updating' }
    // }
    //
    // (3)
    // with { UE in state EMM-REGISTERED and EMM-IDLE mode and has a valid TAI
    //        value }
    // ensure that {
    //   when { UE detects entering a new tracking area not included in the TAI
    //          list }
    //   then { UE sends TRACKING AREA UPDATE REQUEST message with the TAI value
    //          in 'Last visited registered TAI' IE }
    // }

    // Pre-test conditions
    // -------------------
    // System Simulator:
    //   - Cell A, Cell C and Cell D are configured according to Table 6.3.2.2-1 in [18].
    //     - Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
    //     - Cell C belongs to TAI-3(home PLMN, another TAC) and is set to ''Non- Suitable cell''
    //     - Cell D belongs to TAI-4 (home PLMN, another TAC) and is set to ''Non- Suitable cell''
    // UE:
    //   - The UE is configured to initiate EPS attach.
    //   - The UE has a valid GUTI (GUTI-1).
    //   - The UE is registered on TAI-1.

    var template (value) CellPowerList_Type v_CellPowerList;

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

    // 3 Cells: A (serving), C and D (both suitable neighbour cells)
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellC);
    f_EUTRA_CellConfig_Def(eutra_CellD);

    f_UT_ConfigureEPSAttach (UT); // R5-103811
    // Preamble: UE is in state Registered, Idle Mode (state 2) on Cell A
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

    // Now turn other cells back on, before starting the test body
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellD, tsc_NonSuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_1_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE);

  } // function f_TC_9_2_3_1_1_EUTRA
  /*
   * @desc      test body of TC_9_2_3_1_1
   * @status    APPROVED
   */
  function fl_TC_9_2_3_1_1_Body() runs on EUTRA_PTC
  {
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();

    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var NAS_PlmnId v_HomePlmn:= f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
    var NAS_Tac v_Tac1 := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA));
    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellC);
    var GutiParameters_Type v_Guti3_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti1_Params);
    var template (omit) MobileIdentity v_MsId := f_GetMSId ( );
    
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var NasCount_Type v_NasCountUL;
    var template (value) CellPowerList_Type v_CellPowerList;
    
    var NAS_MSG_Indication_Type v_NasInd;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    
    timer t_Wait := f_EUTRA_SetTimerToleranceMax (eutra_CellD, 30.0 );
    
    // ==========================================================================
    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell A to the "Non-Suitable cell".
    //+   Set the cell type of cell C to the "Serving cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 2" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(v_UpdateType,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                         cr_TAI(v_HomePlmn, v_Tac1))));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 2");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
    
    // activate AS security
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellC,
                                                     v_SecurityParams,
                                                     v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams); // Saving security parameters
    
    //@siclog "Step 3" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE ACCEPT message. <-- TRACKING
    //+   AREA UPDATE ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellC,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                  cds_TAIListNonConsecutive_tlv(v_HomePlmn, // Cell C is using the same PLMN ID as Cell A
                                                                                                { '0003'O, '0004'O }), // TAC1=3, TAC2=4
                                                                  v_EpsBearerCtxtStatus,
                                                                  f_EUTRA_GetCellLAI(eutra_CellC),
                                                                  v_MsId,
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));
    
    //@siclog "Step 4" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE COMPLETE message? -->
    //+   TRACKING AREA UPDATE COMPLETE [2,P]
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellC,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    
    //@siclog "Step 5" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellC, tsc_RRC_TI_Def, other);
    
    //@siclog "Step 6" siclog@
    //+   Check: Does the UE respond to paging on cell C with S-TMSI2 for PS
    //+   domain? (Generic Procedure) [2]
    f_EPS_508Check_NAS_Paging(eutra_CellC, ps);
    
    //@siclog "Step 7" siclog@
    //+   Set the cell type of cell C to the "Non-Suitable cell ".
    //+   Set the cell type of cell D to the " Serving cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellD, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 8" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message in
    //+    the next 30 seconds? [1,F]
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellD, cr_RRCConnectionRequest(?)))
        { // even though prose says TAU, as soon as UE sends RRC ConnReq, we know
          // something's wrong
          t_Wait.stop;
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 8");
        }
      [] t_Wait.timeout {}
    }
    
    //@siclog "Step 9" siclog@
    //+   Check: Does the UE respond to paging on cell D with S-TMSI1 for PS
    //+    domain?(Generic Procedure) [1]
    f_EPS_508Check_NAS_Paging(eutra_CellD, ps);
    
    //@siclog "Step 10" siclog@
    //+   Set the cell type of cell D to the "Non-Suitable cell ".
    //+   Set the cell type of cell A to the " Serving cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellD, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 11" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message? -->
    //+   TRACKING AREA UPDATE REQUEST [2;3,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(v_UpdateType,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                                                                         cr_TAI(v_HomePlmn, '0004'O))));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 11");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    
    //@siclog "Step 12" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE ACCEPT message. <-- TRACKING AREA UPDATE ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(
                                                                  v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params),
                                                                  cds_TAIListNonConsecutive_tlv(
                                                                                                v_HomePlmn,
                                                                                                { '0001'O, '0002'O }), // TAC1=1, TAC2=2
                                                                  v_EpsBearerCtxtStatus,
                                                                  f_EUTRA_GetCellLAI(eutra_CellA),
                                                                  v_MsId,
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));
    
    // Store the new GUTI
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti3_Params);
    
    //@siclog "Step 13" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE COMPLETE message?
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    
    //@siclog "Step 14" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
    
  } // function fl_TC_9_2_3_1_1_Body


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.1.2
  ///////////////////////////////////////////////////////////////////////////////
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.3.1.2
   * @status    APPROVED
   */
  function f_TC_9_2_3_1_2_EUTRA() runs on EUTRA_PTC
  {
    // @desc Normal tracking area update / accepted / 'Active' flag set

    /* Purpose
     * -------
     * (1)
     * with { UE in state EMM-SERVICE-REQUEST-INITIATED and EMM-CONNECTED}
     * ensure that {
     *   when { UE detects entering a new tracking area already not included in the TAI list }
     *   then { UE sends TRACKING AREA UPDATE REQUEST message with ''Active'' flag}
     * }
     * (2)
     * with { UE in state EMM-REGISTERED and EMM-CONNECTED}
     * ensure that {
     *   when { UE sends TRACKING AREA UPDATE COMPLETE to NW }
     *   then { UE keeps the user plane and  the NAS signalling connection }
     * }
     *
     * Pre-test conditions
     * -------------------
     * System Simulator:
     *   - Cell A (TAI-1:MCC1/MNC1/TAC1) and Cell B(TAI-2:MCC1/MNC1/TAC2) (FDD for
     *     Cell A and Cell B, or TDD for Cell A and Cell B).
     *   - Cell A is set to the "Serving cell" ,Cell B is set to the "Suitable neighbour cell".
     * UE:
     *   none
     */

    var template (value) CellPowerList_Type v_CellPowerList;

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellB);

    // Preamble:
    //   - UE is in state Loopback Activated (state 4) with condition UE TEST LOOP MODE B on Cell A
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2A_TESTLOOP_ModeB); // @sic R5-104142 sic@
    f_EUTRA_RbEst_Def(eutra_CellA);
    f_EUTRA_CloseUE_TestLoopModeB(eutra_CellA, '0A'O); // @sic R5-104142 sic@
   
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower( eutra_CellB, tsc_SuitableCellRS_EPRE )
    };

    f_EUTRA_SetCellPowerList( v_CellPowerList, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);
    
    fl_TC_9_2_3_1_2_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);

    // Now remove cell A
    f_EUTRA_ReleaseAllCells( );
    
  } // function f_TC_9_2_3_1_2_EUTRA

  /*
   * @desc      test body of TC_9_2_3_1_2
   * @status    APPROVED
   */
  function fl_TC_9_2_3_1_2_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize component specific data structures
    // ==========================================================================
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA); // used in Old GUTI
    var template (value) TrackingAreaIdList v_TaiList;
    // ==========================================================================
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var template (value) CellPowerList_Type v_CellPowerList;
    var NAS_MSG_Indication_Type v_NasInd;
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template octetstring v_IPData :=  crs_IPv4_AnyIcmpEchoReply_1 ( px_IPv4_RemoteAddress, px_IPv4_RemoteAddress );

    // @sic R5-104142 sic@

    //  The SS transmits one IP Packet to the UE
    //@siclog "Step 0A" siclog@
    DRB.send (cas_DRB_COMMON_REQ_PDCP_SDU(eutra_CellA, tsc_RbId_DRB1, cs_TimingInfo_Now, {v_IPData}));
    
    // The SS waits 1 second after the IP packet has been transmitted in step 1 and then transmits an RRCConnectionRelease message
    f_Delay (1.0);
    //@siclog "Step 0B" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
    
    // @siclog "Step 1 VOID" siclog@
    //@siclog "Step 2" siclog@
    //+   The UE transmits SERVICE REQUEST message. --> SERVICE REQUEST
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    
    //@siclog "Step 3" siclog@
    //+   The SS does not perform a radio bearer establishment procedure.
    //+ Note: SS does not send any AS or NAS messages to UE.
    // *** no action required ***
    
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // The following messages are sent and shall be received on Cell B.
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    //@siclog "Step 4" siclog@
    //+   Set the cell type of cell A to the "Non-suitable cell".
    //+   Set the cell type of cell B to the "Serving cell".
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower( eutra_CellB, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 4A" siclog@
    //+   The SS releases the RRC connection. @sic R5-104142 sic@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);

    //@siclog "Step 5" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message with
    //+   'Active' flag  ? --> TRACKING AREA UPDATE REQUEST [1,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,           //  @sic R5-104142 sic@
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti_BearerEst(v_UpdateType,
                                                                                                 f_EUTRA_SecurityKSIasme_Get(),
                                                                                                 v_AdditionalUpdateType,
                                                                                                 f_GutiParameters2MobileIdentity(omit, v_GutiParams))));
          f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");

    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // @sic R5-104142 sic@
    
    //@siclog "Step 6 VOID" siclog@
    //@siclog "Step 7 VOID" siclog@
    //@siclog "Step 8 VOID" siclog@
    //@siclog "Step 9" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE ACCEPT message. <-- TRACKING
    //+   AREA UPDATE ACCEPT
    v_TaiList := cds_TAIListNonConsecutive_tlv( f_Asn2Nas_PlmnId(v_GutiParams.PLMN_Identity),
                                                { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellB)) });
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams),
                                                                  v_TaiList,
                                                                  v_EpsBearerCtxtStatus,
                                                                  f_EUTRA_GetCellLAI(eutra_CellA),
                                                                  omit,
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));
    
    //@siclog "Step 10" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE COMPLETE message? -->
    //+   TRACKING AREA UPDATE COMPLETE [1,P]
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    //@siclog "Step 11" siclog@
    //+   The SS waits 10 seconds (T3440).
    f_Delay(f_EUTRA_SetTimerToleranceMax ( eutra_CellB, 10.0 ));
    
    //@siclog "Step 12" siclog@
    //+   The SS Transmits an IDENTITY REQUEST message R5-104142
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_IDENTITY_REQUEST(tsc_IdType_IMSI))));
    
    //@siclog "Step 13" siclog@
    //+   Check: does the UE transmit an IDENTIY RESPONSE message? [2, P] R5-104142
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_NoSecurityProtection,
                                                      cr_IDENTITY_RESPONSE(f_Imsi2MobileIdentity(px_IMSI_Def)))));
    
  } // function fl_TC_9_2_3_1_2_Body


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.1.4
  ///////////////////////////////////////////////////////////////////////////////

  function f_TC_9_2_3_1_4_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Normal tracking area update / list of equivalent PLMNs in the
    ///       TRACKING AREA UPDATE ACCEPT message

    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN ,LTEmulticell);

    // 5 Cells: A (serving), B, G, I and J
    f_EUTRA_CellConfig_Def( eutra_CellA );
    f_EUTRA_CellConfig_Def( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellG );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellI );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellJ );

    // SS send Authentication Reject with cause: PLMN3 is a forbidden PLMN
    // The "forbidden PLMN list" will contains PLMN3 in UE
    f_EUTRA_Preamble_Reject (eutra_CellI, tsc_Cause_PLMN_NotAllowed);
    // Now turn I off again whilst UE registers on A
    f_EUTRA_SetCellPower ( eutra_CellI, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );

    //Preamble: UE is in state Registered, Idle Mode (state 2) on Cell A
    f_EUTRA_Preamble (eutra_CellA, STATE2_IDLEUPDATE);

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_4_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);
  } // function f_TC_9_2_3_1_4_EUTRA

  function fl_TC_9_2_3_1_4_Body() runs on EUTRA_PTC
  {

    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
    var GutiParameters_Type v_Guti3_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellG);
    var GutiParameters_Type v_Guti4_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
    var template (omit) MobileIdentity v_MsId := f_GetMSId ( );
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var template (omit) LocAreaId v_LAI := f_EUTRA_GetCellLAI(eutra_CellA);

    var NAS_MSG_Indication_Type v_NasInd;
    var template (value) CellPowerList_Type v_CellPowerList;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    timer t_Wait := f_EUTRA_SetTimerToleranceMax(eutra_CellI, 30.0);  // 30 + 10%, Considering the timer tolerance

    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell A to the "Non--Suitable cell".
    //+   Set the cell type of cell B to the "Serving cell".
    //+   Set the cell type of cell G to the "Non-Suitable Off cell"
    //+   Set the cell type of cell I to the "Non-Suitable Off cell"
    //+   Set the cell type of cell J to the "Non-Suitable Off cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    // ==========================================================================

    //@siclog "Step 2" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE REQUEST message --> TRACKING
    //    AREA UPDATE REQUEST
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cr_508_TAU_Request(v_UpdateType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType)));
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 3" siclog@
    //+   The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS
    //+   security. <-- SECURITY MODE COMMAND
    //@siclog "Step 4" siclog@
    //+   The UE transmits a NAS SECURITY MODE COMPLETE message and establishes
    //+   the initial security configuration.  --> SECURITY MODE COMPLETE
     f_EUTRA_NAS_AS_Security (eutra_CellB, false, tsc_PTI_1, tsc_SRB1);

    //@siclog "Step 5" siclog@
    //+   SS responds with a TRACKING AREA UPDATE ACCEPT message including PLMN2
    //+   and PLMN3 in the list of equivalent PLMNs.  <-- TRACKING AREA UPDATE
    //+   ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cds_TAU_Accept_EPLMN(v_UpdateType,
                                                                     f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                     cds_TAIListNonConsecutive_tlv(f_Asn2Nas_PlmnId(v_Guti2_Params.PLMN_Identity),
                                                                                                   { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellB)) }),
                                                                     v_EpsBearerCtxtStatus,
                                                                     v_LAI,
                                                                     v_MsId,
                                                                     f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType), // @sic R5-103681 sic@,
                                                                     cs_PLMNList_2(tsc_PLMN2,tsc_PLMN3)))));

    //@siclog "Step 6" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE COMPLETE message --> TRACKING
    //+   AREA UPDATE COMPLETE
    SRB.receive(car_SRB1_NasPdu_IND(
                                    eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

    //@siclog "Step 7" siclog@
    //+   Set the cell type of cell B to the "Non-Suitable Off cell".
    //+   Set the cell type of cell G to the "Suitable cell"
    //+   Set the cell type of cell J to the "Suitable cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellB, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 8" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on
    //+   cell G (PLMN2)? --> TRACKING AREA UPDATE REQUEST [1,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cr_508_TAU_Request(v_UpdateType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType)));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 8");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 9" siclog@
    //+   The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS
    //+   security.  <-- SECURITY MODE COMMAND
    //@siclog "Step 10" siclog@
    //+   The UE transmits a NAS SECURITY MODE COMPLETE message and establishes
    //+   the initial security configuration.  --> SECURITY MODE COMPLETE
     f_EUTRA_NAS_AS_Security (eutra_CellG, false, tsc_PTI_1, tsc_SRB1);

    //@siclog "Step 11" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE ACCEPT message including PLMN1
    //+   and PLMN3 in the list of equivalent PLMNs. <-- TRACKING AREA UPDATE
    //+   ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellG,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cds_TAU_Accept_EPLMN(v_UpdateType,
                                                                     f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params),
                                                                     cds_TAIListNonConsecutive_tlv(f_Asn2Nas_PlmnId(v_Guti3_Params.PLMN_Identity),
                                                                                                   { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellG)) }),
                                                                     v_EpsBearerCtxtStatus,
                                                                     v_LAI,
                                                                     v_MsId,
                                                                     f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType), // @sic R5-103681 sic@,
                                                                     cs_PLMNList_2(tsc_PLMN1, tsc_PLMN3)))));

    //@siclog "Step 12" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE COMPLETE message?
    //+   --> TRACKING AREA UPDATE COMPLETE [1,P]
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellG,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 12");

    //@siclog "Step 13" siclog@
    //+   Set the cell type of cell G to the "Non-Suitable off cell"
    //+   Set the cell type of cell I to the "Serving cell"
    //+   Set the cell type of cell J to the "Non-Suitable off cell"
    //+ Note: Cell I (PLMN3) belongs to the forbidden PLMN.
    v_CellPowerList := {
      cs_CellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 14" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on
    //+   cell I (PLMN3) in next 30 seconds?  --> TRACKING AREA UPDATE REQUEST
    //+   [1,F]
    t_Wait.start;
    alt {
      []  SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellI, cr_RRCConnectionRequest(?)))
        { // even though prose says TAU, as soon as UE sends RRC ConnReq, we know
          // something's wrong
          t_Wait.stop;
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 14");
        }
      []  t_Wait.timeout {}
    }

    //@siclog "Step 15" siclog@
    //+   The UE is switched to manual PLMN selection mode and is made to select
    //+   PLMN3 in order to remove PLMN3 in the forbidden PLMN list in the UE.
    f_UT_ManualPLMN_Select (UT, "PLMN3");

    //@siclog "Step 16" siclog@
    //+   The UE transmit a TRACKING AREA UPDATE REQUEST message on cell I
    //+   (PLMN3)? --> TRACKING AREA UPDATE REQUEST
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cr_508_TAU_Request(v_UpdateType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType)));
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 17" siclog@
    //+   The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS
    //+   security.  <-- SECURITY MODE COMMAND
    //@siclog "Step 18" siclog@
    //+   The UE transmits a NAS SECURITY MODE COMPLETE message and establishes
    //+   the initial security configuration.  --> SECURITY MODE COMPLETE
     f_EUTRA_NAS_AS_Security (eutra_CellI, false, tsc_PTI_1, tsc_SRB1);

    //@siclog "Step 19" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE ACCEPT message without the list
    //+   of equivalent PLMNs.  <-- TRACKING AREA UPDATE ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellI,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(
                                                                  v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti4_Params),
                                                                  cds_TAIListNonConsecutive_tlv(f_Asn2Nas_PlmnId(v_Guti4_Params.PLMN_Identity),
                                                                                              { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellI)) }),
                                                                  v_EpsBearerCtxtStatus,
                                                                  f_EUTRA_GetCellLAI(eutra_CellI),
                                                                  omit,
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );

    //@siclog "Step 20" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE COMPLETE message?
    //+   --> TRACKING AREA UPDATE COMPLETE [1,P]
    SRB.receive (car_SRB1_NasPdu_IND(eutra_CellI,
                                     cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                       cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 20");

    //@siclog "Step 21" siclog@
    //+   The UE is switched back to automatic PLMN selection mode.
    f_UT_AutomaticPLMN_Select(UT);

    //@siclog "Step 22" siclog@
    //+   Set the cell type of cell B to the "Suitable cell"
    //+   Set the cell type of cell G to the "Serving cell"
    //+   Set the cell type of cell I to the "Non-Suitable off cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellB, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 23" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on
    //+   Cell G (PLMN2)? --> TRACKING AREA UPDATE REQUEST [2,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cr_508_TAU_Request(v_UpdateType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 23");

    //@siclog "Step 24" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause
    //+   "No suitable cells in tracking area".  <-- TRACKING AREA UPDATE REJECT
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellG,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_NoSuitableCells))));

    //@siclog "Step 25" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on
    //+   Cell B (PLMN1)? --> TRACKING AREA UPDATE REQUEST [2,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cr_508_TAU_Request(v_UpdateType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 25");

    //@siclog "Step 26" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause
    //+   "No suitable cells in tracking area". <-- TRACKING AREA UPDATE REJECT
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_NoSuitableCells))));
  } // function tc_9_2_3_1_4_EUTRA


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.1.5
  ///////////////////////////////////////////////////////////////////////////////
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.3.1.5
   * @status    APPROVED
   */
  function f_TC_9_2_3_1_5_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Periodic tracking area update / accepted

    // (1)
    // with { UE in state EMM-REGISTERED and EMM-IDLE mode }
    // ensure that {
    //   when { the periodic tracking area updating timer T3412 expires }
    //   then { UE sends TRACKING AREA UPDATE REQUEST message with EPS
    //          update type = 'Periodic updating' }
    // }

    // (2)
    // with { UE in 'out of E-UTRAN coverage' and the periodic tracking
    //        area updating timer T3412 expires }
    // ensure that {
    //   when { the UE enters E-UTRAN coverage }
    //   then { UE sends TRACKING AREA UPDATE REQUEST message with EPS
    //          update type = 'Periodic updating' }
    // }

    // Pre-test conditions
    // -------------------
    // SS:
    //   - Cell A is configured according to Table 6.3.2.2-1 in [18].
    //   - Cell A belongs to TAI-1. (home PLMN)
    // UE:
    //   - The UE has no valid GUTI.

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble_Reject(eutra_CellA, tsc_Cause_TA_NotAllowed);
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_5_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
  } // function f_TC_9_2_3_1_5_EUTRA

  /*
   * @desc      test body
   * @status    APPROVED
   */
  function fl_TC_9_2_3_1_5_Body() runs on EUTRA_PTC
  {
    const EPS_BearerIdentity tsc_EpsBearerId := '5'H;
    var ReleaseCause v_RrcReleaseCause := other;
    var ProcedureTransactionIdentifier v_EPS_TI  := '01'O;
    var template (omit) AccessPointName v_APN := omit;

    // ==========================================================================
    // initialize component specific data structures
    // ==========================================================================
    // get all data which are required for a GUTI
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti1_Params);
    var GutiParameters_Type v_Guti3_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti2_Params);
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NAS_PlmnId v_Plmn1 := f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
    var NAS_Tac v_Tac1 := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA));
    var boolean v_EIT_Flag := false;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();  //@sic R5s100536 sic@
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();  //used to follow TTCN3 v411 standard
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

    // temporary dummy variable which gets used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    

    //@siclog "Step 1" siclog@
    //+   The UE is powered up or switched on.
    f_UT_SwitchOnUE(UT, false); /* no USIM insertion */

    //@siclog "Step 2" siclog@
    //+   The UE transmits an ATTACH REQUEST message with a PDN
    //+   CONNECTIVITY REQUEST message to request PDN connectivity to the
    //+   default PDN --> ATTACH REQUEST
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                 cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),  //@sic R5s100536 sic@
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 f_GetPdnType())));

    v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses
    if (ispresent(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
      if ( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
        v_EIT_Flag := true;
      }
    }
    v_SecurityParams.NAS_SecurityCap := f_EUTRA_FillNAS_SecurityCapability(v_NasInd.Pdu.Msg.aTTACH_REQUEST);  // @sic R5s100135 sic@
    f_EUTRA_Security_Set ( v_SecurityParams );//Saving security parameters


    //@siclog "Step 3 - 6" siclog@
    //+   The SS starts an authentication procedure <-- AUTHENTICATION
    //+   REQUEST
    
    //+   The UE responds to the authentication procedure -->
    //+   AUTHENTICATION RESPONSE
    
    //+   The SS starts a NAS security mode command procedure to perform
    //+   NAS integrity protection. <-- SECURITY MODE COMMAND
    
    //+   The UE responds to the NAS security mode command procedure -->
    //+   SECURITY MODE COMPLETE
    v_APN := f_EUTRA_Authentication_NAS_AS_Security(eutra_CellA, v_EIT_Flag, v_EPS_TI, false); // @sic R5s100094 sic@

    //@siclog "Step 7" siclog@
    //+   The SS transmits an ATTACH ACCEPT message with GUTI-1 and with
    //+   the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message. <--
    //+   ATTACH ACCEPT @sic R5-104703 sic@
    if (not isvalue(v_APN)) {
      v_APN := cs_AccessPointName (px_AccessPointName);
    }

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                     tsc_RRC_TI_Def,
                                                     cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                                    cds_ATTACH_ACCEPT_T3412(v_AttachType,  //@sic R5s100536 sic@
                                                                                                            cs_TAIListNonConsecutive_lv(v_Plmn1, { v_Tac1 }),
                                                                                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                                                            omit,
                                                                                                            omit,
                                                                                                            omit,
                                                                                                            f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType),
                                                                                                            cs_GprsTimer_v(tsc_GprsTimerUnit_6min, '00001'B)),
                                                                                    cs_508_ActivateDefEpsBearerContextRequest(tsc_EpsBearerId,
                                                                                                      v_EPS_TI,
                                                                                                      v_APN,
                                                                                                      f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (omit)),
                                                                                                      omit,
                                                                                                      omit,
                                                                                                      f_GetDefPCOforPCSCFAddress (v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)))); // @sic R5-104703 sic@

    //@siclog "Step 8" siclog@
    //+   The UE transmits an ATTACH COMPLETE message with the ACTIVATE
    //+   DEFAULT EPS BEARER CONTEXT ACCEPT message --> ATTACH COMPLETE
    f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsBearerId);

    //@siclog "Step 9" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RrcReleaseCause);

    //@siclog "Step 10" siclog@
    //+   The SS waits 6minutes . (Expire of T3412)
    f_Delay(6.0 * 60.0*0.9); // 6 minutes - 10%

    //@siclog "Step 11" siclog@
    //+   Check: Does the UE send TRACKING AREA UPDATE REQUEST message?
    //+   --> TRACKING AREA UPDATE REQUEST [1 P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                         cr_TAI_Any)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 11");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 12" siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT. <-- TRACKING AREA
    //+   UPDATE ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cds_TAU_Accept_T3412(v_UpdateType,
                                                                     f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                     cds_TAIListNonConsecutive_tlv(v_Plmn1, { v_Tac1 }),
                                                                     v_EpsBearerCtxtStatus,
                                                                     f_EUTRA_GetCellLAI(eutra_CellA),
                                                                     omit,
                                                                     f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType), // @sic R5-103681 sic@,
                                                                     cs_GprsTimer_tv('5A'O, tsc_GprsTimerUnit_6min, '00001'B)))));
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti2_Params);

    //@siclog "Step 13" siclog@
    //+   Check: Does the UE send TRACKING AREA UPDATE COMPLETE message?
    //+   --> TRACKING AREA UPDATE COMPLETE [1 P]
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 13");

    //@siclog "Step 14" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RrcReleaseCause);

    //@siclog "Step 15" siclog@
    //+   Check: Does the UE respond to paging on cell A with S-TMSI2
    //+   for PS domain?(Generic procedure) [1]
    f_EPS_508Check_NAS_Paging(eutra_CellA, ps);


    //@siclog "Step 16" siclog@
    //+   Set the cell type of cell A to the 'non-Suitable cell'.
    f_EUTRA_SetCellPower(eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now);

    //@siclog "Step 17" siclog@
    //+   The SS waits 8minutes.
    f_Delay(8.0 * 60.0 * 0.9); // - 10 %

    //@siclog "Step 18" siclog@
    //+   Set the cell type of cell A to the 'Serving cell'.
    f_EUTRA_SetCellPower(eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);

    //@siclog "Step 19" siclog@
    //+   Check: Does the UE send TRACKING AREA UPDATE REQUEST message?
    //+   --> TRACKING AREA UPDATE REQUEST [2, P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                                                                         cr_TAI_Any)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 19");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 20" siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT. <-- TRACKING AREA
    //+   UPDATE ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params),
                                                                  cds_TAIListNonConsecutive_tlv(v_Plmn1, { v_Tac1 }),
                                                                  v_EpsBearerCtxtStatus,
                                                                  f_EUTRA_GetCellLAI(eutra_CellA),
                                                                  omit,
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti3_Params);

    //@siclog "Step 21" siclog@
    //+   Check: Does the UE send TRACKING AREA UPDATE COMPLETE message?
    //+   --> TRACKING AREA UPDATE COMPLETE [2, P]
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 21");

    //@siclog "Step 22" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RrcReleaseCause);

    //@siclog "Step 23" siclog@
    //+   Check: Does the UE respond to paging on cell A with S-TMSI3
    //+   for PS domain?(Generic procedure) [2]
    f_EPS_508Check_NAS_Paging(eutra_CellA, ps);

  } // function fl_TC_9_2_3_1_5_Body


function f_TC_9_2_3_1_6_EUTRA() runs on EUTRA_PTC
    {
    // @desc Normal tracking area update / UE with ISR active moves to E-UTRAN
     /* Test Purpose (TP)
        (1)
        with { ISR activated UE in state EMM-REGISTERED and ECM_IDLE mode}
        ensure that {
          when { ISR activated UE reselects from E-UTRAN to UTRAN/GERAN cell belonging to the RA where the UE is registered }
           then { UE does not send ROUTING AREA UPDATE REQUEST message }
                     }
        (2)
        with { ISR activated UE in state EMM-REGISTERED and ECM_IDLE mode }
        ensure that {
          when { ISR activated UE reselects from E-UTRAN to UTRAN/GERAN cell belonging to a RA which is not the RA where the UE is registered }
           then { UE sends ROUTING AREA UPDATE REQUEST message }
                     }

        (3)
        with { ISR activated UE in state GMM-REGISTERED and PMM_IDLE mode }
        ensure that {
          when { ISR activated UE reselects from UTRAN/GERAN to E-UTRAN cell belonging to one of the TAs of the list of TAs where the UE is registered }
           then { UE does not send TRACKING AREA UPDATE REQUEST message }
                     }
        (4)
        with { ISR activated UE in state GMM-REGISTERED and PMM_IDLE mode }
        ensure that {
          when { ISR activated UE reselects from UTRAN/GERAN to E-UTRAN cell belonging to a TA which is not in the list of TAs where the UE is registered }
           then { UE sends TRACKING AREA UPDATE REQUEST message }
                     }
        (5)
        with { ISR activated UE has a stored TIN value = "RAT-related TMSI" }
        ensure that {
          when { SS sends a Paging with "P-TMSI" to ISR activated UE on UTRAN/GERAN cell }
           then { UE responds to the paging message }
                     }
        (6)
        with { ISR activated UE has a stored TIN value = "RAT-related TMSI" }
        ensure that {
          when { SS sends a Paging with "GUTI" to ISR activated UE on E-UTRAN cell }
           then { UE responds to the paging message }
        }

       System Simulator:
           -    Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18].
           -    Cell A belongs to TAI-1(home PLMN) and is set to ''Non- Suitable cell''
           -    Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non- Suitable cell''
           -    If pc_UTRAN, Cell 5 and Cell 7 are configured.
           -    If NOT pc_UTRAN and pc_GERAN, Cell 24 and Cell 25 are configured.
           -    Cell 5 and Cell 24 belong to RAI-1 (home PLMN) as specified TS34.123-1 clause 12 and is set to ''Serving cell''
           -    Cell 7 and Cell 25 belong to RAI-2 (home PLMN) as specified TS34.123-1 clause 12 and is set to ''Non- Suitable cell''
           -    System information indicate that NMO 1 is used
       UE:
           -    The test USIM contains no valid P-TMSI and no valid GUTI.
       Preamble:
           -    The UE is in state Switched OFF (state 1) according to [18].
     */
       var charstring v_OtherPTC := "";
       var template (value) CellPowerList_Type v_CellPowerList;

        if (pc_UTRA) {
          f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_UTRANCell);
          v_OtherPTC := "UTRAN";
        } else if (pc_GERAN) {
          f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell);
          v_OtherPTC := "GERAN";
        } else { // Neither UMTS, nor GSM, so just do LTE
          f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
          v_OtherPTC := "NONE";
        }

        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellB);

        f_EUTRA_Preamble_Reject(eutra_CellA, tsc_Cause_EPSandNonEPSServNotAllowed);  // Hellen : To DO work out how to fit in the InterRAT preamble
 
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
        }
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
        select (v_OtherPTC) { // send trigger to other RAT to change its power level too
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
          } case else {} // Do nothing
        }
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_6_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellB, E4_DEREGISTERED);

    } // end f_TC_9_2_3_1_6_EUTRA


    function fl_TC_9_2_3_1_6_Body() runs on EUTRA_PTC
    {
      var boolean v_TriggerRxd := false;
      var charstring v_OtherPTC := "";

      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var NAS_MSG_Indication_Type v_NasInd;
      var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var NAS_Lac v_LAC_B := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellB );
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
      var NAS_PlmnId v_PLMN_B := f_Asn2Nas_PlmnId(v_Guti2_Params.PLMN_Identity);
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

      timer t_Wait := f_EUTRA_SetTimerToleranceMin( eutra_CellA, 30.0 );

        if (pc_UTRA) {
          v_OtherPTC := "UTRAN";
        } else if (pc_GERAN) {
          v_OtherPTC := "GERAN";
        } else { // Neither UMTS, nor GSM, so just do LTE
          v_OtherPTC := "NONE";
        }

        //  The UE is switched on.
        //@siclog "Step 1" siclog@
        f_UT_SwitchOnUE (UT, false);
    
        // Behaviour that depends on the UE capability
        //@siclog "Step 2 - 8" siclog@
        select (v_OtherPTC) { // send trigger to other RAT to change its power level too
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }

        // . Set power level for Cell A to "Serving cell"
        //@siclog "Step 9" siclog@
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

 
        //  The UE sends TRACKING AREA UPDATE REQUEST message
        //@siclog "Step 10" siclog@
        v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas ( eutra_CellA, v_RRC_TI, cr_EstablishmentCause_Any,
                                                     cr_NAS_Indication(
                                                                  tsc_SHT_IntegrityProtected,
                                                                  cdr_TAU_RequestIdleMobilityDiffRAT (
                                                                                    tsc_EpsUpdate_Combined_TaLaUpdate_ISRActivated,
                                                                                    f_EUTRA_SecurityKSIasme_Get ( ),
                                                                                    v_AdditionalUpdateType
                                                                                    )));

        //  The SS sends TRACKING AREA UPDATE ACCEPT including GUTI-1 (TIN set to RAT-related TMSI) and TAI-1
        //@siclog "Step 11" siclog@
        v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
        SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(
                                                                  tsc_EpsUpdate_Combined_TaLaUpdate_ISRActivated,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                  cds_TAIListNonConsecutive_tlv(
                                                                                              v_PLMN,
                                                                                              { tsc_TAC1 } ),//TAC-1
                                                                  v_EpsBearerCtxtStatus,
                                                                  v_LAI,
                                                                  f_GetMSId ( ),
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

        //  The UE sends TRACKING AREA UPDATE COMPLETE message
        //@siclog "Step 12" siclog@
        SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

        //@siclog "Step 13" siclog@
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
          }   // change power level of Cell A, send trigger to other RAT then wait for trigger to be returned
        select (v_OtherPTC) {
          case ("UTRAN") {
            f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }

        // Set power level for Cell A to "Serving cell"
        //@siclog "Step 16" siclog@
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

        // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST?
        //@siclog "Step 17" siclog@
        t_Wait.start;
        alt {
          [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA, cr_RRCConnectionRequest(?)))
          {  // as soon as UE sends RRC ConnReq, Fail verdict is raised
             t_Wait.stop;
             f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 17");
          }
          [] t_Wait.timeout {}
        }

        //@siclog "Step 18" siclog@
        // Check: Does the generic test procedure (TS 36.508 subclause 6.4.2.4) indicate that the UE
        // is EMM-REGISTERED on CellA with PagingUE-Identity = S-TMSI1 and with CN domain indicator set to PS?
        f_EPS_508Check_NAS_Paging(eutra_CellA, ps);

        // Step 18A
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
          }   // change power level of Cell A, send trigger to other RAT then wait for trigger to be returned
        select (v_OtherPTC) {
          case ("UTRAN") {
            f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }

        //  Set power level for Cell B to "Serving cell"
        //@siclog "Step 19" siclog@
        f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

        //@siclog "Step 20" siclog@
        // Check: does the UE send a TRACKING AREA UPDATE REQUEST with the correct parameters?
        v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                   tsc_RRC_TI_Def,
                                                   cr_EstablishmentCause_Any,
                                                   cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(v_UpdateType,
                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                    v_AdditionalUpdateType,
                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                    cr_TAI(v_PLMN, tsc_TAC1))));
 
        f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 20");

    
        //@siclog "Step 21" siclog@
        // The SS sends TRACKING AREA UPDATE ACCEPT
        // Note: the default message contents cause the allocation of a new GUTI.
        v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
        SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                        cs_TimingInfo_Now,
                                        cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                           f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                           cds_TAIListNonConsecutive_tlv( v_PLMN, {tsc_TAC2 } ),
                                                                           v_EpsBearerCtxtStatus,
                                                                           f_GetLAI(v_PLMN_B,v_LAC_B),
                                                                           f_GetMSId ( ),
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

        //@siclog "Step 22" siclog@
        //The UE sends TRACKING AREA UPDATE COMPLETE
        SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellB,
                                            cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                                cr_508_TAU_Complete )));

        
        //@siclog "Step 23" siclog@
        // Check: Does the generic test procedure (TS 36.508 subclause 6.4.2.4) indicate that the UE
        // is EMM-REGISTERED on CellB with PagingUE-Identity = S-TMSI1 and with CN domain indicator set to PS?
        f_EPS_508Check_NAS_Paging(eutra_CellB, ps);

        //@siclog "Step 24" siclog@
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
          }   // change power level of Cell B, send trigger to other RAT then wait for trigger to be returned
        select (v_OtherPTC) {
          case ("UTRAN") {
            f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }

        //  Set power level for Cell B to "Serving cell"
        //@siclog "Step 28" siclog@
        f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

        //@siclog "Step 29" siclog@
        // Check: Does the generic test procedure (TS 36.508 subclause 6.4.2.4) indicate that the UE
        // is EMM-REGISTERED on CellB with PagingUE-Identity = S-TMSI1 and with CN domain indicator set to PS?
        f_EPS_508Check_NAS_Paging(eutra_CellB, ps);

    }// end function fl_TC_9_2_3_1_6_Body


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.1.8
  ///////////////////////////////////////////////////////////////////////////////
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.3.1.8
   * @status    APPROVED
   */
  function f_TC_9_2_3_1_8_EUTRA() runs on EUTRA_PTC
  {
    /// @desc UE receives an indication that the RRC connection was released with
    ///       cause "load balancing TAU required"

    // Purpose
    // -------
    // (1)
    // with { UE in state EMM-REGISTERED and EMM-CONNECTED mode}
    // ensure that {
    //   when { UE receives RRC CONNECTION RELEASE message with cause "load
    //          balancing TAU required" and enters EMM-REGISTERED and EMM-IDLE mode}
    //   then { UE sends TRACKING AREA UPDATE REQUEST message with EPS update type
    //          = "TA updating"}
    // }

    // Pre-test conditions
    // -------------------
    // System Simulator:
    //   - Cell A is configured according to Table 6.3.2.2-1 in [18]
    //   - Cell A belongs to TAI-1(home PLMN)
    // UE:
    //   - The UE has a valid GUTI (GUTI-1).
    //   - The UE is registered on TAI-1.

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);

    // Preamble:
    //   - UE is in state Generic RB established (state 3) on Cell A
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_Def(eutra_CellA);
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_8_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);

  } // function f_TC_2_9_3_1_8_EUTRA

  /*
   * @desc      test body of TC_9_2_3_1_8
   * @status    APPROVED
   */
  function fl_TC_9_2_3_1_8_Body() runs on EUTRA_PTC
  {
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti1_Params);
    var template (value) TrackingAreaIdList v_TaiList;
    // get current security parameters

    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var NAS_AttDetValue_Type v_UpdateType := f_GetEAttachType();

    // temporary variable which is used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();  //used to follow TTCN3 v411 standard

    //@siclog "Step 1" siclog@
    //+   The SS transmits RRCConnectionReleaese with cause "load balancing TAU
    //+   required".
    f_EUTRA_RRC_ConnectionRelease_ImmediateReset(eutra_CellA,
                                                 cs_RRCConnectionRelease(tsc_RRC_TI_Def,
                                                                         loadBalancingTAUrequired)); // @sic R5s100135 sic@
    //@siclog "Step 2" siclog@
    //+   Check: Does the UE send TRACKING AREA UPDATE REQUEST message. -->
    //+   TRACKING AREA UPDATE REQUEST [1,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_TAU_Request(tsc_EpsUpdate_TaUpdate, f_EUTRA_SecurityKSIasme_Get(), v_AdditionalUpdateType)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    
    //@siclog "Step3 " siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT. <-- TRACKING AREA UPDATE
    //+   ACCEPT
    //+ Note: The SS assigns a different MME Identifier (MMEI) value in a GUTI.
    v_TaiList := cds_TAIListNonConsecutive_tlv(f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity),
                                               { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA)) } );
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                  v_TaiList,
                                                                  v_EpsBearerCtxtStatus,
                                                                  f_EUTRA_GetCellLAI(eutra_CellA),
                                                                  omit,
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti2_Params);
    
    //@siclog "Step 4" siclog@
    //+   The UE sends TRACKING AREA UPDATE COMPLETE message -->
    //+   TRACKING AREA UPDATE COMPLETE
    SRB.receive (car_SRB1_NasPdu_IND(eutra_CellA,
                                     cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                       cr_508_TAU_Complete)));
    
    
  } // function fl_TC_9_2_3_1_8_Body


function f_TC_9_2_3_1_9a_EUTRA() runs on EUTRA_PTC
    {
    // @desc Normal tracking area update / NAS signalling connection recovery
     /* Test Purpose (TP)
        (1)
        with { UE in state EMM-REGISTERED and EMM-CONNECTED }
        ensure that {
          when { UE receives an indication of "RRC Connection failure" from the lower layers }
            then { UE initiates the tracking area updating procedure }
        }

       System Simulator:
            -   Cell A and Cell M (same TA).
            -   Cell A is "Serving cell" and Cell M is "non-Suitable cell".

       UE:
            -   The test USIM contains IMSI-1, GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".

       Preamble:
            -   The UE is in state Generic RB Established (state 3) with EPSOnlyAttachForced on Cell A according to [18].

     */
        var template (value) CellPowerList_Type v_CellPowerList;

        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

        // create cell and send out system information
        f_EUTRA_CellConfig_Def (eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellM);

        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellM, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        // Preamble:
        //   - UE is in state Generic RB established (state 3) on Cell A
        // ==========================================================================
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        f_EUTRA_RbEst_Def(eutra_CellA);
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_9a_Body ();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellM, E2_CONNECTED);

    } // end f_TC_9_2_3_1_9a_EUTRA


    function fl_TC_9_2_3_1_9a_Body() runs on EUTRA_PTC
    {
        var template (value) CellPowerList_Type v_CellPowerList;

        var SRB_COMMON_IND v_ReceivedAsp;

        var EPS_BearerContextStatus v_EPS_ContextStatus;
        var template (omit) MobileIdentity v_MSId := f_GetMSId (CombinedWithTMSI);
        var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti (eutra_CellA);
        var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
        var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
        var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti_Params.PLMN_Identity);
        var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
        var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
        var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
        var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();

        timer t_WaitTimer := f_EUTRA_SetTimerToleranceMax( eutra_CellM, 10.0 );

        //@siclog "Step 1" siclog@
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellM, tsc_ServingCellRS_EPRE )
        }
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        //  UE transmits an RRCConnectionReestablishmentRequest message
        //@siclog "Step 2" siclog@
        SRB.receive( car_SRB0_RrcPdu_IND( eutra_CellM,
                                          cr_508_RRCConnectionReestablishmentRequest (
                                                              ?,
                                                              f_EUTRA_CellInfo_GetPhyCellId ( eutra_CellM ),
                                                              cr_ReestablishmentCause_Any
                                                              )
                                          ));


        //  The SS transmits an RRCConnectionReestablishmentReject message
        //@siclog "Step 3" siclog@
        SRB.send ( cas_SRB0_RrcPdu_REQ ( eutra_CellM,
                                         cs_TimingInfo_Now,
                                         cs_508_RRCConnectionReestablishmentReject ) );


        //@siclog "Step 4" siclog@
        // Check: does the UE transmits a TRACKING AREA UPDATE REQUEST with the EPS update
        // type set to 'TA updating' in the next 10 seconds?
        t_WaitTimer.start;
        alt {
           []  SRB.receive(car_SRB1_NasPdu_IND(eutra_CellM,
                                          cr_NAS_Indication( tsc_SHT_IntegrityProtected_Ciphered,
                                                             cdr_TAU_Request_OldGuti(
                                                                                  v_UpdateType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType,
                                                                                  f_GutiParameters2MobileIdentity(omit, v_Guti_Params),
                                                                                  cr_TAI(v_PLMN, tsc_TAC1)
                                                                                ))))
              -> value v_ReceivedAsp
             {
               t_WaitTimer.stop;
               f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 4")
             }
           []  t_WaitTimer.timeout
             {
             }
        }

        v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

        // The SS transmits a TRACKING AREA UPDATE ACCEPT message.
        //@siclog "Step 5" siclog@
        SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellM,
                                         cs_TimingInfo_Now,
                                         cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                          cs_TAU_AcceptWithoutGuti ( v_UpdateType,
                                                                                     v_TaiList,
                                                                                     v_EPS_ContextStatus,
                                                                                     v_LAI,
                                                                                     v_MSId) ) ) );


    }// end function fl_TC_9_2_3_1_9a_Body



  function f_TC_9_2_3_1_10_EUTRA() runs on EUTRA_PTC
  {
    // @_9_2_3_1_10: desc Normal tracking area update / rejected / IMSI invalid

    /* (1)
    with { UE has sent a TRACKING AREA UPDATE REQUEST message}
    ensure that {
      when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to ''Illegal UE'' }
        then { UE considers the USIM as invalid for EPS services and non-EPS services and enters state EMM-DEREGISTERED }

    (2)
    with { The UE is in the state EMM-DEREGISTERED }
    ensure that {
      when { UE is powered up }
        then { UE send ATTACH REQUEST message with Old GUTI or IMSI IE = ''IMSI''}

    */

    // Pre-test conditions
    // -------------------
    /* System Simulator:
    -   Cell A, Cell B and Cell G are configured according to Table 6.3.2.2-1 in [18].
      -   Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
      -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non- Suitable cell''
      -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Non- Suitable cell''
        -   Cell 5 (UTRAN) or Cell 24 (GERAN).
    - Cell 5 and Cell 24 belong to RAI-1 as specified TS34.123-1 clause 12 and is set to ''Non- Suitable cell''
    UE:
    -   The UE is configured to initiate EPS attach.
    -   The UE has a valid GUTI (GUTI-1).
    -   The UE is registered on TAI-1.
    -   IF pc_GERAN or pc_UTRAN THEN the UE has a valid P-TMSI.
    Preamble:
    -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].

    */
    var template (value) CellPowerList_Type v_CellPowerList;
    var boolean v_TriggerRxd := false;

    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UTRANCell);
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_GERANcell);
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
    }

    f_UT_ConfigureEPSAttach (UT); // R5-103811
    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellG );

    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    if (pc_UTRA) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    } else if (pc_GERAN) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_10_11_AND_12_Body(tsc_EmmCause_IllegalUe);

    // Postamble
    f_EUTRA_TestBody_Set(false);

    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_3_1_10_EUTRA

  function f_TC_9_2_3_1_11_EUTRA() runs on EUTRA_PTC
  {
    // @_9_2_3_1_11: desc Normal tracking area update / rejected / illegal ME
    /* (1)
    with { UE has sent a TRACKING AREA UPDATE REQUEST message}
    ensure that {
      when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to ''Illegal ME'' }
        then { UE considers the USIM as invalid for EPS services and non-EPS services and enters state EMM-DEREGISTERED }

    (2)
    with { The UE is in the state EMM-DEREGISTERED }
    ensure that {
      when { UE is powered up }
        then { UE send ATTACH REQUEST message with Old GUTI or IMSI IE = ''IMSI''}

    */
    // Pre-test conditions
    // -------------------
    /* System Simulator:
    -   Cell A, Cell B and Cell G are configured according to Table 6.3.2.2-1 in [18].
    -   Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
    -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non- Suitable cell''
    -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Non- Suitable cell''
        -   Cell 5 (UTRAN) or Cell 24 (GERAN).
    - Cell 5 and Cell 24 belong to RAI-1 as specified TS34.123-1 clause 12 and is set to ''Non- Suitable cell''
    UE:
    -   The UE is configured to initiate EPS attach.
    -   The UE has a valid GUTI (GUTI-1).
    -   The UE is registered on TAI-1.
    -   IF pc_GERAN or pc_UTRAN THEN the UE has a valid P-TMSI.
    Preamble:
    -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].

    */
    var template (value) CellPowerList_Type v_CellPowerList;
    var boolean v_TriggerRxd := false;

    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UTRANCell);
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_GERANcell);
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
    }

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellG );

    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    if (pc_UTRA) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    } else if (pc_GERAN) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_10_11_AND_12_Body(tsc_EmmCause_IllegalMe);

    // Postamble
    f_EUTRA_TestBody_Set(false);

    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
    
  } // function f_TC_9_2_3_1_11_EUTRA

/**
  * @desc Normal tracking area update / rejected / EPS service not allowed
*/
  function f_TC_9_2_3_1_12_EUTRA() runs on EUTRA_PTC
  {
   /*
     Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to ''EPS service not allowd'' }
            then { UE considers the USIM as invalid for EPS services and enters state EMM-DEREGISTERED }

        (2)
        with { The UE is in the state EMM-DEREGISTERED }
        ensure that {
          when { UE is powered up or switched on }
            then { UE sends ATTACH REQUEST message with 'Old GUTI or IMSI IE = 'IMSI''}

    Pre-test conditions
        System Simulator:
        -   Cell A, Cell B and Cell G are configured according to Table 6.3.2.2-1 in [18].
        -   Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
        -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non- Suitable cell''
        -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Non- Suitable cell''
            -   Cell 5 (UTRAN) or Cell 24 (GERAN).
        - Cell 5 and Cell 24 belong to RAI-1 as specified TS34.123-1 clause 12 and is set to ''Non- Suitable cell''
        UE:
        -   The UE is configured to initiate EPS attach.
        -   The UE has GUTI-1.
        -   The UE is registered on TAI-1.
        -   IF pc_GERAN or pc_UTRAN THEN the UE has P-TMSI-1 and P-TMSI signature-1.
        Preamble:
        -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18]
   */
    var boolean v_TriggerRxd := false;
    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UTRANCell);
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_GERANcell);
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
    }

    f_UT_ConfigureEPSAttach (UT); // R5-103811

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellG );

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    // If pc_GERAN or pc_UTRAN supported by UE, wait for other RAT to update TMSI-1, P-TMSI-1and RAI-1, and GPRS update status is "GU1:UPDATED"
    if (pc_UTRA) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN, CombinedWithPTMSI);
    } else if (pc_GERAN) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN, CombinedWithPTMSI);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_10_11_AND_12_Body(tsc_Cause_EPSServNotAllowed);

    // Postamble
    f_EUTRA_TestBody_Set(false);

    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);

  } // function f_TC_9_2_3_1_12_EUTRA
  function fl_TC_9_2_3_1_10_11_AND_12_Body(B8_Type p_EmmCause) runs on EUTRA_PTC
  {

    const ReleaseCause tsc_RrcReleaseCause := other;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var template (value) CellPowerList_Type v_CellPowerList;
    // temporary dummy variable which gets used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    var SRB_COMMON_IND v_ReceivedAsp;
    var boolean v_TriggerRxd := false;
    var charstring v_OtherPTC := "";
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template PTMSI_Signature v_PTMSISignature := omit;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

    timer t_Wait := f_EUTRA_SetTimerToleranceMax ( eutra_CellA, 30.0);

    if (pc_UTRA or pc_GERAN) {
      v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
    }

    if (pc_UTRA) {
         v_OtherPTC := "UTRAN";
       } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
       } else { // Neither UMTS, nor GSM, so just do LTE
         v_OtherPTC := "NONE";
    }

    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell A to the ''Non-Suitable cell''. Set the cell type of cell B to the ''Serving cell''.
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 2" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGutiPTMSISig(v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                       v_PTMSISignature)));

    //@siclog "Step 3" siclog@
    //+  The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = "Illegal UE" as specified.
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(p_EmmCause))));

    //@siclog "Step 4" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, tsc_RrcReleaseCause);

    //@siclog "Step 5" siclog@
    //+  Set the cell type of cell A to the ''Serving cell''. Set the cell type of cell B to the ''Non-Suitable cell''.
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 6" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell A? [1,F]
    //   Note: Cell A belongs to the same PLMN where the UE was rejected but a different TAC
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellA, 30.0);

    //@siclog "Step 7" siclog@
    //+   The user initiates an attach by MMI or by AT command.
    f_UT_TriggerAttach(UT);

    //@siclog "Step 8" siclog@
    //+Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell A? [1,F]
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellA, 30.0);

    //@siclog "Step 9" siclog@
    //+  Set the cell type of cell A to the '' Non-Suitable cell''. Set the cell type of cell G to the ''Serving cell''.
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 10" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G? [1,F]
    //   Note: Cell G belongs to a PLMN which is not the same like the one on which the UE was rejected.
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellG, 30.0);

    //+  The user initiates an attach by MMI or by AT command.
    //@siclog "Step 11" siclog@
    f_UT_TriggerAttach(UT);

    //@siclog "Step 12" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G? [1,F]
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellG, 30.0);

    //@siclog "Step 13" siclog@
    //+  Set the cell type of cell G to the ''Non-Suitable cell''. Set the cell type of cell 5 or 24 to the ''Serving cell''.
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    select (v_OtherPTC) { // send trigger to other RAT to change its power level too
      case ("UTRAN") {
        f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
      } case ("GERAN") {
        f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
      } case else {} // Do nothing
    }

    // EXCEPTION: Steps 14a1 to 14a2 describe behaviour that depends on the UE capability; the "lower case letter" identifies a step sequence that take place if a capability is supported

    //@siclog "Step 14a1 - 14a2" siclog@
    //+  IF pc_GERAN or pc_UTRAN THEN the user initiates an attach by MMI or by AT command.
      // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell 5 or 24?
    //@siclog "Step 15" siclog@
    //+   The UE is switched off.

    //@siclog "Step 16" siclog@
    // Set the cell type of cell A to the ''Serving cell''.
    // Set the cell type of cell G to the ''Non-Suitable cell''.
    // Set the cell type of cell 5 or 24 to the ''Non-Suitable cell''.
    select (v_OtherPTC) { // send trigger to other RAT to change its power level too
      case ("UTRAN") {
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN);
      }
      case ("GERAN") {
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (GERAN);
      }
      case else {} // Do nothing
    }

    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE )
    }
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 17" siclog@
    //+   The UE is powered up or switched on.
   f_UT_SwitchOnUE(UT, false);

    //@siclog "Step 18" siclog@
    //+ Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell A? [2,P]
    t_Wait.start;
    alt {
     []  SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA, cr_RRCConnectionRequest(cr_EstablishmentCause_Any)))
      {
        t_Wait.stop;

       // send RRC Connection Setup on SRB0 (CCCH) and switch on UL grant assignments:
        f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellA, cs_TimingInfo_Now, v_RRC_TI);

       // receive RRC Connection Setup Complete with piggy-backed NAS message on SRB1 (DCCH):
        SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                 cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?),
                 cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                   cdr_ATTACH_REQUEST_WithIMSIAndnoTAI(v_AttachType,
                                                                                       v_AdditionalUpdateType,
                                                                                       f_Imsi2MobileIdentity(px_IMSI_Def),
                                                                                       cr_TMSI_Status('0'B) ifpresent),
                                                   cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                   f_GetPdnType()))))
                        -> value v_ReceivedAsp;
        f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 18");
      }
     []  t_Wait.timeout
       {
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 18");
       }
    }
    
    //@siclog "Step 19 - 30" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_ReceivedAsp.Signalling.Nas[0], false);
    
  } // function fl_TC_9_2_3_1_10_11_AND_12_Body

/**
  * @desc  Normal tracking area update / rejected / UE identity cannot be derived by the network
*/
  function f_TC_9_2_3_1_13_EUTRA() runs on EUTRA_PTC
  {
   /* Test Purpose
    (1)
    with { UE has sent a TRACKING AREA UPDATE REQUEST message}
    ensure that {
    when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to ''UE
    identity cannot be derived by the network'' }
    then { UE deletes any GUTI, last visited registered TAI, TAI list and KSI and enters the state
    EMM-DEREGISTERED and subsequently, UE automatically initiates the attach procedure}
        */
       /* Pre-test conditions
    System Simulator:
    - Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18].
    - Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
    - Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non- Suitable cell''
    UE:
    - The UE is configured to initiate EPS attach.
    - The UE has GUTI-1.
    - The UE is registered on TAI-1.
    - IF pc_GERAN or pc_UTRAN THEN the UE has P-TMSI-1 and P-TMSI signature-1.  *** TO DO ***
    Preamble:
    - UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].

    */
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def( eutra_CellB );

    f_UT_ConfigureEPSAttach (UT); // R5-103811

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_13_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);

  } // function f_TC_9_2_3_1_13_EUTRA


  function fl_TC_9_2_3_1_13_Body() runs on EUTRA_PTC
  {

    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    // temporary dummy variable which gets used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    var SRB_COMMON_IND v_ReceivedAsp;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    var template PTMSI_Signature v_PTMSISignature := omit;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    timer t_Wait := f_EUTRA_SetTimerToleranceMax( eutra_CellB, 30.0 );
    
    if (pc_UTRA or pc_GERAN) {
      v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
    }
 
    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell A to the ''Non-Suitable cell''. Set the cell type of cell B to the ''Serving cell''.
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    //@siclog "Step 2" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGutiPTMSISig(v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                       v_PTMSISignature)));

    //@siclog "Step 3" siclog@
    //+  The SS transmits a TRACKING AREA UPDATE REJECT message
    //   with EMM cause = "UE identity can not be derived by the network".
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                 cs_TimingInfo_Now,
                 cs_NAS_Request(tsc_SHT_IntegrityProtected,
                         cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_UEIdentityNotDerived))));

    //@siclog "Step 4" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease_ImmediateReset(eutra_CellB, cs_RRCConnectionRelease(tsc_RRC_TI_Def, other));

    //Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
    //@siclog "Step 5" siclog@
      t_Wait.start;
      alt {
          [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellB, cr_RRCConnectionRequest(cr_EstablishmentCause_Any)))
          {
              t_Wait.stop;
              f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellB, cs_TimingInfo_Now, tsc_RRC_TI_Def);
              SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellB,
                                                 cr_508_RRCConnectionSetupComplete(tsc_RRC_TI_Def, ?),
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cdr_ATTACH_REQUEST_WithIMSIAndnoTAI(
                                                                   v_AttachType,
                                                                   v_AdditionalUpdateType,
                                                                   f_Imsi2MobileIdentity(px_IMSI_Def),
                                                                   cr_TMSI_Status('0'B)))
                                                 ))
                    -> value v_ReceivedAsp;
              f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 5");
          }
          [] t_Wait.timeout
          {
              f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "step 5");
          }
     }

    //@siclog "Step 6 - 17" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_ReceivedAsp.Signalling.Nas[0], false);

  } // function fl_TC_9_2_3_1_13_Body



  function f_TC_9_2_3_1_14_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Normal tracking area update / rejected / UE implicitly detached

    // Purpose
    // -------
    // (1)
    /* with { UE has sent a TRACKING AREA UPDATE REQUEST message}
       ensure that {
       when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to ''UE implicitly detached'' }
       then { UE enters the state EMM-DEREGISTERED.NORMAL-SERVICE and sends ATTACH REQUEST message}

*/
    /* Pre-test conditions
    System Simulator:
    -   Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18].
    -   Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
    -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non- Suitable cell''
    UE:
    -   The UE has GUTI-1.
    -   The UE is registered on TAI-1.
    -   IF pc_GERAN or pc_UTRAN THEN the UE has P-TMSI-1 and P-TMSI signature-1.
    Preamble:
    -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].
    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN,LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellB);

    f_UT_ConfigureEPSAttach (UT); // R5-103811

    // Preamble:
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_14_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);

  } // function f_TC_2_9_3_1_14_EUTRA

  function fl_TC_9_2_3_1_14_Body() runs on EUTRA_PTC
  {
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);

    // temporary variable which is used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    var SRB_COMMON_IND v_ReceivedAsp;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template PTMSI_Signature v_PTMSISignature := omit;
    timer t_Wait := f_EUTRA_SetTimerToleranceMax (eutra_CellB, 30.0 );
 
    if (pc_UTRA or pc_GERAN) {
      v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
    }
 
    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell A to the ''Non-Suitable cell''. Set the cell type of cell B to the ''Serving cell''.
    f_EUTRA_SetCellPower(eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now);

    //@siclog "Step 2" siclog@
    //+  The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGutiPTMSISig(v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                       v_PTMSISignature)));

    //@siclog "Step 3" siclog@
    //+  The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = ''UE implicitly detached'' as specified.
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_ImplicitlyDetached))));

    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);
    
    //@siclog "Step 4" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell B? [1,P]
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellB,
                                    cr_RRCConnectionRequest(cr_EstablishmentCause_Any)))
         {
             t_Wait.stop;
             f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellB, cs_TimingInfo_Now, tsc_RRC_TI_Def);
             SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellB,
                                            cr_508_RRCConnectionSetupComplete(tsc_RRC_TI_Def, ?),
                                            cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                               cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType)
                                                                              )))
                -> value v_ReceivedAsp;
             f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 4");
         }
      [] t_Wait.timeout
        {
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "step 4");
        }
    }

    //@siclog "Step 5 - 16" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_ReceivedAsp.Signalling.Nas[0], false);
    
  } // function fl_TC_9_2_3_1_14_Body


function f_TC_9_2_3_1_15_EUTRA() runs on EUTRA_PTC
    {
    // @desc Normal tracking area update / Rejected / PLMN not allowed
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message }
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to "PLMN not allowed" }
            then { UE deletes the GUTI, the last visited registered TAI and KSI and UE deletes the list of equivalent PLMNs and UE enters state EMM-DEREGISTERED.PLMN-SEARCH and UE stores the PLMN in the "forbidden PLMN list" }
         }
        (2)
        with { UE is switched off having a PLMN stored in the "forbidden PLMN list" }
        ensure that {
          when { UE is powered up on this PLMN }
            then { UE doesn't perform an attach procedure }
        }
        (3)
        with { UE in EMM-DEREGISTERED.PLMN-SEARCH state having a PLMN stored in the "forbidden PLMN list" }
        ensure that {
          when { UE enters a cell which is not in the "forbidden PLMN list" }
            then { UE initiates an attach procedure }
        }
        (4)
        with { UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state having a PLMN stored in the "forbidden PLMN list" }
        ensure that {
          when { UE is in a forbidden PLMN cells and when the PLMN is selected manually }
            then { UE initiates an attach procedure }
        }

        System Simulator:
        -   Cell G, Cell H and Cell I are configured according to Table 6.3.2.2-1 in [18].
        -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Serving cell''
        -   Cell H belongs to TAI-8(visited PLMN, another TAC) and is set to ''Non- Suitable cell''
        -   Cell I belongs to TAI-9(visited PLMN, another PLMN) and is set to ''Non-Suitable cell''
        PLMN in Cell G, Cell H and Cell I are not HPLMN of the UE.
        -   Cell 5 (UTRAN) or Cell 24 (GERAN).
        - Cell 5 and Cell 24 belong to RAI-1 as specified TS34.123-1 clause 12 and are set to ''Non- Suitable cell''
        UE:
        -   The UE is configured to initiate EPS attach.
        -   The UE has GUTI-7.
        -   The UE is registered on TAI-7.
        -   IF pc_GERAN or pc_UTRAN THEN the UE has P-TMSI-1 and P-TMSI signature-1.
        Preamble:
        -   UE is in state Registered, Idle Mode (state 2) on Cell G according to [18].

     */
       var charstring v_OtherPTC := "";
       var template (value) CellPowerList_Type v_CellPowerList;
       var boolean v_TriggerRxd := false;

        if (pc_UTRA) {
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UTRANCell);
          v_OtherPTC := "UTRAN";
        } else if (pc_GERAN) {
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_GERANcell);
          v_OtherPTC := "GERAN";
        } else { // Neither UMTS, nor GSM, so just do LTE
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
          v_OtherPTC := "NONE";
        }

        f_UT_ConfigureEPSAttach (UT); // R5-103811

        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellG);
        f_EUTRA_CellConfig_Def(eutra_CellH);
        f_EUTRA_CellConfig_Def(eutra_CellI);

        // If pc_GERAN or pc_UTRAN supported by UE, wait for other RAT to update TMSI-1, P-TMSI-1and RAI-1, and GPRS update status is "GU1:UPDATED"
        if (pc_UTRA) {
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
        } else if (pc_GERAN) {
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
        } else { // supports neither UTRAN or GERAN
            f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        }

        v_CellPowerList := {
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
        select (v_OtherPTC) { // send trigger to other RAT to change its power level too
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
          } case else {} // Do nothing
        }
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_15_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);

        f_EUTRA_Postamble(eutra_CellG, E2_CONNECTED);
    } // end f_TC_9_2_3_1_15_EUTRA


    function fl_TC_9_2_3_1_15_Body() runs on EUTRA_PTC
    {
      var boolean v_TriggerRxd := false;
      var charstring v_OtherPTC := "";

      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_MSG_Indication_Type v_NasInd;
      var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
      var boolean v_EIT_Flag := false;
      var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
      var template (omit) AccessPointName v_APN := omit;
      var template (omit) ProtocolConfigOptions v_Pco := omit;

      var GutiParameters_Type v_Guti_Params_G := f_EUTRA_CellInfo_GetGuti(eutra_CellG);
      var GutiParameters_Type v_Guti_Params_I := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
      var NAS_PlmnId v_PLMN_I := f_Asn2Nas_PlmnId(v_Guti_Params_I.PLMN_Identity);
      var TrackingAreaCode v_Tac_CellI := f_EUTRA_CellInfo_GetTAC ( eutra_CellI );
      var template (value) TrackingAreaIdList v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN_I, { bit2oct( v_Tac_CellI ) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      var template PTMSI_Signature v_PTMSISignature := omit;

      if (pc_UTRA or pc_GERAN) {
         v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
      }

      if (pc_UTRA) {
         v_OtherPTC := "UTRAN";
       } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
       } else { // Neither UMTS, nor GSM, so just do LTE
         v_OtherPTC := "NONE";
      }

      //@siclog "Step 1" siclog@
      v_CellPowerList := {
          cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellH, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      // The UE transmits a TRACKING AREA UPDATE REQUEST on CellH
      //@siclog "Step 2" siclog@
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellH,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cdr_TAU_Request_OldGutiPTMSISig(
                                                                                       v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti_Params_G), //GUTI-7
                                                                                       v_PTMSISignature)));


     //@siclog "Step 3" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = "PLMN not allowed"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellH,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_PLMN_NotAllowed))));

      // The SS releases the RRC connection
      //@siclog "Step 4" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellH, v_RRC_TI, other);

      //  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell H?
      //@siclog "Step 5" siclog@
      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellH, f_EUTRA_SetTimerToleranceMax( eutra_CellH, 30.0 ));

      // The UE is switched off.
      //@siclog "Step 6" siclog@
      f_UT_SwitchOffUE (UT, false);

      //@siclog "Step 7" siclog@
      // The SS configures: Cell H as the "Non-Suitable cell". Cell G as a "Serving cell"
      // Note: Cell G and H are in the same PLMN
      v_CellPowerList := {
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
      };
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      //  The UE is switched on.
      //@siclog "Step 8" siclog@
      f_UT_SwitchOnUE (UT, false);

      //  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G?
      //@siclog "Step 9" siclog@
      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellG, f_EUTRA_SetTimerToleranceMax( eutra_CellG, 30.0 ));

      //  The user initiates an attach by MMI or by AT command
      //@siclog "Step 10" siclog@
      f_UT_TriggerAttach(UT);

      // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G?
      //@siclog "Step 11" siclog@

      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellG, f_EUTRA_SetTimerToleranceMax( eutra_CellG, 30.0 ));

      //  Change power level of Cell G, send trigger to other RAT then wait for trigger to be returned
      //@siclog "Step 12" siclog@

      f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        select (v_OtherPTC) {
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }

      // Set power level for Cell I to "Serving cell"
      //@siclog "Step 15" siclog@
      f_EUTRA_SetCellPower ( eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );


      //  Does the UE transmit ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message
      // to request PDN connectivity to the default PDN?
      //@siclog "Step 16" siclog@
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                  v_RRC_TI,
                  cr_EstablishmentCause_Any,
                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                    cdr_ATTACH_REQUEST_WithIMSIAndnoTAI(
                                                                   v_AttachType,
                                                                   v_AdditionalUpdateType,
                                                                   f_Imsi2MobileIdentity(px_IMSI_Def),
                                                                   cr_TMSI_Status('0'B)),
                            cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                            f_GetPdnType())));

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 16");

      v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier;
      if (ispresent(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
           if ( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
               v_EIT_Flag := true;
           }
      }
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;


      //@siclog "Step 17 - 20a2" siclog@
      // The SS starts an authentication procedure
      // The UE responds properly to the authentication procedure
     // The SS starts a NAS security mode command procedure to perform NAS integrity protection.
     // The UE responds properly to the NAS security mode command procedure
      //     -    EXCEPTION: Steps 20a1 to 20a2 describe behaviour that depends on UE configuration.
      //   IF the UE sets the ESM information transfer flag in the last PDN CONNECTIVITY REQUEST message THEN the SS transmits an ESM INFORMATION REQUEST message to initiate exchange of protocol configuration options and/or APN.
      //  The UE transmits an ESM INFORMATION RESPONSE message to transfer protocol configuration options and/or APN.
      v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellI,  v_EIT_Flag, v_EPS_TI);

      //  SS responds with ATTACH ACCEPT message with the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message
      //@siclog "Step 21" siclog@
      f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellI,
                                            tsc_EpsDefaultBearerId,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            tsc_EAttachType_EpsOnly,
                                            f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti_Params_I),
                                            v_TaiList,
                                            omit,
                                            omit,
                                            omit,
                                            v_APN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

      // The UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message.
      //@siclog "Step 22" siclog@
      f_EUTRA_NAS_AttachComplete(eutra_CellI, tsc_EpsDefaultBearerId);

      //  The SS releases the RRC connection
      //@siclog "Step 23" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellI, v_RRC_TI, other);

      //  The UE is switched off.
      //@siclog "Step 24" siclog@
      f_UT_SwitchOffUE (UT, false);

      //@siclog "Step 25" siclog@
      // The UE transmit a DETACH REQUEST.
      f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellI, RRC_IDLE, v_RRC_TI );

      //@siclog "Step 27" siclog@
      f_EUTRA_SetCellPower ( eutra_CellG, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
      f_EUTRA_SetCellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

      //  The UE is switched on or powered up.
      //@siclog "Step 28" siclog@
      f_UT_SwitchOnUE (UT, false);

      // The UE is switched to manual PLMN selection mode and is made to select the forbidden PLMN
      //@siclog "Step 29" siclog@
      f_UT_ManualPLMN_Select (UT, "PLMN2");

      // Does the UE transmit ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message
      //@siclog "Step 30" siclog@
      // to request PDN connectivity to the default PDN?
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                  v_RRC_TI,
                  cr_EstablishmentCause_Any,
                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                            cdr_ATTACH_REQUEST_WithGuti(
                                                        v_AttachType,
                                                        v_AdditionalUpdateType,
                                                        v_SecurityParams.KSIasme,
                                                        f_GutiParameters2MobileIdentity(omit, v_Guti_Params_I),
                                                        cr_TAI(v_PLMN_I, tsc_TAC1)),
                            cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                            f_GetPdnType())));

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 30");

    //@siclog "Step 31 - 42" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false);

    }// end function fl_TC_9_2_3_1_15_Body


  function f_TC_9_2_3_1_16_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Normal tracking area update / rejected / Tracking area not allowed

    /* (1)
    with { UE has sent a TRACKING AREA UPDATE REQUEST message}
    ensure that {
      when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to ''Tracking area not allowed '' }
        then { shall delete any GUTI, last visited registered TAI, TAI list and KSI. The UE shall reset the tracking area updating attempt counter and shall enter the state EMM-DEREGISTERED.LIMITED-SERVICE and store the current TAI in the list of "forbidden tracking areas for regional provision of service" }

    (2)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and has a TAI in the list of "forbidden tracking areas for regional provision of service"}
    ensure that {
      when { UE is in the serving cell which the UE is rejected }
        then { UE does not attempt an attach procedure on any other cell}
                }
    (3)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the current TAI in the list of "forbidden tracking areas for regional provision of service"}
    ensure that {
      when { UE entess a new cell in the same TAI it was rejected }
        then { UE does not initiate an attach procedure}
                }
    (4)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the current TAI in the list of "forbidden tracking areas for regional provision of service"}
    ensure that {
      when { UE enters a new cell with defferent TAI without in the list of "forbidden tracking areas for regional provision of service"}
        then { UE initiates attach procedure with IMSI }
                }
    (5)
    with { UE is switched off }
    ensure that {
      when { UE is powered on and enters the cell with "forbidden tracking areas for regional provision of service" before the UE was swithed off }
        then { UE initiates attach procedure on the cell }
    */

    // Pre-test conditions
    // -------------------
    /* System Simulator:
    -   Cell A, Cell B, Cell G, Cell H and Cell M are configured according to Table 6.3.2.2-1 in [18].
    -   Cell A and Cell M belong to TAI-1(home PLMN, same TAC) and are set to ''Non Suitable cell''
    -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Serving cell''
    -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Non-Suitable cell''
    -   Cell H belongs to TAI-8(visited PLMN) and is set to ''Non-Suitable cell''
    UE:
    -   The UE is configured to initiate EPS attach.
    -   The UE has GUTI-2.
    -   The UE is registered on TAI-2.
    Preamble:
    -   UE is in state Registered, Idle Mode (state 2) on Cell B according to [18].
    */

    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN ,LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellB);
    f_EUTRA_CellConfig_Def( eutra_CellA );
    f_EUTRA_CellConfig_Def( eutra_CellG );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellH );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellM );

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellH, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellM, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );

    f_UT_ConfigureEPSAttach (UT); // R5-103811

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellB, STATE2_IDLEUPDATE);
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_1_16_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E4_DEREGISTERED);
  } // function f_TC_9_2_3_1_16_EUTRA

  function fl_TC_9_2_3_1_16_Body() runs on EUTRA_PTC
  {
    const EPS_BearerIdentity tsc_EpsBearerId := '5'H;
    const ReleaseCause tsc_RrcReleaseCause := other;
    var ProcedureTransactionIdentifier v_EPS_TI  := '01'O;
    var template (omit) AccessPointName v_APN := omit;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;

    // ==========================================================================
    // initialize component specific data structures
    // ==========================================================================
    // get all data which are required for a GUTI
    var GutiParameters_Type v_Guti7_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellG);

    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var boolean v_EIT_Flag := false;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;

    var NAS_PlmnId v_PLMN_CellG := f_Asn2Nas_PlmnId (v_Guti7_Params.PLMN_Identity);
    var TrackingAreaCode v_Tac_CellG := f_EUTRA_CellInfo_GetTAC ( eutra_CellG );
    var NAS_Lac  v_LAC_CellG   := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellG);
    var template (value) TrackingAreaIdList v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN_CellG, { bit2oct( v_Tac_CellG ) } );
    // temporary dummy variable which gets used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    var ProtocolConfigOptions v_Pco;
    var boolean v_IPallocationViaNasFlag;
    var SRB_COMMON_IND v_ReceivedAsp;
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template PTMSI_Signature v_PTMSISignature := omit;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    timer t_Wait := f_EUTRA_SetTimerToleranceMax (eutra_CellG, 30.0 );
 
    if (pc_UTRA or pc_GERAN) {
      v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
    }
 
    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell A to the ''Serving cell''.Set the cell type of cell B to the ''Non-Suitable cell''.
    //    Set the cell type of cell G to the ''Suitable neighbour cell''. Set the cell type of cell H to the ''Suitable neighbour cell''.
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellG, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellH, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now );


    //@siclog "Step 2" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE REQUEST on Cell A.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGutiPTMSISig(v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti7_Params),
                                                                                       v_PTMSISignature)));

    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 3" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = ''Tracking area not allowed'' as specified.
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_TA_NotAllowed ))));

    //@siclog "Step 4" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, tsc_RrcReleaseCause);

    //@siclog "Step 5" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G and H? (2,F)
    f_EUTRA_CheckNoAttachOn2Cells ( eutra_CellG, eutra_CellH, 30.0);

    //@siclog "Step 6" siclog@
    //+  The user initiates an attach by MMI or by AT command.
    f_UT_TriggerAttach(UT);

    //@siclog "Step 7" siclog@
    //+   Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell A? (1,F)
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellA, 30.0);

    //@siclog "Step 8" siclog@
    //+ Set the cell type of cell A to the '' Non-Suitable cell ''. Set the cell type of cell M to the ''Serving cell''.
    f_EUTRA_SetCellPower ( eutra_CellM, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );

    //@siclog "Step 9" siclog@
    //+   Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell M? (3,F)
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellM, 30.0);

    //@siclog "Step 10" siclog@
    //+   Set the cell type of cell G to the ''Serving cell''. Set the cell type of cell M to the ''Non-Suitable cell ''
    f_EUTRA_SetCellPower ( eutra_CellG, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellM, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );

    //@siclog "Step 11" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G?[4 P]
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellG,
                                    cr_RRCConnectionRequest(cr_EstablishmentCause_Any)))
         {
             t_Wait.stop;
             f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellG, cs_TimingInfo_Now, tsc_RRC_TI_Def);
             SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellG,
                                            cr_508_RRCConnectionSetupComplete(tsc_RRC_TI_Def, ?),
                                            cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                              cdr_ATTACH_REQUEST_WithOldMobileIdNoTAI(
                                                                                v_AttachType,
                                                                                v_AdditionalUpdateType,
                                                                                f_Imsi2MobileIdentity(px_IMSI_Def)))))
             -> value v_ReceivedAsp;

             f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 11");
         }
      [] t_Wait.timeout
        {
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "step 11");
        }
    }
    v_EPS_TI := v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses
    if (ispresent(v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
      if ( v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
        v_EIT_Flag := true;
      }
    }
    v_Pco := v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;

    
    //@siclog "Step 12 - 15" siclog@
    //+  The SS starts an authentication procedure
    //+  The UE responds properly to the authentication procedure
    //+  The SS starts a NAS security mode command procedure to perform NAS integrity protection.
    //+   The UE responds properly to the NAS security mode command procedure
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellG,  v_EIT_Flag, v_EPS_TI);

    //@siclog "Step 16" siclog@
    //+  The SS sends ATTACH ACCEPT message with the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message.
    v_IPallocationViaNasFlag :=  f_CheckPCOforIPallocationViaNas (v_Pco); // See TS 36.508 v.8.2.2 Table 4.7.3-6
    f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellG,
                                            tsc_EpsBearerId,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            tsc_EAttachType_EpsOnly,
                                            f_GetPDNAddress(v_IPallocationViaNasFlag),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti7_Params),
                                            v_TaiList,
                                            omit,
                                            omit,
                                            omit,
                                            v_APN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

    //@siclog "Step 17" siclog@
  //+   The UE transmits an ATTACH COMPLETE message.
    f_EUTRA_NAS_AttachComplete(eutra_CellG, tsc_EpsBearerId);

    //@siclog "Step 18" siclog@
    //+ The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellG, tsc_RRC_TI_Def, tsc_RrcReleaseCause);

    //@siclog "Step 19" siclog@
    //+  The UE is switched off.
    //@siclog "Step 20" siclog@
    //+  The UE transmit a DETACH REQUEST.
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellG, RRC_IDLE, tsc_RRC_TI_Def );

    ///@siclog "Step 21" siclog@
    //+ The following messages are sent and shall be received on cell A.
    //@siclog "Step 22" siclog@
    //+  Set the cell type of cell A to the '' Serving cell''. Set the cell type of cell G to the '' Non-Suitable cell''.
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );

    //@siclog "Step 23" siclog@
    //+   The UE is powered up or switched on.
    f_UT_SwitchOnUE (UT, false);

    //@siclog "Step 24" siclog@
    //  The UE transmits ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message to request PDN connectivity to the default PDN. (5,P)
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                  tsc_RRC_TI_Def,
                  cr_EstablishmentCause_Any,
                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                            cdr_ATTACH_REQUEST_WithGuti(
                                                        v_AttachType,
                                                        v_AdditionalUpdateType,
                                                        v_SecurityParams.KSIasme,
                                                        f_GutiParameters2MobileIdentity(omit, v_Guti7_Params),
                                                        cr_TAI( v_PLMN_CellG, v_LAC_CellG)),
                            cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                            f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 24");

    //@siclog "Step 25" siclog@
    //  The SS sends ATTACH REJECT message.
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                       cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_TA_NotAllowed),
                                                                             omit))));
    //@siclog "Step 26" siclog@
    //  The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, tsc_RrcReleaseCause);
  } // function fl_TC_9_2_3_1_16_Body



function f_TC_9_2_3_1_17_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Rejected / Roaming not allowed in this tracking area
     /* Test Purpose (TP)
        (1)
        with { the UE has sent TRACKING AREA UPDATE REQUEST message }
        ensure that {
          when { the UE receives TRACKING AREA UPDATE REJECT message with the reject cause set to "roaming not allowed in this tracking area" }
            then { the UE sets the EPS update status to EU3 ROAMING NOT ALLOWED and the UE deletes the last visited registered TAI and the UE enters the state EMM-REGISTERED.PLMN-SEARCH and the UE stores the current TAI in the list of "forbidden tracking areas for roaming" }
                    }
        (2)
        with { the UE is in EMM-REGISTERED.PLMN-SEARCH state and the current TAI in the list of "forbidden tracking areas for roaming"}
        ensure that {
          when { the serving cell belongs to TAI where UE was rejected }
            then { the UE does not attempt to send TRACKING AREA UPDATE REQUEST message }
                    }
        (3)
        with { the UE is in EMM-REGISTERED.PLMN-SEARCH state and the TAI of the current cell belongs to the list of "forbidden tracking areas for roaming"}
        ensure that {
          when { the UE enters a cell belonging to same PLMN and TAI not in the list of "forbidden tracking areas for roaming"}
            then { the UE sends TRACKING AREA UPDATE REQUEST message }
                    }
        (4)
        with { the UE is in EMM-REGISTERED.PLMN-SEARCH state and the TAI of the current cell belongs to the list of "forbidden tracking areas for roaming"}
        ensure that {
          when { the UE enters a cell belonging to another PLMN }
            then { the UE sends TRACKING AREA UPDATE REQUEST message }
                    }

        (5)
        with { the UE, which A/Gb mode or Iu mode is supported by the UE, in EMM-DEREGISTERED.PLMN-SEARCH state and the list of "forbidden tracking areas for roaming" contains more than one TAI }
        ensure that {
          when { the UE move to UTRAN or GERAN cell }
            then { the UE sends ROUTING AREA UPDATE REQUEST message }
        }

        System Simulator:
            -   Cell G, Cell H and Cell I are configured according to Table 6.3.2.2-1 in [18].
            -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Serving cell''
            -   Cell H belongs to TAI-8(visited PLMN, another TAC) and is set to ''Non- Suitable cell''
            -   Cell I belongs to TAI-9(visited PLMN, another PLMN) and is set to ''Non-Suitable cell''
            -   PLMN in Cell G, Cell H and Cell I are not HPLMN of the UE.
            -   If pc_UTRAN, Cell 5;
            -   If NOT pc_UTRAN and pc_GERAN, Cell 24.
            - Cell 5 and Cell 24 belong to RAI-8 (visited PLMN) as specified TS34.123-1 clause 12 and is set to ''Non- Suitable cell''
            -   System information indicate that NMO 1 is used
        UE:
            -   The UE is configured to initiate EPS attach.
        Preamble:
            -   UE is in state Registered, Idle Mode (state 2) on Cell G according to [18]
     */

       var charstring v_OtherPTC := "";
       var template (value) CellPowerList_Type v_CellPowerList;

        if (pc_UTRA) {
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UTRANCell);
          v_OtherPTC := "UTRAN";
        } else if (pc_GERAN) {
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_GERANcell);
          v_OtherPTC := "GERAN";
        } else { // Neither UMTS, nor GSM, so just do LTE
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
          v_OtherPTC := "NONE";
        }

        f_UT_ConfigureEPSAttach (UT); // R5-103811

        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellG);
        f_EUTRA_CellConfig_Def(eutra_CellH);
        f_EUTRA_CellConfig_Def(eutra_CellI);

        if (pc_UTRA) {
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
        } else if (pc_GERAN) {
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
        } else { // supports neither UTRAN or GERAN
            f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        }

        v_CellPowerList := {
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
        select (v_OtherPTC) { // send trigger to other RAT to change its power level too
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
          } case else {} // Do nothing
        }
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_17_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);

        f_EUTRA_Postamble(eutra_CellI, E2_CONNECTED);
    } // end f_TC_9_2_3_1_17_EUTRA


    function fl_TC_9_2_3_1_17_Body() runs on EUTRA_PTC
    {
      var boolean v_TriggerRxd := false;
      var SRB_COMMON_IND v_ReceivedAsp;
      var charstring v_OtherPTC := "";

      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_MSG_Indication_Type v_NasInd;
      var EPS_BearerContextStatus v_EPS_ContextStatus;

      var GutiParameters_Type v_Guti_Params_G := f_EUTRA_CellInfo_GetGuti(eutra_CellG);
      var GutiParameters_Type v_Guti_Params_I := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
      var NAS_PlmnId v_PLMN_I := f_Asn2Nas_PlmnId(v_Guti_Params_I.PLMN_Identity);
      var TrackingAreaCode v_Tac_CellI := f_EUTRA_CellInfo_GetTAC ( eutra_CellI );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellI );
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN_I, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
      var template (value) TrackingAreaIdList v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN_I, { bit2oct( v_Tac_CellI ) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var template PTMSI_Signature v_PTMSISignature := omit;
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

      timer t_WaitTimer := f_EUTRA_SetTimerToleranceMin( eutra_CellH, 30.0 );
      

      if (pc_UTRA or pc_GERAN) {
         v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
      }

      if (pc_UTRA) {
         v_OtherPTC := "UTRAN";
       } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
       } else { // Neither UMTS, nor GSM, so just do LTE
         v_OtherPTC := "NONE";
      }

      //@siclog "Step 1" siclog@
      v_CellPowerList := {
          cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellH, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      //The UE transmits a TRACKING AREA UPDATE REQUEST on CellH
      //@siclog "Step 2" siclog@
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellH,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cdr_TAU_Request_OldGutiPTMSISig(
                                                                                       v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti_Params_G), //GUTI-7
                                                                                       v_PTMSISignature)));

      //@siclog "Step 3" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = "Roaming not allowed in this TA"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellH,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_roaming_NotAllowed))));

      // The SS releases the RRC connection
      //@siclog "Step 4" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellH, v_RRC_TI, other);

      //@siclog "Step 5" siclog@
      // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 30 seconds on CellH? (F)
      t_WaitTimer.start;
      alt {
          []  SRB.receive(car_SRB1_NasPdu_IND(eutra_CellH,
                                              cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                              cr_508_TAU_Request(v_UpdateType,
                                                                 f_EUTRA_SecurityKSIasme_Get(),
                                                                 v_AdditionalUpdateType))))
                {
                    t_WaitTimer.stop;
                    f_EUTRA_SetVerdictFailOrInconc (__FILE__, __LINE__, "Step 5");
                }
          []  t_WaitTimer.timeout
          {
          }
      }
 
      //@siclog "Step 6" siclog@
      // The SS configures: Turn Cell H to "Non-Suitable cell" and Cell G to "Serving cell"
      // Note: Cell G and H are in the same PLMN
      v_CellPowerList := {
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
      };
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      //@siclog "Step 7" siclog@
      // Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 30 seconds on cellG? (P)
      t_WaitTimer.start(f_EUTRA_SetTimerToleranceMin( eutra_CellG, 30.0 ));
      alt {
          []  SRB.receive(car_SRB1_NasPdu_IND(eutra_CellG,
                                              cr_NAS_Indication( tsc_SHT_IntegrityProtected_Ciphered,
                                                                  cdr_TAU_Request_OldGutiPTMSISig(
                                                                                       v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti_Params_G), //GUTI-7
                                                                                       v_PTMSISignature))))
                        -> value v_ReceivedAsp
            {
                t_WaitTimer.stop;
                f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 7")
            }
          []  t_WaitTimer.timeout
          {
          }
       }

      //@siclog "Step 8" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = "Roaming not allowed in this TA"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellG,
                                  cs_TimingInfo_Now,
                                  cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                 cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_roaming_NotAllowed)
                                                 )));


      //  The SS releases the RRC connection
      //@siclog "Step 9" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellG, v_RRC_TI, other);

      //  Change power level of Cell G, send trigger to other RAT then wait for trigger to be returned
      //@siclog "Step 10" siclog@
      f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        select (v_OtherPTC) {
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }


      //  Set power level for Cell I to "Serving cell"
      //@siclog "Step 12" siclog@
      f_EUTRA_SetCellPower ( eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );


      //@siclog "Step 13" siclog@
      // Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 30 seconds on cellI? (P)
      t_WaitTimer.start;
      alt {
          []  SRB.receive(car_SRB1_NasPdu_IND(eutra_CellI,
                                              cr_NAS_Indication( tsc_SHT_IntegrityProtected_Ciphered,
                                                                  cdr_TAU_Request_OldGutiPTMSISig(
                                                                                       v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti_Params_G), //GUTI-7
                                                                                       v_PTMSISignature))))
                        -> value v_ReceivedAsp
            {
                t_WaitTimer.stop;
                f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 13")
            }
          []  t_WaitTimer.timeout
          {
          }
       }

      //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
      //@siclog "Step 14" siclog@
      v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellI,
                                       cs_TimingInfo_Now,
                                       cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                        cs_508_TAU_Accept ( v_UpdateType,
                                                                          f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti_Params_I ),
                                                                          v_TaiList,
                                                                          v_EPS_ContextStatus,
                                                                          v_LAI,
                                                                          v_MSId,
                                                                          f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));


      // The UE transmits a TRACKING AREA UPDATE COMPLETE message.
      //@siclog "Step 15" siclog@
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellI,
                                          cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_TAU_Complete ) ) );
 
    }// end function fl_TC_9_2_3_1_17_Body


    function f_TC_9_2_3_1_18_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Rejected / EPS services not allowed in this PLMN
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the reject cause set to 'EPS services not allowed in this PLMN' }
            then { UE deletes the GUTI, the last visited registered TAI and KSI and UE deletes the list of equivalent PLMNs and UE enters state EMM-DEREGISTERED.PLMN-SEARCH and UE stores the PLMN in the "forbidden PLMNs for GPRS service" }

        (2)
        with { UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state and a PLMN is stored in the "forbidden PLMNs for GPRS service" }
        ensure that {
          when { UE enters a cell which is in the "forbidden PLMNs for GPRS service" }
            then { UE doesn't perform an attach procedure }
                    }
        (3)
        with { UE in EMM-DEREGISTERED.PLMN-SEARCH state and a PLMN is stored in the "forbidden PLMNs for GPRS service" }
        ensure that {
          when { UE enters a cell which is not in the "forbidden PLMNs for GPRS service" }
            then { UE initiates an attach procedure }
                    }
        (4)
        with { UE is switched off and a PLMN is stored in the 'forbidden PLMNs for GPRS service' }
        ensure that {
          when { UE is power ON in a cell with forbidden PLMNs for GPRS service }
            then { UE initiates an attach procedure }


        System Simulator:
            -   Cell G, Cell H and Cell I are configured according to Table 6.3.2.2-1 in [18].
            -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Serving cell''
            -   Cell H belongs to TAI-8(visited PLMN, another TAC) and is set to ''Non- Suitable cell''
            -   Cell I belongs to TAI-9(visited PLMN, another PLMN) and is set to ''Non-Suitable cell''
            -   PLMN in Cell G, Cell H and Cell I are not HPLMN of the UE.
            -   If pc_UTRAN, Cell 5;
            -   If NOT pc_UTRAN and pc_GERAN, Cell 24.
            -    Cell 5 and Cell 24 belong to RAI-8 (visited PLMN) as specified TS34.123-1 clause 12 and is set to ''Non- Suitable cell''
            -   System information indicate that NMO 1 is used

        UE:
            -   The UE is configured to initiate EPS attach.

        Preamble:
            -   UE is in state Registered, Idle Mode (state 2) on Cell G according to [18]
     */

       var charstring v_OtherPTC := "";
       var template (value) CellPowerList_Type v_CellPowerList;

        if (pc_UTRA) {
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UTRANCell);
          v_OtherPTC := "UTRAN";
        } else if (pc_GERAN) {
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_GERANcell);
           v_OtherPTC := "GERAN";
        } else { // Neither UMTS, nor GSM, so just do LTE
          f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
          v_OtherPTC := "NONE";
        }

        f_UT_ConfigureEPSAttach (UT); // R5-103811
        
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellG);
        f_EUTRA_CellConfig_Def(eutra_CellH);
        f_EUTRA_CellConfig_Def(eutra_CellI);

        if (pc_UTRA) {
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
        } else if (pc_GERAN) {
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
        } else { // supports neither UTRAN or GERAN
            f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        }

        v_CellPowerList := {
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        select (v_OtherPTC) { // send trigger to other RAT to change its power level too
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
          } case else {} // Do nothing
        }
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_18_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);

        // Remove cells
        f_EUTRA_Postamble(eutra_CellG, E2_CONNECTED);

    } // end f_TC_9_2_3_1_18_EUTRA


    function fl_TC_9_2_3_1_18_Body() runs on EUTRA_PTC
    {
      var boolean v_TriggerRxd := false;
      //var O10_Type v_GutiStringFromOtherRAT;
      //var IRAT_CoOrd_Auth_Type v_CoOrd_AuthParams;
      var charstring v_OtherPTC := "";

      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_MSG_Indication_Type v_NasInd;
      var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
      var boolean v_EIT_Flag := false;
      var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
      var template (omit) AccessPointName v_APN := omit;
      var template (omit) ProtocolConfigOptions v_Pco := omit;
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      var GutiParameters_Type v_Guti_Params_G := f_EUTRA_CellInfo_GetGuti(eutra_CellG);
      var GutiParameters_Type v_Guti_Params_I := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
      var NAS_PlmnId v_PLMN_I := f_Asn2Nas_PlmnId(v_Guti_Params_I.PLMN_Identity);
      var TrackingAreaCode v_Tac_CellI := f_EUTRA_CellInfo_GetTAC ( eutra_CellI );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var template (value) TrackingAreaIdList v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN_I, { bit2oct( v_Tac_CellI ) } );
      var template PTMSI_Signature v_PTMSISignature := omit;

      if (pc_UTRA or pc_GERAN) {
         v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
      }

      if (pc_UTRA) {
         v_OtherPTC := "UTRAN";
       } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
       } else { // Neither UMTS, nor GSM, so just do LTE
         v_OtherPTC := "NONE";
      }

      //@siclog "Step 1" siclog@
      // Set the cell type of cell G to the "Non-Suitable cell"
      // Set the cell type of cell H to the "Serving cell".
      v_CellPowerList := {
         cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellH, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //  The UE transmits a TRACKING AREA UPDATE REQUEST on CellH
      //@siclog "Step 2" siclog@
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellH,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGutiPTMSISig(
                                                                                       v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti_Params_G), //GUTI-7
                                                                                       v_PTMSISignature)));

      //@siclog "Step 3" siclog@
      //The SS transmits a TRACKING AREA UPDATE REJECT message, EMM cause = "EPS services not allowed in this PLMN"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellH,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_EPSServNotAllowedInThisPLMN))));

      // The SS releases the RRC connection
      //@siclog "Step 4" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellH, v_RRC_TI, other);

      //  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell H?
      //@siclog "Step 5" siclog@
      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellH, f_EUTRA_SetTimerToleranceMax( eutra_CellH, 30.0 ));

      //@siclog "Step 6" siclog@
      // The SS configures: Cell H as the "Non-Suitable cell". Cell G as a "Serving cell"
      // Note: Cell G and H are in the same PLMN
      v_CellPowerList := {
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
      };
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      //  The user initiates an attach by MMI or by AT command
      //@siclog "Step 7" siclog@
      f_UT_TriggerAttach(UT);

      //  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G?
      //@siclog "Step 8" siclog@
      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellG, f_EUTRA_SetTimerToleranceMax( eutra_CellG, 30.0 ));

      //  Change power level of Cell G, send trigger to other RAT then wait for trigger to be returned
      //@siclog "Step 9" siclog@
      f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        select (v_OtherPTC) {
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }

      //  Set power level for Cell I to "Serving cell"
      //@siclog "Step 11" siclog@
      f_EUTRA_SetCellPower ( eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );


      //  Does the UE transmit ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message
      // to request PDN connectivity to the default PDN?
      //@siclog "Step 12" siclog@
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                  v_RRC_TI,
                  cr_EstablishmentCause_Any,
                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                    cdr_ATTACH_REQUEST_WithIMSIAndnoTAI(
                                                                   v_AttachType,
                                                                   v_AdditionalUpdateType,
                                                                   f_Imsi2MobileIdentity( px_IMSI_Def ),
                                                                   cr_TMSI_Status('0'B)),
                            cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                            f_GetPdnType())));

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 12");

      v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier;
      if (ispresent(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
           if ( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
               v_EIT_Flag := true;
           }
      }
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;


      //@siclog "Step 13 - 17a2" siclog@
      // The SS starts an authentication procedure
      // The UE responds properly to the authentication procedure
      // The SS starts a NAS security mode command procedure to perform NAS integrity protection.
      // The UE responds properly to the NAS security mode command procedure
      //     -    EXCEPTION: Steps 17a1 to 17a2 describe behaviour that depends on UE configuration.
      //   IF the UE sets the ESM information transfer flag in the last PDN CONNECTIVITY REQUEST
      //             message THEN the SS transmits an ESM INFORMATION REQUEST message to initiate exchange
      //             of protocol configuration options and/or APN.
      //   The UE transmits an ESM INFORMATION RESPONSE message to transfer protocol configuration
      //             options and/or APN.
      v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellI,  v_EIT_Flag, v_EPS_TI);

      //  The SS sends ATTACH ACCEPT message with the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message.
      //@siclog "Step 18" siclog@
      f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellI,
                                            tsc_EpsDefaultBearerId,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            tsc_EAttachType_EpsOnly,
                                            f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti_Params_I),
                                            v_TaiList,
                                            omit,
                                            omit,
                                            omit,
                                            v_APN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

      ///////////////////////////////////////////////////////////////////////////////////////////////////////////
      //  EXCEPTION: In parallel to the event described in step 19 below the generic procedure for IP address  //
      //  allocation in the U-plane specified in TS 36.508 subclause 4.5A.1 takes place performing IP address  //
      //  allocation in the U-plane if requested by the UE.                                                    //
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////

      //  The UE transmit an ATTACH COMPLETE message
      //@siclog "Step 19" siclog@
      f_EUTRA_NAS_AttachComplete(eutra_CellI, tsc_EpsDefaultBearerId);

      // The SS releases the RRC connection
      //@siclog "Step 20" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellI, v_RRC_TI, other);

      //  The UE is switched off.
      //@siclog "Step 21" siclog@
      f_UT_SwitchOffUE (UT, false);

      //@siclog "Step 22" siclog@
      // The UE transmit a DETACH REQUEST.
      f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellI, RRC_IDLE, v_RRC_TI );

      //@siclog "Step 23" siclog@
      // Set the cell type of cell G to the "Serving cell"
      // Set the cell type of cell I to the "Non-Suitable cell"
      // Note: Cell G belongs to the forbidden PLMNs for GPRS service
      f_EUTRA_SetCellPower ( eutra_CellG, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
      f_EUTRA_SetCellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

      //  The UE is powered up or switched on
      //@siclog "Step 24" siclog@
      f_UT_SwitchOnUE (UT, false);

      //  Does the UE send ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message
      // to request PDN connectivity to the default PDN?
      //@siclog "Step 25" siclog@
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                  v_RRC_TI,
                  cr_EstablishmentCause_Any,
                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                            cdr_ATTACH_REQUEST_WithGuti(
                                                        v_AttachType,
                                                        v_AdditionalUpdateType,
                                                        v_SecurityParams.KSIasme,
                                                        f_GutiParameters2MobileIdentity(omit, v_Guti_Params_I),
                                                        cr_TAI(v_PLMN_I, tsc_TAC1)),
                            cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                            f_GetPdnType())));

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 25");

      //@siclog "Step 26 - 37" siclog@
      f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false);
 
    }// end function fl_TC_9_2_3_1_18_Body



    function f_TC_9_2_3_1_19_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Rejected / No suitable cells in tracking Area
     /* Test Purpose (TP)
        (1)
        with { UE is sending a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to
                 'No Suitable Cells In tracking area' }
            then { UE selects a suitable cell in another tracking area in the same PLMN and
                   performs the tracking area updating procedure and UE does not select a suitable cell
                   in another PLMN}
                  }
          }
        }

        System Simulator:
            -   Cell A, Cell B, Cell C and Cell G are configured according to Table 6.3.2.2-1 in [18].
            -   Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
            -   Cell B belongs to TAI-2(home PLMN) and is set to ''Non- Suitable cell''
            -   Cell C belongs to TAI-3(home PLMN) and is set to ''Non- Suitable cell''.
            -   Cell G belongs to TAI-7(visited PLMN) and is set to ''Non- Suitable cell''.

        UE:
            -   The UE is configured to initiate EPS attach.

        Preamble:
            -   The UE is in state Registered, Idle mode (state 2) Cell A according to [18].

     */
        var template (value) CellPowerList_Type v_CellPowerList;
       
        f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellB);
        f_EUTRA_CellConfig_Def(eutra_CellC);
        f_EUTRA_CellConfig_SRBs_Only(eutra_CellG);

        f_UT_ConfigureEPSAttach (UT); // R5-103811

        // Go to state 2
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

        // The SS pre-configures Cell A as the "Serving cell" and Cells B, C and G as "Non-Suitable cell"
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_19_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellC, E2_CONNECTED);
    } // end f_TC_9_2_3_1_19_EUTRA


    function fl_TC_9_2_3_1_19_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NasInd;
      var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti_Params.PLMN_Identity);
      var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
      var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
          
      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Non-Suitable cell"
      // Set the cell type of cell B to the "Serving cell".
      // Set the cell type of cell C to the "Suitable neighbour cell".
      // Set the cell type of cell G to the "Serving cell".
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellC, tsc_SuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
 

      //@siclog "Step 2" siclog@
      // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cr_508_TAU_Request(v_UpdateType,
                                                                                      f_EUTRA_SecurityKSIasme_Get(),
                                                                                      v_AdditionalUpdateType
                                                                                      )));
 
      //@siclog "Step 3" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause set to
      // "No suitable cells in tracking area"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                   cs_TimingInfo_Now,
                                   cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                  cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_NoSuitableCells))));

      //  The SS releases the RRC connection
      //@siclog "Step 4" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);


      //@siclog "Step 5" siclog@
      // Check: Does the UE send TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cdr_TAU_Request_OldGuti(v_UpdateType,
                                                                                           f_EUTRA_SecurityKSIasme_Get(),
                                                                                           v_AdditionalUpdateType,
                                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti_Params),
                                                                                           cr_TAI_Any)));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");
      v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

      // The SS transmits a TRACKING AREA UPDATE ACCEPT message.
      //@siclog "Step 6" siclog@
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellC,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cs_508_TAU_Accept ( v_UpdateType,
                                                                          f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti_Params ),
                                                                          v_TaiList,
                                                                          v_EpsBearerCtxtStatus,
                                                                          v_LAI,
                                                                          v_MSId,
                                                                          f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

      //The UE transmits a TRACKING AREA UPDATE COMPLETE message.
      //@siclog "Step 7" siclog@
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellC,
                                          cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_TAU_Complete ) ) );
 
    }// end function fl_TC_9_2_3_1_19_Body


   function f_TC_9_2_3_1_23_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Abnormal case / Success after several attempts due to no network response
     //       / TA belongs to TAI list and status is UPDATED / TA does not belong to TAI list or status is not UPDATED
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Periodic updating'
        and has the tracking area updating attempt counter set to the value less than four, the TAI of the current
        serving cell is included in the TAI list and the update status is equal to EU1 UPDATED }
        ensure that {
          when { UE detects release of the NAS signalling connection }
            then { UE keeps the update status to EU1 UPDATED, enters state EMM-REGISTERED.NORMAL-SERVICE and starts
            timer T3411 }
            }

        (2)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Periodic updating',
        has the tracking area updating attempt counter set to the value less than four, has detected T3430 expiry,
        the TAI of the current serving cell is included in the TAI list and the update status is equal to EU1 UPDATED }
        ensure that {
          when { UE detects T3411 expiry }
            then { UE initiates the tracking area updating procedure }
                    }

        (3)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'TA updating' and has
        the tracking area updating attempt counter set to the value less than four and the TAI of the current
        serving cell is not included in the TAI list or the update status is different to EU1 UPDATED }
        ensure that {
          when { UE detects release of the NAS signalling connection }
            then { UE starts timer T3411, sets the update status to EU2 NOT UPDATED and changes to state EMM-REGISTERED.ATTEMPTING-TO-UPDATE }
                    }

        (4)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'TA updating',
        has the tracking area updating attempt counter set to the value less than four, has detected T3430 expiry
        and the TAI of the current serving cell is not included in the TAI list or the update status is different
        to EU1 UPDATED }
        ensure that {
          when { UE detects T3411 expiry }
            then { UE initiates the tracking area updating procedure }
            }


        System Simulator:
            -   Cell A and Cell B

        UE:
            None

        Preamble:
            -   The UE is in state Switched OFF (state 1) according to [18]
       */

        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellB);

        // Go to state 2 and then switch off
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_23_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);

    } // end f_TC_9_2_3_1_23_EUTRA


    function fl_TC_9_2_3_1_23_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NasInd;
      var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var GutiParameters_Type v_GutiParams_B := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var HalfOctet_Type v_EpsBearerId := tsc_EpsDefaultBearerId;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
      var template (omit) ProtocolConfigOptions v_Pco := omit;
      var boolean v_EIT_Flag := false;
      var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
      var template (omit) AccessPointName v_APN := omit;
      var boolean v_IPallocationViaNasFlag;
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
      var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();

      var float v_T3412 := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 360.0 );
      var float v_T3411A :=  f_EUTRA_SetTimerToleranceMax( eutra_CellA, 10.0 );
      var float v_T3411B :=  f_EUTRA_SetTimerToleranceMax( eutra_CellB, 10.0 );

      timer t_T3411A := v_T3411A;
      timer t_T3411B := v_T3411B;
      timer t_Wait := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 5.0 );

      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Serving cell".
      // Set the cell type of cell B to the "Suitable neighbour intra-frequency cell"
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_Suitable_NeighbourIntraFreq_CellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //  The UE is powered on or switched on.
      //@siclog "Step 2" siclog@
      f_UT_SwitchOnUE (UT, false);

      //  The UE transmits an ATTACH REQUEST message in cell A.
      //         The PDN CONNECTIVITY REQUEST message is piggybacked in ATTACH REQUEST message.
      //@siclog "Step 3" siclog@
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                          cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                          cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                          f_GetPdnType())));


      v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier;

      if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
        v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
      }

      //@siclog "Step 4 - 8Aa2" siclog@
      //  The SS transmits an AUTHENTICATION REQUEST message to initiate the EPS authentication and AKA procedure.
      //  The UE transmits an AUTHENTICATION RESPONSE message and establishes mutual authentication.
      //  The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS security.
      //  The UE transmits a NAS SECURITY MODE COMPLETE message and establishes the initial security configuration.
      //  ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
      // IF the UE sets the ESM information transfer flag in the last PDN CONNECTIVITY REQUEST message THEN the SS transmits an ESM INFORMATION
      // REQUEST message to initiate exchange of protocol configuration options and/or APN.
      // The UE transmits an ESM INFORMATION RESPONSE message to transfer protocol configuration options and/or APN.
      if (ispresent(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
        if ( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
          v_EIT_Flag := true;
        }
      }
      v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA, v_EIT_Flag, v_EPS_TI);
  

      // The SS activates UE radio bearer test mode.
      //@siclog "Step 8a" siclog@
      f_EUTRA_Activate_TestMode (eutra_CellA, tsc_UE_TestLoopMode_TypeB);

      //@siclog "Step 9" siclog@
      // The SS responds with an ATTACH ACCEPT message with the T3412 value indicating 6 min.
      // The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message
      v_IPallocationViaNasFlag :=  f_CheckPCOforIPallocationViaNas (v_Pco);
    if (not isvalue(v_APN)) {
      v_APN := cs_AccessPointName (px_AccessPointName);
    }

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                     v_RRC_TI,
                         cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                        cds_ATTACH_ACCEPT_T3412(tsc_EAttachType_EpsOnly,
                                                                             cs_TrackingAreaIdListDef_lv,
                                                                             f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams),
                                                                             omit,
                                                                             omit,
                                                                             omit,
                                                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType), // @sic R5-103681 sic@,
                                                                             cs_GprsTimer_v(tsc_GprsTimerUnit_6min, '00001'B)),
                                                        cs_508_ActivateDefEpsBearerContextRequest(v_EpsBearerId,
                                                                                                  v_EPS_TI,
                                                                                                  v_APN,
                                                                                                  f_GetPDNAddress(v_IPallocationViaNasFlag),
                                                                                                  omit,
                                                                                                  omit,
                                                                                                  f_GetDefPCOforPCSCFAddress (v_Pco))));

     //@siclog "Step 10" siclog@
     //    The UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message
     //    NOTE 1: The tracking area updating attempt counter is reset.
     f_EUTRA_NAS_AttachComplete(eutra_CellA, v_EpsBearerId);


     //  The SS releases the RRC connection
     //@siclog "Step 11" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);


     //  Wait for 6 min to ensure that T3412 expires
     //@siclog "Step 12" siclog@
     f_Delay(v_T3412);


     //@siclog "Step 13" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'Periodic updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));
     t_T3411A.start;

     // The SS releases the RRC connection.
     //          NOTE: The tracking area updating attempt counter is 1.
     //@siclog "Step 14" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);


     //@siclog "Step 15" siclog@
     // The SS pages the UE using S-TMSI with CN domain indicator set to "PS".
     f_EUTRA_UE_Page(eutra_CellA,
                     cs_NasPaging_OneRecord(cs_PagingUE_Identity_S_TMSI(v_GutiParams.MME_Code,
                                                                        v_GutiParams.M_TMSI)));

     //@siclog "Step 16" siclog@
     // Check: Does the UE transmit a SERVICE REQUEST message?
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_mt_Access,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(v_SecurityParams.KSIasme)));


     //@siclog "Step 17" siclog@
     // The SS transmits a SERVICE REJECT message with EMM cause set to "Congestion".
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                          cs_508_SERVICE_REJECT ( tsc_Cause_Congestion ) ) ) );

     //  The SS releases the RRC connection
     //@siclog "Step 18" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);


     //  Wait for 10s after step 14 to ensure that T3411 expires.
     //@siclog "Step 19" siclog@
     t_T3411A.timeout;

     //@siclog "Step 20" siclog@
     // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'Periodic updating'?
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));
     

     v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
     //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     // NOTE: The tracking area updating attempt counter is reset.
     //@siclog "Step 21" siclog@
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_TAU_AcceptWithoutGuti ( v_UpdateType,
                                                                                  v_TaiList,
                                                                                  v_EpsBearerCtxtStatus,
                                                                                  v_LAI,
                                                                                  v_MSId) ) ) );


     //  The SS releases the RRC connection.
     //@siclog "Step 22" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);

     //  Generic test procedure in TS 36.508 subclause 4.5.3A.3 is performed.
     // NOTE: The UE performs the establishment of the new data radio bearer associated with
     // the default EPS bearer context
     //@siclog "Step 22A" siclog@
     f_EUTRA_RbEst_Def ( eutra_CellA );

     //  Generic test procedure in TS 36.508 subclause 4.5.4.3 is performed.
     // NOTE: The UE enters the UE test loop mode
     //f_EUTRA_508Loopback_Activation_Procedure_ModeB  (eutra_CellA, '01'O);
     //@siclog "Step 22B" siclog@
     f_EUTRA_CloseUE_TestLoopModeB(eutra_CellA, '01'O);

     //  The SS transmits one IP packet to the UE on the DRB associated with
     // the default EPS bearer context.
     //@siclog "Step 22C" siclog@
     DRB.send ( cas_DRB_COMMON_REQ_PDCP_SDU( eutra_CellA,
                                             tsc_RbId_DRB1,
                                             cs_TimingInfo_Now,
                                            { crs_IPv4_AnyIcmpEchoReply_1 ( px_IPv4_Address,
                                                                            px_IPv4_Address )}));

     //  Wait for 1 s after the IP packet has been transmitted in step 22C. (Note 1)
     //@siclog "Step 22D" siclog@
     f_Delay ( 1.0 );

     //  The SS releases the RRC connection.
     //@siclog "Step 22E" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);


     //@siclog "Step 23" siclog@
     // Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
     v_CellPowerList := {
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE )
     }
     f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


     //  The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'.
     //@siclog "Step 24" siclog@
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));



     //Wait for 15s after step 24 to ensure that IP PDU delay timer expires.
     //@siclog "Step 24A" siclog@
     f_Delay ( f_EUTRA_SetTimerToleranceMax( eutra_CellB, 15.0 ) );

     //  The SS releases the RRC connection.
     //          NOTE: The tracking area updating attempt counter is 1.
     //@siclog "Step 25" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, other);
     t_T3411B.start;

     //@siclog "Step 26 Void" siclog@

     //  Check: Does the UE transmit a SERVICE REQUEST message within 5s?
     //@siclog "Step 27" siclog@
     t_Wait.start;
     alt {
     [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA, cr_RRCConnectionRequest(?)))
       { // even though prose says SERVICE REQUEST, as soon as UE sends RRC ConnReq, we know
         // something's wrong
         t_Wait.stop;
         f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 27: Service request received");
       }
     [] t_Wait.timeout
       {
         f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 27");
       }
     }

     //  Wait for 10s after step 25 to ensure that T3411 expires.
     //@siclog "Step 28" siclog@
     t_T3411B.timeout;

     // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'?
     //@siclog "Step 29" siclog@
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_AnyActiveFlag_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     //@siclog "Step 30" siclog@
     v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams_B ),
                                                                           v_TaiList,
                                                                           v_EpsBearerCtxtStatus,
                                                                           v_LAI,
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType))) ) ); // @sic R5-103681 sic@


     //  The UE transmits a TRACKING AREA UPDATE COMPLETE message.
     //          NOTE: The tracking area updating attempt counter is reset.
     //@siclog "Step 31" siclog@
     SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                     cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                       cr_508_TAU_Complete)));


 
    }// end function fl_TC_9_2_3_1_23_Body


    function f_TC_9_2_3_1_25_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Abnormal case / Failure after 5 attempts due to no network response
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message and has the tracking area updating attempt
               counter set to four }
        ensure that {
          when { UE detects release of the NAS signalling connection }
            then { UE starts timer T3402, sets the update status to EU2 NOT UPDATED, changes
                   to state EMM-REGISTERED.ATTEMPTING-TO-UPDATE or optionally to EMM-REGISTERED.PLMN-SEARCH
                   in order to perform a PLMN selection }
        }

        System Simulator:
            -   Cell A, Cell B and Cell G

        UE:
            None

        Preamble:
            -   The UE is in state Switched OFF (state 1) according to [18]
     */

        f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellB);
        f_EUTRA_CellConfig_Def(eutra_CellG);

        // Go to state 2 and then switch off
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_25_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellG, E1_IDLE);

    } // end f_TC_9_2_3_1_25_EUTRA


    function fl_TC_9_2_3_1_25_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NasInd;
      var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var HalfOctet_Type v_EpsBearerId := tsc_EpsDefaultBearerId;
      var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
      var template (omit) ProtocolConfigOptions v_Pco := omit;
      var boolean v_EIT_Flag := false;
      var template (omit) AccessPointName v_APN := omit;
      var boolean v_IPallocationViaNasFlag;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
      var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId (  );
      var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();


      var float v_T3412 := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 360.0 );
      var float v_T3402 := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 720.0 );
      var float v_T30sec := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 30.0 );
          
      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Serving cell".
      // Set the cell type of cell B to the "Non-Suitable cell"
      // Set the cell type of cell G to the "Non-Suitable cell"
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //  The UE is powered up or switched on
      //@siclog "Step 2" siclog@
      f_UT_SwitchOnUE (UT, false);


      //  The UE transmits an ATTACH REQUEST message.
      //         The PDN CONNECTIVITY REQUEST message is piggybacked in ATTACH REQUEST message.
      //@siclog "Step 3" siclog@
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                                  cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                                                  cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                  f_GetPdnType())));

      v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses
      // Get the PCO to be used later (TS 36.508 v.8.2.2 Table 4.7.3-6)
      if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
        v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
      }

      //@siclog "Step 4 - 8Aa2" siclog@
      //  The SS transmits an AUTHENTICATION REQUEST message to initiate the EPS authentication and AKA procedure.
      //  The UE transmits an AUTHENTICATION RESPONSE message and establishes mutual authentication.
      //  The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS security.
      //  The UE transmits a NAS SECURITY MODE COMPLETE message and establishes the initial security configuration.
      // Steps 8Aa1 and 8Aa2 ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
      // IF the UE sets the ESM information transfer flag in the last PDN CONNECTIVITY REQUEST message THEN the SS transmits an ESM INFORMATION
      // REQUEST message to initiate exchange of protocol configuration options and/or APN.
      // The UE transmits an ESM INFORMATION RESPONSE message to transfer protocol configuration options and/or APN.
      if (ispresent(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
        if ( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
          v_EIT_Flag := true;
        }
      }
      v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA, v_EIT_Flag, v_EPS_TI);
  

      //@siclog "Step 9" siclog@
      // SS responds with ATTACH ACCEPT message with GUTI-1 and specific T3412 content.
      // The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message
      v_IPallocationViaNasFlag :=  f_CheckPCOforIPallocationViaNas (v_Pco);
    if (not isvalue(v_APN)) {
      v_APN := cs_AccessPointName (px_AccessPointName);
    }

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                     v_RRC_TI,
                         cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                        cds_ATTACH_ACCEPT_T3412(tsc_EAttachType_EpsOnly,
                                                                             cs_TrackingAreaIdListDef_lv,
                                                                             f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams),
                                                                             omit,
                                                                             omit,
                                                                             omit,
                                                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType), // @sic R5-103681 sic@,
                                                                             cs_GprsTimer_v(tsc_GprsTimerUnit_6min, '00001'B)),
                                                        cs_508_ActivateDefEpsBearerContextRequest(v_EpsBearerId,
                                                                                                  v_EPS_TI,
                                                                                                  v_APN,
                                                                                                  f_GetPDNAddress(v_IPallocationViaNasFlag),
                                                                                                  omit,
                                                                                                  omit,
                                                                                                  f_GetDefPCOforPCSCFAddress (v_Pco))));

     //@siclog "Step 10" siclog@
     //    The UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message
     //    NOTE 1: The tracking area updating attempt counter is reset.
     f_EUTRA_NAS_AttachComplete(eutra_CellA, v_EpsBearerId);


     //  The SS releases the RRC connection
     //@siclog "Step 11" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);


     // Wait for 6 min to ensure that T3412 expires
     //@siclog "Step 12" siclog@
     f_Delay(v_T3412);


     //@siclog "Step 13" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'Periodic updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));



 
     //  Wait for 30s to ensure that T3430 and T3411 expire.
     //          NOTE 2: The tracking area updating attempt counter is 1
     //@siclog "Step 14" siclog@
     f_Delay(v_T30sec);


     //@siclog "Step 15" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'Periodic updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     // Wait for 30s to ensure that T3430 and T3411 expire.
     //          NOTE 3: The tracking area updating attempt counter is 2
     //@siclog "Step 16" siclog@
     f_Delay(v_T30sec);


     //@siclog "Step 17" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'Periodic updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     //  Wait for 30s to ensure that T3430 and T3411 expire.
     //          NOTE 4: The tracking area updating attempt counter is 3
     //@siclog "Step 18" siclog@
     f_Delay(v_T30sec);


     //@siclog "Step 19" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'Periodic updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     // Wait for 30s to ensure that T3430 and T3411 expire.
     //          NOTE 5: The tracking area updating attempt counter is 4
     //@siclog "Step 20" siclog@
     f_Delay(v_T30sec);


     //@siclog "Step 21" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'Periodic updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Periodic,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     // The SS releases the RRC connection.
     // NOTE 6: The tracking area updating attempt counter is 5.
     //@siclog "Step 22" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);


     //  Wait for 12 min to ensure that T3402 expires
     //@siclog "Step 23" siclog@
     f_Delay(v_T3402);

     //@siclog "Step 24" siclog@
     // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'TA updating'?
     // NOTE 7: The tracking area updating attempt counter is reset.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));
     f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 24: TAU Request sent by UE");

     v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

     //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     //@siclog "Step 25" siclog@
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_TAU_AcceptWithoutGuti ( v_UpdateType,
                                                                                  v_TaiList,
                                                                                  v_EpsBearerCtxtStatus,
                                                                                  v_LAI,
                                                                                  v_MSId) ) ) );
 
     //@siclog "Step 26" siclog@
     // Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
     v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE )
      }
     f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

     //@siclog "Step 27" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'.
     // NOTE 8: The tracking area updating attempt counter is reset.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     //@siclog "Step 28" siclog@
     // Wait for 30s to ensure that T3430 and T3411 expire.
     // NOTE 9: The tracking area updating attempt counter is 1.
     f_Delay(v_T30sec);


     //@siclog "Step 29" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));


     //@siclog "Step 30" siclog@
     // Wait for 30s to ensure that T3430 and T3411 expire.
     // NOTE 10: The tracking area updating attempt counter is 2.
     f_Delay(v_T30sec);


     //@siclog "Step 31" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));


     //@siclog "Step 32" siclog@
     // Wait for 30s to ensure that T3430 and T3411 expire.
     // NOTE 11: The tracking area updating attempt counter is 3.
     f_Delay(v_T30sec);


     //@siclog "Step 33" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));


     //@siclog "Step 34" siclog@
     // Wait for 30s to ensure that T3430 and T3411 expire.
     // NOTE 12: The tracking area updating attempt counter is 4.
     f_Delay(v_T30sec);


     //@siclog "Step 35" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST message with the EPS update type value set to 'TA updating'.
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));


     //@siclog "Step 36" siclog@
     // The SS releases the RRC connection.
     // NOTE 13: The tracking area updating attempt counter is 5 and reset.
     f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);



     //@siclog "Step 37" siclog@
     // Set the cell type of Cell B to the "non-Suitable cell". Set the cell type of Cell G to the "Serving cell".
     v_CellPowerList := {
         cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
      }
     f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


     //@siclog "Step 38" siclog@
     // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message with the EPS update type value
     // set to 'TA updating'?
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(tsc_EpsUpdate_TaUpdate,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                                       cr_TAI(v_PLMN, tsc_TAC1))));

     f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 38: TAU Request sent by UE");


 

     // The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     //@siclog "Step 39" siclog@
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellG,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (
                                                                                        tsc_IEI_Guti,
                                                                                        f_EUTRA_CellInfo_GetGuti(
                                                                                                        eutra_CellG
                                                                                        ) ), //GUTI-7
                                                                           v_TaiList,
                                                                           v_EpsBearerCtxtStatus,
                                                                           v_LAI,
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

     // The UE transmits a TRACKING AREA UPDATE COMPLETE message.
     //@siclog "Step 40" siclog@
     SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellG,
                                         cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                             cr_508_TAU_Complete ) ) );
 
    }// end function fl_TC_9_2_3_1_25_Body


    function f_TC_9_2_3_1_26_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Abnormal case / TRACKING AREA UPDATE REJECT
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with reject cause #95 "semantically
          incorrect message" }
            then { the UE set the tracking area updating attempt counter to 5, start timer T3402,
            and perform tracking area updating on the expiry of timers T3402}

        (2)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with reject cause #96" invalid mandatory
          information"  }
            then { the UE set the tracking area updating attempt counter to 5, start timer T3402, and perform
            tracking area updating on the expiry of timers T3402}

        (3)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with reject cause #97"message type
          non-existent or not implemented" }
            then { the UE set the tracking area updating attempt counter to 5, start timer T3402, and
            perform tracking area updating on the expiry of timers T3402}

        (4)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with reject cause #99"information element
          non-existent or not implemented" }
            then { the UE set the tracking area updating attempt counter to 5, start timer T3402, and
            perform tracking area updating on the expiry of timers T3402}

        (5)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with reject cause #111"protocol error,
          unspecified" }
            then { the UE set the tracking area updating attempt counter to 5, start timer T3402, and
            perform tracking area updating on the expiry of timers T3402}

        System Simulator:
            -   Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18].

        Preamble:
            -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].
            -   set timer T3402 value to 1 minute to shorten the whole TC execute time in ATTACH ACCEPT
                message when brought UE to state Registered, Idle Mode (state 2).

     */

     var NAS_MSG_Indication_Type v_NasInd;
     var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
     var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_CellInfo := f_EUTRA_CellInfo_GetFDD_TDD_Info ( eutra_CellI );
     var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellI);
     var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
     f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

 
     // create cell and send out system information
     f_EUTRA_CellConfig_Def(eutra_CellA);
     f_EUTRA_CellConfig_Def(eutra_CellB);

     // Go to state 2
     f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

     // Now transmit T3402 to UE with value 1 minute
     f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );
     f_UT_SwitchOnUE (UT, false);

     v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                               cr_508_ATTACH_REQUEST(v_AttachType,v_AdditionalUpdateType),
                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                 f_GetPdnType())));

      SRB.send(cas_SRB1_RrcNasPdu_REQ ( eutra_CellA,
                                        cs_TimingInfo_Now,
                                        cs_RRCConnectionReconfiguration_SRB2_1AM_DRB_Est(tsc_RRC_TI_Def,
                                                                                         v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                         v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                         v_AntennaInfo
                                                                                         ),
                                        cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                            cds_ATTACH_ACCEPT_t3402(v_AttachType,
                                                                                    cs_TrackingAreaIdListDef_lv,
                                                                                    f_GutiParameters2MobileIdentity(tsc_IEI_Guti, f_EUTRA_CellInfo_GetGuti(eutra_CellA)),
                                                                                    omit,
                                                                                    omit,
                                                                                    omit,
                                                                                    f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType),
                                                                                    cs_GprsTimer_v('001'B, '00001'B)), //1 minute
                                                            cs_508_ActivateDefEpsBearerContextRequest(tsc_EpsDefaultBearerId,
                                                                                                      tsc_PTI_Unassigned,
                                                                                                      cs_AccessPointName(px_AccessPointName),
                                                                                                      f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (omit)),
                                                                                                      omit,
                                                                                                      omit,
                                                                                                      f_GetDefPCOforPCSCFAddress (v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions))))); // @sic R5-104703 sic@
      //Receive RRCConnectionReconfigurationComplete
      SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA, cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));

      f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);
 

      f_EUTRA_TestBody_Set(true);

      fl_TC_9_2_3_1_26_Body();

      // Postamble
      f_EUTRA_TestBody_Set(false);
      f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);

    } // end f_TC_9_2_3_1_26_EUTRA


    function fl_TC_9_2_3_1_26_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NasInd;
      var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var GutiParameters_Type v_GutiParams_B := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
      var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
      var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
      var float v_T3402B := f_EUTRA_SetTimerToleranceMax( eutra_CellB, 60.0 );
      var float v_T3402A := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 60.0 );
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      timer t_T3402B := v_T3402B;
      timer t_T3402A := v_T3402A;

      //@siclog "Step 1" siclog@
      // Set the cell type of cell B to the "Serving cell".
      // Set the cell type of cell A to the "Non-Suitable cell"
      v_CellPowerList := {
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //@siclog "Step 2" siclog@
      // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cr_508_TAU_Request(v_UpdateType,
                                                                                      f_EUTRA_SecurityKSIasme_Get(),
                                                                                      v_AdditionalUpdateType
                                                                                      )));


      //@siclog "Step 3" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause #95
      // "semantically incorrect message" as specified
      // Note: Upon reception of TRACKING AREA UPDATE REJECT message with EMM causes #95, #96, #97, #99 and #111
      // timer T3402 shall be started
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                  cs_TimingInfo_Now,
                                  cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                 cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_SemanticallyIncorrect))));

      t_T3402B.start;

      //@siclog "Step 4" siclog@
      // The SS releases the RRC connection.
      f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, other);


      //@siclog "Step 5" siclog@
      // Check: When the timer T3402 expires does the UE re-transmit TRACKING AREA UPDATE REQUEST message on cell B?
      t_T3402B.timeout;

      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType
                                                                                     )));
      v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5: TAU Request sent by UE");


      // The SS transmits a TRACKING AREA UPDATE ACCEPT message.
      //@siclog "Step 6" siclog@
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams_B ),
                                                                           v_TaiList,
                                                                           v_EpsBearerCtxtStatus,
                                                                           v_LAI,
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));


      //The UE transmits a TRACKING AREA UPDATE COMPLETE message.
      //@siclog "Step 7" siclog@
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellB,
                                          cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_TAU_Complete ) ) );
 
      //@siclog "Step 8" siclog@
      // Set the cell type of Cell B to the "non-Suitable cell". Set the cell type of Cell A to the "Serving cell".
      v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
       }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //@siclog "Step 9" siclog@
      // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell A
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cr_508_TAU_Request(v_UpdateType,
                                                                                      f_EUTRA_SecurityKSIasme_Get(),
                                                                                      v_AdditionalUpdateType
                                                                                      )));

      t_T3402A.start;

      //@siclog "Step 10" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause #96
      // "invalid mandatory information" as specified
      // Note: Upon reception of TRACKING AREA UPDATE REJECT message with EMM causes #95, #96, #97, #99 and #111
      // timer T3402 shall be started
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                  cs_TimingInfo_Now,
                                  cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                 cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_InvalidMandatoryInformation))));


      //@siclog "Step 11" siclog@
      // The SS releases the RRC connection.
      f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);


      //@siclog "Step 12" siclog@
      // Check: When the timer T3402 expires does the UE re-transmit TRACKING AREA UPDATE REQUEST message on cell A?
      t_T3402A.timeout;

      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType
                                                                                     )));

      v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 12: TAU Request sent by UE");


      // The SS transmits a TRACKING AREA UPDATE ACCEPT message.
      //@siclog "Step 13" siclog@
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams ),
                                                                           v_TaiList,
                                                                           v_EpsBearerCtxtStatus,
                                                                           v_LAI,
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

      // The UE transmits a TRACKING AREA UPDATE COMPLETE message.
      //@siclog "Step 14" siclog@
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellA,
                                         cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                             cr_508_TAU_Complete ) ) );


      //@siclog "Step 15" siclog@
      // Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
      v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
  

      //@siclog "Step 16" siclog@
      // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cr_508_TAU_Request(v_UpdateType,
                                                                                      f_EUTRA_SecurityKSIasme_Get(),
                                                                                      v_AdditionalUpdateType
                                                                                      )));

     //@siclog "Step 17" siclog@
     // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause #97
     // "message type non-existent or not implemented".
     // Note: Upon reception of TRACKING AREA UPDATE REJECT message with EMM causes #95, #96, #97, #99 and #111
     // timer T3402 shall be started
     SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                  cs_TimingInfo_Now,
                                  cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                 cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_MessageTypeNonExistentOrNotImplemented))));

     t_T3402B.start;

     //@siclog "Step 18" siclog@
     // The SS releases the RRC connection.
     f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, other);


     //@siclog "Step 19" siclog@
     // Check: When the timer T3402 expires does the UE re-transmit TRACKING AREA UPDATE REQUEST message on cell B?
     t_T3402B.timeout;

     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType
                                                                                     )));
     v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
     f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 19: TAU Request sent by UE");


     //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     //@siclog "Step 20" siclog@
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams_B ),
                                                                           v_TaiList,
                                                                           v_EpsBearerCtxtStatus,
                                                                           v_LAI,
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

     // The UE transmits a TRACKING AREA UPDATE COMPLETE message.
     //@siclog "Step 21" siclog@
     SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellB,
                                         cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                             cr_508_TAU_Complete ) ) );


     //@siclog "Step 22" siclog@
     // Set the cell type of Cell B to the "non-Suitable cell". Set the cell type of Cell A to the "Serving cell".
     v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
     }
     f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


     //@siclog "Step 23" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell A
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType)));

     //@siclog "Step 24" siclog@
     // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause #99
     // "information element non-existent or not implemented" as specified.
     // Note: Upon reception of TRACKING AREA UPDATE REJECT message with EMM causes #95, #96, #97, #99 and #111
     // timer T3402 shall be started
     SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                  cs_TimingInfo_Now,
                                  cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                 cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_IENonExistentOrNotImplemented))));


     t_T3402A.start;

     //@siclog "Step 25" siclog@
     // The SS releases the RRC connection.
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);


     //@siclog "Step 26" siclog@
     // Check: When the timer T3402 expires does the UE re-transmit TRACKING AREA UPDATE REQUEST message on cell A?
     t_T3402A.timeout;

     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType
                                                                                     )));

     v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
     f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 26: TAU Request sent by UE");


     //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     //@siclog "Step 27" siclog@
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams ),
                                                                           v_TaiList,
                                                                           v_EpsBearerCtxtStatus,
                                                                           v_LAI,
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

     //The UE transmits a TRACKING AREA UPDATE COMPLETE message.
     //@siclog "Step 28" siclog@
     SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellA,
                                         cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                             cr_508_TAU_Complete ) ) );


     //@siclog "Step 29" siclog@
     // Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
     v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE )
     }
     f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
  

     //@siclog "Step 30" siclog@
     // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B
     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType
                                                                                     )));
 
     //@siclog "Step 31" siclog@
     // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause #111
     // "protocol error, unspecified".
     // Note: Upon reception of TRACKING AREA UPDATE REJECT message with EMM causes #95, #96, #97, #99 and #111
     // timer T3402 shall be started
     SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                  cs_TimingInfo_Now,
                                  cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                 cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_ProtocolErrorUnspecified))));

     t_T3402B.start;

     //@siclog "Step 32" siclog@
     // The SS releases the RRC connection.
     f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, other);


     //@siclog "Step 33" siclog@
     // Check: When the timer T3402 expires does the UE re-transmit TRACKING AREA UPDATE REQUEST message on cell B?
     t_T3402B.timeout;

     v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                v_RRC_TI,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cr_508_TAU_Request(v_UpdateType,
                                                                                     f_EUTRA_SecurityKSIasme_Get(),
                                                                                     v_AdditionalUpdateType
                                                                                     )));
     v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
     f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 33: TAU Request sent by UE");


     //  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
     //@siclog "Step 34" siclog@
     SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cds_TAU_Accept_T3402 (
                                                                     v_UpdateType,
                                                                     f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams_B ),
                                                                     v_TaiList,
                                                                     v_EpsBearerCtxtStatus,
                                                                     v_LAI,
                                                                     v_MSId,
                                                                     f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType), // @sic R5-103681 sic@
                                                                     cs_GprsTimer_v(tsc_GprsTimerUnit_1min, '00001'B
                                                                     ))) ) );

     // The UE transmits a TRACKING AREA UPDATE COMPLETE message.
     //@siclog "Step 35" siclog@
     SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellB,
                                         cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                             cr_508_TAU_Complete ) ) );

 
    }// end function fl_TC_9_2_3_1_26_Body


    function f_TC_9_2_3_1_27_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Abnormal case / Change of cell into a new tracking area
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { cell change into a new tracking area occurs before the tracking area updating procedure is completed }
            then { UE abort the tracking area updating procedure and re-initiate it in the new tracking area immediately }
        }


        System Simulator:
            -   Cell A, Cell B, Cell C are configured according to Table 6.3.2.2-1 in [18].
        UE:
            -   The test USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
        Preamble:
            -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].

     */
         
        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_SRBs_Only(eutra_CellB);
        f_EUTRA_CellConfig_Def(eutra_CellC);

        // Go to state 2
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_27_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellC, E2_CONNECTED);

    } // end f_TC_9_2_3_1_27_EUTRA


    function fl_TC_9_2_3_1_27_Body() runs on EUTRA_PTC
    {
      var SRB_COMMON_IND v_ReceivedAsp;
 
      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_MSG_Indication_Type v_NasInd;

      var EPS_BearerContextStatus v_EPS_ContextStatus;
      var NAS_Tac v_Tac1 := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA));
      var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var GutiParameters_Type v_Guti2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti_Params);
      var GutiParameters_Type v_Guti3_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti2_Params);
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti_Params.PLMN_Identity);
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      timer t_T3430 := f_EUTRA_SetTimerToleranceMin( eutra_CellC, 15.0 );
      timer t_WaitTimer := f_EUTRA_SetTimerToleranceMin( eutra_CellC, 5.0 );
          
      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Non-Suitable cell"
      // Set the cell type of cell B to the "Serving cell".
      // Set the cell type of cell C to the "Non-Suitable cell".
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
 

      //@siclog "Step 2" siclog@
      //   The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             v_RRC_TI,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                               cdr_TAU_Request_OldGuti(v_UpdateType,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType,
                                                                                       f_GutiParameters2MobileIdentity(omit, v_Guti_Params),
                                                                                       cr_TAI(v_PLMN, v_Tac1))));

      t_T3430.start;

      //@siclog "Step 3" siclog@
      //  SS does not send TRACKING AREA UPDATE ACCEPT to the UE.

      //@siclog "Step 4" siclog@
      // Set the cell type of cell A to the "Non-Suitable cell".
      // Set the cell type of cell B to the "Non-Suitable cell".
      // Set the cell type of cell C to the "Serving cell".
      // Note: change of cell power level should happen before timer T3430 expired.
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellC, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //   SS does not send TRACKING AREA UPDATE ACCEPT to the UE.
      //@siclog "Step 3" siclog@
      if (t_T3430.running) {
            t_T3430.stop;
            f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 3: TAU sent");
      }
      else {
               f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 3")
      }

      //  UE initiates RRC connection establishment procedure on cell C.
      //@siclog "Step 5" siclog@
      SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellC,
                                    cr_RRCConnectionRequest(cr_EstablishmentCause_Any)));

      // send RRC Connection Setup on SRB0 (CCCH) and switch on UL grant assignments:
      f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellC, cs_TimingInfo_Now, v_RRC_TI);
      // UE enters RRC_CONNECTED state

      //  Check: Does the UE transmit TRACKING AREA UPDATE REQUEST message on cell C in the next 5 seconds?
      // receive RRC Connection Setup Complete with piggy-backed TRACKING AREA UPDATE REQUEST message
      //@siclog "Step 6" siclog@
      t_WaitTimer.start;
      alt {
          [] SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellC,
                                                cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?),
                                                cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                  cdr_TAU_Request_OldGuti(v_UpdateType,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti_Params),
                                                                                         cr_TAI(v_PLMN, v_Tac1)))))
                                                -> value v_ReceivedAsp
           {
                t_WaitTimer.stop;
                f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 6: TAU Request on cell C")
           }
           [] t_WaitTimer.timeout
           {
           }
      }

     
      //@siclog "Step 7" siclog@
      // SS responds with TRACKING AREA UPDATE ACCEPT message
      v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                       cs_TimingInfo_Now,
                                       cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                        cs_508_TAU_Accept ( v_UpdateType,
                                                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params),
                                                                            cds_TAIListNonConsecutive_tlv( v_PLMN, {'0003'O} ), //TAC-3
                                                                            v_EPS_ContextStatus,
                                                                            f_EUTRA_GetCellLAI(eutra_CellC),
                                                                            f_GetMSId ( ),
                                                                            f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );


    
      //  UE sends TRACKING AREA UPDATE COMPLETE
      //@siclog "Step 8" siclog@
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellC,
                                          cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_TAU_Complete ) ) );
      

 
    }// end function fl_TC_9_2_3_1_27_Body


    function f_TC_9_2_3_1_28_EUTRA() runs on EUTRA_PTC
    {
     // @desc Normal tracking area update / Abnormal case / Tracking area updating and detach procedure collision
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message}
        ensure that {
          when { UE receives a DETACH REQUEST message before the tracking area updating procedure
                 has been completed }
            then { the tracking area updating procedure shall be aborted and the detach procedure
                  shall be progressed }
        }

        System Simulator:
            -   Cell A, Cell B are configured according to Table 6.3.2.2-1 in [18].
        UE:
            -   The test USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
        Preamble:
            -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].
     */
         
        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellB);

        // Go to state 2
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_1_28_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellB, E4_DEREGISTERED);

    } // end f_TC_9_2_3_1_28_EUTRA


    function fl_TC_9_2_3_1_28_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NasInd;
      
      var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
      var template (omit) EMM_Cause v_EMMCause:=cs_EMM_Cause_v(tsc_Cause_TA_NotAllowed);
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();

      var float v_NoReactionTime := f_EUTRA_SetTimerToleranceMax( eutra_CellB, 3.0 );
      timer t_T3430 := f_EUTRA_SetTimerToleranceMin( eutra_CellB, 15.0 );
      timer t_T3422 := f_EUTRA_SetTimerToleranceMax( eutra_CellB, 6.0 );
          
      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Non-Suitable cell"
      // Set the cell type of cell B to the "Serving cell".
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
 

      //@siclog "Step 2" siclog@
      //   The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cr_508_TAU_Request(v_UpdateType,
                                                                   f_EUTRA_SecurityKSIasme_Get(),
                                                                   v_AdditionalUpdateType
                                                                   )));


      t_T3430.start;

      //  SS does not send TRACKING AREA UPDATE ACCEPT to the UE.
      //@siclog "Step 3-4" siclog@
      //The SS transmits a DETACH REQUEST message with Detach type = 're-attach not required' on Cell B.
      //Note: this message should be sent before timer T3430 expired.
      SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellB,
                                   cs_TimingInfo_Now,
                                   cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                  cs_508_DETACH_REQUEST_MT(cs_DetachType(tsc_DetachMT_NoReAttach),
                                                                           v_EMMCause)
                                                  )));
      t_T3422.start;
      if (t_T3430.running) {
            t_T3430.stop;

      }
      else {
            f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 3: TAU sent");
      }

      //@siclog "Step 5" siclog@
      // Check: Does The UE transmit a DETACH ACCEPT message on Cell B in the next 6 seconds?
      // Note: the default value for timer T3422 is 6 seconds
      alt {
          [] SRB.receive(car_SRB2_NasPdu_IND(eutra_CellB,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                               cr_508_DETACH_ACCEPT)))
           {
                t_T3422.stop;
                f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5: Detach accept on cell B");
           }
           [] t_T3422.timeout
           {
           }
      }


      //  The SS releases the RRC connection
      //@siclog "Step 6" siclog@
      f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

     //@siclog "Step 7" siclog@
      // Check: Does the test result of CALL generic procedure "Test procedure for no response to paging
      // (for NAS testing)" defined in clause 6.4.2.5 of TS36.508 indicates that the UE does not respond
      // to paging when paged with S-TMSI1 and with CN domain indicator set to "PS" on Cell B?
      f_EUTRA_508Check_NASNoResponse(eutra_CellB,
                                     cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_Guti_Params.MME_Code, v_Guti_Params.M_TMSI )),
                                     v_NoReactionTime );


 
    }// end function fl_TC_9_2_3_1_28_Body


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.2.1
  ///////////////////////////////////////////////////////////////////////////////
  function f_TC_9_2_3_2_1_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Combined Tracking Area Update / Successful.

    // (1)
    // with { a combined EPS/IMSI attached UE in state EMM-REGISTERED and EMM-IDLE mode}
    // ensure that {
    //   when { UE enters a tracking area included in the TAI list }
    //   then { UE does not transmit a TRACKING AREA UPDATE REQUEST message }
    // }
    //
    // (2)
    // with { a combined EPS/IMSI attached UE in state EMM-REGISTERED and EMM-IDLE mode}
    // ensure that {
    //   when { UE enters a tracking area not included in the TAI list }
    //   then { UE transmits a TRACKING AREA UPDATE REQUEST message with 'EPS update
    //          type = combined TA/LA updating' }
    // }
    //
    // (3)
    // with { UE has sent a combined TRACKING AREA UPDATE REQUEST message }
    // ensure that {
    //   when { UE receives a TRACKING AREA UPDATE ACCEPT message containing a GUTI
    //          and/or a mobile identity }
    //   then { UE transmits a TRACKING AREA UPDATE COMPLETE message and enters EMM-REGISTERED state }
    // }

    // Pre-test conditions
    // -------------------
    // System Simulator:
    //   - Cell A, Cell C and Cell D (HPLMN, different TAs)
    // UE:
    //   -  The UE is configured to initiate combined EPS/IMSI attachNone..
    // Preamble:
    //   -  The UE is in state Registered, Idle Mode (state 2) on cell A according to [18]

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellC);
    f_EUTRA_CellConfig_Def(eutra_CellD);

    f_UT_ConfigureCombinedAttach (UT); // R5-103341

    // Preamble: UE is in state Registered, Idle Mode (state 2) on Cell A
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_1_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_3_2_1_EUTRA

  function fl_TC_9_2_3_2_1_Body() runs on EUTRA_PTC
  {
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var NAS_PlmnId v_PLMN:= f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
    var NAS_Lac v_Lac1 := f_EUTRA_CellInfo_GetLocationAreaCode(eutra_CellA);
    var template (present) LocAreaId v_LAI_RX := cr_LAI(omit, v_PLMN, v_Lac1);
    var template (omit)    LocAreaId v_LAI_TX := f_EUTRA_GetCellLAI(eutra_CellC);
    var NAS_Tac v_Tac1 := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA));
    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellC);
    var template (omit) MobileIdentity v_MsId := f_GetMSId ( );
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NasCount_Type v_NasCountUL;
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var template (value) CellPowerList_Type v_CellPowerList;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_MSG_Indication_Type v_NasInd;

    timer t_Wait := f_EUTRA_SetTimerToleranceMax (eutra_CellD, 30.0 );

    // ==========================================================================
    //@siclog "Step 1 - 13 Void" siclog@
    //+   Set the cell type of cell A to the "Non-Suitable cell".
    //+   Set the cell type of cell C to the "Serving cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellD, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 14" siclog@
    //@siclog "Step 15" siclog@
    //+   Check: Does the UE transmit a combined TRACKING AREA UPDATE REQUEST message as specified?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                     cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                         v_AdditionalUpdateType,
                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                         v_LAI_RX,
                                                         cr_TAI(v_PLMN, v_Tac1),
                                                         cr_TMSI_Status('0'B))));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 15");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;

    // activate AS security
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellC,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams); // Saving security parameters

    //@siclog "Step 16" siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT message including GUTI, TMSI and LAI. The TAI list includes TAI for cell C and cell D
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellC,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                    cs_508_TAU_Accept(
                                        v_UpdateType,
                                        f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                        cds_TAIListNonConsecutive_tlv(
                                          v_PLMN,
                                          { '0003'O, '0004'O }), // TAC1=3, TAC2=4
                                        v_EpsBearerCtxtStatus,
                                        v_LAI_TX,
                                        v_MsId,
                                        f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

    //@siclog "Step 17" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE COMPLETE message? -->
    //+   TRACKING AREA UPDATE COMPLETE [2,P]
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 17");

    //@siclog "Step 18" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellC, tsc_RRC_TI_Def, other);

    //@siclog "Step 19" siclog@
    //+   Check: Does the test results of generic procedure in TS 36.508 [18] subclause 6.4.2.4
    //+   indicate that the UE is in E-UTRA EMM-REGISTERED state on cell C with PagingUE-Identity = S-TMSI2?
    f_EPS_508Check_NAS_Paging(eutra_CellC, ps);

    //@siclog "Step 20" siclog@
    //+   Set the cell type of cell A to OFF
    //+   Set the cell type of cell C to the "Suitable Neigbour cell ".
    //+   Set the cell type of cell D to the " Serving cell"
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellD, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 20a" siclog@
    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message in
    //+    the next 30 seconds? [1,F]
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellD, cr_RRCConnectionRequest(?)))
        { // even though prose says TAU, as soon as UE sends RRC ConnReq, we know
          // something's wrong
          t_Wait.stop;
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 20A");
        }
      [] t_Wait.timeout
        {
          f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 20A");
        }
    }

    //@siclog "Step 20b" siclog@
    //+   Check: Does the test results of generic procedure in TS 36.508 [18] subclause 6.4.2.4
    //+   indicate that the UE is in E-UTRA EMM-REGISTERED state on cell D with PagingUE-Identity = S-TMSI2?
    f_EPS_508Check_NAS_Paging(eutra_CellD, ps);


    //@siclog "Step 20c" siclog@
    //+   Set the cell type of cell D to the "Suitable Neighbour cell ".
    //+   Set the cell type of cell A to the " Serving cell"
    //+   Set the cell type of cell C to OFF
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellD, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 21" siclog@
    //+   Check: Does the UE transmit a combined TRACKING AREA UPDATE REQUEST message? -->
    //+   TRACKING AREA UPDATE REQUEST [2;3,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                     tsc_RRC_TI_Def,
                     cr_EstablishmentCause_Any,
                     cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                        cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                         v_AdditionalUpdateType,
                                                         f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                                         v_LAI_RX,
                                                         cr_TAI(v_PLMN, '0004'O),
                                                         omit)));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 21");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 22" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE ACCEPT message. <-- TRACKING AREA UPDATE ACCEPT
    SRB.send(cas_SRB1_NasPdu_REQ(
         eutra_CellA,
         cs_TimingInfo_Now,
         cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                   cs_TAU_AcceptWithoutGuti(
                          tsc_EpsUpdate_Combined_TaLaUpdate,
                          cds_TAIListNonConsecutive_tlv(
                                      v_PLMN,
                                      { '0001'O }), // TAC1=1
                          v_EpsBearerCtxtStatus,
                          omit,
                          f_GetMSId ()))));  // Need a new TMSI

    //@siclog "Step 23" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE COMPLETE message?
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 23");
  } // function fl_TC_9_2_3_2_1_Body


  function f_TC_9_2_3_2_2_EUTRA() runs on EUTRA_PTC
  {
    // @desc Combined tracking area update / Successful for EPS services only / IMSI unknown in HSS
    /*
    Test Purpose (TP)
    (1)
    with { UE has sent a combined TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
    ensure that {
      when { UE receives a TRACKING AREA UPDATE ACCEPT message with EPS update result set to "TA updated" and EMM cause set to "IMSI unknown in HSS" }
       then { UE considers the USIM as invalid for non-EPS services and enters EMM-REGISTERED.NORMAL-SERVICE state and MM idle state }
                 }


    Pre-test conditions
    System Simulator:
        -   cells A and B are configured according to Table 6.3.2.2-1 in [18].
        -   cell A belongs to TAI-1 and is set to ''Serving cell''
        -   cell B belongs to TAI-2 and is set to ''Non-Suitable cell''.
    UE:
        None.
    Preamble:
        -   The UE is in state Registered, Idle mode (state 2) on cell A according to [18].
    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellB );

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_2_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);
  } // function f_TC_9_2_3_2_2_EUTRA
  
  
  function fl_TC_9_2_3_2_2_Body( ) runs on EUTRA_PTC
  {
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti1_Params.PLMN_Identity);
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var NAS_MSG_Indication_Type v_NasInd;
    var EPS_BearerContextStatus v_EPS_ContextStatus;
    var template (omit) EMM_Cause v_EMMCause:=cs_EMM_Cause_v(tsc_EmmCause_UnknownIMSI);
    var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN,v_LAC);
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var ProcedureTransactionIdentifier v_EPS_TI := tsc_PTI_1;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_AuthParams := f_EUTRA_Security_Get();
    var template (omit) AccessPointName v_APN := omit;
    var template (omit) MobileIdentity v_MSId := f_GetMSId ( );

    // Set the cell type of Cell B to the "Serving cell".
    // Set the cell type of Cell A to the "non-Suitable cell".
    //@siclog "Step 1" siclog@
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

    //The following messages are to be observed on Cell B
    //@siclog "Step 2" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE REQUEST message.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_specificGutiTaiLai(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                             f_EUTRA_SecurityKSIasme_Get(),
                                                                                             v_AdditionalUpdateType,
                                                                                             f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                             v_LAI,
                                                                                             cr_TAI( v_PLMN, v_LAC),
                                                                                             omit)));

    //@siclog "Step 3" siclog@
    //+ The SS transmits a TRACKING AREA UPDATE ACCEPT message.
    v_EPS_ContextStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cds_TAU_Accept_EMM_Cause ( tsc_EpsUpdate_TaUpdate,
                                                                                 f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti2_Params ),
                                                                                 cds_TAIListNonConsecutive_tlv(v_PLMN, {'0002'O}),
                                                                                 v_EPS_ContextStatus,
                                                                                 f_EUTRA_GetCellLAI(eutra_CellB),
                                                                                 omit,
                                                                                 f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                                 v_EMMCause
                                                                                 ) )  ));
    //@siclog "Step 4" siclog@
    // +The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

    //@siclog "Step 5" siclog@
    //+ The SS pages the UE using S-TMSI with CN domain indicator set to "PS"
    f_EUTRA_UE_Page ( eutra_CellB,
                      cs_NasPaging_OneRecord(cs_PagingUE_Identity_S_TMSI(v_Guti2_Params.MME_Code,
                                                                         v_Guti2_Params.M_TMSI)));

    //@siclog "Step 6" siclog@
    //+ The UE transmits a SERVICE REQUEST message
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_mt_Access,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    //@siclog "Step 7" siclog@
    //+ The SS transmits a DETACH REQUEST message with Detach Type set to "re-attach required"
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_DETACH_REQUEST_MT(cs_DetachType(tsc_DetachMT_ReAttach),
                                                                         omit))));
     
    //@siclog "Step 8" siclog@
    //+ The UE sends a DETACH ACCEPT message.
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                    cr_508_DETACH_ACCEPT)));

    //@siclog "Step 9" siclog@
    //+ The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);


    //@siclog "Step 10" siclog@
    //+ Check: Does the UE send ATTACH REQUEST message with EPS attach
    //          type set to "EPS attach", including a PDN CONNECTIVITY REQUEST message ?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_IndicationWithPiggybacking( tsc_SHT_NoSecurityProtection,
                                                                        cr_508_ATTACH_REQUEST(tsc_EAttachType_EpsOnly, v_AdditionalUpdateType),
                                                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 10");

    //@siclog "Step 11 - 22" siclog@
    //     Steps 5 to 16 of generic procedure in 36.508 clause 4.5.2.3-1 are executed so as to
    //     complete the attach procedure (the ATTACH ACCEPT message include "EPS attach result"
    //     IE = '0001'B, "EPS only")
    v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses
    // Get the PCO to be used later (TS 36.508 v.8.2.2 Table 4.7.3-6)
    if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }
    // Step 5-6: Authentication
    v_AuthParams:=f_EUTRA_NAS_Authentication(eutra_CellB,
                                             tsc_SRB1,
                                             v_AuthParams,
                                             tsc_SHT_NoSecurityProtection,
                                             tsc_SHT_NoSecurityProtection,       // @sic R5s090210, R5s090373 sic@
                                             v_PLMN);                        // AUTHENTICATION REQUEST & RESPONSE
    // Step 7-8: NAS Security
    v_NasCountUL := f_EUTRA_NAS_ActivateSecurity(eutra_CellB, v_AuthParams);   // NAS SECURITY COMMAND & COMPLETE

    // Step 9a1 & 2 - ESM information optionally transferred
    if (f_CheckEsmInfoTransferFlag(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST)) {
      v_APN := f_ESM_InformationTransfer_GetAPN (eutra_CellB, v_EPS_TI);
    }

    // Step 10-11: RRC Security Mode procedures
    v_AuthParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellB, v_AuthParams, v_NasCountUL); // RRC SECURITY COMMAND & COMPLETE
    f_EUTRA_Security_Set ( v_AuthParams ); //Saving security parameters

    // Step 12-13 UE Capability check
    f_EUTRA_Capability (eutra_CellB, v_RRC_TI); // This enquires for the eutra capability but does not check the contents of the message received

    f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellB,
                                                                  tsc_EpsDefaultBearerId,
                                                                  v_RRC_TI,
                                                                  v_EPS_TI,
                                                                  tsc_EAttachType_EpsOnly,
                                                                  f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, f_EUTRA_CellInfo_GetGuti(eutra_CellB)),
                                                                  cs_TrackingAreaIdListDef_lv,
                                                                  v_LAI,
                                                                  v_MSId,
                                                                  omit,
                                                                  v_APN,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                  v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

    f_EUTRA_NAS_AttachComplete(eutra_CellB, tsc_EpsDefaultBearerId);                        // step 16

  } // function fl_TC_9_2_3_2_2_Body


  function f_TC_9_2_3_2_3_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Combined tracking area update / Successful for EPS services only / MSC temporarily not reachable

        /* (1)
    with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' or 'Combined TA/LA updating with IMSI attach' and having the tracking area updating attempt counter set to the value less than four }
    ensure that {
      when { UE receives a TRACKING AREA UPDATE ACCEPT message with the EPS update result set to 'TA updated' and the EMM cause set to 'MSC temporarily not reachable', 'Network failure' or 'Congestion' }
        then { UE sends TRACKING AREA UPDATE REQUEST message after T3411 expiry }
                }

    (2)
    with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating with IMSI attach', having the tracking area updating attempt counter set to four and operating in CS/PS mode 2 of operation }
    ensure that {
      when { UE receives a TRACKING AREA UPDATE ACCEPT message with the EPS update result set to 'TA updated' and the EMM cause set to 'MSC temporarily not reachable', 'Network failure' or 'Congestion' }
        then { UE sends TRACKING AREA UPDATE REQUEST message after T3402 expiry }
                }

    (3)
    with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating with IMSI attach', having the tracking area updating attempt counter set to four and operating in CS/PS mode 1 of operation }
    ensure that {
      when { UE receives a TRACKING AREA UPDATE ACCEPT message with the EPS update result set to 'TA updated' and the EMM cause set to 'MSC temporarily not reachable', 'Network failure' or 'Congestion' }
        then { UE attempts to select GERAN or UTRAN radio access technology }
                }

        */

        // Pre-test conditions
        // -------------------
        /* System Simulator:
    -   Cell A and Cell B.
    -   If pc_UTRAN supported by UE, Cell 5.
    -   Cell 5 belongs to LAI-1 and RAI-1(home PLMN)
    -   If pc_GERAN and NOT pc_UTRAN supported by UE, Cell 24.
    -   Cell 24 belongs to LAI-1 and RAI-1(home PLMN)
    UE:
    -   The UE is configured to initiate combined EPS/IMSI attach.
    Preamble:
    -   The UE is in state Switched OFF (state 1) according to [18].

    */
    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell_UTRANCell );
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell );
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
    }

    f_UT_ConfigureCombinedAttach (UT); // R5-103341

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def( eutra_CellB );

    // If pc_GERAN or pc_UTRAN supported by UE, wait for other RAT to update TMSI-1, P-TMSI-1and RAI-1, and GPRS update status is "GU1:UPDATED"
    if (pc_UTRA) {
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    } else if (pc_GERAN) {
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_3_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_UT_SwitchOffUE (UT, false);
    f_EUTRA_ReleaseAllCells( );

  } // function f_TC_9_2_3_2_3_EUTRA

  function fl_TC_9_2_3_2_3_Body() runs on EUTRA_PTC
  {
    fl_TC_9_2_3_2_3_Body_Loop(cs_EMM_Cause_v(tsc_EmmCause_MSCnotReachable));
    fl_TC_9_2_3_2_3_Body_Loop(cs_EMM_Cause_v(tsc_EmmCause_NetworkFailure));
    fl_TC_9_2_3_2_3_Body_Loop(cs_EMM_Cause_v(tsc_Cause_Congestion));
  }

  function fl_TC_9_2_3_2_3_Body_Loop(template (omit) EMM_Cause p_EMMCause) runs on EUTRA_PTC
  {
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
    var boolean v_TriggerRxd := false;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    //var boolean v_EIT_Flag := false;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    // temporary dummy variable which gets used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    //var ProtocolConfigOptions v_Pco;
    //var boolean v_IPallocationViaNasFlag;
    var integer i;
    var template (value) CellPowerList_Type v_CellPowerList;
    var NasCount_Type v_NasCountUL;
    var boolean   v_Px_CS_PSmode2       := false; // TODO, add by Mohongbo, this is a temporarily used parameter.
    var NAS_Tac v_Tac :=bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellB));
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
    var NAS_Lac v_Lac1 := f_EUTRA_CellInfo_GetLocationAreaCode(eutra_CellB);
    var charstring v_OtherPTC := "";
  //  var Common_AuthenticationParams_Type v_Auth_Params;
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();

    timer t_Timer3411 := f_EUTRA_SetTimerToleranceMax (eutra_CellB, 10.0);
    timer t_Timer3402 := f_EUTRA_SetTimerToleranceMax (eutra_CellB, 720.0);

      if (pc_UTRA) {
         v_OtherPTC := "UTRAN";
       } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
       } else { // Neither UMTS, nor GSM, so just do LTE
         v_OtherPTC := "NONE";
      }

    //@siclog "Step 0" siclog@
    // Set Cell A to the "Serving cell". Set Cell B to the "non-Suitable cell".
    // Set the cell type of Cell 5 or Cell 24 to the "non-Suitable cell".
    v_CellPowerList := {
                         cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
                         cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
                       };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    select (v_OtherPTC) { // send trigger to other RAT to change its power level too
      case ("UTRAN") {
        f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
      } case ("GERAN") {
        f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
      } case else {} // Do nothing
    }

    //+  The UE is powered on or switched on.
    //@siclog "Step 0A" siclog@
    f_UT_SwitchOnUE(UT, false);

    //+ Step 0B Generic test procedure in TS 36.508 subclause 4.5.2.3 is performed.
    //          NOTE: The UE performs an ATTACH procedure and the RRC connection is released.
    f_EUTRA_AttachProcedure (eutra_CellA, "No Verdict");

    //+ Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
    //@siclog "Step 1" siclog@
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    //+  Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message?
    //@siclog "Step 2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                         cr_TAI_Any)));
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");

    //@siclog "Step 3 - 4 void" siclog@


    //+  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
    //@siclog "Step 5" siclog@
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellB,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);

    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cds_TAU_Accept_EMM_Cause ( v_UpdateType,
                                                                          f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                          cs_TrackingAreaIdListDef_lv,
                                                                          v_EpsBearerCtxtStatus,
                                                                          omit,
                                                                          omit,
                                                                          f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                          p_EMMCause))));

    f_EUTRA_CellInfo_SetGuti(eutra_CellB, v_Guti2_Params);

    //+ The UE transmits a TRACKING AREA UPDATE COMPLETE message.
    //@siclog "Step 6" siclog@
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

    //+ The SS releases the RRC connection.
    //@siclog "Step 7" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

    // EXCEPTION: The step 8 to 13 shall be repeated 4 times.
    //@siclog "Step 8 - 13" siclog@
    for (i := 0; i < 4; i := i + 1) {
    //+ Step 8 Wait for 10s (T3411).
    t_Timer3411.start;
    t_Timer3411.timeout;

    //+ Step 9 Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message at the time which T3411 expired?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                        cdr_TAU_Request_combinedupdating_IMSIattach(tsc_EpsUpdate_Combined_IMSIAttach,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                                                                                    f_EUTRA_GetCellLAI(eutra_CellB),
                                                                                                    f_Asn2Nas_PlmnId (v_Guti2_Params.PLMN_Identity),
                                                                                                    v_Tac)));
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9");
    //+ Step 10 Void

    //+ Step 11 Void

    //+ Step 12 The SS transmits a TRACKING AREA UPDATE ACCEPT message.
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellB,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);

    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cds_TAU_Accept_EMM_Cause ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                                                          cs_TrackingAreaIdListDef_lv,
                                                                          v_EpsBearerCtxtStatus,
                                                                          omit,
                                                                          omit,
                                                                          f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                          p_EMMCause))));

    //+ Step 13 The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);
    }

    //@siclog "Step 14 - 19 Void" siclog@
    // EXCEPTION: Steps 20a1 to 20b6 describe behaviour that depends on UE configuration; the "lower case letter" identifies a step
    //            sequence that takes place according to UE mode of operation.

    //@siclog "Step 20a1" siclog@
    //+ IF the UE is configured to operate in CS/PS mode 2 THEN the SS waits for 12 min (T3402).
    if(v_Px_CS_PSmode2){
    t_Timer3402.start;
    t_Timer3402.timeout;

    //+  Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message?
    //@siclog "Step 20a2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                        cdr_TAU_Request_combinedupdating_IMSIattach(tsc_EpsUpdate_Combined_IMSIAttach,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                                                                                    f_EUTRA_GetCellLAI(eutra_CellB),
                                                                                                    f_Asn2Nas_PlmnId (v_Guti2_Params.PLMN_Identity),
                                                                                                    v_Tac)));
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 20a2");

    //+ The SS transmits a TRACKING AREA UPDATE ACCEPT message.
    //@siclog "Step 20a3" siclog@
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellB,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);
    SRB.send(cas_SRB1_NasPdu_REQ(
                                 eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_TAU_AcceptWithoutGuti(
                                                      tsc_EpsUpdate_Combined_TaLaUpdate,
                                                      cs_TrackingAreaIdListDef_lv,
                                                      v_EpsBearerCtxtStatus,
                                                      cs_LAI('13'O, v_PLMN, v_Lac1),
                                                      f_GetMSId ( )))));

    //+  The UE transmits a TRACKING AREA UPDATE COMPLETE message.
    //@siclog "Step 20a4" siclog@
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

    //+ The SS releases the RRC connection.
    //@siclog "Step 20a5" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);
    }
    //+  ELSE the SS configures:- Cell B as a "Non-Suitable cell",- Cell 5 or Cell 24 as the "Serving cell".
    //+   The following messages are sent and shall be received on Cell 5 or 24.
    //@siclog "Step 20b1 - 20b2" siclog@
    else{
           f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
           select (v_OtherPTC) {
           case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
        }
    }

    //+  The UE is powered off or switched off.
    //@siclog "Step 21" siclog@
    f_UT_SwitchOffUE(UT, false);

  } // function fl_TC_9_2_3_2_3_Body


  function f_TC_9_2_3_2_4_EUTRA() runs on EUTRA_PTC
  {
    // @desc Combined tracking area update / Successful for EPS services only / CS domain not available
        /*
        Test Purpose (TP)
        (1)
        with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
        ensure that {
            when { UE receives a TRACKING AREA UPDATE ACCEPT message with the EPS update result set to 'TA updated' and the EMM cause set to
            'CS domain not available' }
                then { UE transmits TRACKING AREA UPDATE COMPLETE message and set the update status to U2 NOT UPDATED and enters EMM-REGISTERED state }
            }

        (2)
        with { UE receives a TRACKING AREA UPDATE ACCEPT message with the EPS update result set to 'TA updated' and the EMM cause set to 'CS domain not available' }
        ensure that {
          when { UE enters a new tracking area }
            then { UE initiates the tracking area updating procedure with EPS update type as "TA updating" }
        }

        // Pre-test conditions
        System Simulator:
            -   Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18].
            -   Cell A belongs to TAI-1(home PLMN) and is set to "Serving cell"
            -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to "Non-Suitable cell"
        UE:
            -   The test USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
            -   The test USIM contains TMSI-1 and LAI-1 for CS service and Location update status is "U1: UPDATED".
        Preamble:
            -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].
    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellB );

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_4_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_3_2_4_EUTRA
  
  
  function fl_TC_9_2_3_2_4_Body( ) runs on EUTRA_PTC
  {
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
    var NAS_MSG_Indication_Type v_NasInd;
    var EPS_BearerContextStatus v_EPS_ContextStatus;
    var template (omit) EMM_Cause v_EMMCause:=cs_EMM_Cause_v(tsc_Cause_CSDomainNotAvailable);
    var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var float v_NoReactionTime := f_EUTRA_SetTimerToleranceMax( eutra_CellB, 3.0 );
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

    //@siclog "Step 1" siclog@
    //+ Set the cell type of Cell B to the "Serving cell". Set the cell type of Cell A to the "non-Suitable cell".
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    

    //The following messages are to be observed on Cell B
    //@siclog "Step 2" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE REQUEST message.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_TAU_Request(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                    v_AdditionalUpdateType
                                                                                    )));
    //@siclog "Step 3" siclog@
    //+ The SS transmits a TRACKING AREA UPDATE ACCEPT message.
    v_EPS_ContextStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cds_TAU_Accept_EMM_Cause ( v_UpdateType,
                                                                                 f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti2_Params ),
                                                                                 cs_TrackingAreaIdListDef_lv,
                                                                                 v_EPS_ContextStatus,
                                                                                 f_EUTRA_GetCellLAI(eutra_CellB),
                                                                                 v_MSId,
                                                                                 f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                                 v_EMMCause
                                                                                 ) )  ));
    //@siclog "Step 4" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE COMPLETE message.
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

    //@siclog "Step 5" siclog@
    //+ The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

    //@siclog "Step 6" siclog@
    //+ Check: Does the test result of generic procedure in TS 36.508 subclause 6.4.2.5 indicate
    //         that the UE does not respond to paging when paged with GUTI-2 and with CN domain indicator set to "CS"?
    f_EUTRA_508Check_NASNoResponse ( eutra_CellB,
                                     cs_NasPaging_OneRecord(cs_PagingUE_Identity_S_TMSI(v_Guti2_Params.MME_Code, v_Guti2_Params.M_TMSI)),
                                     v_NoReactionTime );

    //@siclog "Step 7" siclog@
    // Check: Does the test result of generic test procedure in TS 36.508 subclause 6.4.2.2 indicate
    //        that the UE is in state Registered, Idle Mode on Cell B?
    f_EUTRA_508Check_IdleState ( eutra_CellB );

    //@siclog "Step 8" siclog@
    //+ Set the cell type of Cell A to the "Serving cell". Set the cell type of Cell B to the "non-Suitable cell".
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    
    //@siclog "Step 9" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE REQUEST message.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_TAU_Request(tsc_EpsUpdate_TaUpdate,
                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                    v_AdditionalUpdateType
                                                                                    )));
    //@siclog "Step 10" siclog@
    //+ The SS transmits a TRACKING AREA UPDATE ACCEPT message.
    v_EPS_ContextStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cs_508_TAU_Accept ( v_UpdateType,
                                                                          f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti1_Params ),
                                                                          cs_TrackingAreaIdListDef_lv,
                                                                          v_EPS_ContextStatus,
                                                                          f_EUTRA_GetCellLAI(eutra_CellA),
                                                                          v_MSId,
                                                                          f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)
                                                                          ) ) ));
    //@siclog "Step 11" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE COMPLETE message.
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

  } // function fl_TC_9_2_3_2_4_Body


  function f_TC_9_2_3_2_6_EUTRA() runs on EUTRA_PTC
  {
    /// @desc tracking area update / Rejected / Illegal ME

        /* (1)
        with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'Illegal ME' }
            then { UE considers the USIM as invalid for EPS services and non-EPS services and enters state EMM-DEREGISTERED }
            }
        */

        // Pre-test conditions
        // -------------------
        /* System Simulator:
            -   Cell A, Cell B and Cell C.
            -   If pc_UTRAN supported by UE, Cell 5.
            -   Cell 5 belongs to RAI-1(home PLMN)
            -   If pc_GERAN and NOT pc_UTRAN supported by UE, Cell 24.
            -   Cell 24 belongs to RAI-1(home PLMN)
            -   Cell A is "Serving cell" and Cell B, Cell C, Cell 5 and Cell 24 are "non-Suitable cell".
        UE:
            -   The UE is configured to initiate combined EPS/IMSI attach.
        Preamble:
            -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].

    */

    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell_UTRANCell );
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell );
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
    }

    f_UT_ConfigureCombinedAttach (UT); // R5-103341

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellC );

    if (pc_UTRA) {
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    } else if (pc_GERAN) {
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_6and7_Body(tsc_EmmCause_IllegalUe);

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E4_DEREGISTERED);
  } // function f_TC_9_2_3_2_6_EUTRA


  function f_TC_9_2_3_2_7_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Combined tracking area update / Rejected / EPS services and non-EPS services not allowed

        /* Test Purpose (TP)
        (1)
            with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set
                   to 'Combined TA/LA updating' }
              ensure that {
                  when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set
                         to 'EPS services and non-EPS services not allowed' }
              then { UE considers the USIM as invalid for EPS services and non-EPS services and enters
                     state EMM-DEREGISTERED }
            }
        */

        // Pre-test conditions
        // -------------------
        /* System Simulator:
        -   Cell A, Cell B and Cell C.
        -   If pc_UTRAN supported by UE, Cell 5.
        -   Cell 5 belongs to RAI-1(home PLMN)
        -   If pc_GERAN and NOT pc_UTRAN supported by UE, Cell 24.
        -   Cell 24 belongs to RAI-1(home PLMN)
        -   Cell A is "Serving cell" and Cell B, Cell C, Cell 5 and Cell 24 are "non-Suitable cell".
        UE:
        -   The UE is configured to initiate combined EPS/IMSI attach.
        None.
        Preamble:
        -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].

    */

    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell_UTRANCell );
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell );
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
    }

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellC );

    if (pc_UTRA) {
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    } else if (pc_GERAN) {
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_6and7_Body(tsc_Cause_EPSandNonEPSServNotAllowed);

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E4_DEREGISTERED);
  } // function f_TC_9_2_3_2_7_EUTRA

  function fl_TC_9_2_3_2_6and7_Body(B8_Type p_EmmCause ) runs on EUTRA_PTC
  {

    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var boolean v_TriggerRxd := false;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_MSG_Indication_Type v_NasInd;
    var charstring v_OtherPTC := "";

    if (pc_UTRA) {
        v_OtherPTC := "UTRAN";
      } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
      } else { // Neither UMTS, nor GSM, so just do LTE
        v_OtherPTC := "NONE";
    }

    //@siclog "Step 1" siclog@
    //+  Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    //The following messages are to be observed on Cell B unless explicitly stated otherwise.
    //@siclog "Step 2" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE REQUEST message.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                         cr_TAI_Any)));
    //@siclog "Step 3" siclog@
    //+  The SS transmits a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'Illegal ME'.
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT( p_EmmCause ))));

    //@siclog "Step 4" siclog@
    //+ The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

    //@siclog "Step 5" siclog@
    //+  Set the cell type of Cell B to the "non-Suitable cell". Set the cell type of Cell C to the "Serving cell".
    f_EUTRA_SetCellPower ( eutra_CellC, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    // The following messages are to be observed on Cell C unless explicitly stated otherwise.
    //@siclog "Step 6" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds? [1,F]
      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellC, f_EUTRA_SetTimerToleranceMin( eutra_CellC, 30.0 ));

    // EXCEPTION:   Steps 7a1 to 7a3 describe behaviour that depends on the UE capability;
    //              the "lower case letter" identifies a step sequence that take place if a capability is supported
    //@siclog "Steps 7a1 to 7a3" siclog@
    f_EUTRA_SetCellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    select (v_OtherPTC) {
           case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
          } case else {} // Do nothing
    }
    //@siclog "Step 8" siclog@
    //+  Set the cell type of the cell other than Cell A to the "non-Suitable cell". Set the cell type of Cell A to the "Serving cell".
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

    //The following messages are to be observed on Cell A unless explicitly stated otherwise.
    //@siclog "Step 9" siclog@
    //+ Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds? [1,F]
      f_EUTRA_CheckNoAttachOn1Cell(eutra_CellA, f_EUTRA_SetTimerToleranceMin( eutra_CellA, 30.0 ));
  } // function fl_TC_9_2_3_2_6and7_Body


function f_TC_9_2_3_2_9_EUTRA() runs on EUTRA_PTC
    {
     // @desc Combined tracking area update / Rejected / UE identity cannot be derived by the network
     /* Test Purpose (TP)
        (1)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'UE identity cannot be derived by the network' }
            then { UE deletes GUTI, last visited registered TAI, TAI list and KSI, enters the state EMM-DEREGISTERED, subsequently, automatically initiates the attach procedure and is still IMSI attached for non-EPS services }
                    }

        (2)
        with { UE has sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'UE identity cannot be derived by the network' }
            then { UE deletes P-TMSI, P-TMSI signature, RAI and GPRS ciphering key sequence number }
            }


        System Simulator:
            -   Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18].
            -   Cell A belongs to TAI-1(home PLMN) and is set to ''Serving cell''
            -   Cell B belongs to TAI-2(home PLMN, another TAC) and is set to ''Non-Suitable cell''
            -   If pc_UTRAN supported by UE, Cell 5 is configured.
            -   Cell 5 belongs to RAI-1(home PLMN) and is set to ''Non-Suitable cell''
            -   If pc_GERAN and NOT pc_UTRAN supported by UE, Cell 24 is configured.
            -   Cell 24 belongs to RAI-1(home PLMN) and is set to ''Non-Suitable cell''
        UE:
            -   The UE is configured to initiate combined EPS/IMSI attach.
            -   The UE has GUTI-1.
            -   The UE is registered on TAI-1.
            -   IF pc_GERAN or pc_UTRAN THEN the UE has TMSI-1, P-TMSI-1 and P-TMSI signature-1, and the UE is registered on LAI-1 and RAI-1.
        Preamble:
            -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].

     */

       var charstring v_OtherPTC := "";
       var template (value) CellPowerList_Type v_CellPowerList;
       var boolean v_TriggerRxd := false;

        if (pc_UTRA) {
          f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_UTRANCell);
          v_OtherPTC := "UTRAN";
        } else if (pc_GERAN) {
          f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell);
           v_OtherPTC := "GERAN";
        } else { // Neither UMTS, nor GSM, so just do LTE
          f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
          v_OtherPTC := "NONE";
        }

        f_UT_ConfigureCombinedAttach (UT); // R5-103341

        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_Def(eutra_CellB);

        if (pc_UTRA) {
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
        } else if (pc_GERAN) {
            v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
            f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
        } else { // supports neither UTRAN or GERAN
            f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        }

        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
        select (v_OtherPTC) { // send trigger to other RAT to change its power level too
          case ("UTRAN") {
            f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
          } case ("GERAN") {
            f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
          } case else {} // Do nothing
        }
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_2_9_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);

        // Remove cells
        f_EUTRA_ReleaseAllCells ( );

    } // end f_TC_9_2_3_2_9_EUTRA


    function fl_TC_9_2_3_2_9_Body() runs on EUTRA_PTC
    {
      var boolean v_TriggerRxd := false;
      var charstring v_OtherPTC := "";

      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_MSG_Indication_Type v_NasInd;
      var SRB_COMMON_IND v_ReceivedAsp;
      var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti_Params.PLMN_Identity);
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
      var template PTMSI_Signature v_PTMSISignature := omit;

      timer t_WaitTimer := f_EUTRA_SetTimerToleranceMin( eutra_CellB, 30.0 );

      //var Common_AuthenticationParams_Type v_Auth_Params;

      if (pc_UTRA or pc_GERAN) {
         v_PTMSISignature := cr_PTMSI_Signature (px_PTMSI_Def);
      }
     
      if (pc_UTRA) {
         v_OtherPTC := "UTRAN";
       } else if (pc_GERAN) {
         v_OtherPTC := "GERAN";
       } else { // Neither UMTS, nor GSM, so just do LTE
         v_OtherPTC := "NONE";
      }

      //@siclog "Step 1" siclog@
      v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //  The UE transmits a TRACKING AREA UPDATE REQUEST
      //@siclog "Step 2" siclog@
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cdr_TAU_Request_combinedupdate_OldGuti_LAI_PTMSI
                                                                                           (v_UpdateType,
                                                                                           f_EUTRA_SecurityKSIasme_Get(),
                                                                                           v_AdditionalUpdateType,
                                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti_Params), //GUTI-1
                                                                                           v_LAI,
                                                                                           v_PTMSISignature
                                                                                           )));
 
      //@siclog "Step 3" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = "UE identity can not be derived
      // by the network"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_UEIdentityNotDerived))));

    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);
 
      //@siclog "Step 4" siclog@
      // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds? (P)
      t_WaitTimer.start;
      alt {
       [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellB, cr_RRCConnectionRequest(cr_EstablishmentCause_Any)))
        {
           t_WaitTimer.stop;
           f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellB, cs_TimingInfo_Now, tsc_RRC_TI_Def);
           SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellB,
                                              cr_508_RRCConnectionSetupComplete(tsc_RRC_TI_Def, ?),
                                              cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                cdr_ATTACH_REQUEST_WithImsiAndLAI(
                                                                                   v_AttachType,
                                                                                   v_AdditionalUpdateType,
                                                                                   v_LAI))))
                                 -> value v_ReceivedAsp;
           f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
        }
       [] t_WaitTimer.timeout
        {
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 4");
        }
      }

 
      //  depends on the UE capability
      //@siclog "Step 5a1 - 5a7" siclog@
      select (v_OtherPTC) {
        case ("UTRAN") {
          f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
          v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side to finish
        } case ("GERAN") {
          f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
          v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side to finish
        } case else {
          // Finish Attach procedure on this cell
          //@siclog "Step 4a1 - 4a13" siclog@
          f_EUTRA_IdleUpdated_Step5_17 (eutra_CellB, STATE2_IDLEUPDATE, NORMAL, v_ReceivedAsp.Signalling.Nas[0]);
        }
      }
 
    }// end function fl_TC_9_2_3_2_9_Body


  function f_TC_9_2_3_2_10_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Combined tracking area update / Rejected / UE implicitly detached

        /* (1)
            with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
            ensure that {
              when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'Implicitly detached' }
                then { UE sends an ATTACH REQUEST message }
                }
        */

        // Pre-test conditions
        // -------------------
        /* System Simulator:
    -   Cell A and Cell B
    -   Cell A is set to the "Serving cell" and Cell B is set to the "non-Suitable cell".
    UE:
    -   The UE is configured to initiate combined EPS/IMSI attach.
    Preamble:
    -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].

    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellB );

    f_UT_ConfigureCombinedAttach (UT); // R5-103341

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_10_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_3_2_10_EUTRA

  function fl_TC_9_2_3_2_10_Body() runs on EUTRA_PTC
  {

    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var NAS_MSG_Indication_Type v_NasInd;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType :=f_GetEAttachType();

    //@siclog "Step 1" siclog@
    //+  Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "Serving cell".
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    //The following messages are to be observed on Cell B unless explicitly stated otherwise.
    //@siclog "Step 2" siclog@
    //+ The UE transmits a TRACKING AREA UPDATE REQUEST message.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                         cr_TAI_Any)));
    //@siclog "Step 3" siclog@
    //+  The SS transmits a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'Implicitly detached'.
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_EmmCause_ImplicitlyDetached ))));

    //@siclog "Step 4" siclog@
    //+ Check: Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message?
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                tsc_RRC_TI_Def,
                                                cr_EstablishmentCause_Any,
                                                cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                          cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                          cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                          f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");

    //@siclog "Step 5 - 16" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellB, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false);

    } // function fl_TC_9_2_3_2_10_Body


  function f_TC_9_2_3_2_12_EUTRA() runs on EUTRA_PTC
  {
    /// @desc Combined tracking area update / Rejected / Tracking area not allowed

    /* (1)
        with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'Tracking Area not allowed' }
            then { UE sets the EPS update status to EU3 ROAMING NOT ALLOWED, deletes any GUTI, last visited registered TAI, TAI List and KSI, enters the state EMM-DEREGISTERED.LIMITED-SERVICE and stores the current TAI in the list of "forbidden tracking areas for regional provision of service" }
                    }

        (2)
        with { UE in EMM-DEREGISTERED.LIMITED-SERVICE state having the list of "forbidden tracking areas for regional provision of service" }
        ensure that {
          when { serving cell belongs to TAI where UE was rejected }
            then { UE does not attempt to attach }
                    }

        (3)
        with { UE in EMM-DEREGISTERED.LIMITED-SERVICE state having the list of "forbidden tracking areas for regional provision of service" }
        ensure that {
          when { UE reselects a new cell which belongs to the TAI in the list of "forbidden tracking areas for regional provision of service" }
            then { UE does not attempt to attach }
                    }

        (4)
        with { UE is powered off or switched off }
        ensure that {
          when { UE is powered on or switched on in the cell belonging to the TAI which was in the list of "forbidden tracking areas for regional provision of service" before the UE was powered off or switched off }
            then { UE attempts to attach }
                    }

    */

    // Pre-test conditions
    // -------------------
    /* System Simulator:
        -   Cell A, Cell B and Cell M.
        -   Cell A is set to the "Serving cell", and Cell B and Cell M is set to the "non-Suitable cell".
        UE:
        -   The UE is configured to initiate combined EPS/IMSI attach.
        Preamble:
        -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].

    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellB );
    f_EUTRA_CellConfig_SRBs_Only( eutra_CellM );

    f_UT_ConfigureCombinedAttach (UT); // R5-103341

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellM, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_2_12_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_3_2_12_EUTRA

  function fl_TC_9_2_3_2_12_Body() runs on EUTRA_PTC
  {
    const ReleaseCause tsc_RrcReleaseCause := other;

    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    // temporary dummy variable which gets used when receiving NAS ASPs
    var NAS_MSG_Indication_Type v_NasInd;
    var template TMSI_Status v_TMSI_Status := omit;
    var NAS_AttDetValue_Type v_AttachType :=f_GetEAttachType();
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();

    //@siclog "Step 1" siclog@
    //+   Set the cell type of cell B to the ''Serving cell''.Set the cell type of cell A to the ''Suitable cell''.
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now );


    //@siclog "Step 2" siclog@
    //+   The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B (specific msg. content)
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                         f_EUTRA_SecurityKSIasme_Get(),
                                                                                         v_AdditionalUpdateType,
                                                                                         f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                         cr_TAI_Any)));
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

    //@siclog "Step 3" siclog@
    //+   The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause = "Tracking area not allowed" as specified.
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_TA_NotAllowed ))));

    //@siclog "Step 4" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, tsc_RrcReleaseCause);

    //@siclog "Step 5" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell A or B? (1,2,F)
    f_EUTRA_CheckNoAttachOn2Cells ( eutra_CellA, eutra_CellB, 30.0);

    //@siclog "Step 6" siclog@
    //+  Set the cell type of Cell A to the "non-Suitable cell". Set the cell type of Cell B to the "non-Suitable cell". Set the cell type of Cell M to the "Serving cell".
    f_EUTRA_SetCellPower ( eutra_CellM, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    //@siclog "Step 7" siclog@
    //+   Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds? (3,F)
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellM, 30.0);

     //@siclog "Step 8" siclog@
    //+ Set the cell type of Cell A to the "Serving cell". Set the cell type of Cell M to the "non-Suitable cell".
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellM, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

    //@siclog "Step 9" siclog@
    //+   Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds? (3,F)
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellA, 30.0);

    //@siclog "Step 10" siclog@
    //+ The UE is powered off or switched off.
    f_UT_SwitchOffUE(UT, false);
  
    //@siclog "Step 11" siclog@
    //+  The UE is powered on or switched on.
    f_UT_SwitchOnUE(UT, false);
  
    if (pc_CS_Fallback or pc_SMS_SGs_MO or pc_SMS_SGs_MT) {
        v_TMSI_Status := cr_TMSI_Status('0'B);
      }

    //@siclog "Step 12" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message?[1,4 P] (specific msg. content)
      v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                            tsc_RRC_TI_Def,
                                            cr_EstablishmentCause_Any,
                                            cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                              cdr_ATTACH_REQUEST_WithIMSIAndnoTAI(v_AttachType,
                                                                                                                  v_AdditionalUpdateType,
                                                                                                                  f_Imsi2MobileIdentity(px_IMSI_Def),
                                                                                                                  v_TMSI_Status),
                                                                              cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                              f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 12");
    
    //@siclog "Step 13 - 24" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false);

  } // function fl_TC_9_2_3_2_12_Body


    function f_TC_9_2_3_2_15_EUTRA() runs on EUTRA_PTC
    {
     // @desc Combined tracking area update / Rejected / No suitable cells in tracking area
     /* Test Purpose (TP)
        (1)
        with { UE having sent a TRACKING AREA UPDATE REQUEST message with EPS update type set to 'Combined TA/LA updating' }
        ensure that {
          when { UE receives a TRACKING AREA UPDATE REJECT message with the EMM cause set to 'No Suitable Cells In tracking area' }
            then { UE selects a suitable cell in another tracking area in the same PLMN and performs the tracking area updating procedure with EPS update type set to 'combined TA/LA updating with IMSI attach' }
                    }


       System Simulator:
        -   Cell A, Cell B and Cell C.
        -   Cell A is set to the "Serving cell" and Cell B and Cell C is set to the "non-Suitable cell".
        UE:
        -   The UE is configured to initiate combined EPS/IMSI attach.
        Preamble:
        -   The UE is in state Registered, Idle mode (state 2) on Cell A according to [18].


     */
        var template (value) CellPowerList_Type v_CellPowerList;
       
        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_SRBs_Only(eutra_CellB);
        f_EUTRA_CellConfig_SRBs_Only(eutra_CellC);

        f_UT_ConfigureCombinedAttach (UT); // R5-103341

        // Go to state 2
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

        // The SS pre-configures Cell A as the "Serving cell" and Cells B, C and G as "Non-Suitable cell"
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_2_15_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellC, E2_CONNECTED);
    } // end f_TC_9_2_3_2_15_EUTRA


    function fl_TC_9_2_3_2_15_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NasInd;
      var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellC);
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti_Params.PLMN_Identity);
      var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellC );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellC );
      var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
      var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
          
      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Non-Suitable cell"
      // Set the cell type of cell B to the "Serving cell".
      // Set the cell type of cell C to the "Suitable neighbour cell".
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
         cs_CellPower ( eutra_CellC, tsc_SuitableCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
 

      //@siclog "Step 2" siclog@
      // The UE transmits a TRACKING AREA UPDATE REQUEST on Cell B.
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cr_508_TAU_Request(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                      f_EUTRA_SecurityKSIasme_Get(),
                                                                                      v_AdditionalUpdateType
                                                                                      )));
 
      //@siclog "Step 3" siclog@
      // The SS transmits a TRACKING AREA UPDATE REJECT message with EMM cause set to
      // "No suitable cells in tracking area"
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellB,
                                   cs_TimingInfo_Now,
                                   cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                  cs_508_TRACKING_AREA_UPDATE_REJECT(tsc_Cause_NoSuitableCells))));

      //@siclog "Step 4" siclog@
      //+  The SS releases the RRC connection
      f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

      //@siclog "Step 5" siclog@
      // Step 5 (specific msg contents)
      // Check: Does the UE send TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                    cr_508_TAU_Request(tsc_EpsUpdate_Combined_IMSIAttach,
                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                       v_AdditionalUpdateType
                                                                                      )));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");
      v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;

      //@siclog "Step 6" siclog@
      //+ The SS transmits a TRACKING AREA UPDATE ACCEPT message.
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellC,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cs_508_TAU_Accept ( v_UpdateType,
                                                                          f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti_Params ),
                                                                          v_TaiList,
                                                                          v_EpsBearerCtxtStatus,
                                                                          v_LAI,
                                                                          v_MSId,
                                                                          f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));
      //@siclog "Step 7" siclog@
      //+ The UE transmits a TRACKING AREA UPDATE COMPLETE message.
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellC,
                                          cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_TAU_Complete ) ) );
 
    }// end function fl_TC_9_2_3_2_15_Body


    function f_TC_9_2_3_2_17_EUTRA() runs on EUTRA_PTC
    {
     // @desc Combined tracking area update / Abnormal case / handling of the EPS tracking area updating attempt counter
     /* Test Purpose (TP)
        (1)
        with { UE has initiated combined tracking area updating procedure and has the tracking area updating attempt counter less than 5 }
        ensure that {
          when { UE detects release of the NAS signalling connection and in a EPS update status different to EU1 UPDATED and update status different from U1 UPDATED }
            then { UE starts timer T3411, deletes any LAI, TMSI, ciphering key sequence number and list of equivalent PLMNs and set the update status to U2 NOT UPDATED }
                    }

        (2)
        with { UE has initiated combined tracking area updating procedure and has the tracking area updating attempt counter equal to 5 }
        ensure that {
          when { UE detects release of the NAS signalling connection }
            then { UE starts timer T3402, deletes any LAI, TMSI, ciphering key sequence number and list of equivalent PLMNs and set the update status to U2 NOT UPDATED }
            }


        Pre-test conditions
        System Simulator:
            -   Cell A, and Cell B.
        UE:
            -   The UE has GUTI-1.
        Preamble:
            -   UE is in state Registered, Idle Mode (state 2) on Cell A according to [18]
     */
       
        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
 
        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        f_EUTRA_CellConfig_SRBs_Only(eutra_CellB);

        // Go to state 2
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_2_17_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellB, E2_CONNECTED);
    } // end f_TC_9_2_3_2_17_EUTRA


    function fl_TC_9_2_3_2_17_Body() runs on EUTRA_PTC
    {
      var template (value) CellPowerList_Type v_CellPowerList;
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_MSG_Indication_Type v_NasInd;
      var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
      var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti1_Params.PLMN_Identity);
      var NAS_Tac v_Tac1 := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellB));
      var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

      timer t_WaitB := f_EUTRA_SetTimerToleranceMin( eutra_CellB, 25.0 );
      timer t_Wait_12Min := f_EUTRA_SetTimerToleranceMin( eutra_CellB, 720.0 );
          
      //@siclog "Step 1" siclog@
      // Set the cell type of cell A to the "Non-Suitable cell"
      // Set the cell type of cell B to the "Serving cell".
      v_CellPowerList := {
         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
         cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
 

      //@siclog "Step 2" siclog@
      // Check: Does the UE transmits a TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 v_RRC_TI,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                   cdr_TAU_Request_OldGuti(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                           f_EUTRA_SecurityKSIasme_Get(),
                                                                                           v_AdditionalUpdateType,
                                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                           cr_TAI(v_PLMN, v_Tac1))));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");

      //@siclog "Step 3" siclog@
      // Wait for 25s to ensure that T3430 and T3411 expire.
      // NOTE 1: The tracking area updating attempt counter is 1.
      t_WaitB.start;
      t_WaitB.stop;

      //@siclog "Step 4" siclog@
      // Check: Does the UE transmits a TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                    cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                                    omit,
                                                                                                    cr_TAI_Any,
                                                                                                    cr_TMSI_Status('0'B))));

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");

      //@siclog "Step 5" siclog@
      // Wait for 25s to ensure that T3430 and T3411 expire.
      // NOTE 2: The tracking area updating attempt counter is 2
      t_WaitB.start;
      t_WaitB.stop;

      //@siclog "Step 6" siclog@
      // Check: Does the UE transmits a TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                    cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                                    omit,
                                                                                                    cr_TAI_Any,
                                                                                                    cr_TMSI_Status('0'B))));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 6");

      //@siclog "Step 7" siclog@
      // Wait for 25s to ensure that T3430 and T3411 expire.
      // NOTE 3: The tracking area updating attempt counter is 3.
      t_WaitB.start;
      t_WaitB.stop;

      //@siclog "Step 8" siclog@
      // Check: Does the UE transmits a TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                    cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                                    omit,
                                                                                                    cr_TAI_Any,
                                                                                                    cr_TMSI_Status('0'B))));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 8");

      //@siclog "Step 9" siclog@
      // Wait for 25s to ensure that T3430 and T3411 expire.
      // NOTE 4: The tracking area updating attempt counter is 4.
      t_WaitB.start;
      t_WaitB.stop;

      //@siclog "Step 10" siclog@
      // Check: Does the UE transmits a TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                    cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                                    omit,
                                                                                                    cr_TAI_Any,
                                                                                                    cr_TMSI_Status('0'B))));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 10");

      //@siclog "Step 11" siclog@
      // The SS releases the RRC connection.
      // NOTE 5: The tracking area updating attempt counter is 5 and reset.
      f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

      //@siclog "Step 12" siclog@
      //+  Wait for 12 min to ensure that T3402 expires.
      t_Wait_12Min.start;
      t_Wait_12Min.stop;
      
      //@siclog "Step 13" siclog@
      //+  Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message?
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                    cdr_TAU_RequestOldGutiLaiTmsiStatus(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                                    omit,
                                                                                                    cr_TAI_Any,
                                                                                                    cr_TMSI_Status('0'B))));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 13");

    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
      //@siclog "Step 14" siclog@
      //+  The SS transmits a TRACKING AREA UPDATE ACCEPT message.
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                       cs_TimingInfo_Now,
                                       cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_TAU_Accept ( v_UpdateType,
                                                                           f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_Guti2_Params ),
                                                                           cds_TAIListNonConsecutive_tlv( v_PLMN, {'0002'O} ), //TAC-2
                                                                           v_EpsBearerCtxtStatus,
                                                                           f_EUTRA_GetCellLAI(eutra_CellB),
                                                                           v_MSId,
                                                                           f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));

      //@siclog "Step 15" siclog@
      //+  The UE transmits a TRACKING AREA UPDATE COMPLETE message.
      SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellB,
                                          cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_TAU_Complete ) ) );
 
    }// end function fl_TC_9_2_3_2_17_Body


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.3.1
  ///////////////////////////////////////////////////////////////////////////////
  function f_TC_9_2_3_3_1_EUTRA() runs on EUTRA_PTC
  {
    /// @desc First Iu mode to S1 mode intersystem change after attach; go to E-UTRAN RRC idle; RAU to UTRAN

    /*
       (1)
       with { the UE is powered on in UTRAN with a USIM containing valid EPS identities and EPS security context and has attached in UTRAN and activated a PDP context  }
       ensure that {
       when { the UE reselects a E-UTRAN cell }
       then { the UE transmits a TRACKING AREA UPDATE REQUEST message including eKSI stored in the USIM, old GUTI mapped from RAI and P-TMSI, GPRS ciphering sequence number, nonceUE and the UE radio capability information update needed IE, the message is integrity protected using the EPS security context stored in the USIM and encapsulated in an RRCConnectionSetupComplete message whith registeredMME set to the MME part of the mapped GUTI }
       (2)
       with { the UE has performed a TAU procedure in EUTRAN after initial registration at power on in UTRAN  }
       ensure that {
       when { the UE reselects a UTRAN cell }
       then { the UE transmits a ROUTING AREA UPDATE REQUEST message including P-TMSI and P-TMSI signature mapped from GUTI, previously allocated P-TMSI as additional mobile identity, RAI where P-TMSI was allocated as additional old routing area identification, eKSI allocated in UTRAN as GPRS ciphering key sequence number, the message is encapsulated in an INITIAL DIRECT TRANSFER message including IDNSS mapped from P-TMSI, START value set to 0 and PLMN identity }
       (3)
       with { the UE has performed a TAU procedure in EUTRAN after initial registration at power on in UTRAN and has transmitted a ROUTING AREA UPDATE REQUEST message }
       ensure that {
       when { the UE receives a SECURITY MODE COMMAND message }
       then { the UE transmits a SECURITY MODE COMPLETE and starts performing ciphering an integrity protection using CK' and IK' derived from KASME and UL NAS COUNT }

       Note: ISR considered not in the scope of this test case, so it is never activated.

    */

    // Pre-test conditions
    /*
      System Simulator:
      - Cell A, and Cell 5 (UTRA cell in LAI-1/RAI-1)
      - Cell 5 is configured as Serving cell, Cell A as Non-Suitable Off cell.
      Note: For Cell 5, power levels are defined in TS 34.108 subclause 6.1.5 (FDD) or 6.1.6 (TDD).
      UE:
      - The test USIM contains a valid GUTI-1 and TAI-2, valid EPS security parameters, and EPS update status is "EU1: UPDATED".
      Preamble:
      - The UE is in state Switched OFF (state 1) according to TS 36.508, [18].
    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_UTRANCell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );

    // switch off cell A.
    f_EUTRA_SetCellPower(eutra_CellA, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_TestBody_Set(true);
    f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);

    fl_TC_9_2_3_3_1_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_ReleaseAllCells( );
  } // function f_TC_9_2_3_3_1_EUTRA

  function fl_TC_9_2_3_3_1_Body() runs on EUTRA_PTC
  {
    const ReleaseCause tsc_RrcReleaseCause := other;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var SRB_COMMON_IND v_ReceivedAsp;
    var boolean v_TriggerRxd := false;

    // ==========================================================================
    // initialize component specific data structures
    // ==========================================================================
    // get all data which are required for a GUTI
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti1_Params);
    //var GutiParameters_Type v_Guti3_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti2_Params);
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
    //var NAS_Tac v_TAC := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA));
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
    //var Common_AuthenticationParams_Type v_Auth_Params;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();
    //+ Step 2 to step 14 are implementaed in UTRAN side.

    //@siclog "Step 14" siclog@
    //+   Cell A is configured as the Serving Cell, Cell 5 is configured as a Suitable Neighbour Cell.
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);

    //@siclog "Step 15" siclog@
    //+   Check: does the UE send an RRCConnectionRequest with the InitialUE-Identity set to "randomValue" and the establishmentcause
    //     set to MO-signalling on Cell A?
    SRB.receive( car_SRB0_RrcPdu_IND ( eutra_CellA,
                                       cdr_RRCConnectionRequest_NotSTMSI ( cr_EstablishmentCause_MoSignalling ) ) );
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 15");

    //@siclog "Step 16" siclog@
    //+   The SS responds with RRCConnectionSetup
    f_EUTRA_RRC_ConnectionSetup_Def ( eutra_CellA, cs_TimingInfo_Now, v_RRC_TI );

    //@siclog "Step 17" siclog@
    //+   Check: does the UE send an RRCConnectionSetupComplete with the selectedPLMN-identity set to the value of the registered MME
    //(i.e. to the value in the GUTI stored on the USIM in EFEPSLOCI), and, the mmegi and mmec are set to the values derived from the GUTI stored on the USIM in EFEPSLOCI; [1,P]
    //  Check: are the contents of the TRACKING AREA UPDATE REQUEST with the correct parameters? [2,3,P]
    SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?,
                                                                         cr_RegisteredMME(v_Guti1_Params.PLMN_Identity,
                                                                                          v_Guti1_Params.MME_GroupId,
                                                                                          v_Guti1_Params.MME_Code)), //TODO, MME from step 8
                                       cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                         cdr_TAU_Request_OldandAdditionalGuti(v_UpdateType,
                                                                                              f_EUTRA_SecurityKSIasme_Get(),
                                                                                              v_AdditionalUpdateType,
                                                                                              ?, //TODO, old GUTI come from step 8, how to map from P-TMSI and RAI?
                                                                                              f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                              cs_UeRadioCap))))-> value v_ReceivedAsp;
    //TODO,GPRS ciphering key sequence number should be added after baseline move forward.
   f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 17");

    //@siclog "Step 18" siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT
    //  Note: the default message contents cause the allocation of a new GUTI and new TAI list
    v_EpsBearerCtxtStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(
                                                                  v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                  cds_TAIListNonConsecutive_tlv(
                                                                                              v_PLMN,
                                                                                              { '0001'O, '0002'O }), // TAC1=1, TAC2=2
                                                                  v_EpsBearerCtxtStatus,
                                                                  v_LAI,
                                                                  f_GetMSId ( ),
                                                                  f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));
    //@siclog "Step 18A" siclog@
    // The UE sends TRACKING AREA UPDATE COMPLETE.
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

    //+  the SS releases the RRC connection
    //@siclog "Step 19" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, tsc_RrcReleaseCause);

    //@siclog "Step 20 Void" siclog@
    //@siclog "Step 21" siclog@

    //+  Cell 5 is configured as the Serving Cell and Cell A is configured as a Suitable Neighbour Cell as defined in table 6.2.2.1-1 of TS 36.508 [18].
    //    Note: Cell A is still suitable but the UE shall select Cell 7.
    f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);

    //+ Step 22 to 28 are implemented in UTRAN side.
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN);
  } // function fl_TC_9_2_3_3_1_Body

  // ===============================================================
 /**
   *@desc: Periodic Routing Area Update (multi RAT test)
   */
  function f_TC_9_2_3_3_5_EUTRA() runs on EUTRA_PTC
  {
   /*
    Test Purpose (TP)
  (1)
  with { UE is camped on an E-UTRAN cell or in ECM-CONNECTED state and ISR is activated }
  ensure that {
    when { UE performs E-UTRA RRC state transitions }
      then { UE keeps the periodic routing area update timer T3312 running }
              }
   (2)
  with { UE is camped on an E-UTRAN cell or ECM-CONNECTED state and ISR is activated }
  ensure that {
    when { the periodic routing area update timer T3312 expires }
      then { UE does not change RAT }
              }
  (3)
  with { UE is in state GMM-REGISTERED.NO-CELL-AVAILABLE and ISR is activated and the periodic routing area update timer T3312 expires }
  ensure that {
    when { UE enters the state GMM-REGISTERED.NORMAL-SERVICE }
      then { UE initiates the routing area updating procedure }

    */

    /*
    Pre-test conditions
    System Simulator:
    -   Cell A and if pc_UTRAN  Cell 5 or if (NOT pc_UTRAN AND pc_GERAN) Cell 24:
    -   Cell A belongs to TAI-1 (home PLMN) and is set to "Serving cell"
    -   if pc_UTRAN, Cell 5 (only active when stated)
    -   home PLMN
    -   RAI-1 (RAC & LAC values chosen by SS)
    -   System information indicate that NMO 1 is used
    -   Set to ''Non-suitable cell''
    -   if  (NOT pc_UTRAN AND pc_GERAN), Cell 24 (only active when stated)
    -   home PLMN
    -   RAC-1 (RAC & LAC values chosen by SS)
    -   System information indicate that NMO 1 is used
    -   Set to ''Non-suitable cell''
    UE:
    -   The test USIM contains IMSI-1, GUTI-1 and TAI-1 (MCC1/MNC1/TAC1), and EPS update status is "EU1: UPDATED".
    -   if pc_UTRAN or pc_GERAN, the test USIM contains P-TMSI-1 (belonging to RAI-1) and the update status is "U1: UPDATED".
    Preamble:
    -   The UE is in state Registered, Idle Mode (state 2) on Cell A according to [18].

    */
    var boolean v_TriggerRxd := false;
    if (pc_UTRA) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_UTRANCell);
    } else if (pc_GERAN) {
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell);
    } else { // Neither UMTS, nor GSM, so just do LTE
      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
    }

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);

    if (pc_UTRA) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    } else if (pc_GERAN) {
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    } else { // supports neither UTRAN or GERAN
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    }
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_3_5_Body();
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_ReleaseAllCells( ); //UE turned off on UTRAN cell, just release cell
  }// function f_TC_9_2_3_3_5_EUTRA

//!!!!!!!!Guard timer should be 20 mins !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1Hellen
  function fl_TC_9_2_3_3_5_Body() runs on EUTRA_PTC
  {
    var boolean v_TriggerRxd := false;
    var charstring v_OtherPTC := "";
 //   var Common_AuthenticationParams_Type v_Auth_Params;
    timer t_T3312 := f_EUTRA_SetTimerToleranceMax (eutra_CellA, 7.0*60.0); // Periodic Routing Area Update timer on UTRAN
    timer t_Wait1Min := f_EUTRA_SetTimerToleranceMax(eutra_CellA, 60.0);
    timer t_Wait2Min := f_EUTRA_SetTimerToleranceMax(eutra_CellA, 120.0);

    if (pc_UTRA) {
       v_OtherPTC := "UTRAN";
     } else if (pc_GERAN) {
       v_OtherPTC := "GERAN";
     } else { // Neither UMTS, nor GSM, so just do LTE
       v_OtherPTC := "NONE";
    }

    // Step 1a/b1. IF pc_UTRAN THEN the SS sets the cell type of Cell 5/24 to "Serving cell" and
    // the cell type of Cell A to "Non-suitable cell".
    //@siclog "Step 1" siclog@
    select (v_OtherPTC) { // send trigger to other RAT to change its power level too
      case ("UTRAN") {
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
      } case ("GERAN") {
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
      } case else {} // Do nothing
    }

   // Wait for 1 minute.
   //@siclog "Step 2" siclog@
   t_Wait1Min.start;
   t_Wait1Min.stop;

   //@siclog "Step 3 - 6" siclog@
   f_EUTRA_RbEst_508_AM(eutra_CellA);
   //@siclog "Step 7 - 8" siclog@
   fl_DeactivateEPSBearer(eutra_CellA);

   //@siclog "Step 9a1 - 9a5" siclog@
    select (v_OtherPTC) { // send trigger to other RAT to change its power level too
      case ("UTRAN") {
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
        t_T3312.start;
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
      } case ("GERAN") {
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
        t_T3312.start;
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
      } case else {} // Do nothing
    }

   // Wait for 1 minute.
   //@siclog "Step 10" siclog@
   t_Wait1Min.start;
   t_Wait1Min.stop;

   //@siclog "Step 11 - 14" siclog@
   f_EUTRA_RbEst_508_AM(eutra_CellA);
   //@siclog "Step 15" siclog@
   if (v_OtherPTC != "NONE") {
       t_T3312.timeout;
    }
   //@siclog "Step 16" siclog@
   f_EUTRA_508Check_DedicatedEPSIsActive(eutra_CellA, tsc_EpsDedicatedBearerId, cs_508_EPS_QoS_Dedicated_1, cds_Tft_Dedicated_2_Modify(tsc_EpsDedicatedBearerId));

   //@siclog "Step 17 - 18" siclog@
   fl_DeactivateEPSBearer(eutra_CellA);

   //  Wait for 2 minutes.
   //@siclog "Step 19" siclog@
   t_Wait2Min.start;
   t_Wait2Min.stop;

   //  Check: Does the test result of generic test procedure in TS 36.508
   // subclause 6.4.2.2 indicate that the UE is in state Registered, Idle Mode on Cell A?
   //@siclog "Step 20" siclog@
    f_EUTRA_508Check_IdleState(eutra_CellA);

   //@siclog "Step 20a1" siclog@
    select (v_OtherPTC) { // send trigger to other RAT to change its power level too
      case ("UTRAN") {
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side
      } case ("GERAN") {
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
        f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);
        v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN); // wait for trigger from GERAN side
      } case else {
        // Incase only LTE, detach here so UE in right state for postamble
        f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE);
      }
    }

  }// function fl_tc_9_2_3_3_5_Body

  // ===============================================================
  /**
    * @desc E-UTRAN RRC connection failure / reselection of UTRAN cell / NAS signaling
    *        to release old S1 interface connection (multi RAT test)
    */
  function f_TC_9_2_3_3_6_EUTRA() runs on EUTRA_PTC
  {
    /*
    Test Purpose (TP)
     (1)
    with { UE is E-UTRA RRC_CONNECTED state and ISR not activated }
    ensure that {
      when { Radio link failure is detected and UE attempts to select a suitable E-UTRA cell to re-establish the RRC connection }
        then { UE can not find a suitable cell for T311 and leaves RRC_CONNECTED state with release cause 'RRC connection failure' }
     (2)
    with { UE searches for a suitable cell after an indication of E-UTRAN 'RRC connection failure'}
    ensure that {
      when { UE detects an UTRA cell and returns to coverage }
        then { UE performs a routing area update }
                }
    */

    /*
    Pre-test conditions

    System Simulator:
    -   Cell A is configured according to Table 6.3.2.2-1 in [18].
    -   Cell A belongs to TAI-1 and is set to "Serving cell"
    -   Cell 5 is configured according to Table 4.4.4-2 in [18].
    -   Cell 5 belongs to RAI-1 and is set to ''Non-suitable cell''
    -   System information indicate that NMO 1 is used
    UE:
    None.
    Preamble:
    -   UE is in state Generic RB established (state 3) on Cell A according to [18].

    */
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_UTRANCell);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);

    f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN);
    f_EUTRA_RbEst_Def(eutra_CellA); // Enter state 3, dedicated DRB established

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_3_6_Body();
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_ReleaseAllCells( );
  }// function f_TC_9_2_3_3_6_EUTRA


  function fl_TC_9_2_3_3_6_Body() runs on EUTRA_PTC
  {
    var boolean v_TriggerRxd := false;
    timer t_Wait;

    //@siclog "Step 1" siclog@
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    t_Wait.start( f_EUTRA_SetTimerToleranceMax ( eutra_CellA, 1.0));
    t_Wait.stop;

    //@siclog "Step 2" siclog@
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );
    f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger); // Send 2nd trigger to UTRAN side
    t_Wait.start( f_EUTRA_SetTimerToleranceMax ( eutra_CellA, 10.0));
    t_Wait.stop;

   //  Check: does the UE transmit a RRCConnectionReestablishmentRequest messages within the next 60s?
   //@siclog "Step 3" siclog@
   t_Wait.start(f_EUTRA_SetTimerToleranceMax ( eutra_CellA, 60.0));
   alt {
      [] SRB.receive( car_SRB0_RrcPdu_IND( eutra_CellA,
           cr_508_RRCConnectionReestablishmentRequest ( ?, ?, cr_ReestablishmentCause_Any ) ) )
      {
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 3");
      }
      [] t_Wait.timeout {   }
    }


   v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side

  }// function fl_tc_9_2_3_3_6_Body


  ///////////////////////////////////////////////////////////////////////////////
  // TC 9.2.3.4.1
  ///////////////////////////////////////////////////////////////////////////////
  function f_TC_9_2_3_4_1_EUTRA() runs on EUTRA_PTC
  {
    /// @desc TAU/RAU procedure for inter-system cell re-selection between A/Gb and S1 modes

    /*
    (1)
    with { UE attached to GERAN with a PDP context active, and, E-UTRAN NAS and Security parameters inclding a valid GUTI stored on the USIM  }
    ensure that {
      when { UE performs a cell reselection to E-UTRAN and performs a Tracking Area Update }
        then { the UE encodes the RRC parameters in the RRC Connection Establishment messages correctly (i.e. in the RRCConnectionRequest message, the InitialUE-Identity is set to "randomValue" and the establishmentcause is set to MO-signalling; and, in the RRCConnectionSetupComplete message the selectedPLMN-identity, mmegi and mmec indicate the value of the registered MME (e.g. as retrieved from the USIM at power-on, or, as received in the last TRACKING AREA UPDATE ACCEPT message) }
               }

    (2)
    with { UE attached to GERAN with a PDP context active, and, E-UTRAN NAS and EPS Security parameters including a valid GUTI stored on the USIM, and ISR not activated  }
    ensure that {
      when { UE performs a cell reselection to E-UTRAN and performs a Tracking Area Update }
        then { the UE encodes the parameters in the TRACKING AREA UPDATE REQUEST correctly i.e.:
               - the NAS key set identifierASME IE is set to the value stored in the USIM/allocated in
                      the last TRACKING AREA UPDATE ACCEPT message;
               - the Old GUTI IE is derived from the mapped P-TMSI and RAI;
               - the Additional GUTI IE is set to the GUTI stored in the USIM/allocated in the last
                      TRACKING AREA UPDATE ACCEPT message;
               - the GPRS cipherign key sequence number IE is set to the value allocated in the
                      AUTHENTICATION AND CIPHERING REQUEST message; and
               - the NONCEue IE is included;
               - the DRX parameter IE is not included. }
               }

    (3)
    with { UE powered on in GERAN }
    ensure that {
      when { UE makes its first Tracking Area Update to E-UTRAN}
        then { UE sends the UE radio capability information update needed IE }
               }

    (4)
    with { UE registered in E-UTRAN, and, GERAN NAS and Security parameters including a valid P-TMSI available in the UE and ISR not activated }
    ensure that {
      when { UE performs a cell reselection to GERAN and performs a Routeing Area Update }
        then { the UE derives the TLLI parameter in the RLC/MAC header from the GUTI allocated in the TRACKING AREA UPDATE ACCEPT message }
               }
    (5)
    with { UE registered in E-UTRAN, and, GERAN NAS and GERAN Security parameters including a valid P-TMSI available in the UE, and ISR not activated }
    ensure that {
      when { UE performs a cell reselection to GERAN and performs a Routeing Area Update }
        then { the UE encodes the parameters in the ROUTING AREA UPDATE REQUEST correctly i.e.:
               - [the GPRS ciphering key sequence number IE is set to the value mapped from
                      KSI-ASME;;]           - the Old routing area identification IE, and the Old P-TMSI signature IE are
                      mapped from the GUTI allocated in the TRACKING AREA UPDATE ACCEPT message;
               - the Additional mobile identity IE contains the P-TMSI allocated in the last received
                      ATTACH ACCEPT/ROUTING AREA UPDATE ACCEPT message;
               - the Additional old routing area identification IE contains the RAI allocated in the
                      last received ATTACH ACCEPT/ROUTING AREA UPDATE ACCEPT message; and
               - [the DRX parameter IE is not included]. }
               }

    (6)
    with { UE registered }
    ensure that {
      when { UE makes its second Tracking Area Update to E-UTRAN}
        then { UE does not send the UE radio capability information update needed IE }
               }
   */

    // Pre-test conditions
    /*
    System Simulator:
    NOTE:   while this test describes the uses of 3 cells, it is intended that this test only requires 2 cells to be active at any one instant.
    -   Cell A (E-UTRAN), Cell 24 and Cell 26 (GERAN)
        With the exception of the MCC and MNC, cell 24 and cell 26 take the default parameters of the GERAN cells as defined in clause 6.3.1 of TS 36.508 [18], Cells 24 and 26 are configured with the same MCC and MNC as cell A. Cells 24 and 26 are in the same Routeing Area.
    As defined in table 4.4.2-1 of TS 36.508 [18], cell 24 and cell 26 are GERAN cells.
    -
    -   -   As defined in clause 40.1 of TS 51.010 [23], the GERAN cells are configured to use Network Mode of Operation I.
    -   The power level of Cell 24 is the Serving Cell level defined in table 6.2.2.1-1 of TS 36.508 [18].
    -   The power levels of Cells A and 26 are set to the Non-suitable "Off" level defined in table 6.2.2.1-1 of TS 36.508 [18].
    UE:
    -   The test USIM contains a valid GUTI = GUTIx (stored in EFEPSLOCI), valid EPS security parameters (stored in EFEPSNSC), and EPS update status is "EU1: UPDATED". GUTIx has MNC=987, MCC= 65, MMEGI = 'fedc' hex, MMEC = 'ba' hex, and arbitrary M-TMSI.
    Preamble:
    -   The UE is in state Switched OFF (state 1) according to [18].

    */
    var template (value) PLMN_Identity v_HPLMN_987_65 := { mcc := {9, 8, 7},  mnc := {6, 5} };
    var  template(value) GutiParameters_Type v_Guti_Parameters := cs_Guti(v_HPLMN_987_65, 65244, 186);
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_GERANcell);
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti_Parameters);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);

    // Preamble: The UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, GERAN);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );

    // switch off cell A.
    f_EUTRA_SetCellPower(eutra_CellA, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_3_4_1_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_3_4_1_EUTRA

  function fl_TC_9_2_3_4_1_Body() runs on EUTRA_PTC
  {
    const ReleaseCause tsc_RrcReleaseCause := other;
    var SRB_COMMON_IND v_ReceivedAsp;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var boolean v_TriggerRxd := false;
    var IRAT_CoOrd_Auth_Type v_CoOrd_AuthParams;
    var EPS_UpdateTypeValue v_UpdateType := f_GetEPSTAUType();

    // ==========================================================================
    // initialize component specific data structures
    // ==========================================================================
    // get all data which are required for a GUTI
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti1_Params);
    var GutiParameters_Type v_Guti3_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti2_Params);
    var O10_Type v_GutiStringFromGERAN;
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
    var NAS_Tac v_TAC := bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA));
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var template (omit) LocAreaId v_LAI := f_GetLAI ( v_PLMN, v_LAC);
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var Common_AuthenticationParams_Type v_Auth_Params;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();

    v_SecurityParams.AuthParams.KeySeq := v_SecurityParams.KSIasme; // The KSIasme value needs to be passed over as it will be used as the GERAN CKSN
    f_EUTRA_Security_Set(v_SecurityParams);
    v_Auth_Params := f_AuthenticationInit(v_SecurityParams.AuthParams);
    f_EUTRA_SendAuthCoOrdParameters(GERAN, eutra_CellA, v_Auth_Params);

    //+ Steps 1 to step 9 are implemented in GERAN side.

    //@siclog "Step 10 - 12 Void" siclog@

    //@siclog "Step 13" siclog@
    //+   The signal strength of Cell A is raised to that of the Serving Cell and that of Cell 24 is lowered to that of a Suitable Neighbour Cell as defined in table 6.2.2.1-1 of TS 36.508 [18].
    //    Note: Cell 24 is still suitable but the UE is expected to select Cell A.
    v_CoOrd_AuthParams := f_ReceiveAuthCoOrdParameters(GERAN);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    v_GutiStringFromGERAN := v_PLMN & bit2oct(v_CoOrd_AuthParams.GutiParams.MME_GroupId) & bit2oct(v_CoOrd_AuthParams.GutiParams.MME_Code) & bit2oct(v_CoOrd_AuthParams.GutiParams.M_TMSI);

    //@siclog "Step 14 Void" siclog@

    //@siclog "Step 15" siclog@
    //+   Check: does the UE send an RRCConnectionRequest with the InitialUE-Identity set to "randomValue" and the establishmentcause
    //     set to MO-signalling on Cell A?
    // Editor's Note: Cell reselection to E-UTRAN might not occur until the GPRS READY timer has expired. Hence this step might occur up to 40 seconds after step 13.
    SRB.receive( car_SRB0_RrcPdu_IND ( eutra_CellA,
                                       cdr_RRCConnectionRequest_NotSTMSI ( cr_EstablishmentCause_MoSignalling ) ) );


    //@siclog "Step 16" siclog@
    //+   The SS responds with RRCConnectionSetup
    f_EUTRA_RRC_ConnectionSetup_Def ( eutra_CellA, cs_TimingInfo_Now, v_RRC_TI );

    //@siclog "Step 17" siclog@
    //+   Check: does the UE send an RRCConnectionSetupComplete with the selectedPLMN-identity set to the value of the registered MME
    //(i.e. to the value in the GUTI stored on the USIM in EFEPSLOCI), and, the mmegi and mmec are set to the values derived from the GUTI stored on the USIM in EFEPSLOCI; [1,P]
    //  Check: are the contents of the TRACKING AREA UPDATE REQUEST with the correct parameters? [2,3,P]
    SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?,
                                                                         cr_RegisteredMME(v_Guti1_Params.PLMN_Identity,
                                                                                          v_Guti1_Params.MME_GroupId,
                                                                                          v_Guti1_Params.MME_Code)),
                                       cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                         cdr_TAU_Request_OldandAdditionalGuti(v_UpdateType,
                                                                                              f_EUTRA_SecurityKSIasme_Get(),
                                                                                              v_AdditionalUpdateType,
                                                                                              cs_MobileIdentityGuti(omit, v_GutiStringFromGERAN),
                                                                                              f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                                              cs_UeRadioCap)))) -> value v_ReceivedAsp;
                                                                                                              //TODO,GPRS ciphering key sequence number should be added after baseline move forward.
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 17");

    //@siclog "Step 18" siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT
    //  Note: the default message contents cause the allocation of a new GUTI and new TAI list
    v_EpsBearerCtxtStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(
                                                                  v_UpdateType,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                  cds_TAIListNonConsecutive_tlv(
                                                                                              v_PLMN,
                                                                                              { '0001'O, '0002'O }), // TAC1=1, TAC2=2
                                                                  v_EpsBearerCtxtStatus,
                                                                  v_LAI,
                                                                  f_GetMSId ( ),
                                                                  f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );

    //+  The UE sends TRACKING AREA UPDATE COMPLETE
    //@siclog "Step 19" siclog@
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));

    //+ the SS releases the RRC connection
    //@siclog "Step 20" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, tsc_RrcReleaseCause);

    //+ Cell 24 is switched off
    //@siclog "Step 21" siclog@

    //@siclog "Step 22" siclog@
    // The signal strength of Cell 26 is raised to that of the Serving Cell and that of Cell A is lowered to that of a Suitable Neighbour Cell as defined in table 6.2.2.1-1 of TS 36.508 [18].
    // Note: Cell A is still suitable but the UE is expected to select Cell 26.
    f_EUTRA_SetCellPower(eutra_CellA, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger);

    //+ Step 21 to step 26 is implemented in GERAN side

    //@siclog "Step 27" siclog@
    //+  The signal strength of Cell A is raised to that of the Serving Cell and that of Cell 26 is lowered to that of a Suitable Neighbour Cell as defined in table 6.2.2.1-1 of TS 36.508 [18].
    //   Note: Cell 26 is still suitable but the UE is expected to select Cell A.
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(GERAN);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);

    //@siclog "Step 28" siclog@
    // Check: does the UE send on Cell A an RRCConnectionSetupComplete with the selectedPLMN-identity indicating the registered MME
    // (i.e. the PLMN in the GUTI allocated in step 18 ), and, the mmegi and mmec are set to the values in the GUTI allocated in step 18? [1,P]
    // Check: does the UE send a TRACKING AREA UPDATE REQUEST with the correct parameters? [2,6,P]
    SRB.receive( car_SRB0_RrcPdu_IND ( eutra_CellA,
                                       cr_RRCConnectionRequest(?) ) );

    f_EUTRA_RRC_ConnectionSetup_Def ( eutra_CellA, cs_TimingInfo_Now, v_RRC_TI );

    SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?,
                                                                         cr_RegisteredMME(v_Guti2_Params.PLMN_Identity,
                                                                                          v_Guti2_Params.MME_GroupId,
                                                                                          v_Guti2_Params.MME_Code)),
                                       cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                         cdr_TAU_Request_OldandAdditionalGuti(v_UpdateType,
                                                                                              f_EUTRA_SecurityKSIasme_Get(),
                                                                                              v_AdditionalUpdateType,
                                                                                              cs_MobileIdentityGuti(omit, v_GutiStringFromGERAN),
                                                                                              f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti2_Params),
                                                                                              omit)))) -> value v_ReceivedAsp;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 28");
    
    //@siclog "Step 29" siclog@
    // The SS sends TRACKING AREA UPDATE ACCEPT
    // Note: the default message contents cause the allocation of a new GUTI.
    v_EpsBearerCtxtStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                    cs_TimingInfo_Now,
                                    cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                   cs_508_TAU_Accept ( v_UpdateType,
                                                                       f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params),
                                                                       cds_TAIListNonConsecutive_tlv( v_PLMN, {v_TAC } ),
                                                                       v_EpsBearerCtxtStatus,
                                                                       v_LAI,
                                                                       f_GetMSId ( ),
                                                                       f_GetAdditionalUpdateResult( v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.aTTACH_REQUEST.addUpdateType)))));

    //@siclog "Step 30" siclog@
    //The UE sends TRACKING AREA UPDATE COMPLETE
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                     cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                         cr_508_TAU_Complete )));

    f_SendIRATCoOrd (GERAN, cms_IRAT_Trigger); //send Trigger to release GERAN cell.

  } // function fl_TC_9_2_3_4_1_Body

    function f_TC_9_2_3_3_4_EUTRA() runs on EUTRA_PTC
    {
     // @desc Attach in E-UTRAN / RAU to UTRAN / Go to UTRAN RRC idle / TAU in E-UTRAN
     /* Test Purpose (TP)
        (1)
        with { the UE powered on in E-UTRAN with a USIM containing valid E-UTRAN NAS and Security parameters including a valid GUTI, and has successfully performed a combined EPS/IMSI attach, established PDN connectivity, and performed TRACKING AREA UPDATE REQUEST  }
        ensure that {
          when { the UE reselects UTRAN configured in MNO=II and TIN is set to the temporary ID belonging to the currently used RAT (i.e. ISR not active) }
            then { the UE transmits a LOCATION UPDATING REQUEST to the MSC/VLR and derives the IDNNS from the MSC/VLR TMSI, and transmits a ROUTING AREA UPDATE REQUEST message including P-TMSI, P-TMSI signature including the NAS token, and RAI mapped from GUTI, the old routing area identification mapped from the RAI, the GPRS ciphering key sequence number indicating the eKSI associated with the EPS security context. Old P-TMSI signature and Old routing area identifion are mapped from the GUTI. The message is encapsulated in an INITIAL DIRECT TRANSFER message including IDNSS mapped from GUTI, Establishment cause set to inter-RAT cell-selection, START value set to 0 and PLMN identity }

        (2)
        with { the UE camped on E-UTRAN and has a valid GUTI and P-TMSI }
        ensure that {
          when { the UE reselects UTRAN and receives a new P-TMSI as part of the RAU procedure }
            then { the UE uses the new P-TMSI (and not GUTI or old P-TMSI) for subsequent IDNNS network access (e.g. via the Service Request procedure }
                   }

        (3)
        with { the UE has performed a RAU procedure in UTRAN after initial registration at power on in E-UTRAN  }
        ensure that {
          when { the UE reselects a E-UTRAN cell with the same LA as previously selected}
            then { the UE transmits a TRACKING AREA UPDATE REQUEST message including eKSI stored in the USIM,
            old GUTI mapped from RAI and P-TMSI, GPRS ciphering sequence number, nonceUE.
            The UE encodes the RRC parameters in the RRC Connection Establishment messages correctly
            (i.e. in the RRCConnectionRequest message, the InitialUE-Identity is set to "Random value"
             and the establishmentcause is set to MO-signalling; and, in the RRCConnectionSetupComplete
             message the selectedPLMN-identity, mmegi and mmec indicate the value of the registered MME
             (e.g. as retrieved from the USIM at power-on, or, as received in the last TRACKING AREA UPDATE
             ACCEPT message) }
           }

        System Simulator:
        -   Cell A, and Cell 5
        -   Cell A is configured as Serving cell, Cell 5 as Non-Suitable Off cells.
        -   Cell 5 is operating in network operation mode II (No Gs interface present).
        -   Cell A has the absolute priorities set to LTE.
        NOTE:   For Cell 5, power levels are defined in TS 34.108 subclause 6.1.5 (FDD) or 6.1.6 (TDD).
        UE:
        -   The test USIM contains a valid IMSI-1, P-TMSI-1, RAI-1, valid GUTI-1 and TAI-1, and valid EPS security parameters
        Preamble:
        -   The UE is in state Registered Idle Mode  (state 2) according to TS 36.508, [18]
       */

        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell_UTRANCell);

        // create cell and send out system information
        f_EUTRA_CellConfig_Def(eutra_CellA);
        // Go to state 2
        f_EUTRA_Preamble_InterRAT(eutra_CellA, STATE2_IDLEUPDATE, UTRAN, CombinedWithPTMSI);
 
        f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_3_3_4_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellA, E1_IDLE);

    } // end f_TC_9_2_3_3_4_EUTRA

 
    function fl_TC_9_2_3_3_4_Body() runs on EUTRA_PTC
    {
      var boolean v_TriggerRxd := false;

      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
      var EPS_BearerContextStatus v_EPS_ContextStatus;
      var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId(v_Guti1_Params.PLMN_Identity);
      var SRB_COMMON_IND v_ReceivedAsp;
      var NAS_KsiValue v_KsiValue := f_EUTRA_SecurityKSIasme_Get ( );
      var B3_Type v_EpsUpdate_TypeValue := f_GetEPSTAUType(); // @sic R5s100029 sic@
      var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
      var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
      var NasCount_Type v_NasCountUL;
      var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
      var template (omit) LocAreaId v_LAI := f_GetLAI (v_PLMN, v_LAC);
      var template (omit) MobileIdentity v_MSId := f_GetMSId (CombinedWithPTMSI);
      var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv( v_PLMN, { bit2oct(v_Tac) } );
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      
      //v_Auth_Params := f_AuthenticationInit(v_Auth_Params);
      //  f_EUTRA_SendAuthCoOrdParameters(UTRAN, eutra_CellA, v_Auth_Params);
      
      
      //The signal strength of Cell A is lowered to that of a non-suitable neighbour cell
      // @siclog "Step 1" siclog@
      f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
      f_SendIRATCoOrd (UTRAN, cms_IRAT_Trigger);
      // Steps 2 to 12 in UTRAN side
      v_TriggerRxd := f_WaitForIRATCoOrd_Trigger(UTRAN); // wait for trigger from UTRAN side to finish

      // Cell A is configured as the Serving cell and cell 5 is configured as a Suitable Neighbour Cell.
      //v_CoOrd_AuthParams := f_ReceiveAuthCoOrdParameters(UTRAN);
      f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
     // v_GutiStringFromUTRAN := v_PLMN & bit2oct(v_CoOrd_AuthParams.GutiParams.MME_GroupId) & bit2oct(v_CoOrd_AuthParams.GutiParams.MME_Code) & bit2oct(v_CoOrd_AuthParams.GutiParams.M_TMSI);

      // Step 12. Check: does the UE transmit an RRCConnectionRequest with the InitialUE-Identity
      //          set to "random value" and the establishmentcause set to MO-signalling?
      // @siclog "Step 12" siclog@
      SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA, cr_RRCConnectionRequest_withUE_Identity(
                                                                                      cr_InitialUE_Identity_Random,
                                                                                      mo_Signalling )));

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 12");
      

      // Step 13. The SS responds with RRCConnectionSetup
      // @siclog "Step 13" siclog@
      f_EUTRA_RRC_ConnectionSetup_Def ( eutra_CellA, cs_TimingInfo_Now, v_RRC_TI );

      v_SecurityParams := f_EUTRA_Security_Get();
      // Step 14
      // Check: does the UE transmit an RRCConnectionSetupComplete message with the mmegi and mmec
      //        set to the values derived from the mapped RAI and P-TMSI, and containing
      //        a TRACKING AREA UPDATE REQUEST message as described in the specific message contents?
      // NOTE: The UE should not include "radio capability information" in the TAU request.
      // @siclog "Step 14" siclog@
    /* The TAU Request shall be integrity-protected, but not confidentiality-protected.
       UE uses the cached security context algorithms to protect the TAU Request message.
       ( reuse of keys allocated during attach procedure )
       ( 33.401 cl. 9.1.2 Idle mode procedures in E-UTRAN ) */
        SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?,
                                                                         cr_RegisteredMME(omit,
                                                                                          v_Guti1_Params.MME_GroupId,
                                                                                          v_Guti1_Params.MME_Code)),
                                                               //TBD: values derived from the mapped RAI and P-TMSI?
                                                               //get params from step12...
                                                            cr_NAS_Indication(tsc_SHT_NoSecurityProtection,
                                                                    cdr_TAU_RequestIdleMobilityDiffRAT ( v_EpsUpdate_TypeValue,
                                                                                                         v_KsiValue,
                                                                                                         v_AdditionalUpdateType )))) -> value v_ReceivedAsp;
     // UE has now establish SRB1 acc. to 36.331 cl. 5.3.3.4 and entered RRC_CONNECTED state

     v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept
     v_SecurityParams.NonceUE := oct2bit(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.nonce.nonceValue);
     // Store NonceUE
     /* Step 4, 5: NAS Security Mode Command / NAS Security Mode Complete*/
    v_NasCountUL := f_EUTRA_NAS_ActivateSecurity_MappedContext(eutra_CellA, v_SecurityParams);

    /* In case MME has the cached security context it verifies the TAU Request message
       and replies with TAU Accept message protected with the cached security context
       ( 33.401 cl. 9.1.2 Idle mode procedures in E-UTRAN ) */
    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cs_508_TAU_Accept ( v_EpsUpdate_TypeValue,
                                                                          f_GutiParameters2MobileIdentity ('50'O, v_Guti1_Params ),
                                                                          v_TaiList,
                                                                          v_EPS_ContextStatus,
                                                                          v_LAI,
                                                                          v_MSId,
                                                                          f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType))) ) ); // @sic R5-103681 sic@

/*      SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?,
                                                                         cr_RegisteredMME(omit,
                                                                                          v_Guti1_Params.MME_GroupId,
                                                                                          v_Guti1_Params.MME_Code)),
                                                               //TBD: values derived from the mapped RAI and P-TMSI?
                                                               //get params from step12...
                                       cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                         cdr_TAU_fromUTRANRRCIdle(tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AuthParams.AuthParams,
                                                                                  v_Tmsi,
                                                                                  cs_MobileIdentityGuti(omit, v_GutiStringFromUTRAN),
                                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                                  cs_UeRadioCap)))) -> value v_ReceivedAsp;
                                                      

                                                                    EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                                    NAS_KsiValue p_KsiValue,
                                                                    template CiphKeySeqNum p_GPRSCiphering_SN,
                                                                    template PTMSI_Signature p_Ptmsi,
                                                                    template (present) MobileIdentity p_AdditionalGuti,
                                                                    template TrackingAreaId p_Tai,
                                                                    template (present) LocAreaId p_LAI
 

      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 14");

      // Step 15. The SS responds with a TRACKING AREA UPDATE ACCEPT message
      // @siclog "Step 15" siclog@
      v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
      SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                       cs_TimingInfo_Now,
                                       cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                        cs_508_TAU_Accept ( tsc_EpsUpdate_TaUpdate,
                                                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                            cds_TAIListNonConsecutive_tlv( v_PLMN, {'0001'O} ), //TAC-1
                                                                            v_EPS_ContextStatus,
                                                                            f_EUTRA_GetCellLAI(eutra_CellA),
                                                                            f_GetMSId ( ),
                                                                            v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );


 */
    // Step 16. The SS releases the RRC connection
    // @siclog "Step 16" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, other);
 
 
    }// end function fl_TC_9_2_3_3_4_Body
 
  } // end of group TestcaseImplementations
} // end of module
