// ***************************************************************************
// @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:45:21 +0200 (Fri, 17 Sep 2010) $
// * $Rev: 3956 $
// ***************************************************************************

module NAS_Attach_EOnly {

  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from EUTRA_Component all;
  import from EUTRA_CellInfo all;
  import from EUTRA_ASP_SrbDefs all;
  import from Parameters all;
  import from EUTRA_LoopBack all;
  import from CommonDefs all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_RRC_Templates all;
  import from EUTRA_SRB_Templates all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_CommonProcedures all;
  import from EUTRA_Paging all;
  import from NAS_CommonTypeDefs all;
  import from EPS_NAS_TypeDefs all;
  import from EPS_NAS_Constants all;
  import from EPS_NAS_Templates all;
  import from NAS_CommonTemplates all;
  import from EUTRA_NASCommonFunctions all;
  import from EUTRA_NASCommonTemplates all;
  import from EPS_NAS_MsgContainers all;
  import from EUTRA_RRCSteps all;
  import from EUTRA_NASSteps all;
  import from EUTRA_ConfigurationSteps all;
  import from UpperTesterFunctions all;
  import from EUTRA_AuxiliaryFunctions all;
  import from NAS_AuxiliaryDefsAndFunctions all;
  import from EUTRA_SecurityFunctions all;
  import from NAS_24008Templates all;
  import from EUTRA_SecuritySteps all;
  import from EUTRA_Timing all;
  import from L2_CommonFunctions all;
  import from EUTRA_CellInfoFrequency all;
  import from EUTRA_SysInfo_Templates all;

  group LocalTemplates {
  
  template (value) AccessBarringInformation_Type cs_AccessBarringInformation_TC_9_1_1_20 :=
  { /* @status    APPROVED */
    ac_BarringForEmergency := false,
    ac_BarringForMO_Signalling := {
      ac_BarringFactor := p00,
      ac_BarringTime := s4,
      ac_BarringForSpecialAC := '11111'B
    },
    ac_BarringForMO_Data := omit
  };
  
  template NAS_UL_Message_Type cdr_ATTACH_REQUEST_IMSIonly(template (present) NAS_AttDetValue_Type p_AttachTypeValue,
                                                           template AdditionalUpdateType p_AdditionalUpdateType)
    modifies cr_508_ATTACH_REQUEST  :=
  { /* @status    APPROVED */
    aTTACH_REQUEST := {
      oldGutiOrImsi            := f_Imsi2MobileIdentity(px_IMSI_Def),
      lastVisitedRegisteredTai := omit
    }
  };
  
  template (value) PartialTaiType cs_MultiplePlmnsList (template (value) PlmnAndTacs p_PlmnAndTacs) :=
  {
    type2List := {
      {
        plmnAndTacs := p_PlmnAndTacs
      }
    }
  };
  
  template (value) PartialTai cs_PartialTAI(NAS_PlmnId  p_PlmnId,
                                            NAS_Tac p_Tac) :=
  {
    plmnId := p_PlmnId,
    tac := p_Tac
  };
  
  template (value) ListOfPartialTaiList cs_PartialTaiListConsecutive (integer p_NumOfTACs, template(value)  PartialTai p_PartialTAI) :=
  {
    spareBit         := tsc_Spare1,
    typeOfList       := tsc_ConsecutiveTacs,
    numberOfElements := int2bit((p_NumOfTACs - 1), 5),
    partialTaiList := {
      type1List := {
        {
          partialTac := p_PartialTAI
        }
      }
    }
  };
  
  template (value) ListOfPartialTaiList cs_PartialTaiListMultiplePlmns (template(value)  PartialTaiType p_PartialTAIList) :=
  {
    spareBit         := tsc_Spare1,
    typeOfList       := tsc_MultiplePlmns,
    numberOfElements := int2bit((2), 5),
    partialTaiList   := p_PartialTAIList
  };
  
  template (value) TrackingAreaIdList cs_TAIListMultiplePlmns (template(value)  PartialTaiType p_PartialTAI) :=
  {
    iei := omit,
    iel := int2oct(11, 1),
    listOfPartialTais := {cs_PartialTaiListMultiplePlmns (p_PartialTAI)}
  };
  
  template (value) TrackingAreaIdList cs_TAIListMultiplePlmns_multiTAI (template(value) PartialTaiType p_MultiplePlmnPartialTAI,
                                                                        integer p_NumOfConsecutiveTACs,
                                                                        template(value)  PartialTai p_ConsecutivePartialTAI,
                                                                        NAS_PlmnId  p_NonConsecutivePlmnId,
                                                                        NAS_TacList p_NonConsecutiveTacList) :=
  {
    iei := omit,
    iel := int2oct(32, 1),
    listOfPartialTais := {cs_PartialTaiListMultiplePlmns (p_MultiplePlmnPartialTAI),
                          cs_PartialTaiListConsecutive (p_NumOfConsecutiveTACs, p_ConsecutivePartialTAI),
                          cs_ListNonConsecutivePartialTaiList (p_NonConsecutivePlmnId, p_NonConsecutiveTacList)
    }
  };
  
  
  
  template (value) PLMN_List cs_PLMN_List_4PLMNs(octetstring p_Plmn1,
                                                 octetstring p_Plmn2,
                                                 octetstring p_Plmn3,
                                                 octetstring p_Plmn4) :=
  {
    iei             := '4A'O,                  // '01001010'B
    iel             := '0C'O,
    plmnList        := { p_Plmn1, p_Plmn2, p_Plmn3, p_Plmn4 }
  };
  
  template NAS_UL_Message_Type cdr_TAU_Request_combinedupdate_OldGuti_LAI(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                                          NAS_KsiValue p_KsiValue,
                                                                          template AdditionalUpdateType p_AdditionalUpdateType,
                                                                          template (present) MobileIdentity p_OldGuti,
                                                                          template  LocAreaId p_LAI)
    
    modifies cr_508_TAU_Request :=
  {
    tRACKING_AREA_UPDATE_REQUEST := {
      oldGuti            := p_OldGuti,
      oldLai             := p_LAI,
      tmsiStatus         := omit,
      addUpdateType      := p_AdditionalUpdateType
    }
  };
  
  template (value) NAS_DL_Message_Type cds_SERVICE_REJECT_withT3442(NAS_CauseValue_Type p_CauseValue,
                                                                    template (value) GPRS_Timer p_T3442 )
    modifies cs_508_SERVICE_REJECT :=
  {
    sERVICE_REJECT := {
      t3442 := p_T3442
    }
  };
  
  
  template NAS_UL_Message_Type cdr_ATTACH_REQUEST_AttachType(template (present) NAS_AttDetValue_Type p_AttachTypeValue,
                                                             template AdditionalUpdateType p_AdditionalUpdateType,
                                                             template (present) MobileIdentity p_MobileId,
                                                             template TrackingAreaId p_Tai,
                                                             template LocAreaId p_LAI,
                                                             template TMSI_Status p_TmsiStatus)
    modifies cr_508_ATTACH_REQUEST :=
  { /* @status     */
    aTTACH_REQUEST := {
      epsAttachType            := cr_EPS_AttachType(p_AttachTypeValue),
      oldGutiOrImsi            := p_MobileId,
      lastVisitedRegisteredTai := p_Tai,
      oldLai                   := p_LAI,
      tmsiStatus               := p_TmsiStatus
    }
  };
  
  template NAS_UL_Message_Type cr_DETACH_REQUEST_921125 :=
    cr_508_DETACH_REQUEST_MO(?, ?, cr_DetachType( '0'B, tsc_DetachMO_GprsOnly));
  
  } // group LocalTemplates
  
  group LocalFunctions {

  function fl_InitSIB5Info_92111a (CellId_Type p_CellId) runs on EUTRA_PTC  return template (value) SystemInformationBlockType5
 {
    var template (value) SystemInformationBlockType5 v_SIB5;
    var Ul_Bandwidth_Type v_UL_Bandwidth := f_EUTRA_CellInfo_GetUL_ChBandwidth (p_CellId);
    var Dl_Bandwidth_Type v_DL_Bandwidth := f_EUTRA_CellInfo_GetDL_ChBandwidth (p_CellId);
    var Frequency_fList_Type v_Frequency_PrimaryBand := f_EUTRA_InitFrequency_f1Tof4 (px_ePrimaryFrequencyBand, v_DL_Bandwidth, v_UL_Bandwidth);
    var ChannelBandwidthDependency_Type v_ChannelBandwidthDependency := f_EUTRA_BandDependentParam ( v_DL_Bandwidth, v_UL_Bandwidth );

    select (p_CellId) {
        case (eutra_CellA, eutra_CellB, eutra_CellC) {
            v_SIB5 := cs_508_SystemInformationBlockType5_Def ( { cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f2,
                                                                                                    v_ChannelBandwidthDependency.AllowedMeasBandwidth),
                                                                                               cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f3,
                                                                                                    v_ChannelBandwidthDependency.AllowedMeasBandwidth)} );
            
        }
        case (eutra_CellI, eutra_CellK)
        {
           v_SIB5 := cs_508_SystemInformationBlockType5_Def ( { cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1,
                                                                                                    v_ChannelBandwidthDependency.AllowedMeasBandwidth),
                                                                                               cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f2,
                                                                                                    v_ChannelBandwidthDependency.AllowedMeasBandwidth)} );
        }
        case(eutra_CellE, eutra_CellG, eutra_CellH)
        {
            v_SIB5 := cs_508_SystemInformationBlockType5_Def ( { cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1,
                                                                                                    v_ChannelBandwidthDependency.AllowedMeasBandwidth),
                                                                                               cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f3,
                                                                                                    v_ChannelBandwidthDependency.AllowedMeasBandwidth)} );
        }
        case else {
        FatalError (__FILE__, __LINE__, "invalid CellId");
        }
    }
    return v_SIB5
  }

  // @desc      step 5 .. 13 of UE Registration acc. to 36.508 cl. 4.5.2
  function f_EUTRA_IdleUpdated_Step5_13 (CellId_Type p_CellId,
                                         IDLEUPDATED_STATE_Type p_State,
                                         NAS_MSG_Indication_Type p_NAS_Ind) runs on EUTRA_PTC
  {
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var template (present) SecurityHeaderType v_ExpectedSecurityHeader; // @sic R5s090373 sic@
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(p_CellId);
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
    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) ProtocolConfigOptions v_Pco := omit;

    // Set UE network capabilities as sent by the UE to be used later (see TS 24.301 clause 5.4.3.3)
    v_AuthParams.NAS_SecurityCap := f_EUTRA_FillNAS_SecurityCapability(p_NAS_Ind.Pdu.Msg.aTTACH_REQUEST);  // @sic R5s100135 sic@
    f_EUTRA_Security_Set(v_AuthParams);

    if (p_NAS_Ind.SecurityProtection.Status == tsc_SHT_NoSecurityProtection) // @sic R5s090210, R5s090373 sic@
    {
      v_ExpectedSecurityHeader := tsc_SHT_NoSecurityProtection;
    } else {
      v_ExpectedSecurityHeader := (tsc_SHT_NoSecurityProtection, tsc_SHT_IntegrityProtected);
    }

    v_PdnConnectivityRequest := p_NAS_Ind.Pdu.PiggybackedPduList[0].Msg;
    v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }
    // Step 5-6: Authentication
    v_AuthParams:=f_EUTRA_NAS_Authentication(p_CellId,
                                             tsc_SRB1,
                                             v_AuthParams,
                                             tsc_SHT_NoSecurityProtection,
                                             v_ExpectedSecurityHeader,       // @sic R5s090210, R5s090373 sic@
                                             v_PLMN);                        // AUTHENTICATION REQUEST & RESPONSE
    // Step 7-8: NAS Security
    v_NasCountUL := f_EUTRA_NAS_ActivateSecurity(p_CellId, v_AuthParams);   // NAS SECURITY COMMAND & COMPLETE

    // Step 9a1 & 2 - ESM information optionally transferred
    if (f_CheckEsmInfoTransferFlag(v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST)) {
      v_APN := f_ESM_InformationTransfer_GetAPN (p_CellId, v_EPS_TI);
    }
    // optional
    if (p_State == STATE2A_TESTLOOP_ModeA) {
      f_EUTRA_Activate_TestMode (p_CellId,tsc_UE_TestLoopMode_TypeA);
    }
    else if (p_State == STATE2A_TESTLOOP_ModeB) {
      f_EUTRA_Activate_TestMode (p_CellId,tsc_UE_TestLoopMode_TypeB);
    }

    // Step 10-11: RRC Security Mode procedures
    v_AuthParams := f_EUTRA_RRC_ActivateSecurity(p_CellId, 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 (p_CellId, v_RRC_TI); // This enquires for the eutra capability but does not check the contents of the message received
  }

 } // group LocalFunctions
  
  group TestcaseImplementations {
  
  // ==========================TC 9.2.1.1.1 =====================================
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.1.1.1
   * @status    APPROVED
   */
  function f_TC_9_2_1_1_1_EUTRA() runs on EUTRA_PTC
  { /* @desc Attach procedure for EPS services. Attach Procedure / Success (valid GUTI). */
    
    var GutiParameters_Type v_Guti_Params;
    var GutiParameters_Type v_Guti_Old_Params;
    
    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell); // @sic R5-101121 sic@ Cell H is just used for preamble
    
    // Initial conditions state that UE is updated to Cell H parameters  // @sic R5-101121 sic@
    // so change this now to force Attach Accept to contain TAC2
    f_EUTRA_CellInfo_SetTAC(eutra_CellA, oct2bit(tsc_TAC2));
    v_Guti_Params := f_EUTRA_CellInfo_GetGuti (eutra_CellA); // @sic R5-101121 sic@
    v_Guti_Old_Params := f_EUTRA_CellInfo_GetGuti (eutra_CellH); // @sic R5-101121 sic@
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti_Old_Params);
    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    
    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    
    // now change TAC back again as Cell A is to have TAI-1
    f_EUTRA_CellInfo_SetTAC(eutra_CellA, oct2bit(tsc_TAC1));
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_Guti_Params); // @sic R5s100008 sic@
    f_EUTRA_ModifySysinfoUE_Off(eutra_CellA);
    
    f_EUTRA_TestBody_Set(true);
    fl_TC_9_2_1_1_1_Body(v_Guti_Params, v_Guti_Old_Params); // @sic R5-101121 sic@
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE); //@sic R5-103849 sic@
  }
  
  // ==========================TC 9.2.1.1.1a =====================================
  
  function f_TC_9_2_1_1_1a_EUTRA() runs on EUTRA_PTC
  {
    // @desc Attach Procedure / Success (last visited TAI, TAI list and equivalent PLMN list handling)
    
    const NAS_Tac tsc_TAC0  := '0000'O;
    const NAS_Tac tsc_TAC27  := '0027'O;
    const NAS_Tac tsc_TAC_FFF0  := 'FFF0'O;
    const NAS_Tac tsc_TAC_FFF9  := 'FFF9'O;
    template (value) PLMN_Identity cs_HPLMN_310_102 := { mcc := {3,1,0},  mnc :={1,0,2} };
    template (value) PLMN_Identity cs_HPLMN_004_07 := { mcc := {0,0,4},  mnc :={0,7} };
    template (value) PLMN_Identity cs_HPLMN_004_02 := { mcc := {0,0,4},  mnc :={0,2} };
    template (value) PLMN_Identity cs_HPLMN_316_002 := { mcc := {3,1,6},  mnc :={0,0,2} };

    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell_UsingE);
    f_EUTRA_CellInfo_SetTAC(eutra_CellA, oct2bit(tsc_TAC0));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellA, cs_HPLMN_Def );
    f_EUTRA_CellInfo_SetTAC(eutra_CellI, oct2bit(tsc_TAC0));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellI, cs_HPLMN_310_102 );
    f_EUTRA_CellInfo_SetTAC(eutra_CellB, oct2bit(tsc_TAC1));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellB, cs_HPLMN_Def );
    f_EUTRA_CellInfo_SetTAC(eutra_CellC, oct2bit(tsc_TAC27));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellC, cs_HPLMN_Def );
    f_EUTRA_CellInfo_SetTAC(eutra_CellG, oct2bit(tsc_TAC_FFF0));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellG, cs_HPLMN_004_07 );
    f_EUTRA_CellInfo_SetTAC(eutra_CellH, oct2bit(tsc_TAC_FFF9));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellH, cs_HPLMN_004_07 );
    f_EUTRA_CellInfo_SetTAC(eutra_CellK, oct2bit(tsc_TAC3));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellK, cs_HPLMN_316_002 );
    f_EUTRA_CellInfo_SetTAC(eutra_CellE, oct2bit(tsc_TAC3));
    f_EUTRA_CellInfo_SetPLMN_1Entry(eutra_CellE, cs_HPLMN_004_02 );
    
    // The SIB5 for every cell is specific for this test case
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellA, fl_InitSIB5Info_92111a (eutra_CellA));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellI, fl_InitSIB5Info_92111a (eutra_CellI));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellB, fl_InitSIB5Info_92111a (eutra_CellB));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellC, fl_InitSIB5Info_92111a (eutra_CellC));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellG, fl_InitSIB5Info_92111a (eutra_CellG));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellH, fl_InitSIB5Info_92111a (eutra_CellH));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellK, fl_InitSIB5Info_92111a (eutra_CellK));
     f_EUTRA_ChangeSIB5_Combination3 (eutra_CellL, fl_InitSIB5Info_92111a (eutra_CellL));

    // create cell and send out system information
    //Cell A
    f_EUTRA_CellConfig_Def(eutra_CellA);
    
    //Cell I
    f_EUTRA_CellConfig_Def(eutra_CellI);
    
    //Cell B
    f_EUTRA_CellConfig_Def(eutra_CellB);
    
    //Cell C
    f_EUTRA_CellConfig_Def(eutra_CellC);
    
    //Cell G
    f_EUTRA_CellConfig_Def(eutra_CellG);
    
    //Cell H
    f_EUTRA_CellConfig_Def(eutra_CellH);
    
    //Cell K
    f_EUTRA_CellConfig_Def(eutra_CellK);
    
    //Cell E
    f_EUTRA_CellConfig_Def(eutra_CellE);
    
    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    // make sure that UE has a valid GUTI before starting with actual test steps
    f_EUTRA_Preamble (eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_9_2_1_1_1a_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  }

  // ==========================TC 9.2.1.1.2 =====================================
  /*
   * @desc      Attach procedure for EPS services. Attach Procedure / Success / With IMSI, GURI Reallocation.
   * @status    APPROVED
   */
  function f_TC_9_2_1_1_2_EUTRA() runs on EUTRA_PTC
  {
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN,LTEsinglecell);
    
    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellA);
    
    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    // make sure that UE has a valid GUTI before starting with actual test steps
    f_EUTRA_Preamble (eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_9_2_1_1_2_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E4_DEREGISTERED); // @sic R5-103875 sic@
  }
  
  // ==========================TC 9.2.1.1.4 =====================================
    function f_TC_9_2_1_1_4_EUTRA() runs on EUTRA_PTC
    {
      // @desc Attach Procedure / Success / Request for obtaining the IPv4 address of the home agent
      //
      //Test Purpose (TP)
      //(1)
      //with { UE and is configured to request the DSMIPv6 IPv4 Home Agent Address }
      //  ensure that {
      //    when { UE is switched on and has established the RRC connection }
      //       then { the UE transmits a ATTACH REQUEST and a PDN CONNECTIVITY REQUEST message indicating a request for DSMIPv6 IPv4 Home Agent Address in the protocol configuration options }
      //  }
      //(2)
      //with { UE and is configured to request the DSMIPv6 IPv4 Home Agent Address, and has indicated in the PDN CONNECTIVITY REQUEST a request for DSMIPv6 IPv4 Home Agent Address }
      //  ensure that {
      //     when { the SS responds to the ATTACH REQUEST with a DSMIPv6 IPv4 Home Agent Address }
      //        then { the UE transmits an ATTACH COMPLETE message }
      //  }

      // Pre-test conditions
      // System Simulator:
      //   -    Cell A is a E-UTRAN cell with TAI-1 (PLMN-1 + TAC-1).
      //   -    The cell power levels are such that Cell A is guaranteed to become the serving cell
      // UE:
      //   -    The test USIM contains a valid GUTI and EPS update status is "EU1: UPDATED".
      //   -    The UE is configured to request the DSMIPv6 IPv4 Home Agent Address in the protocol
      //        configuration options IE as part of the Attach / PDN connectivity request procedure.
      // Preamble:
      //   -    The UE is in state Switched OFF (state 1) according to [18].


      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 switched OFF (state 1)
      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_1_1_4_Body();

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


  // ==========================TC 9.2.1.1.7 =====================================
  function f_TC_9_2_1_1_7_EUTRA() runs on EUTRA_PTC
  {
    /*Attach Procedure / Success / list of equivalent PLMNs in the ATTACH ACCEPT message
      Test Purpose (TP)
      (1)
    with { UE in EMM-REGISTERED-INITIATED state }
    ensure that {
      when { the UE receives ATTACH ACCEPT message including a list of equivalent PLMNs }
       then { the UE stores correctly the list and does not consider forbidden PLMNs as equivalent PLMNs }
    }

    (2)
    with { UE in EMM-REGISTERED-INITIATED state }
    ensure that {
      when { the UE receives ATTACH ACCEPT message without a list of equivalent PLMNs }
       then { the UE deletes the stored list and applies a normal PLMN selection process }
    }

    Pre-test conditions
    System Simulator:
      -    Cell A (PLMN1), Cell G (PLMN2), Cell I (PLMN3) and Cell J (PLMN4) are configured according to Table 6.3.2.2-1 in [18].
      -    Cell A (HPLMN)
      -    Cell G (visited PLMN)
      -    Cell I (another visited PLMN)
      -    Cell J (another visited PLMN, different than Cell I and switched OFF, at most 3 cells are active simultaneously)
    UE:
        -   The UE is configured to initiate EPS attach.
        -   The "forbidden PLMN list" contains PLMN3
    Preamble:
        -   The UE is in state Switched OFF (state 1) according to [18].
    */

    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);
    
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellG);
    f_EUTRA_CellConfig_SRBs_Only(eutra_CellI);
    f_EUTRA_CellConfig_SRBs_Only(eutra_CellJ);
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellJ, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    
    f_UT_ConfigureEPSAttach (UT); // R5-103810

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    
    // SS sends Authentication Reject with cause 'PLMN not allowed' to include PLMN3 the "forbidden PLMN list"
    f_EUTRA_Preamble_Reject (eutra_CellI, tsc_Cause_PLMN_NotAllowed);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_9_2_1_1_7_Body();
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_9_2_1_1_7_EUTRA

  // ========================== TC 9.2.1.1.9 =====================================
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.1.1.9
   * @status    APPROVED
   */
  function f_TC_9_2_1_1_9_EUTRA() runs on EUTRA_PTC
  { // @desc: Attach / rejected / IMSI invalid
    /* Test Purpose (TP)
     * (1)
     * with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
     * ensure that {
     *   when { UE receives an ATTACH 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 { UE receives an ATTACH REJECT message with the reject cause set to "Illegal UE" }
     *  ensure that {
     *    when { the UE has been switched off, then switched on }
     *    then { the UE sends an ATTACH REQUEST message with IMSI, including a PDN CONNECTIVITY REQUEST message }
     * }
     *
     * Pre-test conditions
     * System Simulator:
     * -    Cell A, Cell B (home PLMN, different TAs) and Cell G (another PLMN)
     * -    The different cells may not be simultaneously activated.
     * UE:
     * -     The test USIM contains IMSI1, GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
     * Preamble:
     * -    The UE is in state Switched OFF (state 1) according to clause [18].
     */
    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, 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_CellG);
    
    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_9_2_1_1_9_and_10_Body(tsc_EmmCause_IllegalUe);
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED); // @sic R5-105005 sic@
  }// function f_TC_9_2_1_1_9_EUTRA
  
  // ========================== TC 9.2.1.1.10 ===================================
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.1.1.10
   * @status    APPROVED
   */
  function f_TC_9_2_1_1_10_EUTRA() runs on EUTRA_PTC
  { // @desc: Attach / rejected / IMSI invalid
    /* Test Purpose (TP)
     * (1)
     * with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
     * ensure that {
     *   when { UE receives an ATTACH 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 { UE receives an ATTACH REJECT message with the reject cause set to "Illegal UE" }
     * ensure that {
     *   when { the UE has been switched off, then switched on }
     *   then { the UE sends an ATTACH REQUEST message with IMSI, including a PDN CONNECTIVITY REQUEST message }
     * }
     *
     * Pre-test conditions
     * System Simulator:
     *    -    Cell A, Cell B (home PLMN, different TAs) and Cell G (another PLMN)
     *    -    The different cells may not be simultaneously activated.
     * UE:
     *    -    The UE is configured to initiate EPS attach.
     *    -    The test USIM contains IMSI1, GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
     * Preamble:
     *    -    The UE is in state Switched OFF (state 1) according to clause [18].
     */

    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, 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_CellG);

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    // Note the test is identical to 9.2.1.1.9 except that the reject cause is 'Illegal ME'
    fl_TC_9_2_1_1_9_and_10_Body(tsc_EmmCause_IllegalMe);

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED); // @sic R5-105005 sic@
  }// function f_TC_9_2_1_1_10_EUTRA

  function f_TC_9_2_1_1_13_EUTRA() runs on EUTRA_PTC
  { // @desc: Attach / rejected / PLMN not allowed
    /* Test Purpose (TP)
        (1)
        with { the UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
        ensure that {
          when { the UE receives an ATTACH REJECT message with the reject cause set to "PLMN not allowed" }
            then { the UE deletes the GUTI, the last visited registered TAI, KSI, the list of equivalent PLMNs and UE enters state EMM-DEREGISTERED.PLMN-SEARCH and UE stores the PLMN in the "forbidden PLMN list" in the USIM }
                    }
        (2)
        with { the UE is switched off and a PLMN is stored in the "forbidden PLMN list" in the USIM }
        ensure that {
          when { the UE is switched on  }
            then { the UE doesn't  attempt to attach on this PLMN }
                    }
        (3)
        with { the UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state and a PLMN is stored in the "forbidden PLMN list" }
        ensure that {
          when { the UE detects a cell belonging to a PLMN which is not in the "forbidden PLMN list" }
            then { the UE attaches to this PLMN }
                    }
        (4)
        with {the  UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state and a PLMN is stored in the "forbidden PLMN list" }
        ensure that {
          when { the forbidden PLMN is selected manually }
            then { the UE attaches to the forbidden PLMN and deletes this PLMN from the USIM}
                    }
    

        Pre-test conditions
        System Simulator:
            -   Cell G, Cell H, and Cell I
            -   Cell G and Cell H (VPLMN, same MCC like HPLMN, different TAs)
            -   Cell I (VPLMN, different MCC from HPLMN).
            -   The cells may not be simultaneously activated.
        UE:
            -   The test USIM contains IMSI1, GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
            -   The "forbidden PLMN list" is empty.
            -   The UE is configured to initiate EPS attach.
        Preamble:
            -   The UE is in state Switched OFF (state 1) according to clause [18]
     */
    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);

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

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble
    f_EUTRA_Preamble(eutra_CellG, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellG, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_1_13_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellG, E1_IDLE);
  }// function f_TC_9_2_1_1_13_EUTRA


  // ========================== TC 9.2.1.1.14 ===================================
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.1.1.14
   * @status    APPROVED
   */
  function f_TC_9_2_1_1_14_EUTRA() runs on EUTRA_PTC
  {
    // @desc: Attach / rejected / tracking area not allowed
    /*
     * Test Purpose (TP)
    * (1)
    * with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
    * ensure that {
    *   when { UE receives an ATTACH REJECT message with the reject cause set to "Tracking area not allowed" }
    *   then { UE sets the EPS update status to EU3 ROAMING NOT ALLOWED, UE deletes the GUTI, last visited registered TAI and KSI,
    *          UE enters the state EMM-DEREGISTERED.LIMITED-SERVICE and UE stores 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 the current TAI in 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 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 re-selects a new cell in the same TAI it was already rejected }
    *   then { UE does not attempt to attach }
    * }
    * (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 cell belonging to a tracking area not in the list of "forbidden tracking areas for regional provision of service"}
    *   then { UE attempts to attach with IMSI }
    * }
    * (5)
    * with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the list of "forbidden tracking areas for regional provision of service" contains more than one TAI}
    * ensure that {
    *   when { UE re-selects a cell belonging to one of the TAIs in the list of "forbidden tracking areas for regional provision of service" }
    *   then { UE does not attempt to attach }
    * }
    * (6)
    * with { UE is switched off }
    * ensure that {
    *   when { UE is powered 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 swithed off }
    *   then { UE performs registration on that cell }
    * }
    *
    * System Simulator:
    *   -   Cell A and Cell B are configured according to Table 6.3.2.2-1 in [18] and belong to the same frequency as specified in [20]# :
    *   -   Cell A  in  (home PLMN),
    *   -   Cell  B in  (home PLMN, another TA),
    * UE:
    *   -    The USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".# .
    * Preamble:
    *   -   The UE is configured to initiate EPS attach.
    *   -   The UE is in state Switched OFF (state 1) according to clause [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-103810

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_9_2_1_1_14_Body();
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
  }// function f_TC_9_2_1_1_14_EUTRA

  // ==========================TC 9.2.1.1.15 =====================================
  function f_TC_9_2_1_1_15_EUTRA() runs on EUTRA_PTC
  {//@desc:     Attach / rejected / roaming not allowed in this tracking area
    /*
    Test Purpose (TP)
    (1)
    with { the UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
    ensure that {
      when { the UE receives an ATTACH 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 GUTI, the last visited registered TAI and KSI and the UE enters the state EMM-DEREGISTERED.LIMITED-SERVICE or optionally EMM-DEREGISTERED.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-DEREGISTERED.LIMITED-SERVICE or EMM-DEREGISTERED.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 a tracking area not in the list of "forbidden tracking areas for roaming"}
        then { the UE attempts to attach with IMSI }
                }
    (3)
    with { the UE is in EMM-DEREGISTERED.LIMITED-SERVICE or EMM-DEREGISTERED.PLMN-SEARCH state and the list of "forbidden tracking areas for roaming" contains more than one TAI}
    ensure that {
      when { the UE selects a cell belonging to one of the TAIs in the list of "forbidden tracking areas for roaming" }
        then { the UE does not attempt to attach }
                }
    (4)
    with { the UE is switched off or the UICC containing the USIM is removed }
    ensure that {
      when { UE is powered on in the cell belonging to the TAI which was in the list of "forbidden tracking areas for roaming" before the UE was swithed off or the USIM is inserted again on that cell }
        then { UE performs registration on that cell }
                }
    (5)
    with { the UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
    ensure that {
      when { the UE receives an ATTACH REJECT message with the reject cause set to "roaming not allowed in this tracking area" }
        then { the UE performs a PLMN selection }
                }


    */

    /*
    System Simulator:
        -    Cell C, Cell I and Cell L, but at most two cells are simultaneously activated:
        -    Cell I (visited PLMN),
        -    Cell E (same visited PLMN, another TA),
        -    Cell C (home PLMN).
        NOTE 1:    Cell E shall not use the same frequency as cell I.
        NOTE 2:    The requirement in 3GPP TS 24.301 to store at least 40 entries in the list of "forbidden tracking areas for roaming" is not fully tested.
        NOTE 3:    Different types of UE may use different methods to periodically clear the list of forbidden
                   areas (e.g. every day at 12 am) for roaming. If the list is cleared while the test is being run,
                   it may be necessary to re-run the test.
    UE:
        -     The UE is configured to initiate EPS attach.
        -     The test USIM contains IMSI-1, GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
    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_CellI);
    f_EUTRA_CellConfig_Def(eutra_CellE);
    f_EUTRA_CellConfig_Def(eutra_CellC);

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1), but updated with GUTI-1, TAI-1
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellC, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellC, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_1_15_Body();
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellC, E1_IDLE);
  }// function f_TC_9_2_1_1_15_EUTRA

    // ==========================TC 9.2.1.1.16 =====================================
    function f_TC_9_2_1_1_16_EUTRA() runs on EUTRA_PTC
    {
       // @desc Attach / Rejected / EPS services not allowed in this PLMN
        /* Test Purpose (TP)
          (1)
            with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
            ensure that {
              when { UE receives an ATTACH REJECT message with the reject cause set to "EPS services not allowed in this PLMN" }
                then { UE deletes any GUTI, last visited registered TAI, KSI and enters EMM-DEREGISTERED.PLMN-SEARCH state}
             }
          (2)
            with { UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state, and a PLMN is stored in the "forbidden PLMNs for GPRS service list" }
            ensure that {
              when { UE detects a cell which belongs to a PLMN which is in the "forbidden PLMNs for GPRS service list" }
                then { UE doesn't perform an attach procedure }
             }
          (3)
            with { UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state, and a PLMN is stored in the "forbidden PLMNs for GPRS service list" }
            ensure that {
              when { UE detects a cell which belongs to a PLMN which is not in the "forbidden PLMNs for GPRS service list" }
                then { UE performs an attach procedure }
                        }
          (4)
            with { UE is switched off when a PLMN is stored in the "forbidden PLMNs for GPRS service list" }
            ensure that {
              when { UE is powered on a cell which belongs to this PLMN }
                then { UE performs an attach procedure }
                        }
          (5)
            with { UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state, and a PLMN is stored in the "forbidden PLMNs for GPRS service list" }
            ensure that {
              when { UE is in the cell which belongs to the rejected PLMN and when that PLMN is selected manually }
                then { UE performs 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 and Cell H with MCC-1/MNC-2 (visited PLMN, different TAs)
          - Cell I with MCC-2/MNC-101 (visited PLMN)
          - The cells may not be simultaneously activated.
         UE:
          - The test USIM contains IMSI-1, GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
          - The "forbidden PLMNs for GPRS service list" is empty.
         Preamble:
          - The UE is in state Switched OFF (state 1) according to clause [18]
        */

        f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell);

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

        f_UT_ConfigureEPSAttach (UT); // R5-103810
        
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellG, RRC_IDLE, tsc_RRC_TI_Def );

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_1_1_16_Body ();

        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellG, E1_IDLE);
    } // end f_TC_9_2_1_1_16_EUTRA


  // ==========================TC 9.2.1.1.17 =====================================
  function f_TC_9_2_1_1_17_EUTRA() runs on EUTRA_PTC
  { // @desc: Attach / rejected / no suitable cells in this TA
    /*Test Purpose (TP)

     (1)
    with { UE has sent an ATTACH#  REQUEST message including a PDN CONNECTIVITY REQUEST message }
    ensure that {
      when { UE receives an ATTACH#  REJECT message with the EMM cause set to "No suitable cells in tracking area" }
        then { UE set the EPS update status to EU3 ROAMING NOT ALLOWED, UE deletes any GUTI, last visited registered TAI and KSI, UE enters the state EMM-DEREGISTERED.LIMITED-SERVICE and UE stores the current TAI in the list of "forbidden tracking areas for roaming" }
                }
     (2)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the current TAI in the list of "forbidden tracking areas for roaming"}
    ensure that {
      when { UE re-selects a cell that belongs to the TAI where UE was rejected }
        then { UE does not attempt to attach }
                }
    (3)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the current TAI in the list of "forbidden tracking areas for roaming" and KSI was deleted }
    ensure that {
      when { in the same PLMN, UE enters a cell which provides normal service and belongs to the tracking area not in the list of "forbidden tracking areas for roaming" }
        then { UE attempts to attach with IMSI indicated that no key is available }
                }
    (4)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the current TAI in the list of "forbidden tracking areas for roaming"}
    ensure that {
      when { there are cells in the same PLMN and other PLMN that provide normal service and belong to the tracking area not in the list of "forbidden tracking areas for roaming" }
        then { UE attempts to attach to the cell in the same PLMN }
                }
     (5)
    with { UE is in EMM-DEREGISTERED.LIMITED-SERVICE state and the list of "forbidden tracking areas for roaming" contains more than one TAI}
    ensure that {
      when { UE re-selects a cell that belongs to one of the TAIs in the list of "forbidden tracking areas for roaming" }
        then { UE does not attempt to attach }
                }
    (6)
    with { UE is swithched off }
    ensure that {
      when { UE is powered on in the cell belonging to the TAI which was in the list of "forbidden tracking areas for roaming" before the UE was swithed off }
        then { UE attempts to attach }
            }
*/
  //SS: -   Cell I, Cell J, Cell K and Cell L are configured according to Table 6.3.2.2-1 in [18] (maximum 3 cells are simultaneously active):
  //    -   Cell I and Cell K (visited PLMN, same TA)
  //      -     Cell L (same visited PLMN, another TA)
  //      - Cell J (another VPLMN).


  // UE:    The USIM contains IMSI-1, GUTI-1 and TAI-1 (MCC1/MNC1/TAC1), and EPS update status is "EU1: UPDATED".
  //        The UE is configured to initiate EPS attach.
  // Preamble:  The UE is in state Switched OFF (state 1) according to clause [18].
    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN ,LTEmulticell, LTE_NAS_Usef1_f2);

    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellI);
    f_EUTRA_CellConfig_SRBs_Only(eutra_CellJ);
    f_EUTRA_CellConfig_SRBs_Only(eutra_CellK);
    f_EUTRA_CellConfig_Def(eutra_CellL);

    f_UT_ConfigureEPSAttach (UT); // R5-103810
 
    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellI, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellI, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_1_17_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellI, E1_IDLE);
  }// function f_TC_9_2_1_1_17_EUTRA

  // ==========================TC 9.2.1.1.18 =====================================
  function f_TC_9_2_1_1_18_EUTRA() runs on EUTRA_PTC
  {//@desc:     Attach / Rejected / Not authorized for this CSG
    /*
    Test Purpose (TP)
    (1)
    with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
    ensure that {
      when { UE receives an ATTACH REJECT message with the reject cause set to " Not authorized for this CSG " }
        then { UE shall remove the CSG ID from the allowed CSG list and search for a suitable cell in the same PLMN }
                }
    (2)
    with { UE in state EMM-REGISTERED and EMM-IDLE mode and the CSG ID is removed from the Allowed CSG list }
    ensure that {
      when { UE detects entering new tracking areas not included in the TAI list }
        then { UE attempts to enter a normal cell and does not choose a cell which not included in the allowed CSG list }
            }

    */

    /*
   System Simulator:
    -   Cell A , Cell B, Cell C.
    -   Cell A(TAC1, frequency 1,  not a CSG cell)
    -   Cell B(TAC2, frequency 1,  is a CSG cell)
    -   Cell C(TAC3, frequency 2,  not a CSG cell)
    UE:
    -   The UE has a valid GUTI (GUTI-1).
    -   The test USIM contains IMSI1, GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
    -   The test USIM contains a allowed CSG list which include CSG ID of Cell B.
    -   The UE has a valid security context.
    Preamble:
    -   The UE is in state Switched OFF (state 1) according to clause [18].
    */
    var B27_Type v_CSG_Identity_CellB := '000000000000000000000000010'B;

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

    // create cell and send out system information
    f_EUTRA_CellInfo_SetSysInfo_Csg_Ind ( eutra_CellB, true );
    f_EUTRA_CellInfo_SetSysInfo_Csg_Id ( eutra_CellB, v_CSG_Identity_CellB );
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellB);
    f_EUTRA_CellConfig_Def(eutra_CellC);

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1), but updated with GUTI-1, TAI-1
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

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


  // ==========================TC 9.2.1.1.20 =====================================
  /*
   * @desc      REFERENCE TS 36.523-1 clause 9.2.1.1.20
   * @status    APPROVED
   */
  function f_TC_9_2_1_1_20_EUTRA() runs on EUTRA_PTC
  { // @desc: Attach / Abnormal case / Access barred because of access class barring or NAS signalling connection establishment rejected by the network
    /*
     * (1)
     * with { UE switched-on, and not yet attached to EPS }
     * ensure that {
     *   when { Access is barred for signalling in the cell UE is camping [Access Class barred in System information] }
     *     then { the UE will not initiate any Attach procedure }
     * }
     (2)
     * with { UE switched-on, and not yet attached to EPS }
     * ensure that {
     *   when { Access is barred for signalling in the cell UE is camping [T302 running due to RRCConnectionReject message reception] }
     *     then { the UE will not initiate any Attach procedure }
     * }
     * (3)
     * with { UE switched-on, and not yet attached to EPS }
     * ensure that {
     *   when { Access is not barred for signalling in the cell UE is camping }
     *     then { the UE will initiate Attach procedure }
     * }
     *
     * Pre-test conditions
     * System Simulator:
     *     -   Cell I and K
     *
     * UE:
     *     -   The UE is configured to initiate EPS attach.
     *     -   The test USIM contains a valid GUTI1 and TAI9, and EPS update status is "EU1: UPDATED".
     * Preamble:
     *     -   The UE is in state Switched OFF (state 1) according to [18].
     */
   
    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell, LTE_NAS_Usef1_f2); // @sic R5s100398 sic@
    // create cell and send out system information
    f_EUTRA_CellConfig_Def(eutra_CellI);
    f_EUTRA_CellConfig_Def( eutra_CellK ); // @sic R5s100380 sic@

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================

    f_EUTRA_Preamble(eutra_CellI, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe( eutra_CellI, RRC_IDLE );

    f_EUTRA_CellInfo_SetSysInfo_AccessBarring ( eutra_CellI, cs_AccessBarringInformation_TC_9_1_1_20 );
    f_EUTRA_ModifySysinfoUE_Off (eutra_CellI);

    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_1_20_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellK, E2_CONNECTED);
  }  // function f_TC_9_2_1_1_20_EUTRA


  // ==========================TC 9.2.1.1.21 =====================================
  function f_TC_9_2_1_1_21_EUTRA() runs on EUTRA_PTC
  {// @desc: Attach / Abnormal case / Success after several attempts due to no network response
    /*
    (1)
    with { UE has sent an ATTACH REQUEST message and started T3410 timer}
    ensure that {
      when { T3410 timer epires }
        then { the UE release NAS signalling connection locally}
    }
    (2)
    with { UE has sent an ATTACH REQUEST message and T3410 timer expired}
    ensure that {
      when { T3411 timer epires and attach attempt counter is less than 5 }
        then { the UE restarts the attach procedure}

    (3)
    with { UE has sent an ATTACH REQUEST message }
    ensure that {
      when { Lower Layer failure (RRC Connection is released) before the ATTACH ACCEPT or ATTACH REJECT message is received, T3411 has expired and attach attempt counter is less than 5}
        then { the UE restarts the attach procedure }
    }


    Pre-test conditions
    System Simulator:
    -   Cell A
    -   Cell A is the serving cell with TAI1 (PLMN1+TAC1);
    UE:
    -   The test USIM is inserted.
    Preamble:
    -   The UE is in state Switched OFF (state 1) according to [18].
    */
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN,LTEsinglecell);

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

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_1_21_Body();

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


  
  // ==========================TC 9.2.1.1.22 =====================================
  function f_TC_9_2_1_1_22_EUTRA() runs on EUTRA_PTC
  {// @desc: Attach / Abnormal case / Unsuccessful attach after 5 attempts
    /*
    (1)
    with { UE has sent an ATTACH REQUEST message }
    ensure that {
      when { T3411 has expired and attach attempt counter is equal to 5}
        then { the UE stops attach attempts and starts timer T3402 }
    }



    Pre-test conditions
    System Simulator:
    -   Cell A
    -   Cell A is the serving cell with TAI1 (PLMN1+TAC1);
    -   T3402 is set to default (12 min.).
    UE:
    -   The test USIM is inserted.
    -   The test USIM contains a valid GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
    Preamble:
    -   The UE is in state Switched OFF (state 1) according to [18].
    */
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN,LTEsinglecell);

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

    f_UT_ConfigureEPSAttach (UT); // R5-103810

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_1_22_Body();

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



  // ==========================TC 9.2.1.1.22 =====================================
  function f_TC_9_2_1_1_23_EUTRA() runs on EUTRA_PTC
  {
      // @desc Attach / Abnormal case / Repeated rejects for network failures
      /* Test Purpose (TP)
      (1)
      with { UE having valid GUTI, has sent an ATTACH REQUEST message }
        ensure that {
          when { UE receives an ATTACH REJECT message with the reject cause set to #17 or #22 and attach attempt
                 counter is less than 5}
            then { UE starts timer T3411 and shall not deleate stored GUTI }
            when { Timer T3411 expires}
            then { UE restarts attach procedure }
        }

      (2)
      with { UE having valid GUTI, has sent an ATTACH REQUEST message }
        ensure that {
          when { UE receives an ATTACH REJECT message with the reject cause set to #22 and attempt counter is
                 set to 5}
            then { the UE stops attach attempts and starts timer T3402, shall delete stored GUTI }
        }

      NOTE: Only representative coverage for various abnormal reject causes is provided.


      System Simulator:
          -   Cell A
          -   Cell A is the serving cell with TAI1 (PLMN1+TAC1);
          -   T3402 is set to default (12 min.)
      UE:
          -   The test USIM is inserted.
          -   The test USIM contains a valid GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
      Preamble:
          -   The UE is in state Switched OFF (state 1) according to [18].

      */

      f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

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

      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_1_1_23_Body();

      // Postamble
      f_EUTRA_TestBody_Set(false);
      f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
        
    } // end f_TC_9_2_1_1_23_EUTRA



  /*
   * @desc      test body of TC_9_2_1_1_1
   * @param     p_GutiParams
   * @param     p_GutiOldParams
   * @status    APPROVED
   */
  function fl_TC_9_2_1_1_1_Body(GutiParameters_Type p_GutiParams,
                                GutiParameters_Type p_GutiOldParams) runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize constant test case data structures
    // ==========================================================================
    var HalfOctet_Type v_EPS_Bearer_Id := tsc_EpsDefaultBearerId;
    var ProcedureTransactionIdentifier v_EPS_TI := tsc_PTI_1;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var ReleaseCause v_RRC_ReleaseCause := other;
    
    var template (omit) MobileIdentity v_MSId := f_GetMSId ();  // @sic R5-103847 sic@
    
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (p_GutiParams.PLMN_Identity);
    var NAS_PlmnId v_NAS_Old_PlmnId := f_Asn2Nas_PlmnId(p_GutiOldParams.PLMN_Identity);
    
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN, v_LAC);
    //v_AdditionalUpdateType is also used to follow TTCN3 v411 standard
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType (); // @sic R5-103681 sic@
    var template (omit) AccessPointName v_APN := omit;
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var NAS_AttDetValue_Type v_AttachType :=f_GetEAttachType();
    
    var SRB_COMMON_IND v_NasInd;
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var boolean v_EIT_Flag := false;
    
    // Switch on UE
    //@siclog "Step 1" siclog@
    f_UT_SwitchOnUE (UT, false);
    
    //@siclog "Step 2" siclog@
    //+ Check: Does the UE transmit an RRCConnectionRequest message not including S-TMSI
    //         and with establishmentCause set to mo-Signalling?
    SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA,
                                    cr_RRCConnectionRequest_withUE_Identity(cr_InitialUE_Identity_Random, mo_Signalling)));
    
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");
    
    //@siclog "Step 3" siclog@
    // send RRC Connection Setup on SRB0 (CCCH):
    f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellA, cs_TimingInfo_Now, v_RRC_TI);
    
    // UE shall establish SRB1 acc. to 36.331 cl. 5.3.3.4 and 5.3.9
    // UE enters RRC_CONNECTED state
    
    //@siclog "Step 4" siclog@
    // Check: does the UE transmit an RRCConnectionSetupComplete message including MME group ID and MME code
    // with ATTACH REQUEST message including a GUTI and a PDN CONNECTIVITY REQUEST message?
    SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                       cr_508_RRCConnectionSetupComplete(v_RRC_TI,
                                                                         ?,
                                                                         cr_RegisteredMME(p_GutiOldParams.PLMN_Identity, // @sic R5s100008 sic@
                                                                                          p_GutiOldParams.MME_GroupId,
                                                                                          p_GutiOldParams.MME_Code)),
                                       cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                         cdr_ATTACH_REQUEST_WithGuti(v_AttachType,
                                                                                                     v_AdditionalUpdateType,
                                                                                                     ?,
                                                                                                     f_GutiParameters2MobileIdentity(omit, p_GutiOldParams), // GUTI1
                                                                                                     cr_TAI( v_NAS_Old_PlmnId, tsc_TAC2)),
                                                                         cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach, ?))))
      -> value v_NasInd;
    v_PdnConnectivityRequest := v_NasInd.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg;
    v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }
    
    //+   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 optionally transferred
    //@siclog "Step 5 - 9" siclog@
    if (ispresent(v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
      if ( v_PdnConnectivityRequest.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, true);
    
    //@siclog "Step 10" siclog@
    //+   SS responds with ATTACH ACCEPT message including a valid TAI list. The
    //+   ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in
    //+   ATTACH ACCEPT message.
    //+   Note: The IP addresses of the UE are not allocated in this test so PDN
    //+   address is not included in the message.
    f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                                  v_EPS_Bearer_Id,
                                                                  v_RRC_TI,
                                                                  v_EPS_TI,
                                                                  v_AttachType,
                                                                  f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, p_GutiParams), // GUTI1
                                                                  cs_TrackingAreaIdListDef_lv,
                                                                  v_LAI,
                                                                  v_MSId,
                                                                  omit,
                                                                  v_APN,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                  v_NasInd.Signalling.Nas[0].Pdu.Msg.aTTACH_REQUEST.addUpdateType); // @sic R5-103681 sic@
    
    //@siclog "Step 11" siclog@
    //+   Check: does the UE transmit an ATTACH COMPLETE message including an
    //+   ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message?
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EPS_Bearer_Id))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 11"); // TP2
    
    //@siclog "Step 12 Void" siclog@
    
    //@siclog "Step 13" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, v_RRC_ReleaseCause);
    
    //@siclog "Step 14" siclog@
    //+   Check: Does the test result of CALL generic procedure [36.508]
    //    indicate that the UE is in E-UTRA EMM-REGISTERED state on
    //    CellA? TP3
    f_EUTRA_508Check_IdleState(eutra_CellA);

    // ==========================================================================
  } // function fl_tc_9_2_1_1_1_Body


  function fl_TC_9_2_1_1_1a_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize constant test case data structures
    // ==========================================================================
    var HalfOctet_Type                  v_EPS_Bearer_Id      := tsc_EpsDefaultBearerId;
    var ProcedureTransactionIdentifier  v_EPS_TI             := tsc_PTI_1;
    // var template (omit) ProcedureTransactionIdentifier v_ESMInfo_TI := omit;
    var RRC_TransactionIdentifier       v_RRC_TI             := tsc_RRC_TI_Def;
    var ReleaseCause                    v_RRC_ReleaseCause   := other;
    var EUTRA_SecurityParams_Type       v_AuthParams_authentication := f_EUTRA_Security_Get();
    // var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var template (omit) MobileIdentity  v_MSId               := f_GetMSId ();
    var template AdditionalUpdateType   v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var GutiParameters_Type             v_GutiParams_CellA   := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    // var NAS_Lac                         v_LAC_CellA          := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA);
    //var NAS_PlmnId                      v_PLMN_CellA         := f_Asn2Nas_PlmnId (v_GutiParams_CellA.PLMN_Identity);

    var GutiParameters_Type             v_GutiParams_CellB   := f_EUTRA_CellInfo_GetGuti(eutra_CellB);

    var GutiParameters_Type             v_GutiParams_CellI   := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
    var NAS_Lac                         v_LAC_CellI          := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellI);
    var NAS_PlmnId                      v_PLMN_CellI         := f_Asn2Nas_PlmnId (v_GutiParams_CellI.PLMN_Identity);

    var GutiParameters_Type             v_GutiParams_CellE   := f_EUTRA_CellInfo_GetGuti(eutra_CellE);
    var NAS_Lac                         v_LAC_CellE          := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellE);
    var NAS_PlmnId                      v_PLMN_CellE         := f_Asn2Nas_PlmnId (v_GutiParams_CellE.PLMN_Identity);

    var template (omit) AccessPointName v_APN                := omit;

    var NAS_MSG_Indication_Type         v_NasInd;
    var NAS_UL_Message_Type             v_PdnConnectivityRequest;
    var template (omit) ProtocolConfigOptions v_Pco          := omit;
   
    var NAS_AttDetValue_Type v_AttachType :=f_GetEAttachType();

    var NAS_Tac v_TAC0  := '0000'O;
    var NAS_Tac v_TAC1  := '0001'O;
    var NAS_Tac v_TAC2  := '0002'O;
    var NAS_Tac v_TAC3  := '0003'O;
    var NAS_Tac v_TAC27  := '0027'O;
    var NAS_Tac v_TAC_FFF0  := 'FFF0'O;
    var PLMN_Identity v_HPLMN_005_002 := { mcc := {0,0,5},  mnc :={0,0,2} };
    var PLMN_Identity v_HPLMN_004_02 := { mcc := {0,0,4},  mnc :={0,2} };
    var PLMN_Identity v_HPLMN_004_03 := { mcc := {0,0,4},  mnc :={0,3} };
    var PLMN_Identity v_HPLMN_001_01 := { mcc := {0,0,1},  mnc :={0,1} };
    var PLMN_Identity v_HPLMN_004_07 := { mcc := {0,0,4},  mnc :={0,7} };
    var PLMN_Identity v_HPLMN_316_002 := { mcc := {3,1,6},  mnc :={0,0,2} };
    var PLMN_Identity v_HPLMN_310_102 := { mcc := {3,1,0},  mnc :={1,0,2} };
    
    var template (value) PLMN_List v_OneEquivalentPLMN  := cs_PLMN_List1(f_Asn2Nas_PlmnId ( f_EUTRA_CellInfo_GetGutiPLMN (eutra_CellI) ) );
    var template (value) PLMN_List v_FourEquivalentPLMN := cs_PLMN_List_4PLMNs(f_Asn2Nas_PlmnId ( v_HPLMN_004_02),
                                                                               f_Asn2Nas_PlmnId ( v_HPLMN_004_03),
                                                                               f_Asn2Nas_PlmnId ( v_HPLMN_004_07),
                                                                               f_Asn2Nas_PlmnId ( v_HPLMN_316_002) );

    timer t_Wait := f_EUTRA_SetTimerToleranceMax(eutra_CellI, 15.0);

    // Switch on UE
    //@siclog "Step 1" siclog@
    f_UT_SwitchOnUE (UT, false);

    //+ //@siclog "Step 2" siclog@
    //+ The UE transmits an ATTACH REQUEST message on cell A including a PDN CONNECTIVITY REQUEST message
    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())));
   v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
   v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
   }

    //+   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.
    //@siclog "Step 3 - 7a2" siclog@
    v_APN:= f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA,
                                                   f_CheckEsmInfoTransferFlag(v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST),
                                                   v_EPS_TI);

    //@siclog "Step 8" siclog@
    //+   SS responds with ATTACH ACCEPT message including a valid TAI list containing the TAIs of Cell A and Cell I; with
    //    PLMN ID of Cell A included in the GUTI; and with the PLMN ID of Cell I included in the Equivalent PLMNs IE. The ACTIVATE
    //    DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message
    f_TxAttachAcceptWithEquivalentPLMNList(eutra_CellA,
                                            v_EPS_Bearer_Id,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            v_AttachType,
                                            f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams_CellA),
                                            cs_TAIListMultiplePlmns(cs_MultiplePlmnsList({cs_PartialTAI(f_Asn2Nas_PlmnId(v_HPLMN_310_102), v_TAC0),
                                                                                          cs_PartialTAI(f_Asn2Nas_PlmnId(v_HPLMN_001_01), v_TAC0)})),
                                            omit,
                                            v_MSId,
                                            omit,
                                            v_APN,
                                            v_OneEquivalentPLMN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

    //@siclog "Step 9" siclog@
    //+   The UE transmits an ATTACH COMPLETE message including an
    //+   ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message?
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EPS_Bearer_Id))));
     //@siclog "Step 10 Void" siclog@

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

    //+   The signal strength of Cell I 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 shall select Cell I
    //@siclog "Step 12" siclog@
    f_EUTRA_SetCellPower(eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);

     //+ Wait [10] seconds for mobile to camp on cell I
     //@siclog "Step 13" siclog@
    f_Delay(10.0); // can't use t_Wait

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

    //@siclog "Step 15" siclog@
    //Check: does the UE send DETACH on cell I?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_MoSignalling,
                                             cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                               cr_508_DETACH_REQUEST_MO(cr_NAS_KeySetIdentifier (?, tsc_NasKsi_NativeSecurityContext),
                                                                                        f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                                        cr_DetachType( '1'B, v_AttachType))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 15");

    //@siclog "Step 16" siclog@
    //    Cells A and I are set to the Non-suitable "Off" level and cell B is set to the Serving Cell level
    f_EUTRA_SetCellPower(eutra_CellB, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellI, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now);

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

    //@siclog "Step 18" siclog@
    //   Check: does the UE send an ATTACH REQUEST message on cell B (including a PDN CONNECTIVITY REQUEST message) with the last visited
    //          TAI correctly indicating the TAI of cell I; the GUTI allocated in step 8 and the KSIASME allocated in step 3?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas( eutra_CellB,
                                              tsc_RRC_TI_Def,
                                              cr_EstablishmentCause_Any,
                                                cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                                  cdr_ATTACH_REQUEST_WithGuti(v_AttachType,
                                                                                                     v_AdditionalUpdateType,
                                                                                                     v_AuthParams_authentication.KSIasme,
                                                                                                     f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                                                     cr_TAI( v_PLMN_CellI, v_LAC_CellI)),
                                                                                  cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                  f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 18");

    v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
   v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
   }

   //@siclog "Step 18A - 18a2" siclog@
    v_APN:= f_EUTRA_NAS_AS_Security (eutra_CellA,
                                       f_CheckEsmInfoTransferFlag(v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST),
                                       v_EPS_TI,
                                       tsc_SRB1);
  
    //@siclog "Step 19" siclog@
    //   The SS sends an ATTACH ACCEPT message allocating 16 TAIs and an aligned set of equivalent PLMNs
    f_TxAttachAcceptWithEquivalentPLMNList(eutra_CellB,
                                            v_EPS_Bearer_Id,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            v_AttachType,
                                            f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams_CellB),
                                            cs_TAIListMultiplePlmns_multiTAI(cs_MultiplePlmnsList({cs_PartialTAI(f_Asn2Nas_PlmnId(v_HPLMN_004_02), v_TAC3),
                                                                                                    cs_PartialTAI(f_Asn2Nas_PlmnId(v_HPLMN_005_002), v_TAC3),
                                                                                                    cs_PartialTAI(f_Asn2Nas_PlmnId(v_HPLMN_004_03), v_TAC3)}),
                                                                             10,
                                                                             cs_PartialTAI(f_Asn2Nas_PlmnId(v_HPLMN_004_07), v_TAC_FFF0),
                                                                             f_Asn2Nas_PlmnId(v_HPLMN_001_01),
                                                                             {v_TAC1,v_TAC2,v_TAC27}
                                                                             ),
                                            omit,
                                            v_MSId,
                                            omit,
                                            v_APN,
                                            v_FourEquivalentPLMN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

    //+ The UE sends ATTACH COMPLETE
    //@siclog "Step 20" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellB,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EPS_Bearer_Id))));

    //@siclog "Step 21 Void" siclog@

    //@siclog "Step 22" siclog@
    //+  The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, v_RRC_ReleaseCause);

    //+ SS Wait [5] seconds
    //@siclog "Step 23" siclog@
    f_Delay( f_EUTRA_SetTimerToleranceMax(eutra_CellB, 5.0));

    //  EXCEPTION: steps 24 to 26 are repeated for N = 3 to N = 7 with cells B,C,G,H,K,N according to T3 in table 9.2.1.1.1a-2.

    //+    Cell power levels are set according to T3 and the value of N.
    //@siclog "Step 24(N=3)" siclog@
    f_EUTRA_SetCellPower(eutra_CellC, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellB, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    
    //+ Step 25(N=3)    Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 15 seconds?
    //@siclog "Step 25(N=3)" siclog@
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellC, 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 25(N=3)");
        }
      [] t_Wait.timeout {}
    }

    //+     Using the procedure of clause 6.4.2.2 of TS 36.508 [18],Check: does the UE camp on the strongest cell?
    //@siclog "Step 26(N=3)" siclog@
    f_EUTRA_508Check_IdleState ( eutra_CellC );

    //+     Cell power levels are set according to T3 and the value of N.
    //@siclog "Step 24(N=4)" siclog@
    f_EUTRA_SetCellPower(eutra_CellG, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellC, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now);
    
    //+     Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 15 seconds?
    //@siclog "Step 25(N=4)" siclog@
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellG, 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 25(N=4)");
        }
      [] t_Wait.timeout {}
    }

    //+    Using the procedure of clause 6.4.2.2 of TS 36.508 [18],Check: does the UE camp on the strongest cell?
    //@siclog "Step 26(N=4)" siclog@
    f_EUTRA_508Check_IdleState ( eutra_CellG );

    //+    Cell power levels are set according to T3 and the value of N.
    //@siclog "Step 24(N=5)" siclog@
    f_EUTRA_SetCellPower(eutra_CellH, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellG, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellC, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now);
    
    //+    Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 15 seconds?
    //@siclog "Step 25(N=5)" siclog@
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellH, 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 25(N=5)");
        }
      [] t_Wait.timeout {}
    }

    //+    Using the procedure of clause 6.4.2.2 of TS 36.508 [18],Check: does the UE camp on the strongest cell?
    //@siclog "Step 26(N=5)" siclog@
    f_EUTRA_508Check_IdleState ( eutra_CellH );

    //+    Cell power levels are set according to T3 and the value of N.
    //@siclog "Step 24(N=6)" siclog@
    f_EUTRA_SetCellPower(eutra_CellK, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellH, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellG, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now);
    
    //+   Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 15 seconds?
    //@siclog "Step 25(N=6)" siclog@
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellK, 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 25(N=6)");
        }
      [] t_Wait.timeout {}
    }

    //+     Using the procedure of clause 6.4.2.2 of TS 36.508 [18],Check: does the UE camp on the strongest cell?
    //@siclog "Step 26(N=6)" siclog@
    f_EUTRA_508Check_IdleState ( eutra_CellK );

    //+    Cell power levels are set according to T3 and the value of N.
    //@siclog "Step 24(N=7)" siclog@
    f_EUTRA_SetCellPower(eutra_CellE, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellK, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellH, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now);
    //+    Check: does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 15 seconds?
    //@siclog "Step 25(N=7)" siclog@
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellE, 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 25(N=7)");
        }
      [] t_Wait.timeout {}
    }

    //+   Using the procedure of clause 6.4.2.2 of TS 36.508 [18],Check: does the UE camp on the strongest cell?
    //@siclog "Step 26(N=7)" siclog@
    f_EUTRA_508Check_IdleState ( eutra_CellE );

    //+   Cell K is is set to the Non-suitable "Off" level. The signal strength of Cell E is lowered to
    //      that of a Suitable Neighbour Cell and that of Cell I is raised to the Serving Cell level.
    //      Note: the new list of equivalent PLMNs allocated in step 19 means that list of equivalent PLMNs
    //       allocated in step 8 should have been deleted. Hence the PLMN of cell I shall not be selected by a cell
    //       reselection process, and the UE shall remain camped on cell E.
    //@siclog "Step 27" siclog@
    f_EUTRA_SetCellPower(eutra_CellE, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellK, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);

    //+   Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on cell I in the next 15 seconds?
    //@siclog "Step 28" siclog@
    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 28");
        }
      [] t_Wait.timeout{}
    }

    //+  Using the procedure of clause 6.4.2.2 of TS 36.508 [18], page the UE on cells E and I.
                   //   Check: Does the UE camp on cell E and not on cell I?
    //@siclog "Step 29" siclog@
    // We just need to page the UE on Cell I at this point.  If it responds on Cell I it should be caught in the Check Idle function
    f_EUTRA_UE_Page ( eutra_CellI,
                      cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_GutiParams_CellI.MME_Code, v_GutiParams_CellI.M_TMSI )) );
    f_EUTRA_508Check_IdleState ( eutra_CellE );

   //+  Cell I is set to the Non-suitable "Off" level. The signal strength of Cell A
   //         is raised to the Serving Cell level such that that the UE shall select Cell A.
   //@siclog "Step 30" siclog@
    f_EUTRA_SetCellPower(eutra_CellI, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now);
    f_EUTRA_SetCellPower(eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now);
   //+ Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on cell A
   //         with the last visted TAI set to the TAI of cell E; the GUTI allocated in step 8 and the KSIASME allocated in step 3?
   //@siclog "Step 31" siclog@
   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_CellB),
                                                                                       cr_TAI(v_PLMN_CellE, v_LAC_CellE))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 31");

    // Bring UE to a stable state
    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))));
  } // function fl_tc_9_2_1_1_1a_Body

  //----------------------------------------------------------------------------
  /*
   * @desc      test body of test case 9.2.1.1.2
   * @status    APPROVED
   */
  function fl_TC_9_2_1_1_2_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize constant test case data structures
    // ==========================================================================
    var HalfOctet_Type v_EPS_Bearer_Id := tsc_EpsDefaultBearerId;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var template (omit) AccessPointName v_APN := omit;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();  //used to follow TTCN3 v411 standard
    var boolean v_EIT_Flag := false;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType(); //used to follow TTCN3 v411 standard

    // ==========================================================================
    // initialize component specific data structures
    // ==========================================================================
    // get all data which are required for a GUTI
    var GutiParameters_Type v_Guti_1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    // create new GUTI with different S-TMSI (gets sent to UE in Attach Accept)
    var GutiParameters_Type v_Guti_2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_Guti_1_Params);
    var B3_Type v_PDNValue := f_GetPdnType();
    var template (omit) ProtocolConfigOptions v_Pco := omit; // @sic R5s100084 sic@
    // ==========================================================================

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

    //  Send Paging with IMSI
    //@siclog "Step 1" siclog@
    f_EUTRA_UE_Page ( eutra_CellA,
                    cs_NasPaging_OneRecord ( cs_PagingUE_Identity_IMSI (f_ConvertImsi2ASN(px_IMSI_Def))));

    // - Does the UE send an ATTACH REQUEST including the IMSI?
    //@siclog "Step 2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               v_RRC_TI,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                 cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType), // @sic R5-103681 sic@
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 v_PDNValue)));

    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;
      }
    }
    if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) { // @sic R5s100084 sic@
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }

    // TP 1
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");

    //+   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.  Enable
    //    integrity protection/ciphering for RRC connection
    //@siclog "Step 3 - 6" siclog@
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA,  v_EIT_Flag, v_EPS_TI, false); // @sic R5s100094 sic@

    //@siclog "Step 7" siclog@
    //+   SS responds with ATTACH ACCEPT message with a new GUTI2 in the EPS Mobile Identity.
    f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                                  v_EPS_Bearer_Id,
                                                                  v_RRC_TI,
                                                                  v_EPS_TI,
                                                                  tsc_EAttachType_EpsOnly,
                                                                  f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)), // @sic R5s100084 sic@
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti_2_Params),
                                                                  cs_TrackingAreaIdListDef_lv,
                                                                  omit,
                                                                  omit,
                                                                  omit,
                                                                  v_APN,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                  v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType); // @sic R5-103681 sic@

    //@siclog "Step 8" siclog@
    //+   Check: does the UE transmit an ATTACH COMPLETE message including an
    //+   ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message?
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EPS_Bearer_Id))));
    //+  R5s100189
    //@siclog "Step 9" siclog@
    //+   Cause the UE to detach
    f_UT_InitiateDetach_EPSOnly (UT);

    //@siclog "Step 10" siclog@
    //+   UE transmits a Detach Request containing GUTI2
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_DETACH_REQUEST_MO (cr_NAS_KeySetIdentifier (?, tsc_NasKsi_NativeSecurityContext),
                                                                                      f_GutiParameters2MobileIdentity(omit, v_Guti_2_Params),
                                                                                      cr_DetachType( '0'B, v_AttachType))))); // R5-103675
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 10");
    
    //@siclog "Step 11" siclog@
    //+   SS responds with a Detach Accept message
        SRB.send (cas_SRB2_NasPdu_REQ ( eutra_CellA,
                                    cs_TimingInfo_Now,
                                    cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                   cs_508_DETACH_ACCEPT)));
  } // end of fl_TC_9_2_1_1_2_Body

  //----------------------------------------------------------------------------

    function fl_TC_9_2_1_1_4_Body() runs on EUTRA_PTC
    {
      var SRB_COMMON_IND v_ReceivedAsp;
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      var B3_Type v_PDNType := f_GetPdnType();
      var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
      var NAS_UL_Message_Type v_PdnConnectivityRequest;
      var template (omit) AccessPointName v_APN := omit;
      var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
      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 TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
      var template (value) TrackingAreaIdList v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN, { bit2oct( v_Tac) } );
      var template (omit) ProtocolConfigOptions v_Pco := omit;
      

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

      //  Check: Does the UE transmit an RRCConnectionRequest message not including S-TMSI and with
      //         establishmentCause set to 'mo-Signalling'?
      //@siclog "Step 2" siclog@
      SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA,
                                      cr_RRCConnectionRequest_withUE_Identity(
                                                           cr_InitialUE_Identity_Random,
                                                           mo_Signalling)));


      // The SS transmits a RRCConnectionSetup message
      //@siclog "Step 3" siclog@
      f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellA, cs_TimingInfo_Now, v_RRC_TI);


      // Check: does the UE transmit an RRCConnectionSetupComplete message including a
      //        PDN CONNECTIVITY REQUEST message with IE PROTOCOL CONFIGURATION OPTIONS
      //        indicating a DSMIPv6 IPv4 Home Agent Address Request?
      //@siclog "Step 4" siclog@
      SRB.receive(car_SRB1_RrcNasPdu_IND( eutra_CellA,
                                          cr_508_RRCConnectionSetupComplete(v_RRC_TI, ?),
                                          cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                          cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                          cr_508_PDN_CONNECTIVITY_REQUEST( tsc_PdnRequest_InitialAttach,
                                                                                           v_PDNType ))))
        -> value v_ReceivedAsp;

      v_PdnConnectivityRequest := v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg;
      v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
        v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
      
          //The IE Protocol configuration options contains a configuration protocol option = "0009H" ("DSMIPv6 IPv4 Home Agent Address Request", lenght of contents = 0).
          if (not (isvalue (v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions.pco[0].content)) and
                  (v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions.pco[0].protocolLength == '00'O) and
                   (v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions.pco[0].protocolID == hex2oct('0009'H)))
               {
                      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4: ATTACH REQUEST message received from UE indicating a DSMIPv6 IPv4 Home Agent Address");
                  }
          else {
                      f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 4: ATTACH REQUEST message not properly configured from UE");
                  }

      }
      else {
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 4: Protocol configuration options IE not included from UE");
      }


      // + Steps 5 to 13 of the generic test procedure in TS 36.508 Table 4.5.2.3-1 (Attach procedure)
      //          are performed on Cell A
      //@siclog "Steps 5 to 13" siclog@
      f_EUTRA_IdleUpdated_Step5_13( eutra_CellA, STATE2_IDLEUPDATE, v_ReceivedAsp.Signalling.Nas[0]);


      // + SS responds with ATTACH ACCEPT message including a valid TAI list.
      //          The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message,
      //          including the IE PROTOCOL CONFIGURATION OPTIONS indicating a DSMIPv6 IPv4 Home Agent Address
      //  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.
      //@siclog "Step 14" siclog@
      v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN,
                                               { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA)) });

      f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                                    tsc_EpsDefaultBearerId,
                                                                    tsc_RRC_TI_Def,
                                                                    v_EPS_TI,
                                                                    v_AttachType,
                                                                    f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                                    f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                    v_TaiList,
                                                                    omit,
                                                                    omit,
                                                                    omit,
                                                                    v_APN,
                                                                    v_Pco,
                                                                    v_PdnConnectivityRequest.aTTACH_REQUEST.addUpdateType);
 

      // + The UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message.
      //@siclog "Step 15" siclog@
      f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5: ATTACH COMPLETE");

    } // function tc_9_2_1_1_4_EUTRA

  //----------------------------------------------------------------------------

  function fl_TC_9_2_1_1_7_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    var HalfOctet_Type v_EPS_Bearer_Id := tsc_EpsDefaultBearerId;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var NAS_MSG_Indication_Type v_NasInd;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellG);
    var template (omit) AccessPointName v_APN := omit;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var template (value) TrackingAreaIdList v_TaiList;
    var template (value) CellPowerList_Type v_CellPowerList;
    var boolean v_EIT_Flag := false;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();

    //@siclog "Step 1" siclog@
    //The SS configures: Cell A as the "Serving cell". Cell G as a "Non-Suitable cell". Cell I as a "Non-Suitable cell".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

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

    //@siclog "Step 3" siclog@
    //+  The UE transmits an ATTACH REQUEST message.
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                              v_RRC_TI,
                                              cr_EstablishmentCause_Any,
                                            cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                              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

    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;
    }}
    if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }


    //+  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 7Aa1 and 7Aa2 ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
    //@siclog "Step 4 - 7Aa2" siclog@
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA,v_EIT_Flag, v_EPS_TI, false);

    //@siclog "Step 8" siclog@
    //+  SS responds with ATTACH ACCEPT message including PLMN2, PLMN3 and PLMN4 in the list of equivalent PLMNs.
    f_TxAttachAcceptWithEquivalentPLMNList(eutra_CellA,
                                           v_EPS_Bearer_Id,
                                           v_RRC_TI,
                                           v_EPS_TI,
                                           tsc_EAttachType_EpsOnly,
                                           f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                           f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                           cs_TrackingAreaIdListDef_lv,
                                           omit,
                                           omit,
                                           omit,
                                           omit,
                                           cs_PLMNList_3(tsc_PLMN2,tsc_PLMN3, tsc_PLMN4),
                                           f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                           v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

    //@siclog "Step 9" siclog@
    //+  The UE transmits an ATTACH COMPLETE message
    f_EUTRA_NAS_AttachComplete(eutra_CellA, v_EPS_Bearer_Id);

    //@siclog "Step 10" siclog@
    //+  The UE is switched off.
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_CONNECTED );

    //@siclog "Step 11" siclog@
    //+  The SS configures: Cell A as the "Non-Suitable cell". Cell G as a "Suitable cell". Cell I as a "Serving cell".
    //   Note: Cell I belongs to the forbidden PLMN.
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

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

    // EXCEPTION: The behaviour in table 9.2.1.1.7.3.2-2 occurs in parallel with step 13.
    // This is implicitely tested, i.e. if the UE sends any message other than that in step 13,
    // the test will fail.

    //@siclog "Step 13" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message on PLMN2?
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                              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

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

    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
   // @sic R5-101122 sic@
   //  Security Mode Command, Security Mode Complete
   //@siclog "Step 13A - 13B" siclog@
   v_NasCountUL := f_EUTRA_NAS_ActivateSecurity(eutra_CellG,v_SecurityParams);

   // ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
   //@siclog "Step 13Aa1 - 13Aa2" siclog@
    if (f_CheckEsmInfoTransferFlag(v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST)) {
      v_APN := f_ESM_InformationTransfer_GetAPN (eutra_CellG, v_EPS_TI);
    }
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellG,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);


    //@siclog "Step 14" siclog@
    // The SS transmits an ATTACH ACCEPT message without the Equivalent PLMNs list.
    // The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message.
    f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellG,
                                            tsc_EpsDefaultBearerId,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            tsc_EAttachType_EpsOnly,
                                            f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                            cs_TrackingAreaIdListDef_lv,
                                            omit,
                                            omit,
                                            omit,
                                            v_APN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);
    //@siclog "Step 15" siclog@
    //+ Check: does the UE transmit an ATTACH COMPLETE?
    f_EUTRA_NAS_AttachComplete(eutra_CellG, tsc_EpsDefaultBearerId);

    // The SS configures: Cell A as a "Suitable cell",
    //  Cell I as a "Non-suitable "Off" cell".
    //  Cell J as a "Serving cell".
    //@siclog "Step 15A" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    // Tested implicitly: EXCEPTION: The behaviour in table 9.2.1.1.7.3.2-3 occurs in parallel with step 15B.

    //  Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message on Cell A (PLMN1)?
    //@siclog "Step 15b" siclog@
    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 15b");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;

    // enable integrity/ciphering in AS (but not NAS as the NAS security context
    // gets activated implicitly by receiving the TAU request with a valid MAC)
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellA,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);

    //The SS sends TRACKING AREA UPDATE ACCEPT.
    //@siclog "Step 15c" siclog@
    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(
                                                                  tsc_EpsUpdate_TaUpdate,
                                                                  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);

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

   //@siclog "Step 16-34 Void" siclog@

  }// function fl_tc_9_2_1_1_7_Body

  /*
   * @desc      test body of TC_9_2_1_1_9 and TC_9_2_1_1_10
   * @param     p_RejectCause
   * @status    APPROVED
   */
  function fl_TC_9_2_1_1_9_and_10_Body(NAS_CauseValue_Type p_RejectCause) runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var ReleaseCause v_RRC_ReleaseCause := other;
    var NAS_MSG_Indication_Type v_NasInd;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var float v_NoReactionTime := f_EUTRA_SetTimerToleranceMax( eutra_CellB, 3.0 );
    var template (value) CellPowerList_Type v_CellPowerList;

    //@siclog "Step 1" siclog@
    //+ The SS configures Cell A as the "Serving cell". Cell B as a "Non-Suitable cell". Cell G as a "Non-Suitable cell"
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_ServingCellRS_EPRE ),
      cs_CellPower( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower( eutra_CellG, tsc_NonSuitableOffCellRS_EPRE ) // @sic R5-104728 sic@
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 2" siclog@
    //+   The UE is switched on.
    f_UT_SwitchOnUE (UT, false );
    
    //@siclog "Step 3" siclog@
    //+   Check: does the UE transmit an ATTACH REQUEST message
    //    including a GUTI and a PDN CONNECTIVITY REQUEST message on cell A?
    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())));
    
    //@siclog "Step 4" siclog@
    //+ The SS transmits an ATTACH REJECT message with EMM cause = "Illegal UE" as specified.
    // Note: In test case 9.2.1.1.9 the reject cause is tsc_EmmCause_IllegalUe
    //       Test case 9.2.1.1.10 is identical to 9.2.1.1.9 except that reject cause is tsc_EmmCause_IllegalMe
    SRB.send( cas_SRB1_NasPdu_REQ( eutra_CellA,
                                   cs_TimingInfo_Now,
                                   cs_NAS_Request( tsc_SHT_NoSecurityProtection,
                                                   cs_508_AttachReject( cs_EMM_Cause_v(p_RejectCause),
                                                                        omit ))));
    
    //@siclog "Step 5" siclog@
    //+  The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, v_RRC_ReleaseCause);
    
    //@siclog "Step 6" siclog@
    //+ The SS configures: Cell A as a "Non-Suitable cell". Cell B as 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 7" siclog@
    // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
    // Note: Cell B belongs to the same PLMN where the UE was rejected but a different TA
    f_EUTRA_CheckNoAttachOn1Cell( eutra_CellB, 30.0, "Step 7");
    
    //@siclog "Step 8" siclog@
    //+ The operator initiates an attach by MMI or by AT command.
    f_UT_TriggerAttach(UT);
    
    //@siclog "Step 9" siclog@
    //  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
    f_EUTRA_CheckNoAttachOn1Cell( eutra_CellB, 30.0, "Step 9");
    
    //@siclog "Step 10 Void" siclog@
    
    //@siclog "Step 11" siclog@
    //  Check: Does the test result of CALL generic procedure (TS 36.508 subclause 6.4.2.5) indicate that
    //         the UE ignores paging on cell B for PS domain with GUTI-1?
    f_EUTRA_508Check_NASNoResponse( eutra_CellB,
                                    cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_GutiParams.MME_Code, v_GutiParams.M_TMSI )),
                                    v_NoReactionTime );
    
    //@siclog "Step 12" siclog@
    //+ The SS configures: Cell A as "Off", Cell B as a "Non-Suitable cell". Cell G as the "Serving cell".
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE ), // @sic R5-104728 sic@
      cs_CellPower( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower( eutra_CellG, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 13" siclog@
    //+ Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on cell G or on cell B?
    f_EUTRA_CheckNoAttachOn1Cell( eutra_CellG, 30.0, "Step 13");
    
    //@siclog "Step 14" siclog@
    //+ The user initiates an attach by MMI or by AT command
    f_UT_TriggerAttach(UT);
    
    //@siclog "Step 15" siclog@
    // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
    f_EUTRA_CheckNoAttachOn1Cell( eutra_CellG, 30.0, "Step 15");
    
    //@siclog "Step 16" siclog@
    f_UT_SwitchOffUE( UT, false );
    //@siclog "Step 17" siclog@
    f_UT_SwitchOnUE(UT, false );
    
    //@siclog "Step 18 Void" siclog@
    
    // Check: Does the UE transmit an ATTACH REQUEST message with IMSI-1? (on Cell G)
    //@siclog "Step 19" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                               v_RRC_TI,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                 cdr_ATTACH_REQUEST_IMSIonly( v_AttachType, v_AdditionalUpdateType),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 19");

    //@siclog "Step 20-31" siclog@
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellG, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false); // R5-105005
    
  }// function fl_tc_9_2_1_1_9_and_10_Body


function fl_TC_9_2_1_1_13_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    var template (value) CellPowerList_Type v_CellPowerList;
    var NAS_MSG_Indication_Type v_NasInd;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var B3_Type v_PDNValue := f_GetPdnType();
    var GutiParameters_Type v_GutiParams_CellI := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
    var NAS_PlmnId v_PLMN_I := f_Asn2Nas_PlmnId (v_GutiParams_CellI.PLMN_Identity);
    var NAS_Lac  v_LAC_CellI   := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellI);
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();

    //@siclog "Step 1" siclog@
    // The SS configures Cell G as the "Serving cell",Cell H as a " Suitable Neighbour cell", Cell I as a "Non-Suitable Off cell".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellH, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 2 - 5" siclog@
    // UE is switched on, sends and ATTACH REQUEST and SS transmits an ATTACH REJECT with reject cause set to illegalME
    f_EUTRA_AttachReject (eutra_CellG, tsc_Cause_PLMN_NotAllowed);  // @sic R5-101012 sic@

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

    //@siclog "Step 7" siclog@
    f_UT_SwitchOffUE (UT, false );
    //@siclog "Step 8" siclog@
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 9" siclog@
    f_EUTRA_CheckNoAttachOn2Cells (eutra_CellG, eutra_CellH, 30.0);

    //@siclog "Step 10" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellH, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellI, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //  The following messages are sent and shall be received on cell I
    //  - Does the UE send an ATTACH REQUEST including the IMSI?
    //@siclog "Step 11 - 12" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                               v_RRC_TI,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                 cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 v_PDNValue)));

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

    // //@siclog "Step 12A 12M" siclog@
    // The SS completes the attach procedure successfully and then releases the RRC -connection by executing
    // steps 5 to 17 of UE registration procedure in TS 36.508 clause 4.5.2.3.
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellI, STATE2_IDLEUPDATE, NORMAL, v_NasInd);

    //@siclog "Step 13 - 19 Void" siclog@

    //@siclog "Step 20 - 21" siclog@
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellI, RRC_IDLE );

    //@siclog "Step 22" siclog@
    v_CellPowerList := {
      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@
    f_UT_SwitchOnUE (UT, false );
    // Steps 25 and 26. Select PLMN of cell G (as set in fl_EUTRA_InitNAS_forNAS_Cells)
    //@siclog "Step 25 - 26" siclog@
    f_UT_ManualPLMN_Select (UT, "PLMN(001,02)");

    //@siclog "Step 27" siclog@
    // Check: Does the UE transmit an ATTACH REQUEST message including
    // a PDN CONNECTIVITY REQUEST message as specified?
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                               cdr_ATTACH_REQUEST_AttachType(v_AttachType,
                                                                             v_AdditionalUpdateType,
                                                                             f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellI),
                                                                             cr_TAI (v_PLMN_I, v_LAC_CellI),
                                                                             cr_LAI_Any ifpresent,
                                                                             cr_TMSI_Status ifpresent),
                                                cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                f_GetPdnType())));

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

    //@siclog "Step 28 - 40" siclog@
    // The SS completes the attach procedure successfully and then releases the RRC -connection by executing
    // steps 5 to 17 of UE registration procedure in TS 36.508 clause 4.5.2.3.
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellI, STATE2_IDLEUPDATE, NORMAL, v_NasInd);

    }// function fl_tc_9_2_1_1_13_Body



  /*
   * @desc      test body of TC_9_2_1_1_14
   * @status    APPROVED
   */
  function fl_TC_9_2_1_1_14_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================

    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var ReleaseCause v_RRC_ReleaseCause := other;
    var NAS_MSG_Indication_Type v_NasInd;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var template (value) CellPowerList_Type v_CellPowerList;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var B3_Type v_PDNType := f_GetPdnType();
    
    //@siclog "Step 1" siclog@
    //The SS configures:The SS configures:Cell A as the "Serving cell".Cell B as a "Suitable cell".
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_ServingCellRS_EPRE  ),
      cs_CellPower( eutra_CellB, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList( v_CellPowerList, cs_TimingInfo_Now );

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

    //@siclog "Step 3" siclog@
    //+ The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message as specified on Cell A.
    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())));
    
    v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses
    
    //@siclog "Step 4" siclog@
    //+ The SS transmits an ATTACH REJECT message, EMM cause = "Tracking area not allowed".
    //+ (The list of "forbidden tracking areas for roaming" in the UE should now contain TAI-1)
    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 5" siclog@
    //+ The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, v_RRC_ReleaseCause);

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

    // The user initiates an attach by MMI or by AT command.
    //@siclog "Step 7" siclog@
    f_UT_TriggerAttach(UT); // @sic R5-101012 sic@
    
    //+ Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on Cell A? (F)
    //@siclog "Step 8" siclog@
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellA, 30.0); // @sic R5-101012 sic@
    
    //@siclog "Step 9" siclog@
    //+ The SS reconfigures:
    //+ Cell A as a "Suitable cell".  Cell B as a " serving cell"
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_SuitableCellRS_EPRE ),
      cs_CellPower( eutra_CellB, tsc_ServingCellRS_EPRE  )
    };
    f_EUTRA_SetCellPowerList( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 10" siclog@
    //+ Check: Does the UE transmit the ATTACH REQUEST message including
    //         a PDN CONNECTIVITY REQUEST message as specified on Cell B? ( 1,4, P)
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                 cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 f_GetPdnType())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 10");
    
    //+ The SS transmits an ATTACH REJECT message, EMM cause = "Tracking area not allowed".
    //+ (The list of "forbidden tracking areas for roaming" in the UE should now contain TAI-1 and TAI-2)
    //@siclog "Step 11" siclog@
    SRB.send( cas_SRB1_NasPdu_REQ( eutra_CellB,
                                   cs_TimingInfo_Now,
                                   cs_NAS_Request( tsc_SHT_NoSecurityProtection,
                                                   cs_508_AttachReject( cs_EMM_Cause_v(tsc_Cause_TA_NotAllowed),
                                                                        omit ))));
    
    //+ The SS releases the RRC connection.
    //@siclog "Step 12" siclog@
    f_EUTRA_RRC_ConnectionRelease( eutra_CellB, v_RRC_TI, v_RRC_ReleaseCause );
    
    //+ The SS reconfigures:
    //+ Cell A as the "Serving cell". Cell B as a " Suitable cell",
    //@siclog "Step 13" siclog@
    v_CellPowerList := {
      cs_CellPower( eutra_CellA, tsc_ServingCellRS_EPRE  ),
      cs_CellPower( eutra_CellB, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 14" siclog@
    //+ Check: Does the UE transmit the ATTACH REQUEST message in the next 30 seconds? (1,3,5, F)
    f_EUTRA_CheckNoAttachOn2Cells( eutra_CellA, eutra_CellB, 30.0);

    //@siclog "Step 15" siclog@
    //+ If possible (see ICS) switch off is performed. Otherwise the power is removed.
    f_UT_SwitchOffUE(UT, false);

    //@siclog "Step 16" siclog@
    //+ The SS reconfigures:
    //+ Cell A as the "Serving cell". Cell B as a " 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 );

    //@siclog "Step 17" siclog@
    //+ The UE is brought back to operation.
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 18 Void" siclog@

    //@siclog "Step 19" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               v_RRC_TI,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                 cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach, v_PDNType)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 19");
    
    //@siclog "Step 30 - 32" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd);
    
  }// function fl_tc_9_2_1_1_14_Body
  

  function fl_TC_9_2_1_1_15_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================

    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_MSG_Indication_Type v_NasInd;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var template (value) CellPowerList_Type v_CellPowerList;
    var B3_Type v_PDNValue := f_GetPdnType();
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();

    //@siclog "Step 1" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellE, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now ); // @sic R5-101012 sic@

    //@siclog "Step 2" siclog@
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 3" siclog@
    //+ The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on Cell I.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                             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())));
    v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses

    //@siclog "Step 4" siclog@
    //+ The SS transmits an ATTACH REJECT message, EMM cause = "roaming not allowed in this tracking area ".
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellI,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                       cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_roaming_NotAllowed),
                                                                             omit))));
    //@siclog "Step 5" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellI, v_RRC_TI, other);

    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on Cell I? (F)
    //@siclog "Step 6" siclog@
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellI, 30.0);

    //  The operator 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 I? (F)
    //@siclog "Step 8" siclog@
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellI, 30.0);

    //@siclog "Step 8a" siclog@
    // The following messages are to be observed on Cell E unless explicitly stated otherwise.
    //The SS configures:Cell I as the "Serving cell".Cell E as a " Suitable Neighbour cell",Cell C as a "Non-Suitable Off cell".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellE, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now ); // @sic R5-101012 sic@
 
    //  Check: Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on Cell E as specified?
    // Note: according to TS 24.301, the UE has the choice to enter "LIMITED-SERVICE" or "PLMN- SEARCH" state. But in any case it shall do a PLMN selection.
    //      In the first option, the UE shall apply reselection so it will select cell E and then attempt to attach; in the second option it will select the
    //      same PLMN again and exclude cells from forbidden TAs so it will select cell E.
    //@siclog "Step 9" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellE,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_IndicationWithPiggybacking( tsc_SHT_NoSecurityProtection,
                                                                                cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 v_PDNValue)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9");

    //@siclog "Step 10" siclog@
    //+ The SS transmits an ATTACH REJECT message, EMM cause = "roaming not allowed in this tracking area ".
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellE,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                       cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_roaming_NotAllowed),
                                                                             omit))));
    //@siclog "Step 11" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellE, v_RRC_TI, other);

    //@siclog "Step 12" siclog@
    f_EUTRA_CheckNoAttachOn2Cells(eutra_CellI, eutra_CellE, 60.0);

    //@siclog "Step 13" siclog@
    f_UT_SwitchOffUE (UT, false );

    //@siclog "Step 14" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellE, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 15" siclog@
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 16" siclog@
    //+ The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on Cell I.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_IndicationWithPiggybacking( tsc_SHT_NoSecurityProtection,
                                                                                cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                                cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                v_PDNValue)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 16");

    //@siclog "Step 17" siclog@
    //+ The SS transmits an ATTACH REJECT message, EMM cause = "roaming not allowed in this tracking area ".
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellI,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                       cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_roaming_NotAllowed),
                                                                             omit))));

    //@siclog "Step 18" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellE, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 19" siclog@
    // The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on Cell C.
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                              tsc_RRC_TI_Def,
                                              cr_EstablishmentCause_Any,
                                              cr_NAS_IndicationWithPiggybacking( tsc_SHT_NoSecurityProtection,
                                                                                 cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 v_PDNValue)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 19");

    //@siclog "Steps 20 - 32" siclog@
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellC, STATE2_IDLEUPDATE, NORMAL, v_NasInd);

  }// function fl_tc_9_2_1_1_15_Body

  function fl_TC_9_2_1_1_16_Body() runs on EUTRA_PTC
  {
      var template (value) CellPowerList_Type v_CellPowerList;
      var NAS_MSG_Indication_Type v_NAS_Ind;
      var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
      var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
      timer t_Wait := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 30.0 );
 
      //@siclog "Step 1" siclog@
      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 );

      //@siclog "Step 2 Void" siclog@

      // Switch on UE
      //@siclog "Step 3" siclog@
      f_UT_SwitchOnUE (UT, false);
    
      //  The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
      //@siclog "Step 4" siclog@
      v_NAS_Ind:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellG,
                                                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())));

      //@siclog "Step 5" siclog@
      // The SS transmits an ATTACH REJECT message with EMM cause = "EPS services not allowed in this PLMN"
      SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellG,
                                        cs_TimingInfo_Now,
                                        cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                         cs_508_AttachReject (
                                                                     cs_EMM_Cause_v(tsc_Cause_EPSServNotAllowed),
                                                                     omit))
                                       ));

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

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

      //@siclog "Step 8" siclog@
      // Note: cellG and cellH are in the different TAI and same PLMN
      v_CellPowerList := {
        cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE ),
        cs_CellPower ( eutra_CellH, tsc_ServingCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      //@siclog "Step 9 Void" siclog@
      //@siclog "Step 10" siclog@
      // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
      f_EUTRA_CheckNoAttachOn1Cell ( eutra_CellH, 30.0 );

      //@siclog "Step 11" siclog@
      // Note: cellG and cellI are different PLMNs
      v_CellPowerList := {
          cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellH, tsc_NonSuitableCellRS_EPRE )
      }
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


      //@siclog "Step 12 Void" siclog@
      //  Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
      //@siclog "Step 13" siclog@
      v_NAS_Ind:= f_EUTRA_RRC_ConnEst_DefWithNas( eutra_CellI,
                                                  tsc_RRC_TI_Def,
                                                  cr_EstablishmentCause_Any,
                                                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                         cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                         cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                         f_GetPdnType())));
      f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 13");


      //@siclog "Step 13a" siclog@
      // The SS completes the attach procedure successfully and then releases the RRC
      // connection by executing steps 5 to 17 of UE registration procedure in TS 36.508 clause 4.5.2.3
      f_EUTRA_IdleUpdated_Step5_17 (eutra_CellI, STATE2_IDLEUPDATE, NORMAL, v_NAS_Ind);

      //@siclog "Step 14 - 20 Void" siclog@

      // If possible (see ICS) switch off is performed. Otherwise the power is removed.
      //@siclog "Step 21" siclog@
      f_UT_SwitchOffUE (UT, false);

      //@siclog "Step 22" siclog@
      // The SS reconfigures:
      // Cell G as the "Serving cell". Cell I as a " Non Suitable cell",
      v_CellPowerList := {
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE )
      };
      f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

      //@siclog "Step 23" siclog@
      // The UE is brought back to operation.
      f_UT_SwitchOnUE (UT, false );

      //@siclog "Step 24 Void" siclog@
      //@siclog "Step 25" siclog@
      // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
      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,
                                                                   cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType)
                                                                   )
                                                 ));
              f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 25");
          }
          [] t_Wait.timeout
          {
              f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "step 25");
          }
     }

     //@siclog "Step 26" siclog@
     // The SS transmits an ATTACH REJECT message with EMM cause = "EPS services not allowed in this PLMN"
     SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellG,
                                       cs_TimingInfo_Now,
                                       cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                                    cs_508_AttachReject (
                                                                         cs_EMM_Cause_v(tsc_Cause_EPSServNotAllowed),
                                                                         omit))
                                      ));

     //  Select PLMN of cell G (as set in fl_EUTRA_InitNAS_forNAS_Cells)
     //@siclog "Step 27 - 28" siclog@
     f_UT_ManualPLMN_Select (UT, "PLMN(001,02)");

     //  Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
     //@siclog "Step 29" siclog@
     v_NAS_Ind:= f_EUTRA_RRC_ConnEst_DefWithNas( eutra_CellG,
                                                 tsc_RRC_TI_Def,
                                                 cr_EstablishmentCause_Any,
                                                 cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                         cdr_ATTACH_REQUEST_IMSIonly(v_AttachType, v_AdditionalUpdateType),
                                                                         cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                         f_GetPdnType())));
     f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 29");

     //@siclog "Steps 30 - 42" siclog@
     // The attach procedure is completed and the RRC connection is released
     // by executing steps 5 to 17 of TS 36.508 sub clause 4.5.2.3.
     f_EUTRA_IdleUpdated_Step5_17 (eutra_CellG, STATE2_IDLEUPDATE, NORMAL, v_NAS_Ind);
 
    }// end function fl_TC_9_2_1_1_16_Body



  function fl_TC_9_2_1_1_17_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    var NAS_MSG_Indication_Type v_NasInd;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var ReleaseCause v_RRC_ReleaseCause := other;
    var template (value) CellPowerList_Type v_CellPowerList;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();

    //@siclog "Step 1" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellK, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellL, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

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

    //@siclog "Step 3" siclog@
    //+  The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message as specified on Cell I.
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                              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())));

    //@siclog "Step 4" siclog@
    //  The SS transmits an ATTACH REJECT message, EMM cause = "No suitable cells in tracking area".
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellI,
                                      cs_TimingInfo_Now,
                                    cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                     cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_NoSuitableCells),
                                                                           omit))));

    //@siclog "Step 5" siclog@
    //+  The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellI, v_RRC_TI, v_RRC_ReleaseCause);

    //@siclog "Step 6" siclog@
    //   Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on Cell I or Cell K? (1, F)
    f_EUTRA_CheckNoAttachOn2Cells(eutra_CellI, eutra_CellK, 30.0);

    //@siclog "Step 7" siclog@
    //  The SS reconfigures:Cell I as a "Suitable cell",Cell K as the "Serving cell",Cell L as a "Non-Suitable cell",Cell J as a "Non-Suitable cell ".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellK, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellL, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 8" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds on Cell K or Cell I? (2, F)
    f_EUTRA_CheckNoAttachOn2Cells(eutra_CellI, eutra_CellK, 30.0);

    //@siclog "Step 8A" siclog@
    //+  If possible (see ICS) switch off is performed. Otherwise the power is removed.
    f_UT_SwitchOffUE (UT, false);

    //@siclog "Step 9" siclog@
    //+  //  The SS reconfigures:   Cell I as a "Serving cell", Cell K, Cell L and Cell J as a "Off cell".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellK, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellL, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 9A" siclog@
    //+  The UE is brought back to operation.
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 9B" siclog@
    //+  The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message as specified on Cell I.
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                              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())));

    //@siclog "Step 9C" siclog@
    //+  //  The SS reconfigures:   Cell I as a "Serving cell", Cell K as "Off" and Cell L and Cell J as a "Suitable cell".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellK, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellL, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellJ, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    
    //@siclog "Step 9D" siclog@
    //  The SS transmits an ATTACH REJECT message, EMM cause = "No suitable cells in tracking area".
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellI,
                                      cs_TimingInfo_Now,
                                    cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                     cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_NoSuitableCells),
                                                                           omit))));

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

    //@siclog "Step 10" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message as specified on Cell L? (3,4, P)
    SRB.receive(car_SRB1_NasPdu_IND(
                                    eutra_CellL,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                      cdr_ATTACH_REQUEST_WithOldMobileIdNoTAI( v_AttachType,
                                                                                                               v_AdditionalUpdateType,
                                                                                                               f_Imsi2MobileIdentity(px_IMSI_Def)),
                                                                      cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                      f_GetPdnType()))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 10");

    //@siclog "Step 11" siclog@
    //+  The SS transmits an ATTACH REJECT message, EMM cause = "Tracking area not allowed".(The list of "forbidden tracking areas for roaming" in the UE should now contain TAI-9 and TAI-11)
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellL,
                                      cs_TimingInfo_Now,
                                    cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                     cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_TA_NotAllowed),
                                                                           omit))));

    //@siclog "Step 12" siclog@
    //+  The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellL, tsc_RRC_TI_Def, v_RRC_ReleaseCause);

    //@siclog "Step 13" siclog@
    //+  The SS reconfigures:Cell I as the "Serving cell".Cell K as a Non-Suitable off cell,Cell L as a " Suitable cell",Cell J as a "Non-Suitable off cell".
    v_CellPowerList := {
      cs_CellPower ( eutra_CellI, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellK, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellL, tsc_SuitableCellRS_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 the ATTACH REQUEST message in the next 30 seconds? (5,F)
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellI, 30.0);

    //@siclog "Step 15" siclog@
    //+  If possible (see ICS) switch off is performed. Otherwise the power is removed.
    f_UT_SwitchOffUE (UT, false);

    //@siclog "Step 16" siclog@
    //+  The UE is brought back to operation.
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 17 Void" siclog@

    //@siclog "Steps 18 - 31" siclog@
    f_EUTRA_AttachProcedure(eutra_CellI, "Step 18")

  }// function fl_tc_9_2_1_1_17_Body

  function fl_TC_9_2_1_1_18_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================

    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_MSG_Indication_Type v_NasInd;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var GutiParameters_Type v_GutiParams_cellC:= f_EUTRA_CellInfo_GetGuti ( eutra_CellC );
    var GutiParameters_Type v_GutiParams:= f_EUTRA_CellInfo_GetGuti ( eutra_CellA );
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
    var template (value) CellPowerList_Type v_CellPowerList;
    var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellA );
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var EPS_BearerContextStatus v_EPS_ContextStatus;
    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 template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template (value) TrackingAreaIdList v_TaiList := cds_TAIListNonConsecutive_tlv ( v_PLMN, { bit2oct(v_Tac) } );
    var template (omit) AccessPointName v_APN := omit;
    var boolean v_EIT_Flag := false;
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var SRB_COMMON_IND v_ReceivedAsp;

    timer t_WaitTimer_A := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 30.0);
    timer t_WaitTimer_B := f_EUTRA_SetTimerToleranceMin(eutra_CellB, 30.0);


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

    //@siclog "Step 2" siclog@
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 3" siclog@
    //+ The UE transmits 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())));
    v_EPS_TI := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses

    //@siclog "Step 4" siclog@
    //+ The SS transmits an ATTACH REJECT message with EMM cause = " Not authorized for this CSG " as specified.
    SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                      cs_TimingInfo_Now,
                                      cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_NotAuthorizedCSG),
                                                                             omit))));
    //@siclog "Step 5" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, other);

    //+ The SS configures: Cell A as a " Not Suitable cell". Cell B as a " Serving cell". Cell C as a " Suitable cell".
    //@siclog "Step 6" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_SuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //+ Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds? Note: The UE shall search for a suitable cell in the same PLMN.  (1,P)
    //@siclog "Step 7" siclog@
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                            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
    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;
    }}
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 7");

    //+ Step 8  The SS transmits an AUTHENTICATION REQUEST message to initiate the EPS authentication and AKA procedure.
    //+ Step 9  The UE transmits an AUTHENTICATION RESPONSE message and establishes mutual authentication.
    //+ Step 10 The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS security.
    //+ Step 11 The UE transmits a NAS SECURITY MODE COMPLETE message and establishes the initial security configuration.
    //     -    EXCEPTION: Steps 12a1 to 12a2 describe behaviour that depends on UE configuration.
    //+ Step 12a1   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.
    //+ Step 12a2   The UE transmits an ESM INFORMATION RESPONSE message to transfer protocol configuration options and/or APN.
    //+ Step 13 SS responds with ATTACH ACCEPT message. The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message.
    //     -    EXCEPTION: In parallel to the event described in step14 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.
    //+ Step 14 The UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message.
    //@siclog "Step 8 - 14" siclog@
     v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellC, v_EIT_Flag, v_EPS_TI);
     f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellC,
                                            tsc_EpsDefaultBearerId,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            tsc_EAttachType_EpsOnly,
                                            f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams_cellC),
                                            cs_TrackingAreaIdListDef_lv,
                                            omit,
                                            omit,
                                            omit,
                                            v_APN,
                                            f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                            v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);
    f_EUTRA_NAS_AttachComplete(eutra_CellC, tsc_EpsDefaultBearerId);

    //+  The SS configures:- Cell A as a "Non-Suitable cell".- Cell B as the "Serving cell".- Cell C as a "Not Suitable cell".
    //@siclog "Step 15" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


    //@siclog "Step 16" siclog@
    //+ Check: does the UE transmits a TRACKING AREA UPDATE REQUEST message in the next 30 seconds? (2,F)
    t_WaitTimer_B.start;
    alt {
       []  SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                      cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                         cr_508_TAU_Request(tsc_EpsUpdate_TaUpdate,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType))))
         {
           t_WaitTimer_B.stop;
           f_EUTRA_SetVerdictFailOrInconc (__FILE__, __LINE__, "Step 16");
         }
       []  t_WaitTimer_B.timeout
         {
         }
    }

    //@siclog "Step 17" siclog@
    //  The SS configures:- Cell A as a " Serving cell".- Cell B as the "Not Suitable cell".- Cell C as a " 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 );


    //  Check: does the UE transmits a TRACKING AREA UPDATE REQUEST message in the next 30 seconds? (2,P)
    //@siclog "Step 18" siclog@
    t_WaitTimer_A.start;
    alt {
       []  SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                      cr_NAS_Indication( tsc_SHT_IntegrityProtected_Ciphered,
                                                         cr_508_TAU_Request(v_AttachType,
                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                  v_AdditionalUpdateType))))
          -> value v_ReceivedAsp
         {
           t_WaitTimer_A.stop;
           f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 18")
         }
       []  t_WaitTimer_A.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 19" siclog@
    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cs_508_TAU_Accept ( v_AttachType,
                                                                          f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams ),
                                                                          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 20" siclog@
    SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_TAU_Complete ) ) );
  }// function fl_tc_9_2_1_1_18_Body


/**
  * @desc: Attach / Abnormal case / Failure due to non integrity protection
  */
  function f_TC_9_2_1_1_19_EUTRA() runs on EUTRA_PTC
  {
  /* Test Purpose (TP)
    (1)
    with { UE has not performed NAS security mode control procedure }
    ensure that {
    when { UE receives an ATTACH ACCEPT messages without NAS integrity protection }
    then { UE discards this message }
    }
    (2)
    with { a valid NAS security context exists and the NAS security mode control procedure has been
    successfully completed in the network and the UE }
    ensure that {
    when { UE receives a NAS signalling message without integrity protection }
    then { UE discards this NAS signalling message }
    }
  (3)
  with { a valid NAS security context exists and the NAS security mode control procedure has been
  successfully completed in the network and the UE }
  ensure that {
  when { UE receives a security protected NAS signalling message with the Message authentication
  code set to an incorrect value }
  then { UE discards this NAS signalling message }
  }
  (4)
  with { a valid NAS security context exists and the NAS security mode control procedure has been
  successfully completed in the network and the UE }
  ensure that {
  when { UE receives a NAS signalling message with integrity protection }
  then { UE sends the response as a security protected NAS message }
  }
  */
  /* 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
    UE:
    - The test USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
    Preamble:
    - The UE is in state Switched OFF (state 1) according to [18].
   */
   f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

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

   f_UT_ConfigureEPSAttach (UT); // R5-103810

   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_1_1_19_Body();

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

  function fl_TC_9_2_1_1_19_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti2_Params := f_CreateGutiParamsWithUpdatedSTmsi(v_GutiParams);
    var template (value) NAS_MSG_Request_Type v_AttachAccept;
    var template (value) MobileIdentity v_Guti := f_GutiParameters2MobileIdentity( tsc_IEI_Guti, v_GutiParams);
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
    var template (omit) LocAreaId v_LAI := f_EUTRA_GetCellLAI(eutra_CellA);
    var template (omit) MobileIdentity v_MSId := f_GetMSId ();
    var template (value) PDN_Address v_PDN_Address;
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var NAS_MSG_Indication_Type v_NasInd;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NasCount_Type v_NasCountUL;
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template (omit) AccessPointName v_APN := omit;
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    timer t_Wait1s := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 1.0);

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

    //@siclog "Step 2" siclog@
    //+  The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
    //   Note:  The ATTACH REQUEST message shall be sent as a security protected NAS message
    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())));

    v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
    v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }
    if (ispresent(v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
      if ( v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
        v_APN := f_ESM_InformationTransfer_GetAPN (eutra_CellA, v_EPS_TI);
      }
    }
    
    v_PDN_Address := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    if (not isvalue(v_APN)) {
      v_APN := cs_AccessPointName (px_AccessPointName);
    }

    //  The SS transmits an ATTACH ACCEPT although UE has not
    //   successfully completed any NAS security mode control procedure.

    // activate security in AS with parameters from AKA performed in preamble
    //@siclog "Step 3" siclog@
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
    v_SecurityParams := f_EUTRA_Authentication_InitAS(v_SecurityParams, v_NasCountUL);
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellA,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);
    
    v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                        cs_508_ATTACH_ACCEPT(v_AttachType,
                                                                 cs_TrackingAreaIdListDef_lv,
                                                                 f_GutiParameters2MobileIdentity( tsc_IEI_Guti, v_Guti2_Params),
                                                                 v_LAI,
                                                                 v_MSId,
                                                                 omit,
                                                                 f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                                                        cs_508_ActivateDefEpsBearerContextRequest(tsc_EpsDefaultBearerId,
                                                                  v_EPS_TI,
                                                                  v_APN,
                                                                  v_PDN_Address,
                                                                  omit,
                                                                  omit,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco)));

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                    tsc_RRC_TI_Def,
                                                    v_AttachAccept);

    //  Check: Does the UE transmit an ATTACH COMPLETE message within the next 1s? (F)
    //@siclog "Step 4" siclog@
    t_Wait1s.start;
    alt {
      
      []SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(?,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      ?)))
          {
          f_EUTRA_SetVerdictFailOrInconc (__FILE__, __LINE__, "Step 4");
          }
      
      []  t_Wait1s.timeout {}

    }

    //@siclog "Step 5 - 6" siclog@
    v_SecurityParams := f_EUTRA_NAS_Authentication(eutra_CellA,
                                             tsc_SRB2,
                                             v_SecurityParams,
                                             tsc_SHT_IntegrityProtected_Ciphered,
                                             tsc_SHT_IntegrityProtected_Ciphered,
                                             v_PLMN);
    //@siclog "Step 7 - 8" siclog@
    f_EUTRA_NAS_AS_Security (eutra_CellA, false, v_EPS_TI, tsc_SRB2);

    // The SS transmits an ATTACH ACCEPT without integrity protection.
    //@siclog "Step 9" siclog@
    SRB.send  ( cas_SRB2_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      v_AttachAccept ));

    //  Check: Does the UE transmit an ATTACH COMPLETE message within the next 1s? (F)
    //@siclog "Step 10" siclog@
    t_Wait1s.start;
    alt {
      
      []SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(?,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      ?)))
          {
          f_EUTRA_SetVerdictFailOrInconc (__FILE__, __LINE__, "Step 10");
          }
      
      []  t_Wait1s.timeout{}
    }

    //  The SS transmits an ATTACH ACCEPT with integrity protection
    // with the Message authentication code set to an incorrect value.
    // Use GUTI-3 different from GUTI-2
    //@siclog "Step 11" siclog@
    v_GutiParams.M_TMSI := oct2bit('33345678'O); // different from previous value, default is oct2bit('12345678'O)
    v_Guti := f_GutiParameters2MobileIdentity( tsc_IEI_Guti, v_GutiParams);

    // TODO Define a new SecurityHeaderType tsc_SHT_IntegrityProtectedErrMAC to be passed to NASEmu
    v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                        cs_508_ATTACH_ACCEPT(v_AttachType,
                                                                 cs_TrackingAreaIdListDef_lv,
                                                                 v_Guti,
                                                                 v_LAI,
                                                                 v_MSId,
                                                                 omit,
                                                                 f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                                                        cs_508_ActivateDefEpsBearerContextRequest(tsc_EpsDefaultBearerId,
                                                                  v_EPS_TI,
                                                                  cs_AccessPointName (px_AccessPointName),
                                                                  v_PDN_Address,
                                                                  omit,
                                                                  omit,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco))); // @sic R5-104703 sic@


    SRB.send  ( cas_SRB2_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      v_AttachAccept ));

    //  Check: Does the UE transmit an ATTACH COMPLETE message within the next 1s? (F)
    //@siclog "Step 12" siclog@
    t_Wait1s.start;
    alt {
      
      []SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(?,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      ?)))
          {
          f_EUTRA_SetVerdictFailOrInconc (__FILE__, __LINE__, "");
          }
      
      []  t_Wait1s.timeout {}
    }

    // The SS transmits an ATTACH ACCEPT message including an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST.
    // Note: The ATTACH ACCEPT message is sent as a security protected NAS message

    // Use GUTI-4 different from GUTI-3
    v_GutiParams.M_TMSI := oct2bit('44445678'O); // default is oct2bit('12345678'O)
    // Set global GUTI to be used by other sub-functions
    //@siclog "Step 13" siclog@
    f_EUTRA_CellInfo_SetGuti(eutra_CellA, v_GutiParams);
    v_Guti := f_GutiParameters2MobileIdentity( tsc_IEI_Guti, v_GutiParams);
    v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                        cs_508_ATTACH_ACCEPT(v_AttachType,
                                                                 cs_TrackingAreaIdListDef_lv,
                                                                 v_Guti,
                                                                 v_LAI,
                                                                 v_MSId,
                                                                 omit,
                                                                 f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                                                        cs_508_ActivateDefEpsBearerContextRequest(tsc_EpsDefaultBearerId,
                                                                  v_EPS_TI,
                                                                  cs_AccessPointName (px_AccessPointName),
                                                                  v_PDN_Address,
                                                                  omit,
                                                                  omit,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco))); // @sic R5-104703 sic@


    SRB.send  ( cas_SRB2_NasPdu_REQ ( eutra_CellA,
                                      cs_TimingInfo_Now,
                                      v_AttachAccept ));


    //@siclog "Step 14" siclog@
    f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 14");

    //@siclog "Step 15" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);

    //  Check : Does the test results of CALL generic procedure [18] indicate that the UE is in EUTRA EMM-REGISTERED state?
    //@siclog "Step 16" siclog@
    f_EUTRA_508Check_IdleState(eutra_CellA);

  } // function fl_tc_9_2_1_1_19_Body

  /*
   * @desc      test body of TC_9_2_1_1_20
   * @status    APPROVED
   */
  function fl_TC_9_2_1_1_20_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_MSG_Indication_Type v_NasInd;
    var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellI);
    var ProcedureTransactionIdentifier v_EPS_TI := tsc_PTI_1;
    var template (omit) AccessPointName v_APN := omit;
    var boolean v_EIT_Flag := false;
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti_Params.PLMN_Identity);
    var TrackingAreaCode v_TAC := f_EUTRA_CellInfo_GetTAC(eutra_CellI);

    timer t_Wait_RRCConnectReject := f_EUTRA_SetTimerToleranceMin( eutra_CellI, 10.0 );
 
    //@siclog "Step 1" siclog@
    //+ The SS set the cell type of cell I to the ''Serving cell'', set the cell type of cell K to the '' Non- Suitable cell'',
    //  and set SystemInformationBlockType2 parameters as described below.
    //  The UE is switched on
    f_EUTRA_SetCellPower ( eutra_CellK, tsc_NonSuitableOffCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 2" siclog@
    //+ Check: for 5 seconds if UE initiates Attach procedure and hence transmits RRC Connection Request? (1, F)
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellI, 5.0);
 
    //@siclog "Step 3 - 4" siclog@
    //+ The SS transmits a Paging message including systemInfoModification.
    
    //+ The SS changes SystemInformationBlockType2 parameters to default parameters defined in [18].
    f_EUTRA_ChangeSystemInformation_ToDefault ( eutra_CellI );
    f_EUTRA_ModifySysinfo ( eutra_CellI );

    //@siclog "Step 5" siclog@
    //+ The UE transmits RRC Connection Request
    SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellI, cr_RRCConnectionRequest(?)));

    //@siclog "Step 6" siclog@
    //+ SS responds with RRCConnectionReject message with IE waitTime set to 10 seconds(Max Value).
    SRB.send ( cas_SRB0_RrcPdu_REQ ( eutra_CellI,
                                     cs_TimingInfo_Now,
                                     cs_RRCConnectionReject ) );
    //@siclog "Step 7" siclog@
    //+ Check: for 10 seconds if UE initiates Attach procedure and hence transmits RRC Connection Request? (2, F)
    t_Wait_RRCConnectReject.start;
    alt {
    []  SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellI, cr_RRCConnectionRequest(?)))
      {
        t_Wait_RRCConnectReject.stop;
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 7"); // R5-104796
      }
    []  t_Wait_RRCConnectReject.timeout {}
    }

    //@siclog "Step 8" siclog@
    //+ Check: Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message? (3, P)
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellI,
                                            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
    if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) { // @sic R5s100084 sic@
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }

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

    //@siclog "Step 9 - 12" 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.
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellI, v_EIT_Flag, v_EPS_TI, true);

    //@siclog "Step 13" siclog@
    //+ SS responds with ATTACH ACCEPT message including a valid TAI list. The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message
    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),
                                                                  cs_TAIListNonConsecutive_lv (v_PLMN, {bit2oct(v_TAC)}),
                                                                  omit,
                                                                  omit,
                                                                  omit,
                                                                  v_APN,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                  v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);
    //@siclog "Step 14" siclog@
    //+ Check: does the UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message?
    f_EUTRA_NAS_AttachComplete(eutra_CellI, tsc_EpsDefaultBearerId);
    
    //@siclog "Step 15" siclog@
    //+ The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellI, tsc_RRC_TI_Def, other);
    
    //+ The UE is switched off.
    //@siclog "Step 16" siclog@
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellI, RRC_IDLE ); // @sic R5-104083 sic@

    //+  The SS set the cell type of cell I to the ''Serving cell'', set the cell type of cell K to the '' Non- Suitable cell'', and set SystemInformationBlockType2 parameters as described below.
    //          The UE is switched on.
    //@siclog "Step 17" siclog@
    f_EUTRA_CellInfo_SetSysInfo_AccessBarring ( eutra_CellI, cs_AccessBarringInformation_TC_9_1_1_20 );
    f_EUTRA_Cellinfo_SetSysInfo_IntraFreqRes ( eutra_CellI, allowed ); // @sic R5-104729 sic@
    f_EUTRA_ModifySysinfoUE_Off (eutra_CellI);
    
    f_EUTRA_SetCellPower ( eutra_CellK, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellI, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    
    f_UT_SwitchOnUE (UT, false );
    
    //+  Check: for 5 seconds if UE initiates Attach procedure and hence transmits RRC Connection Request?
    //@siclog "Step 18" siclog@
    f_EUTRA_CheckNoAttachOn1Cell(eutra_CellI, 5.0);

    //+  The SS set the cell type of cell K to "Serving Cell" and cell I to "Suitable Cell".
    //@siclog "Step 19" siclog@
    f_EUTRA_SetCellPower ( eutra_CellK, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now ); // @sic R5-104729 sic@
    f_EUTRA_SetCellPower ( eutra_CellI, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now ); // @sic R5-104729 sic@

    //@siclog "Step  20" siclog@
    // Check: Does the UE transit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message R5-105005
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellK,
                                                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())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 20");
    
    //@siclog "Step  21 - 32" siclog@
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellK, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false); // @sic R5-105005 sic@
      
  }// function fl_tc_9_2_1_1_20_Body


  function fl_TC_9_2_1_1_21_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_MSG_Indication_Type v_NasInd;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();

    timer t_Timer3410 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 15.0);
    timer t_Timer3411 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 10.0);
    timer t_Timer3411_half := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 5.0);


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

    //+ The UE transmit an ATTACH REQUEST message.
    //@siclog "Step 2" 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())));

    //+The SS waits 20 seconds (15 seconds T3410 and 5 seconds half of T3411).
    //@siclog "Step 3" siclog@
    t_Timer3410.start;
    t_Timer3410.timeout;
    t_Timer3411_half.start;
    t_Timer3411_half.timeout;

    //+ SS transmits an IDENTITY REQUEST message requesting IMSI in the IE Identity type
    //@siclog "Step 4" siclog@
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_NoSecurityProtection,
                                                cs_IDENTITY_REQUEST(tsc_IdType_IMSI))));
    //  Exception: In parallel with steps 5 and 6, the parallel behaviour defined in table 9.2.1.1.1.3.2-2 is running.
    //             Check: Does the UE sends an IDENTITY RESPONSE message?   --> IDENTITY RESPONSE   1   F
    //+  The SS waits 5 seconds (half of T3411)
    //+  Check: The UE transmit an ATTACH REQUEST message? (2 P)
    //@siclog "Step 5 - 6" siclog@
    t_Timer3411_half.start;
    t_Timer3411_half.timeout;
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                        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 6");

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

    //+  The SS waits 10 seconds (T3411).
    //@siclog "Step 8" siclog@
    t_Timer3411.start;
    t_Timer3411.timeout;

    //@siclog "Step 9 siclog@
    // Check: Does the UE transit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message R5-105005
    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())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9");
    
    //@siclog "Step  10 - 21" siclog@
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false); // @sic R5-105005 sic@
  }// function fl_tc_9_2_1_1_21_Body


  function fl_TC_9_2_1_1_22_Body() runs on EUTRA_PTC
  {
    // ==========================================================================
    // initialize test case data structures
    // ==========================================================================
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var NAS_MSG_Indication_Type v_NasInd;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    timer t_Timer3410 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 15.0);
    timer t_Timer3411 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 10.0);
    timer t_Timer3402 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 720.0);

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

    //+  The UE transmit an ATTACH REQUEST message.
    //@siclog "Step 2" 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())));

    //+ The SS waits 25 seconds (15 seconds T3410 and 10 seconds T3411).
    //@siclog "Step 3" siclog@
    t_Timer3410.start;
    t_Timer3410.timeout;
    t_Timer3411.start;
    t_Timer3411.timeout;

    //+  The UE transmits an ATTACH REQUEST message. (Attach attempt counter = 2)
    //@siclog "Step 4" siclog@
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                      cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                                      cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                      f_GetPdnType()))));

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

    //+ The SS waits 10 seconds ( T3411).
    //@siclog "Step 6" siclog@
    t_Timer3411.start;
    t_Timer3411.timeout;

    //+ The UE transmits an ATTACH REQUEST message. (Attach attempt counter = 3)
    //@siclog "Step 7" 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())));

    //+ The SS waits 25 seconds (15 seconds T3410 and 10 seconds T3411).
    //@siclog "Step 8" siclog@
    t_Timer3410.start;
    t_Timer3410.timeout;
    t_Timer3411.start;
    t_Timer3411.timeout;

    //+ The UE transmits an ATTACH REQUEST message. (Attach attempt counter = 4)
    //@siclog "Step 9" siclog@
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                      cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                                      cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                      f_GetPdnType()))));

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

    //+ The SS waits 10 seconds ( T3411).
    //@siclog "Step 11" siclog@
    t_Timer3411.start;
    t_Timer3411.timeout;

    //+ The UE transmits an ATTACH REQUEST message. (Attach attempt counter = 5)
    //@siclog "Step 12" 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())));

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

    //+ Check: Does the UE transmits an ATTACH REQUEST message after 12 minutes (default value of T3402, after step 13? [1,P]
    //@siclog "Step 14" siclog@
    t_Timer3402.start;
    t_Timer3402.timeout;
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                              v_RRC_TI,
                                              cr_EstablishmentCause_Any,
                                              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())));

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

    //+ The attach procedure is completed and the RRC connection is released by executing steps 5 to 17 of TS 36.508 sub clause 4.5.2.3.
    //@siclog "Steps 15 - 26" siclog@
    f_EUTRA_IdleUpdated_Step5_17 (eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false);
  }// function fl_tc_9_2_1_1_22_Body


    function fl_TC_9_2_1_1_23_Body() runs on EUTRA_PTC
    {
  
        var NAS_MSG_Indication_Type v_NAS_Ind;
        var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
        
        var GutiParameters_Type v_GutiParams1 := f_EUTRA_CellInfo_GetGuti (eutra_CellA);
        var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams1.PLMN_Identity);
        var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();

        timer t_T3402 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 720.0);
        timer t_T3411 := f_EUTRA_SetTimerToleranceMin(eutra_CellA, 10.0);

        // Step 1. Switch on UE
        // Step 2. The UE transmits an ATTACH REQUEST message. (Attach attempt counter = 1)
        // Step 3. The SS transmits an ATTACH REJECT message, with EMM cause = Network failure (#17)
        // Step 4: The SS releases the RRC connection
        //@siclog "Step 1 - 4" siclog@
        f_EUTRA_AttachReject (eutra_CellA, tsc_EmmCause_NetworkFailure);

        //  The SS waits 10 seconds (T3411)
        //@siclog "Step 5" siclog@
        t_T3411.start;
        t_T3411.timeout;

        //  Check: does the UE transmit an ATTACH REQUEST message? (Attach attempt counter = 2)
        //@siclog "Step 6" siclog@
        v_NAS_Ind:= 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,
                                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams1),
                                                                                                       cr_TAI( v_PLMN, tsc_TAC1)),
                                                                           cr_508_PDN_CONNECTIVITY_REQUEST(
                                                                                                       tsc_PdnRequest_InitialAttach,
                                                                                                       f_GetPdnType())
                                                                           ));

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


        // The SS transmits an ATTACH REJECT message, with EMM cause = Network failure (#17)
        //@siclog "Step 7" siclog@
        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_EmmCause_NetworkFailure),
                                                                             omit))));

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

        //  The SS waits 10 seconds (T3411)
        //@siclog "Step 9" siclog@
        t_T3411.start;
        t_T3411.timeout;


        //  Check: does the UE transmit an ATTACH REQUEST message? (Attach attempt counter = 3)
        //@siclog "Step 10" siclog@
        v_NAS_Ind:= 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,
                                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams1),
                                                                                                       cr_TAI( v_PLMN, tsc_TAC1)),
                                                                           cr_508_PDN_CONNECTIVITY_REQUEST(
                                                                                                       tsc_PdnRequest_InitialAttach,
                                                                                                       f_GetPdnType())
                                                                           ));

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


        // The SS transmits an ATTACH REJECT message, with EMM cause = Congestion (#22)
        //@siclog "Step 11" siclog@
        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_Congestion),
                                                                             omit))));

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

        // The SS waits 10 seconds (T3411)
        //@siclog "Step 13" siclog@
        t_T3411.start;
        t_T3411.timeout;


        //  Check: does the UE transmit an ATTACH REQUEST message? (Attach attempt counter = 4)
        //@siclog "Step 14" siclog@
        v_NAS_Ind:= 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,
                                                                                                       f_EUTRA_SecurityKSIasme_Get(),
                                                                                                       f_GutiParameters2MobileIdentity(omit, v_GutiParams1),
                                                                                                       cr_TAI( v_PLMN, tsc_TAC1)),
                                                                           cr_508_PDN_CONNECTIVITY_REQUEST(
                                                                                                       tsc_PdnRequest_InitialAttach,
                                                                                                       f_GetPdnType())
                                                                           ));

 


        // The SS transmits an ATTACH REJECT message, with EMM cause = Congestion (#22)
        //@siclog "Step 15" siclog@
        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_Congestion),
                                                                             omit))));

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

        //  The SS waits 10 seconds (T3411)
        //@siclog "Step 17" siclog@
        t_T3411.start;
        t_T3411.timeout;


        // Check: does the UE transmit an ATTACH REQUEST message? (Attach attempt counter = 5)
        //@siclog "Step 18" siclog@
        v_NAS_Ind := 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),
                                                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                        f_GetPdnType())));

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


        //  The SS transmits an ATTACH REJECT message, with EMM cause = Congestion (#22)
        //@siclog "Step 19" siclog@
        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_Congestion),
                                                                             omit))));

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

        //  The SS waits 12 minutes (default value of T3402)
        //@siclog "Step 21" siclog@
        t_T3402.start;
        t_T3402.timeout;

        //  Check: Does the UE transmit an ATTACH REQUEST message?
        //@siclog "Step 22" siclog@
        v_NAS_Ind := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                  tsc_RRC_TI_Def,
                                                  cr_EstablishmentCause_Any,
                                                  cr_NAS_IndicationWithPiggybacking( tsc_SHT_NoSecurityProtection,
                                                                        cdr_ATTACH_REQUEST_WithOldMobileIdNoTAI(v_AttachType,
                                                                                                                v_AdditionalUpdateType,
                                                                                                                f_Imsi2MobileIdentity(px_IMSI_Def)
                                                                                                                ),
                                                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                        f_GetPdnType())));

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

        //@siclog "Steps 23 - 34" siclog@
        // The attach procedure is completed and the RRC connection is released by executing
        // steps 5 to 16 of TS 36.508 sub clause 4.5.2.3
        f_EUTRA_IdleUpdated_Step5_17 (eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NAS_Ind, false);

 
    }// end function fl_TC_9_2_1_1_23_Body



    function f_TC_9_2_1_1_24_EUTRA() runs on EUTRA_PTC
    {
       // @desc Attach / Abnormal case / Change of cell into a new tracking area
        /* Test Purpose (TP)
        (1)
        with { UE has sent an ATTACH Request message and ATTACH ACCEPT message is not received }
        ensure that {
          when { UE reselects a cell belonging to a new tracking area }
            then { the UE restarts the attach procedure }
                    }

        (2)
        with { UE has sent an ATTACH REQUEST message and received ATTACH ACCEPT message containing GUTI}
        ensure that {
          when { UE reselects a cell belonging to a new tracking area}}
            then { the UE restarts the attach procedure}


        System Simulator:
        -   Cell A and B
        -   Cell A is the serving cell with TAI1 (PLMN1+TAC1);
        -   Cell B is the non-suitable cell with TAI2 (PLMN1+TAC2);
        UE:
        -   The test USIM is inserted.
        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_SRBs_Only(eutra_CellB);

        f_UT_ConfigureEPSAttach (UT); // R5-103810
        
        f_EUTRA_Preamble_Reject(eutra_CellA, tsc_Cause_EPSServNotAllowed); // @sic R5s103832 sic@
        f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );

        f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_1_1_24_Body ();

        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
    } // end f_TC_9_2_1_1_24_EUTRA


    function fl_TC_9_2_1_1_24_Body() runs on EUTRA_PTC
    {
        var template (value) CellPowerList_Type v_CellPowerList;
        var NAS_MSG_Indication_Type v_NAS_Ind;
        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 template (value) TrackingAreaIdList v_TaiList;
        var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
        var HalfOctet_Type v_EpsBearerId := tsc_EpsDefaultBearerId;
        var NAS_UL_Message_Type v_PdnConnectivityRequest;
        var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
        
        var GutiParameters_Type v_GutiParams1 := 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_GutiParams1.PLMN_Identity);

        var template (omit) MobileIdentity v_MSId := f_GetMSId ();
        var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN, v_LAC);
        var NextHopChainingCount v_Ncc0 := 0;  //Default configuration value according to TS 36.508 Table 4.6.1-10


        //  Switch on UE
        //@siclog "Step 1" siclog@
        f_UT_SwitchOnUE (UT, false);
    

        //  The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on cell A
        //@siclog "Step 2" siclog@
        v_NAS_Ind:= 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())));


       //@siclog "Step 3" siclog@
        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 4" siclog@
        //  Check: Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
        // on CellB?
        v_NAS_Ind := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                             cr_NAS_IndicationWithPiggybacking( tsc_SHT_NoSecurityProtection,
                                                                                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");

        v_PdnConnectivityRequest := v_NAS_Ind.Pdu.PiggybackedPduList[0].Msg;
        v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
          v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
        }
        if (ispresent(v_NAS_Ind.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
          if ( v_NAS_Ind.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
            v_EIT_Flag := true;
        }}


        //@siclog "Step 4A - 8b" siclog@
        // Step 4A   @sic R5-102202 @sic
        // The SS transmits an AUTHENTICATION REQUEST message to initiate the EPS authentication and AKA procedure.
        // Step 5
        // The UE transmits an AUTHENTICATION RESPONSE message and establishes mutual authentication.
        // Step 6
        // The SS transmits a NAS SECURITY MODE COMMAND message to activate NAS security.
        // Step 7
        // The UE transmits a NAS SECURITY MODE COMPLETE message and establishes the initial security configuration.
        // Steps 8a and 8b ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
        v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellB, v_EIT_Flag, v_EPS_TI);


        //@siclog "Step 9" siclog@
        f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );

        //  Configure SS not to allocate UL grant to the UE in Cell B
        // Configure SS to disable report of PRACH preamble reception
        //@siclog "Step 10" siclog@
        f_EUTRA_SS_ConfigRachPreambleIndMode (eutra_CellB, tsc_L1Mac_IndicationMode_Disable);
        f_EUTRA_StopULGrantTransmission_PUCCH_Sync ( eutra_CellB, cs_TimingInfo_Now );

        //@siclog "Step 11" siclog@
        // SS responds with ATTACH ACCEPT message including a valid TAI list. The
        // ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in
        // ATTACH ACCEPT message. GUTI-1 is allocated
        f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                                  v_EpsBearerId,
                                                                  tsc_RRC_TI_Def,
                                                                  v_EPS_TI,
                                                                  v_AttachType,
                                                                  f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams1), // GUTI1
                                                                  cs_TrackingAreaIdListDef_lv,
                                                                  v_LAI,
                                                                  v_MSId,
                                                                  omit,
                                                                  v_APN,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                  v_NAS_Ind.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

        //@siclog "Step 12" siclog@
        f_EUTRA_SetCellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE, cs_TimingInfo_Now );

        //@siclog "Step 13" siclog@
        // UE transmits RRCConnectionReestablishmentRequest message on Cell A @sic R5-102202 @sic
        SRB.receive( car_SRB0_RrcPdu_IND( eutra_CellA,
                                          cr_508_RRCConnectionReestablishmentRequest (
                                                              ?,
                                                              f_EUTRA_CellInfo_GetPhyCellId ( eutra_CellA ),
                                                              cr_ReestablishmentCause_Any
                                                              )
                                          ));


        //  Transmit RRConnectionReestablishment to resume SRB1 and re-activate security
        //@siclog "Step 14" siclog@
        f_EUTRA_RRC_RRCConnectionReestablishment_Def ( eutra_CellA, tsc_RRC_TI_Def, v_Ncc0 );


        //  Receive RRCConnectionReestablishmentComplete
        //@siclog "Step 15" siclog@
        SRB.receive ( car_SRB1_RrcPdu_IND ( eutra_CellA,  cr_508_RRCConnectionReestablishmentComplete( tsc_RRC_TI_Def ) ) );

       
        //  Check: Does the UE transmit an ATTACH REQUEST message, containing GUTI-1?
        //@siclog "Step 16" siclog@
        v_NAS_Ind := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                    tsc_RRC_TI_Def,
                                                    cr_EstablishmentCause_Any,
                                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                    cdr_ATTACH_REQUEST_WithGuti(
                                                               v_AttachType,
                                                               v_AdditionalUpdateType,
                                                               f_EUTRA_SecurityKSIasme_Get(),
                                                               f_GutiParameters2MobileIdentity(omit, v_GutiParams1),
                                                               cr_TAI( v_PLMN, tsc_TAC1)),
                                                    cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                    f_GetPdnType()
                                                    )));
        f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 16");


        v_EPS_TI := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier;
        // Get the PCO to be used later (TS 36.508 v.8.2.2 Table 4.7.3-6)
        if (ispresent( v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
          v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
        }
 
        //@siclog "Step 17" siclog@
        // SS responds with ATTACH ACCEPT message including a valid TAI list.
        // The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message
        v_TaiList := cs_TAIListNonConsecutive_lv( v_PLMN,
                                                 { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellA)) });

        f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                                      v_EpsBearerId,
                                                                      tsc_RRC_TI_Def,
                                                                      v_EPS_TI,
                                                                      v_AttachType,
                                                                      f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                                      f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams1),
                                                                      v_TaiList,
                                                                      omit,
                                                                      omit,
                                                                      omit,
                                                                      v_APN,
                                                                      f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                      v_NAS_Ind.Pdu.Msg.aTTACH_REQUEST.addUpdateType);
 
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //   EXCEPTION: In parallel to the event described in step 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 transmits an ATTACH COMPLETE message
        // including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message
        //@siclog "Step 18" siclog@
        f_EUTRA_NAS_AttachComplete(eutra_CellA, v_EpsBearerId);

        //  The SS releases the RRC connection
        //@siclog "Step 19" siclog@
        f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
 
    }// end function fl_TC_9_2_1_1_24_Body




/**
  * @desc Attach / Abnormal case / Mobile originated detach required
  */
  function f_TC_9_2_1_1_25_EUTRA() runs on EUTRA_PTC
  {
  /* Test Purpose (TP)
    (1)
    with { UE in EMM-REGISTERED-INITIATED state }
    ensure that {
    when { the UE initiates mobile originated detach }
       then { the UE aborts the attach procedure }
    }
 
    Pre-test conditions
    System Simulator:
        -   Cell A
    UE:
        -   The UE is configured to initiate EPS attach.
        -   None
    Preamble:
        -   The UE is in state Switched OFF (state 1) according to [18].
        -   The UE has a valid GUTI-1.
   */

   f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

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

   f_UT_ConfigureEPSAttach (UT); // R5-103810

   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_1_1_25_Body();

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

  function fl_TC_9_2_1_1_25_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var NAS_MSG_Indication_Type v_NasInd;
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var boolean v_EIT_Flag := false;
    var template (omit) AccessPointName v_APN := omit;
    var float v_NoReactionTime := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 3.0 );
    timer t_T3410 := f_EUTRA_SetTimerToleranceMax(eutra_CellA, 15.0);

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

    //@siclog "Step 2" siclog@
    //+  The UE transmits an ATTACH REQUEST message
    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())));

    v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
    v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }

    //@siclog "Step 3 - 6" 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.
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA, v_EIT_Flag, v_EPS_TI);

    //  The SS does not respond to ATTACH REQUEST message.
    //@siclog "Step 7" siclog@

    //@siclog "Step 8 - 9" siclog@
    t_T3410.start; // 15 seconds + tolerance
    alt {
      [] SRB.receive(car_SRB1_NasPdu_IND(
                       eutra_CellA,
                       cr_NAS_Indication(
                         tsc_SHT_IntegrityProtected_Ciphered,
                         cr_DETACH_REQUEST_921125)))
        {
        f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "step 9");
        t_T3410.stop;
        SRB.send (cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                    cs_TimingInfo_Now,
                                    cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                   cs_508_DETACH_ACCEPT)));
        }
      [] t_T3410.timeout
        {
        f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "step 9");
        }
        }

     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);

     //@siclog "Step 10" siclog@
     // Check: Does the test result of CALL generic procedure "Test procedure for no response to paging
     // (for NAS testing)" clause 6.4.2.5 [18] indicates that the UE responds to paging when paged with GUTI-1
     // and with CN domain indicator set to "PS"?
     f_EUTRA_508Check_NASNoResponse ( eutra_CellA,
                                     cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_GutiParams.MME_Code, v_GutiParams.M_TMSI )),
                                     v_NoReactionTime );
     //@siclog "Step 11 Void" siclog@

  }// function fl_tc_9_2_1_1_25_EUTRA_Body


    function f_TC_9_2_1_1_26_EUTRA() runs on EUTRA_PTC
    {
       // @desc Attach / Abnormal case / Detach procedure collision
        /* Test Purpose (TP)
        (1)
        with { UE in EMM-REGISTERED-INITIATED  state}
             ensure that {
                 when { UE receives a DETACH REQUEST message and detach type indicates "re-attach not required"}
                      then { the UE sends DETACH ACCEPT }
        (2)
        with { UE in EMM-REGISTERED-INITIATED  state}
             ensure that {
                 when { UE receives a DETACH REQUEST message and detach type  indicates "re-attach  required"}
                      then { the UE continues with ATTACH procedure }
        }

        System Simulator:
        -   Cell A
        -   Cell A is the serving cell with TAI1 (PLMN1+TAC1);
        UE:
        -   The UE is configured to initiate EPS attach.
        -   The test USIM is inserted.
        Preamble:
        -   The UE is in state Switched OFF (state 1) according to [18]
        */

        f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

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

        f_UT_ConfigureEPSAttach (UT); // R5-103810
        
        f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
        f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
        f_EUTRA_TestBody_Set(true);

        fl_TC_9_2_1_1_26_Body();

        // Postamble
        f_EUTRA_TestBody_Set(false);
        f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
        
    } // end f_TC_9_2_1_1_26_EUTRA


    function fl_TC_9_2_1_1_26_Body() runs on EUTRA_PTC
    {
        var NAS_MSG_Indication_Type v_NAS_Ind;
        var boolean v_EIT_Flag := false;
        var HalfOctet_Type v_EpsBearerId := tsc_EpsDefaultBearerId;
        var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
        var template (omit) AccessPointName v_APN := omit;
        var template (omit) ProtocolConfigOptions v_Pco := omit;
        var NAS_UL_Message_Type v_PdnConnectivityRequest;
        var GutiParameters_Type v_GutiParams1 := 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_GutiParams1.PLMN_Identity);
        var NAS_AttDetValue_Type v_AttachType := f_GetEAttachType();
        var template (omit) MobileIdentity v_MSId := f_GetMSId ();
        var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN, v_LAC);
        var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
        var template (omit) EMM_Cause v_EMMCause :=cs_EMM_Cause_v(tsc_Cause_EPSandNonEPSServNotAllowed);


        //  Switch on UE
        //@siclog "Step 1" siclog@
        f_UT_SwitchOnUE (UT, false);


        //  The UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
        //@siclog "Step 2" siclog@
        v_NAS_Ind:= 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),
                                                                           cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                           f_GetPdnType())));


        //  The SS initiates Detach procedure with the Detach Type IE "re-attach not required"
        //@siclog "Step 3" siclog@
        SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request(tsc_SHT_IntegrityProtected,
                                     cs_508_DETACH_REQUEST_MT(cs_DetachType(tsc_DetachMT_NoReAttach), v_EMMCause))));

        // Check: Does the UE send DETACH ACCEPT message?
        //@siclog "Step 4" siclog@
        SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                        cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                          cr_508_DETACH_ACCEPT)));
        
        f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");

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

        //  UE is switched off and switched on
        //@siclog "Step 6" siclog@
        f_UT_SwitchOffUE (UT, false);
        f_UT_SwitchOnUE (UT, false );

        //  Check: Does the UE send ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message?
        //@siclog "Step 7" siclog@
        v_NAS_Ind := 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),
                                                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));

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

        v_PdnConnectivityRequest := v_NAS_Ind.Pdu.PiggybackedPduList[0].Msg;
        v_EPS_TI := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier;
        // Get the PCO to be used later (TS 36.508 v.8.2.2 Table 4.7.3-6)
        if (ispresent( v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
          v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
        }
        if (ispresent(v_NAS_Ind.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
          if ( v_NAS_Ind.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
            v_EIT_Flag := true;
        }}

        //@siclog "Step 8 - 12a2" 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 12a1 and 12a2 ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
        v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA, v_EIT_Flag, v_EPS_TI);

        //  The SS initiates Detach procedure with the Detach Type IE "re-attach required"
        //@siclog "Step 13" siclog@
        SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                     cs_508_DETACH_REQUEST_MT(cs_DetachType(tsc_DetachMT_ReAttach), omit))));


        //@siclog "Step 14" siclog@
        // SS responds with ATTACH ACCEPT message including a valid TAI list. The
        // ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in
        // ATTACH ACCEPT message. GUTI-1 is allocated
        f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                                  v_EpsBearerId,
                                                                  tsc_RRC_TI_Def,
                                                                  v_EPS_TI,
                                                                  v_AttachType,
                                                                  f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams1), // GUTI1
                                                                  cs_TrackingAreaIdListDef_lv,
                                                                  v_LAI,
                                                                  v_MSId,
                                                                  omit,
                                                                  v_APN,
                                                                  f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                  v_NAS_Ind.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

        alt
        { //paralell behaviour
        []SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                            cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                              cr_508_DETACH_ACCEPT)
                                            ))
          {
            f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "parallel behaviour: detach accept Rx");
          }

         // The UE transmits an ATTACH COMPLETE message
         // including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message
         //@siclog "Step 15" siclog@
        []SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EpsBearerId))))
          {
            f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "step 15");
          }
        }

        // The SS waits 5 seconds
        //@siclog "Step 16" siclog@
        f_Delay (5.0);

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //   EXCEPTION: In parallel to the event described in step 13 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.                                                    //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // Step 17: The SS releases the RRC connection
        f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
 
    }// end function fl_TC_9_2_1_1_26_Body

/**
  * @desc Combined attach procedure / Success /EPS and non-EPS services
  */
  function f_TC_9_2_1_2_1_EUTRA() runs on EUTRA_PTC
  {
  /* Test Purpose (TP)
    (1)
    with { UE in state EMM-DEREGISTERED and is switched off }
    ensure that {
    when { UE is powered up or switched on}
    then { UE sends ATTACH REQUEST message with EPS attach type IE 'combined EPS/IMSI attach' }
    }
    (2)
    with { UE in state EMM-REGISTERED-INITIATED}
    ensure that {
    when { UE receives ATTACH ACCEPT message with EPS attach result 'combined EPS/IMSI attach' }
    then { UE sends ATTACH COMPLETE message and enters EMM state EMM-REGISTERED and MM state MM-IDLE
    and UE responsds to a paging message with CS or PS domain}
    }

    (3)
    with { UE in state EMM-REGISTERED and state MM-IDLE}
    ensure that {
    when { SS sends Paging message with CS domain }
    then { UE sends EXTENDED SEREVICE REQUEST message }
    }
    (4)
    with { UE in state EMM-REGISTERED and EMM-IDLE mode}
    ensure that {
    when { UE enters a new tracking area already included in the TAI list }
    then { UE does not send TRACKING AREA UPDATE REQUEST message and UE responsds a paging message
    with CS or PS domain}
    }
    (5)
    with { UE in state EMM-REGISTERED and EMM-IDLE mode}
    ensure that {
    when { UE enters a new tracking area not included in the TAI list }
    then { UE sends TRACKING AREA UPDATE REQUEST message with 'EPS update type = combined TA/LA
    updated '}
    }
    (6)
    with { UE in state EMM-DEREGISTERED and is switched off and has a valid TAI value in 'Last visited
    registered TAI' IE and a valid GUTI}
    ensure that {
    when { UE is powered up or switched on}
    then { UE sends ATTACH REQUEST message with EPS attach type IE 'combined EPS/IMSI attach'and with
    the value in 'Last visited registered TAI' and the valid GUTI}

  */
  /* Pre-test conditions
    System Simulator:
        - Cell A, Cell B and Cell C are configured according to Table 6.3.2.2-1 in [18].
        - Cell A belongs to TAI-1(home PLMN).
        - Cell B belongs to TAI-2(home PLMN, another TAC).
        - Cell C belongs to TAI-3(home PLMN, another TAC).
    UE:
        - The UE is configured to initiate combined EPS/IMSI attach.
        - The test USIM contains GUTI-1 and a valid TAI-1 for EPS service, and EPS update status is "EU1:
        UPDATED".
        - The test USIM contains TMSI-1 and a valid LAI-1 for CS service, and Location update status is " U1:
        UPDATED".
    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);
   f_EUTRA_CellConfig_Def(eutra_CellC);

   f_UT_ConfigureCombinedAttach (UT); // R5-103815

   f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
   f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
   f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_2_1_Body();

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

  function fl_TC_9_2_1_2_1_Body() runs on EUTRA_PTC
  {
    var template (value) CellPowerList_Type v_CellPowerList;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var GutiParameters_Type v_Guti3_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellC);
    var template (value) MobileIdentity v_Guti := f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams);
    var template (value) MobileIdentity v_Guti_3 := f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params);

    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
    var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN,v_LAC);
    var template (omit) LocAreaId v_LAI_3 := f_GetLAI(v_PLMN,v_LAC);
    var template (omit) MobileIdentity v_MSId := f_GetMSId ();
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var boolean v_IPallocationViaNasFlag;
    var template (value) PDN_Address v_PDN_Address;
    var NAS_MSG_Indication_Type v_NasInd;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var template (value) NAS_MSG_Request_Type v_AttachAccept;
    var boolean v_EIT_Flag := false;
    var template (value) AccessPointName v_APN := cs_AccessPointName (px_AccessPointName);
    timer t_Wait := f_EUTRA_SetTimerToleranceMax(eutra_CellB, 30.0);

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

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

    //  Check: Does the UE ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message
    // to request PDN connectivity to the default PDN. EPS attach type = "combined EPS/IMSI attach"?
    //@siclog "Step 3" siclog@
    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_AttachType(tsc_EAttachType_Combined,
                                                                    v_AdditionalUpdateType,
                                                                    f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                    cr_TAI( v_PLMN, v_LAC),
                                                                    v_LAI,
                                                                    omit),
                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));

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

    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;
      }
    }
  
  //@siclog "Step 4 - 7Aa2" 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
    // describe behaviour that depends on UE configuration; the "lower case letter" identifies a step sequence that take place if the UE has ESM information which needs to be transferred.
    // 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_CellA,v_EIT_Flag, v_EPS_TI);

    // The SS sends ATTACH ACCEPT message with the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message.
    //@siclog "Step 8" siclog@
    v_IPallocationViaNasFlag :=  f_CheckPCOforIPallocationViaNas (v_Pco);
    v_PDN_Address := f_GetPDNAddress (v_IPallocationViaNasFlag);
    v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_Combined,
                                             cs_TAIListNonConsecutive_lv (tsc_PLMN1, {tsc_TAC1, tsc_TAC2}),
                                             v_Guti,
                                             v_LAI,
                                             v_MSId,
                                             omit,
                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                        cs_508_ActivateDefEpsBearerContextRequest(
                                            tsc_EpsDefaultBearerId,
                                            v_EPS_TI,
                                            v_APN,
                                            v_PDN_Address,
                                            omit,
                                            omit,
                                            f_GetDefPCOforPCSCFAddress (v_Pco))); // @sic R5-104703 sic@

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                     tsc_RRC_TI_Def,
                                                     v_AttachAccept);

   //  ATTACH COMPLETE
   //@siclog "Step 9" siclog@
   f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);
   f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9");

   //@siclog "Step 10" siclog@
   f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);

   //  Check: Does the UE respond to paging on cell A
   // with S-TMSI in GUTI-2 for PS domain?(Generic Procedure in TS36.508 )
   // We use PS paging procedure in TS 36.508 6.4.2.4 which is identical to that in 6.4.2.2.
   //@siclog "Step 11" siclog@
   f_EPS_508Check_NAS_Paging(eutra_CellA, ps);

   // The SS transmits a paging on cell A with S-TMSI in GUTI-2 for CS domain.
   //@siclog "Step 12" siclog@
   f_EUTRA_UE_Page(eutra_CellA,
                    cs_DomainNasPaging_OneRecord(
                                           cs_PagingUE_Identity_S_TMSI(v_GutiParams.MME_Code,
                                                                       v_GutiParams.M_TMSI),
                                           cs));
    // Check: Does the UE send EXTENDED SERVICE REQUEST message?
    //@siclog "Step 13" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(
                         eutra_CellA,
                         tsc_RRC_TI_Def,
                         cr_EstablishmentCause_mt_Access,
                         cr_NAS_Indication(
                            tsc_SHT_IntegrityProtected,
                            cr_508_EXT_SERVICE_REQUEST(v_SecurityParams.KSIasme,
                               tsc_EST_CsFallback_MO,
                               bit2oct(v_GutiParams.M_TMSI))
                                          ));

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

    //  The SS transmits SERVICE REJECT with cause #39
    //          'CS domain temporarily not available' with T3442 = 5s and the SS waits 5 sec.
    //@siclog "Step 14" siclog@
    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
               cs_TimingInfo_Now,
               cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                cds_SERVICE_REJECT_withT3442 (
                                  tsc_Cause_CSDomainNotTemporarilyAvailable,  //#39 'CS domain temporarily not available'
                                  cs_GprsTimer_v('000'B, '00101'B) )))); // See TS 24.008 clause 10.5.7.4


    //@siclog "Step 15 Void." siclog@

    //  Set power levels
    //@siclog "Step 16" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_NonSuitableOffCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    // Check: Does the UE transmit a TRACKING AREA UPDATE REQUEST message in the next 30 seconds?
    //@siclog "Step 17" siclog@
    t_Wait.start;
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellB, 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 17");
        }
      [] t_Wait.timeout {}
    }
   //  Check: Does the UE respond to paging on cell B
   // with S-TMSI in GUTI-2 for PS domain?(Generic Procedure in TS 36.508)
   //@siclog "Step 18" siclog@
    f_EPS_508Check_NAS_Paging(eutra_CellB, ps);

    //@siclog "Step 19" siclog@
    f_EPS_508Check_NAS_Paging(eutra_CellB, cs);

    //  Set power levels
    //@siclog "Step 20" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_NonSuitableOffCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellC, tsc_ServingCellRS_EPRE )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

    //@siclog "Step 21" 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_combinedupdate_OldGuti_LAI
                                                                               (tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                                f_EUTRA_SecurityKSIasme_Get(),
                                                                                v_AdditionalUpdateType,
                                                                                f_GutiParameters2MobileIdentity(omit, v_Guti3_Params), //GUTI-3
                                                                                v_LAI
                                                                                )));

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

    //@siclog "Step 22" siclog@
    //+   The SS sends TRACKING AREA UPDATE ACCEPT
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellC,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(
                                                tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_TAU_Accept(
                                                                  tsc_EpsUpdate_Combined_TaLaUpdate,
                                                                  f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti3_Params),
                                                                  cds_TAIListNonConsecutive_tlv(
                                                                                              v_PLMN,
                                                                                              { '0003'O }), // TAC3=3
                                                                  v_EpsBearerCtxtStatus,
                                                                  v_LAI_3,
                                                                  f_GetMSId ( ),
                                                                  f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)) ) ) );

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

    // The SS releases connection
    //@siclog "Step 24" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellC, tsc_RRC_TI_Def, other);

    //  Switch off and detach
    //@siclog "Step 25 - 26" siclog@
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellC, RRC_IDLE );  // @sic R5-101012 sic@

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

    //  Attach Procedure.
    //@siclog "Step28 - 34" siclog@
    // Step 28 Check: Does the UE ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message
    v_NasInd:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellC,
                                  tsc_RRC_TI_Def,
                                  cr_EstablishmentCause_Any,
                                  cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                        cr_508_ATTACH_REQUEST(tsc_EAttachType_Combined, v_AdditionalUpdateType),
                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));

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

    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;
      }
    }

    // Steps 29 and 30 - Steps 5 to 16 of the UE registration procedure
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellC,v_EIT_Flag, v_EPS_TI);

    v_PDN_Address := f_GetPDNAddress (v_IPallocationViaNasFlag);
    v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_Combined,
                                             cs_TAIListNonConsecutive_lv (tsc_PLMN1, {tsc_TAC1}),
                                             v_Guti_3,
                                             v_LAI,
                                             v_MSId,
                                             omit,
                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                        cs_508_ActivateDefEpsBearerContextRequest(
                                            tsc_EpsDefaultBearerId,
                                            v_EPS_TI,
                                            cs_AccessPointName (px_AccessPointName),
                                            v_PDN_Address,
                                            omit,
                                            omit,
                                            f_GetDefPCOforPCSCFAddress (v_Pco))); // @sic R5-104703 sic@

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellC,
                                                     tsc_RRC_TI_Def,
                                                     v_AttachAccept); // @sic R5-101012 sic@

   //  ATTACH COMPLETE
   f_EUTRA_NAS_AttachComplete(eutra_CellC, tsc_EpsDefaultBearerId);   // @sic R5-101012 sic@

  }// function fl_tc_9_2_1_2_1_Body


/**
  * @desc Combined attach procedure / Success / EPS services only / IMSI unknown in HSS
  */
  function f_TC_9_2_1_2_2_EUTRA() runs on EUTRA_PTC
  {
  /* Test Purpose (TP)
      (1)
      with { UE in state EMM-DEREGISTERED and is switched off }
      ensure that {
      when { the UE is powered up or switched on }
      then { the UE transmits an ATTACH REQUEST message with the EPS attach type set to "combined
      EPS/IMSI attach" and enters EMM-REGISTERED-INITIATED state }
      }
      (2)
      with { UE in state EMM-REGISTERED-INITIATED }
      ensure that {
      when { the UE receives an ATTACH ACCEPT message with EPS attach result set to "EPS only" and EMM
      cause set to "IMSI unknown in HSS" }
      then { the UE transmits an ATTACH COMPLETE message, the UE set the update status to U3 ROAMING
      NOT ALLOWED, shall delete any TMSI, LAI and ciphering key sequence number and enters EMMREGISTERED.
      NORMAL-SERVICE state and MM IDLE state. The USIM shall be considered as invalid for non-
      EPS services until switching off or the UICC containing the USIM is removed }
      }
      (3)
      with { UE in E-UTRA EMM-REGISTERED.NORMAL-SERVICE state and MM IDLE state and USIM is invalidated by
      network for non-EPS services }
      ensure that {
      when { SS sends DETACH REQUEST message with the Detach type IE "re-attach required" }
      then { the UE sends DETACH ACCEPT message, and then the UE sends ATTACH REQUEST message with EPS
      attach type set to 'EPS attach', including the value in 'Last visited registered TAI' and the valid
      GUTI and initiates an attach procedure }
      }
      (4)
      with { UE in EMM-REGISTERED.NORMAL-SERVICE state and MM IDLE state and USIM is invalidated by
      network for non-EPS services }
      ensure that {
      when { the UE is switch off and then powered up or switched on }
      then { the UE sends ATTACH REQUEST message with EPS attach type IE 'combined EPS/IMSI attach' }
      }
      (5)
      with { UE in EMM-REGISTERED-INITIATED state }
      ensure that {
      when { the UE receives ATTACH ACCEPT message with EPS attach result 'combined EPS/IMSI attach' }
      then { UE

  */
  /* Pre-test conditions
    System Simulator:
    - Cell A is configured according to Table 6.3.2.2-1 in [18].
    UE:
    - The UE is configured to initiate combined EPS/IMSI attach.
    - The USIM contains IMSI-1, GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED", and also P-TMSI
    signature1.
    - The USIM contains TMSI-1 and LAI-1 for CS service, and Location update status is "U1: UPDATED".
    Preamble:
    - The UE is in state Switched OFF (state 1) according to [18].
*/
  f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

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

   f_UT_ConfigureCombinedAttach (UT); // R5-103815

   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_1_2_2_Body();

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

  function fl_TC_9_2_1_2_2_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var template (value) MobileIdentity v_Guti := f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_GutiParams);
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
    var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN,v_LAC);
    var template (omit) MobileIdentity v_MSId := f_GetMSId ( );
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var boolean v_IPallocationViaNasFlag;
    var template (value) PDN_Address v_PDN_Address;
    var NAS_MSG_Indication_Type v_NasInd;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NasCount_Type v_NasCountUL;
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var template (value) NAS_MSG_Request_Type v_AttachAccept;
    var template (value) AccessPointName v_APN := cs_AccessPointName (px_AccessPointName);
    var boolean v_EIT_Flag := false;
   

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

    //@siclog "Step 2" siclog@
    // The UE transmits ATTACH REQUEST message with a PDN CONNECTIVITY REQUEST message to request
    // PDN connectivity to the default PDN with EPS attach type set to "combined EPS/IMSI attach"
    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_AttachType(tsc_EAttachType_Combined,
                                                                      v_AdditionalUpdateType,
                                                                      v_Guti,
                                                                      cr_TAI( v_PLMN, v_LAC),
                                                                      v_LAI,
                                                                      omit
                                                                      ),
                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));

    v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
    v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }

    if (ispresent(v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag)) {
      if ( v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.esmInfoTransferFlag.eitValue == '1'B ) {
        v_EIT_Flag := true;
    }}

    // Steps 3 and 4 - Authentication procedure.
    // Steps 5 and 6  - NAS SECURITY MODE COMMAND / NAS SECURITY MODE COMPLETE
    // Steps 6Aa1 and 6Aa2 -ESM INFORMATION TRANSFER
    //@siclog "Step 3 - 6Aa2" siclog@
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA, v_EIT_Flag, v_EPS_TI);

    //  ATTACH ACCEPT
    //@siclog "Step 7" siclog@
    v_IPallocationViaNasFlag :=  f_CheckPCOforIPallocationViaNas (v_Pco); // See TS 36.508 v.8.2.2 Table 4.7.3-6
    v_PDN_Address := f_GetPDNAddress (v_IPallocationViaNasFlag);
    v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_EpsOnly,
                                             cs_TAIListNonConsecutive_lv (tsc_PLMN1, {tsc_TAC1, tsc_TAC2}),
                                             v_Guti,
                                             omit,
                                             omit,
                                             cs_EMM_Cause_tv(tsc_EmmCause_UnknownIMSI),
                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                        cs_508_ActivateDefEpsBearerContextRequest(
                                            tsc_EpsDefaultBearerId,
                                            v_EPS_TI,
                                            v_APN,
                                            v_PDN_Address,
                                            omit,
                                            omit,
                                            f_GetDefPCOforPCSCFAddress (v_Pco))); // @sic R5-104703 sic@

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                     tsc_RRC_TI_Def,
                                                     v_AttachAccept);

   // ATTACH COMPLETE
   //@siclog "Step 8" siclog@
   f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);

   //@siclog "Step 9" siclog@
   f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);

   //@siclog "Step 10 - 12 Void" siclog@

   //@siclog "Step 13" siclog@
   //  The SS initiates Detach procedure with the Detach Type IE
   //+   "re-attach required"
   SRB.send(cas_SRB2_NasPdu_REQ(
               eutra_CellA,
               cs_TimingInfo_Now,
               cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                              cs_508_DETACH_REQUEST_MT(cs_DetachType(tsc_DetachMT_ReAttach), omit))));
    
    //@siclog "Step 14" siclog@
    //+   Check: Does the UE send DETACH ACCEPT message? [1,P]
    SRB.receive(car_SRB2_NasPdu_IND(
                eutra_CellA,
                cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                  cr_508_DETACH_ACCEPT)));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 14");

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

    //+ Step 16 Check: Does the UE send ATTACH REQUEST message? [1,P]
    //@siclog "Step 16" siclog@
    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_AttachType(tsc_EAttachType_EpsOnly,
                                          v_AdditionalUpdateType,
                                          f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                          cr_TAI (tsc_PLMN1, (tsc_TAC1)),
                                          omit,
                                          omit),
                                          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; // Use this value in SS responses
  v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
  v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellA, v_SecurityParams, v_NasCountUL); // RRC SECURITY COMMAND & COMPLETE
  f_EUTRA_Security_Set ( v_SecurityParams );//Saving security parameters

  //@siclog "Step 17" siclog@
  f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellA,
                                                tsc_EpsDefaultBearerId,
                                                tsc_RRC_TI_Def,
                                                v_EPS_TI,
                                                tsc_EAttachType_EpsOnly,
                                                f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco)),
                                                omit,
                                                cs_TrackingAreaIdListDef_lv,
                                                v_LAI,
                                                v_MSId,
                                                omit,
                                                omit,
                                                f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType);

  //@siclog "Step 18" siclog@
  //+   Check: Does the UE send ATTACH COMPLETE message? [1,P]
  f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);
  f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 18");

  //@siclog "Step 19a" siclog@
  f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
  
  //@siclog "Step 20" siclog@
  f_UT_SwitchOnUE (UT, false);

  //@siclog "Step 21" siclog@
  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_AttachType(tsc_EAttachType_Combined,
                                                                      v_AdditionalUpdateType,
                                                                      cr_MobileIdAny (omit),//f_GutiParameters2MobileIdentity(omit, v_GutiParams),
                                                                      cr_TAI (tsc_PLMN1, (tsc_TAC1)),
                                                                      omit,
                                                                      cr_TMSI_Status('0'B)),
                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));

  f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 21");
  v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
  v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
    v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
  }

   //@siclog "Step 22" siclog@
  //  ATTACH ACCEPT
  v_IPallocationViaNasFlag :=  f_CheckPCOforIPallocationViaNas (v_Pco); // See TS 36.508 v.8.2.2 Table 4.7.3-6
  v_PDN_Address := f_GetPDNAddress (v_IPallocationViaNasFlag);
  v_AttachAccept := cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_Combined,
                                             cs_TAIListNonConsecutive_lv (tsc_PLMN1, {tsc_TAC1, tsc_TAC2}),
                                             v_Guti,
                                             v_LAI,
                                             v_MSId,
                                             omit,
                                            f_GetAdditionalUpdateResult( v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),
                        cs_508_ActivateDefEpsBearerContextRequest(
                                            tsc_EpsDefaultBearerId,
                                            v_EPS_TI,
                                            cs_AccessPointName (px_AccessPointName),
                                            v_PDN_Address,
                                            omit,
                                            omit,
                                            f_GetDefPCOforPCSCFAddress (v_Pco))); // @sic R5-104703 sic@

  f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellA,
                                                   tsc_RRC_TI_Def,
                                                   v_AttachAccept);

  // ATTACH COMPLETE
  //@siclog "Step 23" siclog@
  f_EUTRA_NAS_AttachComplete(eutra_CellA, tsc_EpsDefaultBearerId);
  f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 23");

  }// function fl_tc_9_2_1_2_2_Body


///////////////////////////////////////////////////////////////////////////////
// TC 9.2.1.2.3
///////////////////////////////////////////////////////////////////////////////

function f_TC_9_2_1_2_3_EUTRA() runs on EUTRA_PTC
{
  // @desc Successful combined attach procedure, EPS service only / MSC temporarily not reachable.

  // (1)
  /* with { the UE has sent a combined ATTACH REQUEST message }
  ensure that {
  when { the UE receives an ATTACH ACCEPT message with EPS attach result set to "EPS only" and EMM reject cause set to "MSC temporarily not
  reachable" or "Network failure" or "Congestion" and including an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with IE EPS Bearer
  Identity matching the ATTACH REQUEST message and including a PDN address, an APN and an uplink TFT }
  then { UE transmits an ATTACH COMPLETE message, containing the EPS bearer identity, together with ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT
  message and the UE resets the attach attempt counter and tracking area updating attempt counter and the UE increments tracking area updating
  attempt counter and starts timer T3411 and enters EMM-REGISTERED.ATTEMPTING-TO-UPDATE-MM state }
            }
  (2)
  with { the UE is in E-UTRA EMM-REGISTERED.ATTEMPTING-TO-UPDATE-MM state }
  ensure that {
  when { timer T3411 expires or timer T3402 expires }
  then { the UE initiates a combined tracking area update procedure indicating "combined TA/LA updating with IMSI attach" }


  (3)
  with { the UE is in E-UTRA EMM-REGISTERED.ATTEMPTING-TO-UPDATE-MM state }
  ensure that {
  when { UE receives a TRACKING AREA UPDATE ACCEPT with EPS update result set to "EPS only" and EMM reject cause set to "MSC temporarily not
  reachable" or "Network failure" or "Congestion"  }
  then { UE increments tracking area updating attempt counter unless it was already set to 5 and starts timer T3411 if tracking area
  updating attempt counter is less than 5 or starts timer T3402 if tracking area updating attempt counter is equal to 5 }
            }


  System Simulator:
     -   Cell A is configured according to Table 6.3.2.2-1 in [18].
     -   Cell A belongs to TAI-1
     -   T3402 is set to default (12 min.).
  UE:
     -   The UE is configured to initiate combined EPS/IMSI attach.
     -   The USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED", and also P-TMSI signature1.
     -   The USIM contains TMSI-1 and LAI-1 for CS service, and Location update status is "U1: UPDATED".
  Preamble:
     -   The UE is in state Switched OFF (state 1) according to clause [18].
  */

   f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);

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

   f_UT_ConfigureCombinedAttach (UT); // R5-103815

   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);
   //k=1
   fl_TC_9_2_1_2_3_Body(cs_EMM_Cause_v(tsc_EmmCause_MSCnotReachable));

   //k=2
   f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );
   fl_TC_9_2_1_2_3_Body(cs_EMM_Cause_v(tsc_EmmCause_NetworkFailure));

   //k=3
   f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE, tsc_RRC_TI_Def );
   fl_TC_9_2_1_2_3_Body(cs_EMM_Cause_v(tsc_Cause_Congestion));

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

  }// function f_TC_9_2_1_2_3_EUTRA

function fl_TC_9_2_1_2_3_Body(template (value) EMM_Cause p_EMMCause) runs on EUTRA_PTC
   {
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var HalfOctet_Type v_EPS_Bearer_Id := tsc_EpsDefaultBearerId;
    var GutiParameters_Type v_GutiParams_CellA := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var NAS_MSG_Indication_Type v_NasInd;
    var NAS_UL_Message_Type v_PdnConnectivityRequest;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var template AdditionalUpdateType   v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var ReleaseCause v_ReleaseCause := other;
    var EPS_BearerContextStatus v_EPS_ContextStatus;
    var SRB_COMMON_IND v_ReceivedAsp;
    var template (omit) AccessPointName v_APN := omit;
    var boolean v_EIT_Flag := false;
    var integer v_Step := 10;
    var NAS_Lac v_LAC := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams_CellA.PLMN_Identity);
    var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN,v_LAC);

    timer t_T3411 := f_EUTRA_SetTimerToleranceMax(eutra_CellA, 10.0);
    timer t_T3402 := f_EUTRA_SetTimerToleranceMax(eutra_CellA, 720.0);

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

  //@siclog "Step 2" siclog@
  //+  The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message as specified
    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_AttachType(tsc_EAttachType_Combined,
                                                                    v_AdditionalUpdateType,
                                                                    f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                    cr_TAI( v_PLMN, v_LAC),
                                                                    v_LAI,
                                                                    omit),
                                        cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                        f_GetPdnType())));

    v_PdnConnectivityRequest := v_NasInd.Pdu.PiggybackedPduList[0].Msg;
    v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }
    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;
    }}

    //@siclog "Step 3 - 6Aa2" 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 6Aa1 and 6Aa2 -ESM INFORMATION TRANSFER
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA, v_EIT_Flag, v_EPS_TI);

    //@siclog "Step 7" siclog@
    //The SS transmits an ATTACH ACCEPT message with IE EPS Bearer Identity set to default EPS bearer context. The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST
    //message is piggybacked in ATTACH ACCEPT.
    //Note 1: SS allocates a PDN address of a PDN type which is compliant with from the PDN type requested by the UE.
    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,
                                                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_EpsOnly,
                                                                             cs_TrackingAreaIdListDef_lv,
                                                                             omit,
                                                                             omit,
                                                                             omit,
                                                                             p_EMMCause,
                                                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),  // @sic R5-103681 sic@
                                                        cs_508_ActivateDefEpsBearerContextRequest(v_EPS_Bearer_Id,
                                                                                                  v_EPS_TI,
                                                                                                  v_APN,
                                                                                                  f_GetPDNAddress(f_CheckPCOforIPallocationViaNas(v_Pco)),
                                                                                                  omit,
                                                                                                  omit,
                                                                                                  f_GetDefPCOforPCSCFAddress (v_Pco)))); // @sic R5-104703 sic@
    t_T3411.start;

    //@siclog "Step 8" siclog@
    //+   Check: does the UE transmit an ATTACH COMPLETE message including an  ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message?  [1,P]
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                                      cr_508_ATTACH_COMPLETE,
                                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EPS_Bearer_Id))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 8");

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

    //@siclog "Step 10" siclog@
    //Check1: Does the UE transmit a TRACKING AREA UPDATE REQUEST message with  "combined TA/LA updating with IMSI attach"?
    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_specificGutiTaiLai(tsc_EpsUpdate_Combined_IMSIAttach,
                                                                                             f_EUTRA_SecurityKSIasme_Get(),
                                                                                             v_AdditionalUpdateType,
                                                                                             f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                                             v_LAI,
                                                                                             cr_TAI( v_PLMN, v_LAC),
                                                                                             omit)));
    //@siclog "Step 11 - 16" siclog@
    //Check2: Is the time between the previous ATTACH ACCEPT and TRACKING AREA UPDATE REQUEST equal to T3411?
    //SS transmits a TRACKING AREA UPDATE ACCEPT message.
    //Note: Tracking area updating attempt counter is incrementing  [1,2,P]
    for (v_Step := 10; v_Step < 15; v_Step := v_Step + 2)
    {
        t_T3411.stop; // If the timer times out, it will be caught in the default behaviour
        f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step "&int2str(v_Step));

        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,
                                                          cds_TAU_Accept_EMM_Cause ( tsc_EpsUpdate_TaUpdate,
                                                                              f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                              cs_TrackingAreaIdListDef_lv,
                                                                              v_EPS_ContextStatus,
                                                                              omit,
                                                                              omit,
                                                                              f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                              p_EMMCause))));


        t_T3411.start;
        SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                          cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                            cdr_TAU_Request_specificGutiTaiLai(tsc_EpsUpdate_Combined_IMSIAttach,
                                                                                                  f_EUTRA_SecurityKSIasme_Get(),
                                                                                                  v_AdditionalUpdateType,
                                                                                                  f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                                                  v_LAI,
                                                                                                  cr_TAI( v_PLMN, v_LAC),
                                                                                                  omit))))
        -> value v_ReceivedAsp;
    }

    t_T3411.stop; // If the timer times out, it will be caught in the default behaviour
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 16");
    v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

    //@siclog "Step 17" siclog@
    //SS transmits a TRACKING AREA UPDATE ACCEPT message.
    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cds_TAU_Accept_EMM_Cause ( tsc_EpsUpdate_TaUpdate,
                                                                         f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                          cs_TrackingAreaIdListDef_lv,
                                                                          v_EPS_ContextStatus,
                                                                          omit,
                                                                          omit,
                                                                          f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                          p_EMMCause))));

    //@siclog "Step 18" siclog@
    //Check1: Does the UE send TRACKING AREA UPDATE REQUEST message with  "combined TA/LA updating with IMSI attach"?
    //Check2: Is the time between the previous TRACKING AREA UPDATE ACCEPT and TRACKING AREA UPDATE REQUEST equal to T3402?
    //Note: Tracking area updating attempt counter=5
    t_T3402.start;
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                      cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                        cdr_TAU_Request_specificGutiTaiLai(tsc_EpsUpdate_Combined_IMSIAttach,
                                                                                              f_EUTRA_SecurityKSIasme_Get(),
                                                                                              v_AdditionalUpdateType,
                                                                                              f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                                              v_LAI,
                                                                                              cr_TAI( v_PLMN, v_LAC),
                                                                                              omit))))
    -> value v_ReceivedAsp;

    t_T3402.stop; // If the timer times out, it will be caught in the default behaviour
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 18");
    v_EPS_ContextStatus := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus; // Send this back in the Accept

    //@siclog "Step 19" siclog@
    //SS transmits a TRACKING AREA UPDATE ACCEPT message.
    SRB.send ( cas_SRB2_NasPdu_REQ ( eutra_CellA,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cds_TAU_Accept_EMM_Cause ( tsc_EpsUpdate_TaUpdate,
                                                                          f_GutiParameters2MobileIdentity(omit, v_GutiParams_CellA),
                                                                          cs_TrackingAreaIdListDef_lv,
                                                                          v_EPS_ContextStatus,
                                                                          omit,
                                                                          omit,
                                                                          f_GetAdditionalUpdateResult(v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                                                          p_EMMCause))));
    //@siclog "Step 20" siclog@
    //Check: Does the UE answer to paging with S-TMSI2 (associated with GUTI2) for PS domain (generic procedure)? [3,P]
    f_EPS_508Check_NAS_Paging(eutra_CellA, ps);

} // function tc_9_2_1_2_3_EUTRA


 /**
   * @desc Successful combined attach procedure, EPS service only / CS domain not available
   */
  function f_TC_9_2_1_2_4_EUTRA() runs on EUTRA_PTC
  {
  /*  Test Purpose (TP)
    (1)
    with { UE is switched-off }
    ensure that {
      when { UE is powered on and a valid GUTI is available }
        then { the UE transmits an ATTACH REQUEST message with the EPS attach type set to "combined EPS/IMSI attach", including GUTI, last visited registered TAI and a PDN CONNECTIVITY REQUEST message with the request type set to "initial attach" }
                }
    (2)
    with { UE has sent a combined ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
    ensure that {
      when { UE receives an ATTACH ACCEPT message including EPS attach result set to "EPS only" and EMM reject cause set to "CS domain not available" and including an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with IE EPS Bearer Identity matching the PDN CONNECTIVITY REQUEST message }
        then { UE transmits ATTACH COMPLETE message, containing the EPS bearer identity, including an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message and sets the update status to U2 NOT UPDATED and enters EMM-REGISTERED state }
                }
    (3)
    with { The UE received an ATTACH ACCEPT message with EPS attach result set to "EPS only" and EMM cause set to "CS domain not available" }
    ensure that {
      when { UE enters a TA where it is not registered and which belongs to the PLMN where the UE received the EMM cause "CS domain not available" }
        then { UE initiates a normal tracking area update procedure indicating "TA updating" without valid LAI, TMSI, GSM ciphering key, UMTS integrity key, UMTS ciphering key or ciphering key sequence number }
                }
    (4)
    with { The UE received an ATTACH ACCEPT message with EPS attach result set to "EPS only" and EMM cause set to "CS domain not available" }
    ensure that {
      when { UE is powered up or switched on }
        then { UE initiates a combined attach procedure indicating "combined EPS/IMSI attach" }
                }

   */
  /*    Pre-test conditions
      System Simulator:
      -    Cell A are Cell B are configured according to Table 6.3.2.2-1 in [18].
      -    Cell A belongs to TAI-1(home PLMN).
      -    Cell B belongs to TAI-2(home PLMN, another TAC).
      UE:
      -    The UE is configured to initiate combined EPS/IMSI attach.
      -    The test USIM contains GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
      -    The test USIM contains TMSI1 and LAI1 for CS service, and Location update status is "U1: UPDATED".
      Preamble:
      -    The UE is in state Switched OFF (state 1) according to [18].
    */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN ,LTEmulticell);

    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_Def(eutra_CellB);
    
    f_UT_ConfigureCombinedAttach (UT); // R5-103815

    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );

    f_EUTRA_TestBody_Set(true);

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


  function fl_TC_9_2_1_2_4_Body() runs on EUTRA_PTC
  {
    var HalfOctet_Type v_EPS_Bearer_Id := tsc_EpsDefaultBearerId;
    var ProcedureTransactionIdentifier v_EPS_TI := '00'O;
    var NAS_MSG_Indication_Type v_NasInd;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    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_LacA := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellA );
    var NAS_Lac v_LacB := f_EUTRA_CellInfo_GetLocationAreaCode ( eutra_CellB );
    var template (omit) LocAreaId v_LAI := f_GetLAI(v_PLMN, v_LacA);
    var template (omit) LocAreaId v_LAI_B := f_GetLAI(v_PLMN, v_LacB);
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var template (omit) AccessPointName v_APN := omit;
    var template (omit) ProtocolConfigOptions v_Pco := omit;
    var EPS_BearerContextStatus v_EpsBearerCtxtStatus;
    var template (value) CellPowerList_Type v_CellPowerList;
    var boolean v_EIT_Flag := false;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();

    //  Set the cell type of cell A to the "Serving cell" Set the cell type of cell B to the "Non-suitable cell"
    //@siclog "Step 1" siclog@
    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 2" siclog@
    f_UT_SwitchOnUE (UT, false);

    //@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,
                             cdr_ATTACH_REQUEST_AttachType(tsc_EAttachType_Combined,
                                                           v_AdditionalUpdateType,
                                                           f_GutiParameters2MobileIdentity(omit, v_Guti1_Params), // GUTI1
                                                           cr_TAI( v_PLMN, tsc_TAC1),
                                                           v_LAI,
                                                           omit),
                            cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                            f_GetPdnType())));

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

    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;
    }}
    if (ispresent( v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
      v_Pco := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
    }

    //+  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 7Aa1 and 7Aa2 ESM INFORMATION REQUEST / ESM INFORMATION RESPONSE
    //@siclog "Step 4 - 7Aa2" siclog@
    v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellA,v_EIT_Flag, v_EPS_TI);

    //@siclog "Step 8" siclog@
    //+  SS responds with ATTACH ACCEPT message.
    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,
                                                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_EpsOnly,
                                                                             cs_TrackingAreaIdListDef_lv,
                                                                             f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti1_Params),
                                                                             omit,
                                                                             omit,
                                                                             cs_EMM_Cause_v(tsc_Cause_CSDomainNotAvailable),
                                                                             f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),  // @sic R5-103681 sic@
                                                        cs_508_ActivateDefEpsBearerContextRequest(v_EPS_Bearer_Id,
                                                                                                  v_EPS_TI,
                                                                                                  v_APN,
                                                                                                  f_GetPDNAddress(f_CheckPCOforIPallocationViaNas(v_Pco)),
                                                                                                  omit,
                                                                                                  omit,
                                                                                                  f_GetDefPCOforPCSCFAddress (v_Pco))));

    //@siclog "Step 9" siclog@
    //+  The UE transmits an ATTACH COMPLETE message
    f_EUTRA_NAS_AttachComplete(eutra_CellA, v_EPS_Bearer_Id);
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9");

    //@siclog "Step 10" siclog@
     f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);

    //@siclog "Step 11" siclog@
    f_EUTRA_508Check_IdleState ( eutra_CellA );

    //@siclog "Step 12" 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 );

    //@siclog "Step 13" siclog@
    // Check: Does the UE transmit TRACKING AREA UPDATE REQUEST message?  [3,P]
    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_TaUpdate,
                                                                                                    f_EUTRA_SecurityKSIasme_Get(),
                                                                                                    v_AdditionalUpdateType,
                                                                                                    f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                                    omit,
                                                                                                    cr_TAI( v_PLMN, v_LacA),
                                                                                                    cr_TMSI_Status('0'B))));

    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 13");
    v_EpsBearerCtxtStatus := v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.epsBearerContextStatus;
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;

    // enable integrity/ciphering in AS (but not NAS as the NAS security context
    // gets activated implicitly by receiving the TAU request with a valid MAC)
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellB,
                                                   v_SecurityParams,
                                                   v_NasCountUL);
    f_EUTRA_Security_Set(v_SecurityParams);

    //@siclog "Step 14" siclog@
    //+  SS responds with TRACKING AREA UPDATE ACCEPT message
    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),
                                              cs_TrackingAreaIdListDef_lv,
                                              v_EpsBearerCtxtStatus,
                                              omit,
                                              omit,
                                              f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType),
                                              cs_EMM_Cause_v(tsc_Cause_CSDomainNotAvailable)))));

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

   f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, other);

    //@siclog "Step 16a" siclog@
  f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellB, RRC_IDLE );

    //@siclog "Step 17" siclog@
    f_UT_SwitchOnUE (UT, false );

    //@siclog "Step 18" siclog@
    //+   Check : Does the UE transmit a combined ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST
    //    message as specified on cell B?  [4,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                 cdr_ATTACH_REQUEST_AttachType(tsc_EAttachType_Combined,
                                                                               v_AdditionalUpdateType,
                                                                               f_GutiParameters2MobileIdentity(omit, v_Guti2_Params), // GUTI2
                                                                               cr_TAI( v_PLMN, v_LacB),
                                                                               omit,
                                                                               cr_TMSI_Status('0'B)),
                                                cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                f_GetPdnType())));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 18");

    //@siclog "Step 19" siclog@
    //+   SS responds with ATTACH ACCEPT message with IE EPS Bearer Identity set to default EPS bearer context.
    //    The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT.
    f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellB,
                                            v_EPS_Bearer_Id,
                                            v_RRC_TI,
                                            v_EPS_TI,
                                            tsc_EAttachType_Combined,
                                            f_GetPDNAddress(f_CheckPCOforIPallocationViaNas (v_Pco)),
                                            f_GutiParameters2MobileIdentity(omit, v_Guti2_Params),
                                            cs_TrackingAreaIdListDef_lv,
                                            v_LAI_B,
                                            f_GetMSId (),
                                            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 20 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. ///////
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //@siclog "Step 20" siclog@
    //+   Check: Does the UE transmit an ATTACH COMPLETE message
    //    including a ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message as specified?
    f_EUTRA_NAS_AttachComplete(eutra_CellB, v_EPS_Bearer_Id);

  }// function fl_tc_9_2_1_2_4_Body


///////////////////////////////////////////////////////////////////////////////
// TC 9.2.1.2.10
///////////////////////////////////////////////////////////////////////////////

function f_TC_9_2_1_2_10_EUTRA() runs on EUTRA_PTC
{
  // @desc Combined attach / rejected / Tracking area not allowed
   /*    (1)
        with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
        ensure that {
          when { UE receives an ATTACH REJECT message with the reject cause set to "Tracking area not allowed" }
            then { UE deletes the GUTI, last visited registered TAI and KSI, UE enters the state EMM-DEREGISTERED.LIMITED-SERVICE and UE stores 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 the current TAI in 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 on any 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 re-selects a new cell in the same TAI it was rejected }
            then { UE does not attempt to attach on the cell }
                    }

        (4)
        with { UE is switched off }
        ensure that {
          when { UE is powered 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 swithed off }
            then { UE attempts to attach on the cell }
                    }

        System Simulator:
            -   Cell A, Cell B and Cell M
        UE:
            -   The UE is configured to initiate combined EPS/IMSI attach.
            -   The test USIM contains IMSI1, GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
        Preamble:
            -   The UE is in state Switched OFF (state 1) according to clause [18]
   */

   f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);

  // Create cell and send out system information for CellA (serving) and Cell B (suitable)
    f_EUTRA_CellConfig_Def(eutra_CellA);
    f_EUTRA_CellConfig_SRBs_Only(eutra_CellB);
    f_EUTRA_CellConfig_Def(eutra_CellM);

    f_UT_ConfigureCombinedAttach (UT); // R5-103815

    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_1_2_10_Body();

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

  }// function f_TC_9_2_1_2_10_EUTRA

function fl_TC_9_2_1_2_10_Body() runs on EUTRA_PTC
{
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
    var ReleaseCause v_ReleaseCause := other;
    var template (value) CellPowerList_Type v_CellPowerList;
    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@
    //+  The SS configures:
    //   - Cell A as the "Serving cell".
    //   - Cell B as a "Suitable neighbour cell".
    //   - Cell M as a "Non-Suitable cell".
    v_CellPowerList := {
                         cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
                         cs_CellPower ( eutra_CellB, tsc_SuitableCellRS_EPRE ),
                         cs_CellPower ( eutra_CellM, tsc_NonSuitableCellRS_EPRE )
                       };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

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

    // The following messages are sent and shall be received on Cell A.

    //@siclog "Step 3" siclog@
    //+ The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message.
    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())));


    //@siclog "Step 4" siclog@
    //+   The SS transmits an ATTACH REJECT message with EMM cause = "Tracking area not allowed".
    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 5" siclog@
    //+   The SS releases the RRC connection.
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, v_RRC_TI, v_ReleaseCause);

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

    //@siclog "Step 7" siclog@
    //+   The SS configures: Cell A as the "Non-Suitable cell". Cell B as a "Non-Suitable cell". Cell M as a "Serving cell".
    v_CellPowerList := {
                         cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
                         cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
                         cs_CellPower ( eutra_CellM, tsc_ServingCellRS_EPRE )
                       };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

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

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

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

    // The following messages are sent and shall be received on Cell M.

    //@siclog "Step 11" siclog@
    //+  Check: Does the UE transmit an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message as specified? [1,4,P]
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellM,
                                             tsc_RRC_TI_Def,
                                             cr_EstablishmentCause_Any,
                                               cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                                cdr_ATTACH_REQUEST_WithOldMobileIdNoTAI( v_AttachType,
                                                                                                                         v_AdditionalUpdateType,
                                                                                                                         f_Imsi2MobileIdentity(px_IMSI_Def)),
                                                                                 cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                 f_GetPdnType())));
    f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "Step 11");

    //@siclog "Step 12 - 23" siclog@
    f_EUTRA_IdleUpdated_Step5_17(eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_NasInd, false);
} // function tc_9_2_1_2_10_EUTRA


function f_TC_9_2_1_2_12_EUTRA() runs on EUTRA_PTC
{
// @desc Combined attach / Rejected / EPS services not allowed in this PLMN
 /* Test Purpose (TP)
  (1)
  with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message }
    ensure that {
      when { UE receives an ATTACH REJECT message with the reject cause set to "EPS services not allowed in this PLMN" }
        then { UE stores the PLMN identity in the "forbidden PLMNs for GPRS service" list and deletes any GUTI, last visited registered TAI, KSI and enters EMM-DEREGISTERED.PLMN-SEARCH state}
  }

  (2)
  with { UE in E-UTRA EMM-DEREGISTERED.PLMN-SEARCH state, and a PLMN is stored in the "forbidden PLMNs for GPRS service" list }
    ensure that {
      when { UE detects a cell which belongs to a PLMN which is not in the "forbidden PLMNs for GPRS service" list }
        then { UE performs an attach procedure }
  }

  (3)
  with { UE is switched off when a PLMN is stored in the "forbidden PLMNs for GPRS service" list }
    ensure that {
      when { UE is powered on in a cell which belongs to this PLMN }
        then { UE performs an attach procedure }
  }

  System Simulator:
   -   Cell I, Cell J and Cell A
   -   Cell I, Cell J and Cell A belong to different PLMNs and different frequencies

  UE:
   -   The UE is configured to initiate combined EPS/IMSI attach.
   -   The test USIM contains IMSI1, GUTI1 and TAI1, and EPS update status is "EU1: UPDATED".
   -   If pc_GERAN or pc_UTRAN, the test USIM contains TMSI-1 and a valid LAI-1 for CS service, and Location update status is " U1: UPDATED".

  Preamble:
   -   The UE is in state Switched OFF (state 1) according to clause [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_CellI);
    f_EUTRA_CellConfig_Def(eutra_CellJ);

    f_UT_ConfigureCombinedAttach (UT); // R5-103815

    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_1_2_12_Body ();

    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellI, E2_CONNECTED);   // @sic R5-103875 sic@
} // end f_TC_9_2_1_2_12_EUTRA


    function fl_TC_9_2_1_2_12_Body() runs on EUTRA_PTC
    {
        var template (value) CellPowerList_Type v_CellPowerList;
        var NAS_MSG_Indication_Type v_NAS_Ind;
        var SRB_COMMON_IND v_ReceivedAsp;
        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 HalfOctet_Type v_EpsBearerId := tsc_EpsDefaultBearerId;
        var NAS_UL_Message_Type v_PdnConnectivityRequest;
        var float v_NoReactionTime := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 3.0 );
        //var template (omit) MobileIdentity v_MSId := f_GetMSId (CombinedWithTMSI);

        var GutiParameters_Type v_Guti_Params := f_EUTRA_CellInfo_GetGuti (eutra_CellA);
        var GutiParameters_Type v_Guti_Params_J := f_EUTRA_CellInfo_GetGuti (eutra_CellJ);
        var NAS_PlmnId v_PLMN := f_Asn2Nas_PlmnId (v_Guti_Params.PLMN_Identity);

        var TrackingAreaCode v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellJ );
        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 boolean   v_Px_CS_PSmode2       := true;
        timer t_Wait := f_EUTRA_SetTimerToleranceMin( eutra_CellI, 30.0 );
 
        //@siclog "Step 1" siclog@
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellI, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellJ, tsc_SuitableCellRS_EPRE )
        }
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );


        //  Switch on UE
        //@siclog "Step 2" siclog@
        f_UT_SwitchOnUE (UT, false);
    

        // The UE transmits an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message
        //@siclog "Step 3" siclog@
        v_NAS_Ind:= f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                                  tsc_RRC_TI_Def,
                                                  cr_EstablishmentCause_Any,
                                                  cr_NAS_IndicationWithPiggybacking(
                                                             tsc_SHT_IntegrityProtected,
                                                             cdr_ATTACH_REQUEST_AttachType (v_AttachType,
                                                                                            v_AdditionalUpdateType,
                                                                                            f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti_Params),
                                                                                            cr_TAI(v_PLMN, tsc_TAC1),
                                                                                            f_EUTRA_GetCellLAI(eutra_CellA),
                                                                                            omit
                                                                                   ),
                                                             cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                             f_GetPdnType())
                                                   ));


        //@siclog "Step 4" siclog@
        // The SS transmits an ATTACH REJECT message with EMM cause = "EPS services not allowed in this PLMN"
        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_EPSServNotAllowedInThisPLMN),
                                                                       omit))
                                         ));

        // The SS releases the RRC connection
        //@siclog "Step 5" siclog@
        f_EUTRA_RRC_ConnectionRelease(eutra_CellA, 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-1 and with CN domain indicator set to "PS"?
        f_EUTRA_508Check_NASNoResponse ( eutra_CellA,
                            cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_Guti_Params.MME_Code, v_Guti_Params.M_TMSI )),
                            v_NoReactionTime );

        //parallel behaviour -> FFS
        // v_Px_CS_PSmode2 not read until a solution is agreed for this feature
        // since v_Px_CS_PSmode2 doesn't exist in the prose specification
        // For the time being pc_Combined_Attach is not read and the parallel behaviour is done every time
        //if(v_Px_CS_PSmode2)
        //{
            // Check: Does the UE transmit an ATTACH REQUEST message?
            SRB.receive(car_SRB1_NasPdu_IND(eutra_CellJ,
                                            cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                              cr_508_ATTACH_REQUEST(v_AttachType, v_AdditionalUpdateType),
                                                                              cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                              f_GetPdnType()))))
              -> value v_ReceivedAsp;
            v_PdnConnectivityRequest := v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg;
            v_EPS_TI := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.procedureTransactionIdentifier; // Use this value in SS responses
            if (ispresent( v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
               v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
            }

            // The SS transmits an AUTHENTICATION REQUEST message to initiate the EPS authentication and AKA procedure
            // The UE transmits an AUTHENTICATION RESPONSE message
            // The SS transmits a NAS SECURITY MODE COMMAND message
            // The UE transmits a NAS SECURITY MODE COMPLETE message
            v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellJ, v_EIT_Flag, v_EPS_TI);

            // SS responds with ATTACH ACCEPT message
            v_TaiList := cs_TAIListNonConsecutive_lv(f_Asn2Nas_PlmnId(v_Guti_Params_J.PLMN_Identity),
                                                       { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellJ)) } );
  
            f_EUTRA_RRCConnectionReconfigurationWithAttachAcceptAllParams(eutra_CellJ,
                                                                          v_EpsBearerId,
                                                                          tsc_RRC_TI_Def,
                                                                          v_EPS_TI,
                                                                          v_AttachType,
                                                                          f_GetPDNAddress(f_CheckPCOforIPallocationViaNas(v_Pco)),
                                                                          f_GutiParameters2MobileIdentity(tsc_IEI_Guti, v_Guti_Params_J),
                                                                          v_TaiList,
                                                                          omit,
                                                                          omit,
                                                                          omit,
                                                                          v_APN,
                                                                          f_GetDefPCOforPCSCFAddress (v_Pco), // @sic R5-104703 sic@
                                                                          v_PdnConnectivityRequest.aTTACH_REQUEST.addUpdateType);

            // Check: The UE transmits an ATTACH COMPLETE message
            f_EUTRA_NAS_AttachComplete(eutra_CellJ, v_EpsBearerId);
       // }

        //@siclog "Step 8" siclog@
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellI, tsc_SuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellJ, tsc_NonSuitableCellRS_EPRE )
        }
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        //@siclog "Step 9" siclog@
        // Check: Does the UE transmit an ATTACH REQUEST message in the next 30 seconds?
        t_Wait.start;
        alt {
          [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellI, cr_RRCConnectionRequest(cr_EstablishmentCause_Any)))
             {
               t_Wait.stop;
               f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellI, cs_TimingInfo_Now, tsc_RRC_TI_Def);
               SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellI,
                                                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) )
                                                                                  )));
               f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9: Attach request");
             }
          [] t_Wait.timeout
            {
               f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 9");
            }
        }

        //@siclog "Step 10" siclog@
        // The SS transmits an ATTACH REJECT message with EMM cause = "EPS services not allowed in this PLMN"
        SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellI,
                                          cs_TimingInfo_Now,
                                          cs_NAS_Request ( tsc_SHT_NoSecurityProtection,
                                                           cs_508_AttachReject (
                                                                       cs_EMM_Cause_v(tsc_Cause_EPSServNotAllowedInThisPLMN),
                                                                       omit))
                                         ));


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

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

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

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

        //@siclog "Step 14" siclog@
        // Check: Does the UE transmit an ATTACH REQUEST message on Cell I?
        SRB.receive(car_SRB1_NasPdu_IND(eutra_CellI,
                                        cr_NAS_IndicationWithPiggybacking(tsc_SHT_NoSecurityProtection,
                                                                          cdr_ATTACH_REQUEST_WithOldMobileIdNoTAI(v_AttachType, v_AdditionalUpdateType, f_Imsi2MobileIdentity(px_IMSI_Def) ),
                                                                          cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                          f_GetPdnType())
                                                                          )))
            -> value v_ReceivedAsp;

        v_PdnConnectivityRequest := v_ReceivedAsp.Signalling.Nas[0].Pdu.PiggybackedPduList[0].Msg;
        v_EPS_TI := v_PdnConnectivityRequest.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_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions)) {
               v_Pco := v_PdnConnectivityRequest.pDN_CONNECTIVITY_REQUEST.protocolConfigurationOptions;
        }
        f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 14");

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

        //@siclog "Step 15 - 26" 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.
        v_APN := f_EUTRA_Authentication_NAS_AS_Security (eutra_CellI, v_EIT_Flag, v_EPS_TI);

        // SS responds with ATTACH ACCEPT message with IE EPS Bearer Identity set to default EPS Bearer Context.
        // The ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message is piggybacked in ATTACH ACCEPT message
        v_TaiList := cs_TAIListNonConsecutive_lv(f_Asn2Nas_PlmnId(v_Guti_Params.PLMN_Identity),
                                                   { bit2oct(f_EUTRA_CellInfo_GetTAC(eutra_CellI)) } );

    if (not isvalue(v_APN)) {
      v_APN := cs_AccessPointName (px_AccessPointName);
    }

    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS(eutra_CellI,
                                                     tsc_RRC_TI_Def,
                                                     cs_NAS_RequestWithPiggybacking(tsc_SHT_IntegrityProtected_Ciphered,
                                                        cs_508_ATTACH_ACCEPT(tsc_EAttachType_EpsOnly,
                                                                             v_TaiList,
                                                                             omit,
                                                                             omit,
                                                                             omit,
                                                                             cs_EMM_Cause_v(tsc_Cause_CSDomainNotAvailable),
                                                                             f_GetAdditionalUpdateResult(v_NAS_Ind.Pdu.Msg.aTTACH_REQUEST.addUpdateType)),  // @sic R5-103681 sic@
                                                        cs_508_ActivateDefEpsBearerContextRequest(v_EpsBearerId,
                                                                                                  v_EPS_TI,
                                                                                                  v_APN,
                                                                                                  f_GetPDNAddress(f_CheckPCOforIPallocationViaNas(v_Pco)),
                                                                                                  omit,
                                                                                                  omit,
                                                                                                  f_GetDefPCOforPCSCFAddress (v_Pco))));
        // Check: Does the UE transmit an ATTACH COMPLETE message including an ACTIVATE DEFAULT EPS BEARER
        // CONTEXT ACCEPT message?
        f_EUTRA_NAS_AttachComplete(eutra_CellI, v_EpsBearerId);
 
    }// end function fl_TC_9_2_1_2_12_Body



function f_TC_9_2_1_2_14_EUTRA() runs on EUTRA_PTC
{
   // @desc Combined attach / Rejected / Not authorized for this CSG
    /*Test Purpose (TP)
      (1)
       with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on a CSG cell }
        ensure that {
              when { UE receives an ATTACH REJECT message with the reject cause set to "Not authorized for this CSG" and without integrity protection }
                 then { UE discards this message }
           }
      (2)
      with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on a CSG cell which is contained in the Allowed CSG list }
       ensure that {
           when { UE receives an ATTACH REJECT message with the reject cause set to "Not authorized for this CSG" and with integrity protection }
                then { UE removes the CSG ID from the Allowed CSG list }
           }
      (3)
      with { UE has sent an ATTACH REQUEST message including a PDN CONNECTIVITY REQUEST message on a CSG cell }
       ensure that {
           when { UE receives an ATTACH REJECT message with the reject cause set to "Not authorized for this CSG" and with integrity protection }
                then { UE searches for a suitable cell in the same PLMN }
           }

    System Simulator:
       -    Cell A, Cell B, Cell G.
       -    Cell A (TAC-1, frequency 1, not a CSG cell)
       -    Cell B (TAC-2, frequency 1, a CSG cell whose CSG Identity is included in the Allowed CSG list)
       -    Cell G (another PLMN, frequency 2 and not a CSG cell)
    UE:
       -    The UE is configured to initiate combined EPS/IMSI attach.
       -    The UE has a valid GUTI (GUTI-1).
       -    The test USIM contains IMSI-1, GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
       -    The test USIM contains an Allowed CSG list which includes CSG ID of Cell B.
    Preamble:
       -    The UE is in state Switched OFF (state 1) according to clause [18].
   */
    var B27_Type v_CSG_Identity_Cell2 := '000000000000000000000000010'B;

    f_EUTRA_NAS_Init(LTE_CellsOnDifferentPLMN, LTEmulticell );

    // Set Sys. info for CellB acc. to table 9.2.1.2.14.3.3-4
    f_EUTRA_CellInfo_SetSysInfo_Csg_Ind ( eutra_CellB, true );

    f_EUTRA_CellInfo_SetSysInfo_Csg_Id ( eutra_CellB, v_CSG_Identity_Cell2 );

    // 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_UT_ConfigureCombinedAttach (UT); // R5-103815

    // Preamble: UE is in state Switched OFF (state 1)
    // ==========================================================================
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_UE_Detach_SwitchOffUe ( eutra_CellA, RRC_IDLE );
    f_EUTRA_TestBody_Set(true);

    fl_TC_9_2_1_2_14_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
} // end f_TC_9_2_1_2_14_EUTRA

    function fl_TC_9_2_1_2_14_Body() runs on EUTRA_PTC
    {
        var template (value) CellPowerList_Type v_CellPowerList;
        var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI_Def;
        var ReleaseCause v_RRC_ReleaseCause := other;
        var NAS_MSG_Indication_Type v_Nas_Ind;
        var GutiParameters_Type v_Guti1_Params := f_EUTRA_CellInfo_GetGuti(eutra_CellA); //GUTI-1
        var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
        var template (omit) LocAreaId v_LAI := f_GetLAI( tsc_PLMN1, (tsc_TAC1) );
        var SRB_COMMON_IND v_ReceivedAsp;

        var float v_T3410andT3411 := f_EUTRA_SetTimerToleranceMin( eutra_CellA, 25.0 );
        timer t_Wait := f_EUTRA_SetTimerToleranceMax( eutra_CellA, 30.0 );

        //@siclog "Step 1" siclog@
        // The SS configures CellA as "Non-Suitable cell", CellB as the "Serving cell" and CellG as a "Non-Suitable cell"
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE ),
          cs_CellPower ( eutra_CellG, tsc_NonSuitableCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        //@siclog "Step 2" siclog@
        f_UT_SwitchOnUE (UT, false);

        //@siclog "Step 3" siclog@
        // UE initiate attach procedure and send ATTACH REQUEST
        // including a PDN CONNECTIVITY REQUEST message on cell B

        // RRC Connection Establishment, with Attach Request and PDN Connectivity
        v_Nas_Ind := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                                    v_RRC_TI,
                                                    cr_EstablishmentCause_Any,
                                                    cr_NAS_IndicationWithPiggybacking(
                                                               tsc_SHT_IntegrityProtected,
                                                               cdr_ATTACH_REQUEST_AttachType(
                                                                           tsc_EAttachType_Combined,
                                                                           v_AdditionalUpdateType,
                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                           cr_TAI( tsc_PLMN1, (tsc_TAC1) ),
                                                                           v_LAI,
                                                                           omit
                                                                           ),
                                                                cr_508_PDN_CONNECTIVITY_REQUEST(
                                                                           tsc_PdnRequest_InitialAttach,
                                                                           f_GetPdnType())
                                                                ));

        //@siclog "Step 4" siclog@
        // The SS transmits an ATTACH REJECT message with EMM cause = "Not authorized for this CSG"
        // without integrity protection.
        SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                          cs_TimingInfo_Now,
                                          cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                       cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_NotAuthorizedCSG),
                                                                             omit))));
        // The SS releases the RRC connection
        //@siclog "Step 5" siclog@
        f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, other);

        //@siclog "Step 6" siclog@
        // Check: Does the UE transmit an ATTACH REQUEST message on Cell B after the expiry of timer T3410andT3411?
        // Note 1: IF UE initiate ATTACH procedure again, it can prove that this UE has discard
        //         the unprotected ATTACH REJECT message.
        // Note 2: Default value of T3410 is 15s; default value of T3411 is 10s.
        //         In this TC, the network will wait for total 30 seconds.
        t_Wait.start;
        f_Delay(v_T3410andT3411); //Wait for expiry of these first
        alt {
          []  SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellB, 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_CellB, 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_CellB,
                                                   cr_508_RRCConnectionSetupComplete(tsc_RRC_TI_Def, ?),
                                                   cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                                     cdr_ATTACH_REQUEST_AttachType(
                                                                                           tsc_EAttachType_Combined,
                                                                                           v_AdditionalUpdateType,
                                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                           cr_TAI( tsc_PLMN1, (tsc_TAC1) ),
                                                                                           v_LAI,
                                                                                           omit
                                                                                           ),
                                                                                      cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                      f_GetPdnType()))
                                                   ))
                        -> value v_ReceivedAsp;

                f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 6");
          }
          []  t_Wait.timeout
              {
                f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 6");
          }
        }

        //@siclog "Step 7" siclog@
        // The SS transmits an ATTACH REJECT message with EMM cause = ""Not authorized for this CSG"
        // with integrity protection
        SRB.send  ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                    cs_TimingInfo_Now,
                    cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                     cs_508_AttachReject ( cs_EMM_Cause_v(tsc_Cause_NotAuthorizedCSG),
                                                           omit))));
     
        //  The SS releases the RRC connection
        //@siclog "Step 8" siclog@
        f_EUTRA_RRC_ConnectionRelease(eutra_CellB, v_RRC_TI, v_RRC_ReleaseCause);

        // The UE is switched off and switched on
        //@siclog "Step 9" siclog@
        f_UT_SwitchOffUE (UT, false);
        f_UT_SwitchOnUE (UT, false );

        //@siclog "Step 10" siclog@
        // Check: Does the UE transmit an ATTACH REQUEST message on Cell B in the next 30 seconds?
        f_EUTRA_CheckNoAttachOn1Cell(eutra_CellB, 30.0);

        //@siclog "Step 11" siclog@
        // Configure Cell power levels
        v_CellPowerList := {
          cs_CellPower ( eutra_CellA, tsc_SuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellB, tsc_NonSuitableCellRS_EPRE ),
          cs_CellPower ( eutra_CellG, tsc_ServingCellRS_EPRE )
        };
        f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );

        //@siclog "Step 12" siclog@
        // Check: Does the UE transmit an ATTACH REQUEST message on Cell A in the next 30 seconds?
        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(tsc_RRC_TI_Def, ?),
                                                   cr_NAS_IndicationWithPiggybacking(tsc_SHT_IntegrityProtected,
                                                                                     cdr_ATTACH_REQUEST_AttachType(
                                                                                           tsc_EAttachType_Combined,
                                                                                           v_AdditionalUpdateType,
                                                                                           f_GutiParameters2MobileIdentity(omit, v_Guti1_Params),
                                                                                           cr_TAI( tsc_PLMN1, (tsc_TAC1) ),
                                                                                           v_LAI,
                                                                                           omit
                                                                                           ),
                                                                                      cr_508_PDN_CONNECTIVITY_REQUEST(tsc_PdnRequest_InitialAttach,
                                                                                                                      f_GetPdnType()))
                                                   ))
                        -> value v_ReceivedAsp;

                f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 12");
          }
          []  t_Wait.timeout
              {
                f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 12");
          }
        }


        //  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.
        //@siclog "Step 13 - 24" siclog@
        f_EUTRA_IdleUpdated_Step5_17 (eutra_CellA, STATE2_IDLEUPDATE, NORMAL, v_ReceivedAsp.Signalling.Nas[0], false);

    }// end function fl_TC_9_2_1_2_14_Body

  } // group TestcaseImplementations

} // module NAS_Attach_EOnly
