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

module ESM_testcases {

  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 EUTRA_CommonDefs all;
  import from EUTRA_RRC_Templates all;
  import from EUTRA_SRB_Templates all;
  import from EUTRA_AspCommon_Templates all;
  import from EUTRA_SecurityFunctions all;
  import from EUTRA_SecuritySteps 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 EPS_NAS_MsgContainers all;
  import from EUTRA_RRCSteps all;
  import from EUTRA_NASCommonFunctions all;
  import from EUTRA_NASSteps all;
  import from EUTRA_ConfigurationSteps all;
  import from UpperTesterFunctions all;
  import from EUTRA_AuxiliaryFunctions all;
  import from EUTRA_LoopBack all;
  import from CommonDefs all;
  import from CommonIP all;
  import from Parameters all;
  import from EUTRA_DRB_Templates all;
  import from EUTRA_Timing all;
  
  const octetstring tsc_APN1 := '0541504E2D31'O;  /* Access Point Name APN-1;
                                                     @status    APPROVED */
  const charstring tsc_APN1_string := "APN-1";    /* Access Point Name APN-1; R5s100466
                                                     @status    APPROVED */
  
  group LocalTemplates {

  template (value) EPS_QualityOfService cds_EPS_QoS_Def_nonGBR_QCI
  /* 10.7.2 specifies According to reference default Bearer context#2 except for GCI
   * TODO context#2 is still FFS in 36.508 6.6.1 v 8.4.0 using context#1 */
  /* @status    APPROVED */
  modifies cs_508_EPS_QoS_Default_1 :=
  {
    qci     := '00000101'B // non-GBR QCI
  };
    
  template (value) DL_DCCH_Message cs_RRCConnectionReconfiguration_DRB_Reconfig (RRC_TransactionIdentifier p_RRC_TI,
                                                                                 template (value) DRB_ToAddModList p_DRB_ToAddModList) :=
  /* @desc Values according to 36.508 cl. 4.6.1 Table 4.6.1-8 (using condition SRB2-DRB(n, m), where n=1 & m=0) */
  /* @status    APPROVED */
  /* @sic R5s100313 sic@ */
    cs_RRCConnectionReconfiguration_Common(p_RRC_TI,
                                           omit,
                                           omit,
                                           cs_RadioResourceConfig_DRB_RECONFIG(p_DRB_ToAddModList),
                                           omit);
  
  template NAS_UL_Message_Type cr_ActDedicatedEPSBearerCxtReject (EPS_BearerIdentity p_Id,
                                                                  ProcedureTransactionIdentifier p_ProcTi,
                                                                  template ESM_Cause p_EsmCause) :=
  {
    aCTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT := {
      epsBearerId                    := p_Id,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_ActivateDedicatedEpsBearerContextReject,
      esmCause                       := p_EsmCause,
      protocolConfigurationOptions   := cr_ProtocolConfigOptionsAny ifpresent
    }
  };
  
  template NAS_UL_Message_Type cr_DeactivateEPSBearerCxtAccept (EPS_BearerIdentity p_Id,
                                                                ProcedureTransactionIdentifier p_ProcTi) :=
  { /* @status    APPROVED */
    dEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT := {
      epsBearerId                    := p_Id,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_DeactivateEpsBearerContextAccept,
      protocolConfigurationOptions   := cr_ProtocolConfigOptionsAny ifpresent
    }
  };
  
  template (value) EPS_BearerContextStatus cs_EPSBearerCtxtStatus(B3_Type p_EBI5_7,
                                                                  B8_Type p_EBI8_15 := '00000000'B) :=
  { /* See 24.301 clause 9.9.2.1 (TLV) */
    /* @status    APPROVED */
    /* @sic R5s100464 sic@ */
    iei := '57'O,
    iel := '02'O,
    ebi5_7 := p_EBI5_7,
    spare := '00000'B,
    ebi8_15 := p_EBI8_15
  };

  template (value) EPS_BearerContextStatus cs_EPSBearerCtxtStatus_DefaultBearerOnly := cs_EPSBearerCtxtStatus('001'B);  /* @status    APPROVED */
  template (value) EPS_BearerContextStatus cs_EPSBearerCtxtStatus_3Ctxts := cs_EPSBearerCtxtStatus('111'B);             /* @status    APPROVED */

  template NAS_UL_Message_Type cr_PDNConnReqAdditionalPDN ( template (present) PDN_Type p_PDNType,
                                                            template (present) AccessPointName p_AccessPointName := cr_AccessPointName_Any ) :=
  { /* @desc PDN CONNECTIVITY REQUEST requesting an additional PDN   (used e.g. in test 10.5.1)
       @status   APPROVED */
    pDN_CONNECTIVITY_REQUEST := {
      epsBearerId                    := '0'H,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := ?,
      messageType                    := tsc_MT_PdnConnectivityRequest,
      pdnType                        := p_PDNType,
      requestType                    := cr_EPS_PdnRequestType('001'B), // 'initial request' 24.008 clause 10.5.6.17
      esmInfoTransferFlag            := omit,
      accessPointName                := p_AccessPointName,
      protocolConfigurationOptions   := cr_ProtocolConfigOptionsAny ifpresent
    }
  };

  template NAS_UL_Message_Type cr_PDNDisconnectReq (template (present) LinkedEpsBearerIdentity p_LinkedId):=
  { /* @desc PDN DISCONNECT REQUEST
       @status    APPROVED */
    pDN_DISCONNECT_REQUEST := {
      epsBearerId                    := '0'H,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := ?,
      messageType                    := tsc_MT_PdnDisconnectRequest,
      spareHalfOctet                 := ?,
      linkedEpsBearerId              := p_LinkedId,
      protocolConfigurationOptions   := cr_ProtocolConfigOptionsAny ifpresent
    }
  };
  
  template (value) TrafficFlowTemplate cs_TftDef :=
  { // TODO TS 36.508 v.8.2.0 table 6.6.1-1 does not have a default value for TFT
    // TO BE MERGED
    iei   := omit, //  '36'O,
    iel   := '01'O,
    tftOperationCode := '001'B, // Create new TFT
    eBit  := '0'B, // Parameter list not included
    noOfPktFilter := '0000'B,
    packetFilterList := omit,
    parameterList := omit
  };
  
  template NAS_UL_Message_Type cr_SERVICE_REQUESTAny :=
  {
    sERVICE_REQUEST := {
      securityHeaderType    := tsc_SHT_ServiceRequest,
      protocolDiscriminator := tsc_PD_EMM,
      ksiAndSN :=?,
      shortMAC := ?
    }
  };
  
  template NAS_UL_Message_Type cdr_TAU_Request_EPSBearerCtxtStatus(EPS_UpdateTypeValue p_EpsUpdate_TypeValue,
                                                                   NAS_KsiValue p_KsiValue,
                                                                   template AdditionalUpdateType p_AdditionalUpdateType,
                                                                   template (value) EPS_BearerContextStatus p_EPSCtxtStatus)
    modifies cr_508_TAU_Request :=
  { /* @status    APPROVED */
    tRACKING_AREA_UPDATE_REQUEST := {
      epsBearerContextStatus     := p_EPSCtxtStatus ifpresent
    }
  };
  
  template (value) NAS_DL_Message_Type cs_PdnConnectReject(EPS_BearerIdentity p_Id,
                                                           ProcedureTransactionIdentifier p_ProcTi,
                                                           template (value) ESM_Cause p_EsmCause) :=
  {
    pDN_CONNECTIVITY_REJECT:= {
      epsBearerId                    := p_Id,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_PdnConnectivityReject,
      esmCause                       := p_EsmCause,
      protocolConfigurationOptions   := omit
    }
  };
  
  template NAS_UL_Message_Type cr_ActivateDefaultEpsBearerContextReject(EPS_BearerIdentity p_Id,
                                                                        ProcedureTransactionIdentifier p_ProcTi) :=
  {
    aCTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT := {
      epsBearerId                    := p_Id,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_ActivateDefaultEpsBearerContextReject,
      esmCause                       := ?,
      protocolConfigurationOptions   := omit
    }
  };
  
  template (value) NAS_DL_Message_Type cs_PdnDisconnectReject(EPS_BearerIdentity p_Id,
                                                              ProcedureTransactionIdentifier p_ProcTi,
                                                              template (value) ESM_Cause p_EsmCause) :=
  {
    pDN_DISCONNECT_REJECT := {
      epsBearerId                    := p_Id,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_PdnDisconnectReject,
      esmCause                       := p_EsmCause,
      protocolConfigurationOptions   := omit
    }
  };
  
  template (value) NAS_DL_Message_Type cs_508_BearerResourceAllocReject(ProcedureTransactionIdentifier p_ProcTi,
                                                                        template (value) ESM_Cause p_EsmCause) :=
  {
    bEARER_RESOURCE_ALLOCATION_REJECT := {
      epsBearerId                    := '0'H,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_BearerResourceAllocationReject,
      esmCause                       := p_EsmCause,
      protocolConfigurationOptions   := omit
    }
  };
  
  template (value) NAS_DL_Message_Type cs_508_BearerResourceModificationReject(ProcedureTransactionIdentifier p_ProcTi,
                                                                               template (value) ESM_Cause p_EsmCause) :=
  {
    bEARER_RESOURCE_MODIFICATION_REJECT := {
      epsBearerId                    := '0'H,
      protocolDiscriminator          := tsc_PD_ESM,
      procedureTransactionIdentifier := p_ProcTi,
      messageType                    := tsc_MT_BearerResourceModificationReject,
      esmCause                       := p_EsmCause,
      protocolConfigurationOptions   := omit
    }
  };
  } // group LocalTemplates
  
  group LocalFunctions {
  
  /*
   * @desc      reconfigure one ore more DRBs
   * @param     p_CellId
   * @param     p_RRC_TI
   * @param     p_DrbList      .. DRBs to be reconfigured
   * @param     p_NAS_MsgList  .. NAS messages corresponding to the DRBs
   * @status    APPROVED
   */
  function f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS_DrbReconfig (CellId_Type p_CellId,
                                                                         RRC_TransactionIdentifier p_RRC_TI,
                                                                         DRB_IdentityList_Type p_DrbList,
                                                                         template (value) NAS_MSG_RequestList_Type p_NAS_MsgList)
    runs on EUTRA_PTC
  {
    var template (value) DRB_ToAddModList v_DRB_ToAddModList;
    var integer i;
    
    // EPS bearer contexts are to be activated with default parameters.
    for (i:=0; i<lengthof(p_DrbList); i:=i+1) {
      v_DRB_ToAddModList[i] := cs_508_DRB_ToAddMod_DEFAULT_AM (p_DrbList[i]);
    }
    
    SRB.send(cas_SRB1_RrcNasPduList_REQ (p_CellId,
                                         cs_TimingInfo_Now,
                                         cs_RRCConnectionReconfiguration_DRB_Reconfig (p_RRC_TI,
                                                                                       v_DRB_ToAddModList),
                                         p_NAS_MsgList));
    
    //Receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND (p_CellId,
                                     cr_508_RRCConnectionReconfigurationComplete(p_RRC_TI)));
  };
  
  /*
   * @desc      Send RRCConnectionReconfiguration with piggy-backed ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST
   *            Note: This functions is used when activating a default bearer to an additional PDN.
   *                  DRBs are reconfigured at the same time.
   * @param     p_CellId
   * @param     p_RRC_TI
   * @param     p_EpsBearerId
   * @param     p_ProcTransId
   * @param     p_AccessPointName
   * @param     p_PDN_Address
   * @param     p_PCO
   * @status    APPROVED
   */
  function f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig(CellId_Type p_CellId,
                                                                 RRC_TransactionIdentifier p_RRC_TI,
                                                                 EPS_BearerIdentity p_EpsBearerId,
                                                                 template (value) ProcedureTransactionIdentifier p_ProcTransId,
                                                                 template (value) AccessPointName p_AccessPointName,
                                                                 template (value) PDN_Address p_PDN_Address,
                                                                 template (omit) ProtocolConfigOptions p_PCO)
    runs on EUTRA_PTC
  { // send RRCConnectionReconfiguration with piggy-backed ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST
    var template (value) NAS_DL_Message_Type v_ActDefaultEPSBearerCxtReq :=
      cs_508_ActivateDefEpsBearerContextRequest(p_EpsBearerId,
                                                p_ProcTransId,
                                                p_AccessPointName,
                                                p_PDN_Address,
                                                omit,
                                                omit,
                                                p_PCO);
    
    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS_DrbReconfig(p_CellId,
                                                                 p_RRC_TI,
                                                                 {tsc_DRB2},
                                                                 {cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered, v_ActDefaultEPSBearerCxtReq)});
  }; // f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig
  
  /*
   * @desc      Send RRCConnectionReconfiguration with piggy-backed ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST and
   *            ACTIVATE DEDICATED  EPS BEARER CONTEXT REQUEST for a default and a dedicated bearer to an additional PDN.
   *            Note: This functions is used when activating a default bearer to an additional PDN.
   * @param     p_CellId
   * @param     p_RRC_TI
   * @param     p_DefaultEpsBearerId
   * @param     p_DedicatedEpsBearerId
   * @param     p_EpsTI
   * @param     p_AccessPointName
   * @param     p_PDN_Address
   * @param     p_PCO
   * @status    APPROVED
   */
  function f_EUTRA_TxActivateDedicatedBearerCtxtOnAdditionalPDN (CellId_Type p_CellId,
                                                                 RRC_TransactionIdentifier p_RRC_TI,
                                                                 EPS_BearerIdentity p_DefaultEpsBearerId,
                                                                 EPS_BearerIdentity p_DedicatedEpsBearerId,
                                                                 template (value) ProcedureTransactionIdentifier p_EpsTI,
                                                                 template (value) AccessPointName p_AccessPointName,
                                                                 template (value) PDN_Address p_PDN_Address,
                                                                 template (omit) ProtocolConfigOptions p_PCO) runs on EUTRA_PTC
  {
    // send RRCConnectionReconfiguration with piggy-backed ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST
    var ProcedureTransactionIdentifier v_EpsTi2 := tsc_PTI_Unassigned;
    var template (value) NAS_DL_Message_Type v_ActDefaultEPSBearerCxtReq :=
      cs_508_ActivateDefEpsBearerContextRequest(p_DefaultEpsBearerId,
                                                p_EpsTI,
                                                p_AccessPointName,
                                                p_PDN_Address,
                                                omit,
                                                omit,
                                                p_PCO);
    var template (value) NAS_DL_Message_Type v_ActDedicatedEPSBearerCxtReq :=
      cs_508_ActDedicatedEPSBearerCxtReq(p_DedicatedEpsBearerId,
                                         v_EpsTi2,
                                         cs_LinkedId(hex2bit( p_DefaultEpsBearerId)),
                                         cds_EPS_QoS_Dedi_nonGBR_QCI,  // @sic R5s100360 sic@
                                         cs_508_Tft_Dedicated_2(p_DedicatedEpsBearerId));
    
    var template (value) NAS_MSG_RequestList_Type v_NAS_MsgList := {
      cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered, v_ActDefaultEPSBearerCxtReq),
      cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered, v_ActDedicatedEPSBearerCxtReq)
    };
    
    var DRB_IdentityList_Type v_DrbList := {
      tsc_DRB2,
      tsc_DRB3
    };
    
    f_EUTRA_RRCConnectionReconfigurationWithPiggyNAS_DrbReconfig(p_CellId, p_RRC_TI, v_DrbList, v_NAS_MsgList);
    
    // @sic R5s100326 sic@
  }; // f_EUTRA_TxActivateDedicatedBearerCtxtOnAdditionalPDN
  
  /*
   * @desc      Activate a default DRB connected to an additional DRB
   *            see 36.508 clause 6.4.3.2
   *            Note: This function currently assumes no UM bearers are required
   * @param     p_CellId
   * @param     p_EpsBearerId2                          .. Identity of the 2nd Default Bearer that will be configured to connect to the additional PDN
   * @param     p_RRCState
   * @status    APPROVED
   */
  function f_EUTRA_508_ActivateAdditionalPDN(CellId_Type p_CellId,
                                             EPS_BearerIdentity p_EpsBearerId2,
                                             EUTRA_RRC_STATE_Type p_RRCState) runs on EUTRA_PTC
  { // @sic R5s100326 sic@ @sic R5s100520 sic@
    var ProcedureTransactionIdentifier v_PTId_UE;
    var ProtocolConfigOptions v_Pco;
    var template (value) AccessPointName v_AccessPointName;
    var PDN_Address v_PDN_Address2;
    var NAS_MSG_Indication_Type v_NasInd;
    var PDN_CONNECTIVITY_REQUEST v_PDNConnReq;
    var SRB_COMMON_IND v_ReceivedAsp;
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (p_CellId); //Get FDD or TDD mode from Cell-configuration
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NasCount_Type v_NasCountUL;
    var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (p_CellId); //@sic R5-100786 sic@
    var template (value) DRB_ToAddModList v_DRB_ToAddModList;
    var octetstring v_APN_Value := tsc_APN1; // APN-1(New PDN name), different from default
    
    v_DRB_ToAddModList[0] := cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1);
    
    // Step 1.
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(p_EpsBearerId2), tsc_APN1_string); // APN-1(New PDN name), different from default @sic R5s100466 sic@
    
    // The UE transmits a SERVICE REQUEST
    // The UE transmits a PDN CONNECTIVITY REQUEST message as specified to request an additional PDN.
    if ( p_RRCState == RRC_IDLE ){
      // UE is in RRC Idle mode
      // Steps 2a1 to 2a7
      v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(p_CellId,
                                                 tsc_RRC_TI_Def,
                                                 ?, // @sic R5s100326 sic@
                                                 cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                    cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
      
      // activate security in AS with parameters from AKA performed in preamble
      v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
      v_SecurityParams := f_EUTRA_Authentication_InitAS(v_SecurityParams, v_NasCountUL);
      v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(p_CellId,
                                                       v_SecurityParams,
                                                       v_NasCountUL);
      f_EUTRA_Security_Set(v_SecurityParams);
      
      SRB.send(cas_SRB1_RrcPdu_REQ(p_CellId,
                                   cs_TimingInfo_Now,
                                   cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                          omit,
                                                                          omit,
                                                                          cs_508_RadioResourceConfigDedicated_Srb2( v_DRB_ToAddModList,
                                                                                                                    cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                    cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                               v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                               v_AntennaInfo)),
                                                                          omit)));
      
      // receive RRCConnectionReconfigurationComplete
      SRB.receive(car_SRB1_RrcPdu_IND(p_CellId,
                                      cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
      
    } // end of if RRC_Idle
    // UE is now in RRC connected mode
    
    // Step 3. The UE transmits an ULInformationTransfer message including the PDN CONNECTIVITY REQUEST message.
    SRB.receive ( car_SRB2_NasPdu_IND ( p_CellId,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value)))))-> value v_ReceivedAsp;
    
    v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
    v_PDNConnReq := v_NasInd.Pdu.Msg.pDN_CONNECTIVITY_REQUEST;
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := cs_AccessPointName(v_APN_Value);
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;
    
    // Step 4 and 5. The SS transmits an RRCConnectionReconfiguration message including
    // the ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message to establish the
    // default EPS bearer context.
    v_PDN_Address2 := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig(p_CellId,
                                                          tsc_RRC_TI_Def,
                                                          p_EpsBearerId2, // Default bearer ID to additional PDN
                                                          v_PTId_UE,  // use value as defined by the UE
                                                          v_AccessPointName,
                                                          v_PDN_Address2,
                                                          f_GetDefPCOforPCSCFAddress(v_Pco));
    
    // Step 6. The UE transmits an ULInformationTransfer message including the ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message
    SRB.receive(car_SRB2_NasPdu_IND(p_CellId,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActivateDefEpsBearerContextAccept(p_EpsBearerId2))));
    f_EUTRA_RRC_ConnectionRelease(p_CellId, tsc_RRC_TI_Def, other);  // @sic R5s100326 sic@
    
  } // f_EUTRA_508_ActivateAdditionalPDN
  
  
  /**
   * @desc Bring UE into State 5 according to TS 36.508 clause 6.4.1.2 with
   *       with a dedicated DRB established.
   */
  function fl_DedicatedBearerEstabUEState5( CellId_Type p_CellId )
    runs on EUTRA_PTC
  {
    // const EPS_BearerIdentity v_LinkedEpsBearerId := tsc_EpsDefaultBearerId;
    var EPS_BearerIdentity v_DedicatedEpsBeareId := tsc_EpsDedicatedBearerId;
    var ProcedureTransactionIdentifier v_EpsProcedureTransactionId := tsc_PTI_Unassigned;
    // ==========================================================================
    
    // temporary variable which is used when receiving NAS ASPs
    
    // Generic Radio Bearer Establishment (State 3)
    f_EUTRA_RbEst_Def(p_CellId);
    
    // UE enters State 5
    // The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST with
    // settings  according to  Context#1  in  TS 36.508.
    
    /* Note: This message is included in a RRCConnectionReconfiguration message to
     * setup the new radio bearer associated with the dedicated EPS bearer context
     * activated by the NAS message
     */
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(p_CellId,
                                        tsc_DRB2,
                                        v_DedicatedEpsBeareId,
                                        v_EpsProcedureTransactionId,
                                        cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)),
                                        cs_508_EPS_QoS_Dedicated_1, // According to Context#1 in TS 36.508 clause ?
                                        cs_508_Tft_Dedicated_1(v_DedicatedEpsBeareId)); // According to Context#1 in TS 36.508 clause ?
    
    
    // The UE transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified
    SRB.receive(car_SRB2_NasPdu_IND(p_CellId,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(tsc_EpsDefaultBearerId))));
    
  } // fl_DedicatedBearerEstabUEState5
  
  //----------------------------------------------------------------------------
  function f_CheckNoAccessOnCell ( CellId_Type p_CellId,
                                   float p_Wait ) runs on EUTRA_PTC
  {
    timer t_Wait := p_Wait * 0.9; // -10%
    
    t_Wait.start;
    alt {
      []  SRB.receive(car_SRB0_RrcPdu_IND(p_CellId, cr_RRCConnectionRequest(?)))
        {
          t_Wait.stop;
          f_EUTRA_SetVerdictFailOrInconc (__FILE__, __LINE__, "");
        }
      []  t_Wait.timeout
        {
          f_EUTRA_PreliminaryPass (__FILE__, __LINE__, "");
        }
    }
  }
  } // group LocalFunctions
  
  group TestcaseImplementations {
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.2.1
   * @status    APPROVED
   */
  function f_TC_10_2_1_EUTRA() runs on EUTRA_PTC
  { /* @desc Dedicated EPS bearer context activation / Success */
    // @sic R5s100295 sic@
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_2_1_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_2_1_EUTRA
  
  /*
   * @desc      test body of TC_10_2_1
   * @status    APPROVED
   */
  function fl_TC_10_2_1_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EpsProcedureTransactionId := '00'O;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    var NAS_MSG_Indication_Type v_NasInd;
    var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA); //@sic R5-100786 sic@
    var template (value) DRB_ToAddModList v_DRB_ToAddModList;
    
    v_DRB_ToAddModList[0] := cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1);
    v_DRB_ToAddModList[1] := cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB2);
    
    //The SS pages the UE in order to establish a dedicated EPS bearer context.
    //@siclog "Step 1" siclog@
    f_EUTRA_UE_Page(eutra_CellA,
                    cs_NasPaging_OneRecord(cs_PagingUE_Identity_S_TMSI(v_GutiParams.MME_Code,
                                                                       v_GutiParams.M_TMSI)));
    // The UE transmits a SERVICE REQUEST for downlink signalling.
    //@siclog "Step 2" 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_SERVICE_REQUEST(v_SecurityParams.KSIasme)));
    
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    // The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST with
    //        particular settings (use Test Reference dedicated EPS bearer context2 context #1 - see TS 36.508)
    
    /* Note: This message is included in a RRCConnectionReconfiguration message to
     * setup the new radio bearer associated with the dedicated EPS bearer context
     * activated by the NAS message
     */
    //@siclog "Step 3" siclog@
    SRB.send(cas_SRB1_RrcNasPdu_REQ(eutra_CellA,
                                    cs_TimingInfo_Now,
                                    cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                           omit,
                                                                           omit,
                                                                           cs_508_RadioResourceConfigDedicated_Srb2( v_DRB_ToAddModList,
                                                                                                                     cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                     cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                                v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                                v_AntennaInfo)),
                                                                           omit),
                                    cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                   cs_508_ActDedicatedEPSBearerCxtReq(tsc_EpsDedicatedBearerId,
                                                                                      v_EpsProcedureTransactionId,
                                                                                      cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)),
                                                                                      cs_508_EPS_QoS_Dedicated_1, // According to Context#1 in TS 36.508
                                                                                      cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId)))));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    
    // Step 4. Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified?
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(tsc_EpsDedicatedBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    
    
    //  Check: Does the test results of CALL generic procedure indicate
    //     that the UE can transmit data on the newly activated EPS bearer context ?
    //     TS 36.508 clause 6.4.2.6
    //@siclog "Step 5" siclog@
    f_EUTRA_508Check_DedicatedEPSIsActive(eutra_CellA, tsc_EpsDedicatedBearerId, cds_508_EPS_QoS_Dedicated_1_tlv, cds_Tft_Dedicated_2_Modify(tsc_EpsDedicatedBearerId));
    
  } // function fl_TC_10_2_1_Body
  
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.3.1
   * @status    APPROVED
   */
  function f_TC_10_3_1_EUTRA() runs on EUTRA_PTC
  { /* EPS bearer context modification / Success */
    // @sic R5s100360 sic@
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2A_TESTLOOP_ModeB);
    
    // UE is in Loopback Activated(state 4) according to TS 36.508 on Cell A.
    f_EUTRA_RbEst_508_AM ( eutra_CellA );
    f_EUTRA_CloseUE_TestLoopModeB ( eutra_CellA, '00'O );
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_3_1_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_3_1_EUTRA
  
  
  /*
   * @desc      Test body of TC_10_3_1
   * @status    APPROVED
   */
  function fl_TC_10_3_1_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EPS_TI := tsc_PTI_Unassigned;
    var template (value) octetstring v_IpPacket;
    var UInt16_Type v_SourcePort := 60000;  // acc. to Table 10.3.1.3.3-2
    var UInt16_Type v_DestPort   := 60000;  // acc. to Table 10.3.1.3.3-2
    
    //  The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message with new  UL TFT.
    // This message is included in a DL Information Transfer message
    //@siclog "Step 1" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ModifyEPSBearerCxtReq(tsc_EpsDedicatedBearerId,
                                                                             v_EPS_TI,
                                                                             cds_508_EPS_QoS_Dedicated_1_tlv, // @sic R5-103625 sic@
                                                                             cds_Tft_Dedicated_2_Modify(tsc_EpsDedicatedBearerId))))); // @sic R5-103625 sic@
    
    //  Check:  Does the UE transmit a MODIFY EPS BEARER CONTEXT ACCEPT message as specified?
    //@siclog "Step 2" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtAccept(tsc_EpsDedicatedBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");
    
    //@siclog "Step 3 Void" siclog@
    //@siclog "Step 4" siclog@
    //  The SS transmits one IP Packet matching with new TFT (reference packet filter #3),
    // but not existing uplink packet filters (reference packet filter #2).
    if (pc_IPv4) {
      v_IpPacket := crs_IPv4_AnyUdpPacket("192.168.0.1", px_IPv4_RemoteAddress, v_SourcePort, v_DestPort); // R5s100189
    } else {
      v_IpPacket := crs_IPv6_AnyUdpPacket("fe80::1:1",   px_IPv6_RemoteAddress, v_SourcePort, v_DestPort); // R5s100189
    }
    
    DRB.send (cas_DRB_COMMON_REQ_PDCP_SDU(eutra_CellA, tsc_RbId_DRB2, cs_TimingInfo_Now, {v_IpPacket} ));
    
    //  Check: Does UE send the IP Packet on the data radio bearer associated with the dedicated EPS bearer context?
    //@siclog "Step 5" siclog@
    DRB.receive (car_DRB_COMMON_IND_PDCP_SDUList(eutra_CellA, tsc_RbId_DRB2, ?, {v_IpPacket} ));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");
    
  } // function fl_TC_10_3_1_Body

  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.4.1
   * @status    APPROVED
   * @sic R5s100464 sic@ @sic R5-104735 sic@
   */
  function f_TC_10_4_1_EUTRA() runs on EUTRA_PTC
  { /* @desc EPS bearer context deactivation / Success */

    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEmulticell);
    
    // Create cell and send out system information for CellA (serving) and Cell B (suitable)
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 2, 0);
    f_EUTRA_CellConfig_Def(eutra_CellB);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    fl_TC_10_4_1_Body();
    f_EUTRA_TestBody_Set(false);
    
    f_EUTRA_Postamble(eutra_CellB, E1_IDLE);
  } // function f_TC_10_4_1_EUTRA

  /*
   * @desc      test body of TC_10_4_1
   * @status    APPROVED
   */
  function fl_TC_10_4_1_Body() runs on EUTRA_PTC
  {
    var EPS_BearerIdentity v_EpsBearerId2 := '6'H; // default bearer on additional PDN
    var EPS_BearerIdentity v_EpsDedicatedBearerId2 := '7'H; // dedicated bearer id on additional PDN
    var ProcedureTransactionIdentifier v_EpsTi2 := tsc_PTI_Unassigned;
    var ProcedureTransactionIdentifier v_PTId_UE;
    var ProtocolConfigOptions v_Pco;
    var template (value) AccessPointName v_AccessPointName;
    var PDN_Address v_PDN_Address2;
    var ReleaseCause v_RRC_ReleaseCause := other;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NAS_MSG_Indication_Type v_NasInd;
    var PDN_CONNECTIVITY_REQUEST v_PDNConnReq;
    var template (value) ESM_Cause v_EsmCause43 := cs_ESM_Cause_v ('00101011'B); // Invalid EPS bearer identity
    var template (value) ESM_Cause v_EsmCause36 := cs_ESM_Cause_v ('00100100'B); // Regular deactivation
    var template AdditionalUpdateType v_AdditionalUpdateType := f_GetAdditionalUpdateType ();
    var GutiParameters_Type v_GutiParams;
    var NAS_PlmnId v_PLMN;
    var TrackingAreaCode v_Tac;
    var SRB_COMMON_IND v_ReceivedAsp;
    var template (value) TrackingAreaIdList v_TaiList;
    var template (value) CellPowerList_Type v_CellPowerList;
    var M_TMSI_Type v_M_Tmsi_Def := tsc_M_TMSI1;
    var GutiParameters_Type v_GutiParameters := f_EUTRA_CellInfo_GetGuti ( eutra_CellA );
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_CellInfo := f_EUTRA_CellInfo_GetFDD_TDD_Info ( eutra_CellA);
    var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA);
    var octetstring v_APN_Value := tsc_APN1; // APN-1(New PDN name), different from default
    
    timer t_Wait := 1.0;
    
    // Set the cell type of cell A to the ''Serving cell''.
    // Set the cell type of cell B to the ''Suitable cell''.
    f_EUTRA_SetCellPower ( eutra_CellA, tsc_ServingCellRS_EPRE, cs_TimingInfo_Now );
    f_EUTRA_SetCellPower ( eutra_CellB, tsc_SuitableCellRS_EPRE, cs_TimingInfo_Now );
    // Cause the UE to request connectivity to an additional PDN.
    //@siclog "Step 1" siclog@
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(v_EpsBearerId2), tsc_APN1_string); // @sic R5s100466 sic@
    
    // The UE transmits a SERVICE REQUEST
    //@siclog "Step 1A" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    // The SS establishes SRB2 and DRB associated with default EPS bearer context obtained during the attach procedure.
    //@siclog "Step 1B" siclog@
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                                                                                             v_AntennaInfo)),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    // The UE transmits a PDN CONNECTIVITY REQUEST message as specified to request an additional PDN.
    //@siclog "Step 2" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value)))))-> value v_ReceivedAsp;
    v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
    v_PDNConnReq := v_NasInd.Pdu.Msg.pDN_CONNECTIVITY_REQUEST;
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := cs_AccessPointName(v_APN_Value);
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;
    
    // The SS transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with IE EPS Bearer Identity set to new EPS bearer context.
    // Note: the SS allocates a PDN address of a PDN type which is compliant with the PDN type requested by the UE.
    //@siclog "Step 3" siclog@
    v_PDN_Address2 := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig (eutra_CellA,
                                                           tsc_RRC_TI_Def,
                                                           v_EpsBearerId2, // Default bearer ID to additional PDN
                                                           v_PTId_UE,  // use value as defined by the UE
                                                           v_AccessPointName,
                                                           v_PDN_Address2,
                                                           f_GetDefPCOforPCSCFAddress(v_Pco));
    
    // The UE transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 4" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EpsBearerId2))));
    
    // The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST relative to the additional PDN.
    // Note: the same PDN address is applicable because the linked EPS bearer ID refers to the default EBC allocated in step 3.
    //@siclog "Step 5" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB3,
                                        v_EpsDedicatedBearerId2,
                                        v_EpsTi2,
                                        cs_LinkedId(hex2bit( v_EpsBearerId2)),
                                        cs_508_EPS_QoS_Dedicated_1,
                                        cs_508_Tft_Dedicated_1(v_EpsDedicatedBearerId2));
    
    
    // The UE transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 6" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(v_EpsDedicatedBearerId2))));
    
    //  The SS releases the RRC connection.
    //@siclog "Step 7" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RRC_ReleaseCause);
    
    //  The SS transmits a Paging message to the UE using S-TMSI with CN domain indicator set to "PS".
    //@siclog "Step 8" siclog@
    f_EUTRA_UE_Page ( eutra_CellA,
                      cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_GutiParameters.MME_Code, v_M_Tmsi_Def )) );
    //  The UE transmits the SERVICE REQUEST message.
    //@siclog "Step 9" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(v_SecurityParams.KSIasme)));
    
    // The SS establishes SRB2 and DRBs associated with two default EPS bearer context (a first PDN obtained during the attach procedure and an additional PDN).
    //@siclog "Step 9A" siclog@
    // activate security in AS with parameters from AKA performed in preamble
    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);
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2({cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1),
                                                                                                                  cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB2),
                                                                                                                  cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB3)},
                                                                                                                 cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                 cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                                                                                            v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                                                                                            v_AntennaInfo)),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                  cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    // The SS transmits a DEACTIVATE EPS BEARER CONTEXT REQUEST including the EPS bearer identity of the dedicated EPS bearer to the additional PDN.
    //@siclog "Step 10" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_DeactivateEPSBearerCxtReq(v_EpsDedicatedBearerId2,
                                                                                 v_EpsTi2,
                                                                                 v_EsmCause36))));
    
    // Check: Does the UE transmit a DEACTIVATE EPS BEARER CONTEXT ACCEPT?
    //@siclog "Step 11" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_DeactivateEPSBearerCxtAccept(v_EpsDedicatedBearerId2,
                                                                                      v_EpsTi2))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 11");
    // The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST relative to additional PDN.
    // Note: the same PDN address is applicable because the linked EPS bearer ID refers to the default EBC allocated in step 3.
    //@siclog "Step 12" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ActDedicatedEPSBearerCxtReq(v_EpsDedicatedBearerId2,
                                                                                   v_EpsTi2,
                                                                                   cs_LinkedId(hex2bit(v_EpsBearerId2)),
                                                                                   cs_508_EPS_QoS_Dedicated_1,
                                                                                   cs_508_Tft_Dedicated_1(v_EpsDedicatedBearerId2)))));
    
    
    // The UE transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 13" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(v_EpsDedicatedBearerId2))));
    
    // The SS transmits a DEACTIVATE EPS BEARER CONTEXT REQUEST including the EPS bearer identity of the dedicated EPS bearer to the additional PDN.
    //@siclog "Step 14" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_DeactivateEPSBearerCxtReq(v_EpsBearerId2,
                                                                                 v_EpsTi2,
                                                                                 v_EsmCause36))));
    
    // Check: Does the UE transmit a DEACTIVATE EPS BEARER CONTEXT ACCEPT?
    //@siclog "Step 15" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_DeactivateEPSBearerCxtAccept(v_EpsBearerId2,
                                                                                      v_EpsTi2))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 15");
            
    // The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message including the EPS bearer identity of the dedicated EPS bearer.
    // This message is included in a DLInformationTransfer message.
    //@siclog "Step 16" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ModifyEPSBearerCxtReq(v_EpsDedicatedBearerId2,
                                                                             v_EpsTi2,
                                                                             cds_508_EPS_QoS_Dedicated_1_tlv, // @sic R5-103625 sic@
                                                                             cds_Tft_Dedicated_2_Modify(v_EpsDedicatedBearerId2))))); // @sic R5-103625 sic@
    // Check: Does UE transmits a MODIFY EPS BEARER CONTEXT REJECT message with ESM cause #43?
    //@siclog "Step 17" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtReject (v_EpsDedicatedBearerId2,
                                                                                       v_EsmCause43))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 17");
    // The SS transmits a DEACTIVATE EPS BEARER CONTEXT REQUEST that does not point an existing EPS bearer context.
    //@siclog "Step 18" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_DeactivateEPSBearerCxtReq(v_EpsBearerId2,
                                                                                 v_EpsTi2,
                                                                                 v_EsmCause36))));
    
    // Check: Does the UE transmit a DEACTIVATE EPS BEARER CONTEXT ACCEPT?
    //@siclog "Step 19" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_DeactivateEPSBearerCxtAccept(v_EpsBearerId2,
                                                                                      v_EpsTi2))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 19");
    //  The SS releases the RRC connection.
    //@siclog "Step 20" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RRC_ReleaseCause);
    //  Cause the UE to request connectivity to an additional PDN.
    //@siclog "Step 21" siclog@
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(v_EpsBearerId2), tsc_APN1_string); // APN-1(New PDN name), different from default @sic R5s100466 sic@
    // The UE transmits a SERVICE REQUEST.
    //@siclog "Step 21A" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    // The SS establishes SRB2 and DRBs associated with two default EPS bearer context (a first PDN obtained during the attach procedure and an additional PDN).
    //@siclog "Step 21B" siclog@
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                                                                                             v_AntennaInfo)),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    // The UE transmits a PDN CONNECTIVITY REQUEST message as specified to request an additional PDN.
    //@siclog "Step 22" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value)))))-> value v_ReceivedAsp;
    v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
    v_PDNConnReq := v_NasInd.Pdu.Msg.pDN_CONNECTIVITY_REQUEST;
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := cs_AccessPointName(v_APN_Value);
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;
    
    // The SS transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with IE EPS Bearer Identity set to new EPS bearer context.
    // Note: the SS allocates a PDN address of a PDN type which is compliant with the PDN type requested by the UE.
    //@siclog "Step 23" siclog@
    v_PDN_Address2 := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig (eutra_CellA,
                                                           tsc_RRC_TI_Def,
                                                           v_EpsBearerId2, // Default bearer ID to additional PDN
                                                           v_PTId_UE,  // use value as defined by the UE
                                                           v_AccessPointName,
                                                           v_PDN_Address2,
                                                           f_GetDefPCOforPCSCFAddress(v_Pco));
    // The UE transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 24" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EpsBearerId2))));
    
    // The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST relative to additional PDN.
    // Note: the same PDN address is applicable because the linked EPS bearer ID refers to the default EBC allocated in step 3.
    //@siclog "Step 25" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB3,
                                        v_EpsDedicatedBearerId2,
                                        v_EpsTi2,
                                        cs_LinkedId(hex2bit( v_EpsBearerId2)),
                                        cs_508_EPS_QoS_Dedicated_1,
                                        cs_508_Tft_Dedicated_1(v_EpsDedicatedBearerId2));
    
    
    // The UE transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 26" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(v_EpsDedicatedBearerId2))));
    
    // The SS releases the RRC connection.
    //@siclog "Step 27" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RRC_ReleaseCause);
    // The SS transmits a Paging message to the UE using S-TMSI with CN domain indicator set to "PS".
    //@siclog "Step 28" siclog@
    f_EUTRA_UE_Page ( eutra_CellA,
                      cs_NasPaging_OneRecord ( cs_PagingUE_Identity_S_TMSI ( v_GutiParameters.MME_Code, v_M_Tmsi_Def )) );
    // The UE transmits SERVICE REQUEST message.
    //@siclog "Step 29" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(v_SecurityParams.KSIasme)));
    
    // activate security in AS
    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);
    // The SS performs a radio bearer establishment procedure.
    // The RRCConnectionReconfiguration message doesn't include the EPS bearer ID of the additional PDN.
    //@siclog "Step 30" siclog@
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                                                                                             v_AntennaInfo)),
                                                                        omit)));
    
    // Check: Does UE transmit a RRCConnectionReconfigurationComplete message?
    //@siclog "Step 31" siclog@
    SRB.receive ( car_SRB1_RrcPdu_IND ( eutra_CellA, cr_508_RRCConnectionReconfigurationComplete ( tsc_RRC_TI_Def ) ) );
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 31");
    // The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message including the EPS bearer identity of the default EPS bearer to the additional PDN.
    // This message is included in a DLInformationTransfer message.
    //@siclog "Step 32" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ModifyEPSBearerCxtReq(v_EpsBearerId2,
                                                                             v_EpsTi2,
                                                                             cds_508_EPS_QoS_Dedicated_1_tlv, // @sic R5-103625 sic@
                                                                             omit))));
    // Check: Does UE transmit a MODIFY EPS BEARER CONTEXT REJECT message with ESM cause #43?
    //@siclog "Step 32A" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtReject (v_EpsBearerId2,
                                                                                       v_EsmCause43))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 32A");
    // The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message including the EPS bearer identity of the dedicated EPS bearer.
    //@siclog "Step 32B" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ModifyEPSBearerCxtReq(v_EpsDedicatedBearerId2,
                                                                             v_EpsTi2,
                                                                             cds_508_EPS_QoS_Dedicated_1_tlv, // @sic R5-103625 sic@
                                                                             cds_Tft_Dedicated_2_Modify(v_EpsDedicatedBearerId2))))); // @sic R5-103625 sic@
    // Check: Does UE transmit a MODIFY EPS BEARER CONTEXT REJECT message with ESM cause #43? (see Note 4)
    //@siclog "Step 32C" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtReject (v_EpsDedicatedBearerId2,
                                                                                       v_EsmCause43))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 32C");
    // The SS releases the RRC connection.
    //@siclog "Step 33" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RRC_ReleaseCause);
    //  Cause the UE to request connectivity to an additional PDN.
    //@siclog "Step 34" siclog@
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(v_EpsBearerId2), tsc_APN1_string); // APN-1(New PDN name), different from default @sic R5s100466 sic@
    // The UE transmits a SERVICE REQUEST
    //@siclog "Step 34A" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    
    // The SS establishes SRB2 and DRB associated with default EPS bearer context obtained during the attach procedure
    //@siclog "Step 34B" siclog@
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                                                                                             v_AntennaInfo)),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    // The UE transmits a PDN CONNECTIVITY REQUEST message as specified to request an additional PDN.
    //@siclog "Step 35" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value)))))-> value v_ReceivedAsp;
    v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
    v_PDNConnReq := v_NasInd.Pdu.Msg.pDN_CONNECTIVITY_REQUEST;
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := cs_AccessPointName(v_APN_Value);
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;
    
    // The SS transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message
    // with IE EPS Bearer Identity set to new EPS bearer context.
    //@siclog "Step 36" siclog@
    v_PDN_Address2 := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig (eutra_CellA,
                                                           tsc_RRC_TI_Def,
                                                           v_EpsBearerId2, // Default bearer ID to additional PDN
                                                           v_PTId_UE,  // use value as defined by the UE
                                                           v_AccessPointName,
                                                           v_PDN_Address2,
                                                           f_GetDefPCOforPCSCFAddress(v_Pco));
    // The UE transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 37" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EpsBearerId2))));
    
    //  The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST relative to additional PDN.
    //@siclog "Step 38" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB3,
                                        v_EpsDedicatedBearerId2,
                                        v_EpsTi2,
                                        cs_LinkedId(hex2bit( v_EpsBearerId2)),
                                        cs_508_EPS_QoS_Dedicated_1,
                                        cs_508_Tft_Dedicated_1(v_EpsDedicatedBearerId2));
    
    // The UE transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified.
    //@siclog "Step 39" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(v_EpsDedicatedBearerId2))));
    
    // The SS releases the RRC connection.
    //@siclog "Step 40" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, v_RRC_ReleaseCause);
    
    //  Cell A is a suitable cell, Cell B is the serving cell
    //@siclog "Step 41" siclog@
    v_CellPowerList := {
      cs_CellPower ( eutra_CellA, tsc_SuitableCellRS_EPRE ),
      cs_CellPower ( eutra_CellB, tsc_ServingCellRS_EPRE  )
    };
    f_EUTRA_SetCellPowerList ( v_CellPowerList, cs_TimingInfo_Now );
    
    // The UE transmit a TRACKING AREA UPDATE REQUEST message as specified on Cell B.
    //@siclog "Step 42" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellB,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cdr_TAU_Request_EPSBearerCtxtStatus( tsc_EpsUpdate_TaUpdate,
                                                                                                       f_EUTRA_SecurityKSIasme_Get (),
                                                                                                       v_AdditionalUpdateType, // @sic R5-103681 sic@
                                                                                                       cs_EPSBearerCtxtStatus_3Ctxts)));
    
    // activate security in AS
    v_NasCountUL := v_NasInd.SecurityProtection.NasCount;
    v_SecurityParams := f_EUTRA_Authentication_InitAS(v_SecurityParams, v_NasCountUL);
    v_SecurityParams := f_EUTRA_RRC_ActivateSecurity(eutra_CellB,
                                                     v_SecurityParams,
                                                     v_NasCountUL);
    
    
    // The SS transmits a TRACKING AREA UPDATE ACCEPT indicating only one EPS bearer (default EBId-1) active in the EPS bearer context status IE.
    // The EPS bearer ID linked to the additional PDN is deactivated by SS.
    //@siclog "Step 43" siclog@
    v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellB);
    v_PLMN := f_Asn2Nas_PlmnId (v_GutiParams.PLMN_Identity);
    v_Tac := f_EUTRA_CellInfo_GetTAC ( eutra_CellB );
    v_TaiList := cds_TAIListNonConsecutive_tlv( v_PLMN, { bit2oct(v_Tac) } );
    
    SRB.send ( cas_SRB1_NasPdu_REQ ( eutra_CellB,
                                     cs_TimingInfo_Now,
                                     cs_NAS_Request ( tsc_SHT_IntegrityProtected_Ciphered,
                                                      cs_508_TAU_Accept ( '000'B, // EpsUpdate_TypeValue
                                                                          f_GutiParameters2MobileIdentity (tsc_IEI_Guti, v_GutiParams ),
                                                                          v_TaiList,
                                                                          cs_EPSBearerCtxtStatus_DefaultBearerOnly,
                                                                          f_EUTRA_GetCellLAI(eutra_CellB),
                                                                          omit, // v_MSId
                                                                          f_GetAdditionalUpdateResult(v_NasInd.Pdu.Msg.tRACKING_AREA_UPDATE_REQUEST.addUpdateType)))));
    
    // The UE transmits TRACKING AREA UPDATE COMPLETE message.
    //@siclog "Step 43AA" siclog@
    SRB.receive(car_SRB1_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_TAU_Complete)));
    // The SS establishes SRB2.
    //@siclog "Step 43AB" siclog@
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_CellInfo.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_CellInfo.soundingRS_UL_Config,
                                                                                                                                                             v_AntennaInfo)),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellB,
                                  cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));

    // The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message including the EPS bearer identity of the default EPS bearer to the additional PDN.
    // This message is included in a DLInformationTransfer message.
    //@siclog "Step 43A" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ModifyEPSBearerCxtReq(v_EpsBearerId2,
                                                                             v_EpsTi2,
                                                                             cds_508_EPS_QoS_Dedicated_1_tlv, // @sic R5-103625 sic@
                                                                             omit))));
    
    // Check: Does UE transmits a MODIFY EPS BEARER CONTEXT REJECT message with ESM cause #43?
    //@siclog "Step 43B" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtReject (v_EpsBearerId2,
                                                                                       v_EsmCause43))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 43B");
    
    // Step 43C. The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message including the EPS bearer identity of the dedicated EPS bearer.
    //@siclog "Step 43C" siclog@
    SRB.send(cas_SRB2_NasPdu_REQ(eutra_CellB,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_508_ModifyEPSBearerCxtReq(v_EpsDedicatedBearerId2,
                                                                             v_EpsTi2,
                                                                             cds_508_EPS_QoS_Dedicated_1_tlv, // @sic R5-103625 sic@
                                                                             cds_Tft_Dedicated_2_Modify(v_EpsDedicatedBearerId2))))); // @sic R5-103625 sic@
    
    // Check: Does UE transmits a MODIFY EPS BEARER CONTEXT REJECT message with ESM cause #43?
    //@siclog "Step 43D" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellB,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtReject (v_EpsDedicatedBearerId2,
                                                                                       v_EsmCause43))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 43D");
    
    //  The SS releases the RRC connection.
    //@siclog "Step 44" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellB, tsc_RRC_TI_Def, v_RRC_ReleaseCause);
    
    //  Cause the UE to request bearer resource allocation of dedicated EPS bearer associated with additional PDN connectivity.
    //@siclog "Step 45" siclog@
    f_UT_RequestActivateDedicatedBearer (UT,
                                         hex2int(v_EpsDedicatedBearerId2),
                                         hex2int(v_EpsBearerId2),
                                         cs_508_EPS_QoS_Dedicated_1,
                                         cs_508_Tft_Dedicated_1(v_EpsDedicatedBearerId2));
    // Check: Does the UE transmit SERVICE REQUEST?
    //@siclog "Step 46" siclog@
    t_Wait.start(3.0);
    alt {
      [] SRB.receive ( car_SRB1_NasPdu_IND ( eutra_CellB,
                                             cr_NAS_Indication ( ?,
                                                                 ?)))
        {
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 46");
          t_Wait.stop;
        }
      [] t_Wait.timeout
        {
        }
    }
  } // function fl_TC_10_4_1_Body
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.5.1
   * @status    APPROVED
   */
  function f_TC_10_5_1_EUTRA() runs on EUTRA_PTC
  { /* @desc UE requested PDN connectivity accepted by the network */
    // @sic R5s100313 sic@
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 2, 0);
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    fl_TC_10_5_1_Body();
    f_EUTRA_TestBody_Set(false);
    
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
  } // function f_TC_10_5_1_EUTRA
  
  /*
   * @desc      test body of TC_10_5_1
   * @status    APPROVED
   */
  function fl_TC_10_5_1_Body() runs on EUTRA_PTC
  { // @sic R5-104734 sic@
  
    var EPS_BearerIdentity v_EpsBearerId2 := '6'H;
    var EPS_BearerIdentity v_EpsDedicatedBearerId := '7'H;
    var ProcedureTransactionIdentifier v_PTId_UE;
    var ProtocolConfigOptions v_Pco;
    var template (value) AccessPointName v_AccessPointName;
    var PDN_Address v_PDN_Address2;
    var SRB_COMMON_IND v_ReceivedAsp;
    var PDN_CONNECTIVITY_REQUEST v_PDNConnReq;
    var NAS_MSG_Indication_Type v_NasInd;
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var NasCount_Type v_NasCountUL;
    var template (value) PhysicalConfigDedicated_AntennaInfo_Type v_AntennaInfo := f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA); //@sic R5-100786 sic@
    var octetstring v_APN_Value := tsc_APN1; // APN-1(New PDN name), different from default
    
    //  Cause the UE to request connectivity to an additional PDN.
    //@siclog "Step 1" siclog@
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(v_EpsBearerId2), tsc_APN1_string); // APN-1(New PDN name), different from default @sic R5s100466 sic@
    //  UE sends SERVICE REQUEST message
    //@siclog "Step 1A" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 1A");
    //@siclog "Step 1B" siclog@
    // The SS establishes SRB2 and DRB associated with default EPS bearer context.
    // (a first PDN obtained during the attach procedure).
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM(tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             v_AntennaInfo)),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    // Step 2. Check: Does the UE transmit a PDN CONNECTIVITY REQUEST message as specified to request an additional PDN?
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value))))) -> value v_ReceivedAsp;
    v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
    v_PDNConnReq := v_NasInd.Pdu.Msg.pDN_CONNECTIVITY_REQUEST;
    
    // Get Procedure transaction identifier assigned by the UE
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := cs_AccessPointName(v_APN_Value);
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;
    
    // The SS transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST and
    //         a ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST included
    //          in dedicatedInfoNASList of RRCConnectionReconfiguration message.
    // Ask UE to get its additional IP adress via DHCP or ICMP
    //@siclog "Step 3" siclog@
    v_PDN_Address2 := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    f_EUTRA_TxActivateDedicatedBearerCtxtOnAdditionalPDN(eutra_CellA,
                                                         tsc_RRC_TI_Def,
                                                         v_EpsBearerId2, // Default bearer ID to additional PDN
                                                         v_EpsDedicatedBearerId, // Dedicated bearer ID
                                                         v_PTId_UE,  // use value as defined by the UE
                                                         v_AccessPointName,
                                                         v_PDN_Address2,
                                                         f_GetDefPCOforPCSCFAddress(v_Pco));
    
    //  Check: Does the UE transmit an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message as specified?
    // Parallel behaviour: Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified?
    //@siclog "Step 4" siclog@
    interleave {
      [] SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                         cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                           cr_508_ActivateDefEpsBearerContextAccept(v_EpsBearerId2))))
        {
        }
      [] SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                         cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                           cr_508_ActDedicatedEPSBearerCxtAccept(v_EpsDedicatedBearerId))))
        {
        }
    };
    // interleave does not allow to execute f_EUTRA_PreliminaryPass inside
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4 Parallel Behaviour");
    
    //@siclog "Step 5- 6 Void" siclog@
    // The SS releases the RRC connection.
    //@siclog "Step 7" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
    
  } // function fl_TC_10_5_1_Body
  
  /**
   * @desc UE requested PDN connectivity not accepted
   */
  function f_TC_10_5_3_EUTRA() runs on EUTRA_PTC
  {
    /**
     *
     Test Purpose (TP)
     (1)
     with { the UE has sent a PDN CONNECTIVITY REQUEST message to an additional PDN }
     ensure that {
     when { the UE receives an PDN CONNECTIVITY REJECT message with PTI matching the PDN CONNECTIVITY REQUEST message and including a cause value }
     then { the UE enters the state PROCEDURE TRANSACTION INACTIVE }
     }
     
     Pre-test conditions
     System Simulator:
     -   Cell A.
     UE:
     -   The test USIM contains GUTI-1 and TAI-1, and EPS update status is "EU1: UPDATED".
     Preamble:
     -   The UE is in state Registered, Idle mode (state 2) according to [18] (1 default EPS bearer context is active).
     Note:   The PDN type (IPv4, IPv6 or both) of the UE is determined by the PICS.
     
    */
    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_TestBody_Set(true);
    fl_TC_10_5_3_Body();
    f_EUTRA_TestBody_Set(false);
    
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_5_3_EUTRA
  
  function fl_TC_10_5_3_Body() runs on EUTRA_PTC
  {
    var EPS_BearerIdentity v_EpsBearerId2 := '6'H;
    var NAS_MSG_Indication_Type v_NasInd;
    var ProcedureTransactionIdentifier v_PTId_UE;
    var ProtocolConfigOptions v_Pco;
    var AccessPointName v_AccessPointName;
    var PDN_Address v_PDN_Address2;
    var SRB_COMMON_IND v_ReceivedAsp;
    var PDN_CONNECTIVITY_REQUEST v_PDNConnReq;
    var template (value) ESM_Cause v_EsmCause111;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    var octetstring v_APN_Value := tsc_APN1; // APN-1(New PDN name), different from default
    
    // Cause the UE to request connectivity to an additional PDN.
    //@siclog "Step 1" siclog@
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(v_EpsBearerId2), "");
    
    // The UE transmits a SERVICE REQUEST
    //@siclog "Step 1A" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    //@siclog "Step 1B" siclog@
    // The SS establishes SRB2 and DRB associated with the default EPS bearer context activated during the preamble
    // (a first PDN obtained during the attach procedure).
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                        omit)));
    
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    //@siclog "Step 2" siclog@
    // Step 2. The UE transmits a PDN CONNECTIVITY REQUEST message as specified to request an additional PDN.
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value))))) -> value v_ReceivedAsp;
    
    v_PDNConnReq := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST;
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := v_PDNConnReq.accessPointName;
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;
    
    //  The SS transmits a PDN CONNECTIVITY REJECT message.
    //@siclog "Step 3" siclog@
    v_EsmCause111 := cs_ESM_Cause_v ('01101111'B);
    SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                cs_PdnConnectReject( '0'H, // no EPS bearer assigned
                                                                     v_PTId_UE,
                                                                     v_EsmCause111))));
    
    //@siclog "Step 4 - 5 Void" siclog@
    
    // The SS releases the RRC connection
    //@siclog "Step 6" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
    
    // Cause the UE to request connectivity to an additional PDN.
    //@siclog "Step 7" siclog@
    f_UT_RequestAdditionalPDNConnectivity(UT, hex2int(v_EpsBearerId2), "");
    
    //@siclog "Step 8" siclog@
    //  The UE transmits a SERVICE REQUEST
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoSignalling,
                                               cr_NAS_IndicationWithPiggybacking (tsc_SHT_IntegrityProtected,
                                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get()),
                                                                                  cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()))));
    
    //@siclog "Step 9" siclog@
    // The SS establishes a DRB associated with the default EPS bearer context activated during the preamble.
    // Activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                                                                  omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    //@siclog "Step 9A" siclog@
    // Check: Does the UE transmit a PDN CONNECTIVITY REQUEST as specified to request an additional PDN?
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNConnReqAdditionalPDN(cr_PDN_Type(f_GetPdnType()), cr_AccessPointName(v_APN_Value))))) -> value v_ReceivedAsp;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9A");

    v_PDNConnReq := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_CONNECTIVITY_REQUEST;
    v_PTId_UE := v_PDNConnReq.procedureTransactionIdentifier;
    v_AccessPointName := v_PDNConnReq.accessPointName;
    v_Pco := v_PDNConnReq.protocolConfigurationOptions;

    //@siclog "Step 9B" siclog@
    // The SS transmits an ACTIVATE DEFAULT EPS BEARER CONTEXT REQUEST message with IE EPS Bearer Identity set to new EPS bearer context.
    // Ask UE to get its additional IP adress via DHCP or ICMP
    v_PDN_Address2 := f_GetPDNAddress (f_CheckPCOforIPallocationViaNas (v_Pco));
    f_EUTRA_TxActivateDefaultEpsBearerCtxtReq_DrbReconfig (eutra_CellA,
                                                           tsc_RRC_TI_Def,
                                                           v_EpsBearerId2, // Default bearer ID to additional PDN
                                                           v_PTId_UE,  // use value as defined by the UE
                                                           v_AccessPointName,
                                                           v_PDN_Address2,
                                                           f_GetDefPCOforPCSCFAddress(v_Pco));
    // Check: Does the UE transmit an ACTIVATE DEFAULT EPS BEARER CONTEXT ACCEPT message for the additional default EPS bearer?
    //@siclog "Step 10" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActivateDefEpsBearerContextAccept(v_EpsBearerId2))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 10");
    
  } // function fl_TC_10_5_3_Body
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.6.1
   * @status    APPROVED
   */
  function f_TC_10_6_1_EUTRA() runs on EUTRA_PTC
  {
    // @desc UE requested PDN disconnect procedure accepted by the network
    // @sic R5s100326 sic@
    
    /* Purpose
     * (1)
     * with { UE is in BEARER CONTEXT ACTIVE STATE state }
     * ensure that {
     *   when { UE is triggered to disconnect from a PDN }
     *   then { UE sends a PDN DISCONNECT REQUEST message including the default EPS bearer identity
     *          associated with this PDN }
     * }
     * (2)
     * with { UE is in PROCEDURE TRANSACTION PENDING state }
     * ensure that {
     *   when { UE receives a DEACTIVATE EPS BEARER CONTEXT REQUEST message with any valid ESM cause }
     *   then { UE deactivates the default EPS bearer context for this PDN connection between the UE and the SS }
     * }
     */
    /* Preamble:
     * - The UE is in state Registered, Idle mode (state 2) according to [18] on Cell A.
     * - Two default EPS bearer context are activated and present on UE side (a first PDN obtained during the attach procedure and an additional PDN).
     */
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_508_ActivateAdditionalPDN (eutra_CellA, '6'H, RRC_IDLE);
    f_EUTRA_TestBody_Set(true);
    fl_TC_10_6_1_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
  } // function f_TC_10_6_1_EUTRA
  
  /*
   * @desc      test body of TC_10_6_1
   * @status    APPROVED
   */
  function fl_TC_10_6_1_Body() runs on EUTRA_PTC
  { // @sic R5s100461 sic@ @sic R5-104733 sic@
    var EPS_BearerIdentity v_EpsBearerId2 := '6'H; // default bearer on additional PDN
    var template (value) ESM_Cause v_EsmCause;
    var NAS_MSG_Indication_Type v_NasInd;
    var template (value) LinkedEpsBearerIdentity v_LinkedEpsBearerId := {idValue := hex2bit(v_EpsBearerId2)};
    var PDN_DISCONNECT_REQUEST v_PDNDiscReq;
    var ProcedureTransactionIdentifier v_EpsTi := tsc_PTI_Unassigned;
    var NasCount_Type v_NasCountUL;
    var SRB_COMMON_IND v_ReceivedAsp;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    var template (value) DRB_ToAddModList v_DRB_ToAddModList;
        
    // Cause the UE to request disconnection from the additional PDN
    //@siclog "Step 1" siclog@
    f_UT_DeactivateBearer(UT, hex2int(v_EpsBearerId2));
    
    // The UE transmits a SERVICE REQUEST message.
    //@siclog "Step 1A" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               ?,
                                               cr_NAS_Indication (tsc_SHT_IntegrityProtected,
                                                                  cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    //@siclog "Step 1B" siclog@
    // The SS establishes SRB2 and DRBs associated with two default EPS bearer contexts
    // (a first PDN obtained during the attach procedure and an additional PDN).
    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_DRB_ToAddModList[0] := cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1);
    v_DRB_ToAddModList[1] := cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB2);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( v_DRB_ToAddModList,
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    // Step 2. The UE transmits PDN DISCONNECT REQUEST
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_PDNDisconnectReq(v_LinkedEpsBearerId)))) -> value v_ReceivedAsp;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");
    
    v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
    v_PDNDiscReq  := v_NasInd.Pdu.Msg.pDN_DISCONNECT_REQUEST;
    v_EpsTi := v_PDNDiscReq.procedureTransactionIdentifier;
    
    //  The SS transmits a DEACTIVATE EPS BEARER CONTEXT REQUEST
    //@siclog "Step 3" siclog@
    v_EsmCause := cs_ESM_Cause_v ('00100100'B); // #36 regular deactivation
    SRB.send(cas_SRB1_RrcNasPdu_REQ(eutra_CellA,
                                    cs_TimingInfo_Now,
                                    cs_RRCConnectionReconfiguration_DRB_Release (tsc_RRC_TI_Def, tsc_DRB2),
                                    cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                   cs_508_DeactivateEPSBearerCxtReq(v_EpsBearerId2,
                                                                                    v_EpsTi,
                                                                                    v_EsmCause))));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    // Step 4. Check: Does the UE transmit a DEACTIVATE EPS BEARER CONTEXT ACCEPT?
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_DeactivateEPSBearerCxtAccept(v_EpsBearerId2,
                                                                                      tsc_PTI_Unassigned))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    
    //@siclog "Step 5 Void" siclog@
    // The SS releases the RRC connection.
    //@siclog "Step 5A" siclog@
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
    
  } // function fl_TC_10_6_1_Body
  
  /**
   * @desc UE requested PDN disconnect procedure not accepted by the network
   */
  function f_TC_10_6_2_EUTRA() runs on EUTRA_PTC
  {
    /* Purpose
       (1)
       with { UE is in BEARER CONTEXT ACTIVE STATE state }
       ensure that {
       when { UE is triggered for PDN disconnection from a requested PDN }
       then { UE sends a PDN DISCONNECT REQUEST message including the default EPS bearer identity associated with the PDN to disconnect from }
       }
       (2)
       with { UE is in PROCEDURE TRANSACTION PENDING state }
    ensure that {
    when { UE receives a PDN DISCONNECT REJECT message with a valid ESM cause except ESM cause #49:last PDN disconnection not allowed }
    then { UE aborts the PDN disconnection procedure and deactivates default EPS bearer context for this PDN connection locally without peer-to-peer signalling between the UE and the SS }
    
    }
    
    }
    System Simulator:
    -   Cell A
    UE:
    None.
    Preamble:
    -   The UE is in state Registered, Idle mode (state 2) according to [18] on Cell 1.
    
    */
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_6_2_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E1_IDLE);
  } // function f_TC_10_6_2_EUTRA
  
  function fl_TC_10_6_2_Body() runs on EUTRA_PTC
  {
    var EPS_BearerIdentity v_EpsDefBearerId := tsc_EpsDefaultBearerId; // default bearer on additional PDN
    var EPS_BearerIdentity v_EpsDedicatedBearer := tsc_EpsDedicatedBearerId;
    var ProcedureTransactionIdentifier v_EpsProcedureTransactionId := tsc_PTI_Unassigned;
    var template (value) ESM_Cause v_EsmCause49;
    var NAS_MSG_Indication_Type v_NasInd;
    var template (value) LinkedEpsBearerIdentity v_LinkedEpsBearerId := {idValue := hex2bit(v_EpsDedicatedBearer)};
    var PDN_DISCONNECT_REQUEST v_PDNDiscReq;
    var ProcedureTransactionIdentifier v_EpsTi := tsc_PTI_Unassigned;
    var boolean v_UEsentPDNDisconnect := false; // helper variable indicating step 2 has been executed
    var SRB_COMMON_IND v_ReceivedAsp;
    var GutiParameters_Type v_GutiParams := f_EUTRA_CellInfo_GetGuti(eutra_CellA);
    // var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    
    timer t_Wait;
    
    //  Cause the UE to request PDN disconnection from the default PDN
    // [MCC160] It is not clear if it is possible to request the UE to disconnect from the default PDN
    //@siclog "Step 1" siclog@
    f_UT_DeactivateBearer(UT, hex2int(v_EpsDefBearerId));
    
    t_Wait.start(10.0);
    alt {
      [] SRB.receive(car_SRB0_RrcPdu_IND(eutra_CellA,
                                         cr_RRCConnectionRequest(cr_EstablishmentCause_MoData)))
        {
          f_EUTRA_RRC_ConnectionSetup_Def (eutra_CellA, cs_TimingInfo_Now, tsc_RRC_TI_Def);
          
          //@siclog "Step 2a1 - 2a3" siclog@
          SRB.receive(car_SRB1_RrcNasPdu_IND(eutra_CellA,
                                             cr_508_RRCConnectionSetupComplete(tsc_RRC_TI_Def, ?),
                                             cr_NAS_IndicationWithPiggybacking (tsc_SHT_IntegrityProtected,
                                                                                cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get()),
                                                                                cr_PDNDisconnectReq(v_LinkedEpsBearerId)))) -> value v_ReceivedAsp;
          v_UEsentPDNDisconnect := true;
          t_Wait.stop;
          v_NasInd := v_ReceivedAsp.Signalling.Nas[0];
        }
      
      []t_Wait.timeout
        {
          v_UEsentPDNDisconnect := false;
        }
    } // alt
    
    if ( v_UEsentPDNDisconnect ) {
      v_PDNDiscReq := v_NasInd.Pdu.PiggybackedPduList[0].Msg.pDN_DISCONNECT_REQUEST;
      v_EpsTi := v_PDNDiscReq.procedureTransactionIdentifier;
      
      //  The SS transmits a PDN DISCONNECT REJECT message with
      //      cause #49 'last PDN disconnection not allowed'.
      //@siclog "Step 2a4" siclog@
      v_EsmCause49 := cs_ESM_Cause_v ('00110001'B);
      SRB.send(cas_SRB1_NasPdu_REQ(eutra_CellA,
                                   cs_TimingInfo_Now,
                                   cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                  cs_PdnDisconnectReject('0'H,
                                                                         v_EpsTi,
                                                                         v_EsmCause49
                                                                         ))));
    } else {
      // UE did NOT etablish an RRC connection and  sent PDN DISCONNECT REQUEST
      //@siclog "Step 2b1" siclog@
      f_EUTRA_UE_Page(eutra_CellA,
                      cs_NasPaging_OneRecord(cs_PagingUE_Identity_S_TMSI(v_GutiParams.MME_Code,
                                                                         v_GutiParams.M_TMSI)));
      //The UE transmits a SERVICE REQUEST for downlink signalling.
      //@siclog "Step 2b2" 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_SERVICE_REQUEST(v_SecurityParams.KSIasme)));
    }
    
    // The SS tansmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST with a linked EPS bearer ID
    // referring to the default EPS bearer context activated during the preamble
    //@siclog "Step3 " siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB2,
                                        v_EpsDedicatedBearer,
                                        v_EpsProcedureTransactionId,
                                        cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)), // <> prose (=6), prose error !?
                                        cs_508_EPS_QoS_Dedicated_1, // According to Context#1 in TS 36.508
                                        cs_508_Tft_Dedicated_1(v_EpsDedicatedBearer)); // According to Context#1 in TS 36.508
    
    //  Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message as specified?
    //@siclog "Step 4" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(tsc_EpsDedicatedBearerId))));
    
    f_EUTRA_RRC_ConnectionRelease(eutra_CellA, tsc_RRC_TI_Def, other);
    
  } // function fl_TC_10_6_2_Body

  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.7.1
   * @status    APPROVED
   */
  function f_TC_10_7_1_EUTRA() runs on EUTRA_PTC
  {
    //@desc UE requested bearer resource allocation accepted by the network / new EPS bearer context
    // @sic R5s100362 sic@
    
    /* Purpose
     * -------
     * (1)
     * with { UE in PROCEDURE TRANSACTION INACTIVE state and in EMM-IDLE mode }
     * ensure that {
     *   when { UE is requested to make an outgoing call for new QoS }
     *   then { UE sends a BEARER RESOURCE ALLOCATION REQUEST message }
     * }
     
     * (2)
     * with { UE has sent the BEARER RESOURCE ALLOCATION REQUEST message }
     * ensure that {
     *   when { UE receives an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST message with the procedure transaction identity (PTI) indicated in the BEARER RESOURCE ALLOCATION REQUEST message }
     *   then { UE sends an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message }
     * }
     */
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_7_1_Body();
    
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_7_1_EUTRA
  
  /*
   * @desc      test body of TC_10_7_1
   * @status    APPROVED
   */
  function fl_TC_10_7_1_Body() runs on EUTRA_PTC
  {
    var BEARER_RESOURCE_ALLOCATION_REQUEST v_BEARER_RESOURCE_ALLOCATION_Req;
    var  ProcedureTransactionIdentifier v_EpsTi := tsc_PTI_Unassigned;
    var NAS_MSG_Indication_Type v_NasInd;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    
    // Cause the UE to request bearer resource allocation of
    // dedicated EPS bearer associated with first PDN connectivity
    // @siclog "Step 1" siclog@
    f_UT_RequestActivateDedicatedBearer (UT,
                                         hex2int(tsc_EpsDedicatedBearerId),
                                         hex2int(tsc_EpsDefaultBearerId),
                                         cs_508_EPS_QoS_Dedicated_1,
                                         cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    
    // The UE transmits a SERVICE REQUEST message.
    // @siclog "Step 2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                        omit)));
    
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    // @siclog "Step 3" siclog@
    // Step 3. Check: Does the UE transmit a BEARER RESOURCE ALLOCATION REQUEST message?
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(?,
                                                                                          tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 3");
    // store PTI received
    v_BEARER_RESOURCE_ALLOCATION_Req  := v_NasInd.Pdu.Msg.bEARER_RESOURCE_ALLOCATION_REQUEST;
    v_EpsTi := v_BEARER_RESOURCE_ALLOCATION_Req.procedureTransactionIdentifier;
    // The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST message.
    //@siclog "Step 4" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB2,
                                        tsc_EpsDedicatedBearerId,
                                        v_EpsTi,
                                        cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)),
                                        cs_508_EPS_QoS_Dedicated_1,
                                        cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    
    
    //Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message? (2,P)
    //@siclog "Step 5" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(tsc_EpsDedicatedBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");
    
  } // function fl_TC_10_7_1_Body
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.7.2
   * @status    APPROVED
   */
  function f_TC_10_7_2_EUTRA() runs on EUTRA_PTC
  {
    // @desc UE requested bearer resource allocation accepted by the network / existing EPS bearer context
    // @sic R5s100364 sic@
    
    /* Test Purpose
     * (1)
     * with { UE in PROCEDURE TRANSACTION INACTIVE state and in EMM-IDLE mode }
     * ensure that {
     *   when { UE is requested to make an outgoing call for new QoS }
     *   then { UE sends a BEARER RESOURCE ALLOCATION REQUEST message }
     * }
     *
     * (2)
     * with { UE has sent a BEARER RESOURCE ALLOCATION REQUEST message }
     * ensure that {
     *   when { UE receives a MODIFY EPS BEARER CONTEXT REQUEST message with the procedure transaction identity (PTI) indicated in the BEARER RESOURCE ALLOCATION REQUEST message }
     *   then { UE sends a MODIFY EPS BEARER CONTEXT ACCEPT message }
     * }
     */
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_7_2_Body();
    
    f_EUTRA_TestBody_Set(false);
    
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_7_2_EUTRA
  
  /*
   * @desc      test body of TC_10_7_2
   * @status    APPROVED
   */
  function fl_TC_10_7_2_Body() runs on EUTRA_PTC
  {  // @sic R5-105012 sic@
    var ProcedureTransactionIdentifier v_EpsTi := tsc_PTI_Unassigned;
    var BEARER_RESOURCE_ALLOCATION_REQUEST v_BEARER_RESOURCE_ALLOCATION_Req;
    var template (value) NAS_DL_Message_Type v_ModifyEPSBearerCxtReq;
    var NAS_MSG_Indication_Type v_NasInd;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration

    //  Cause the UE to request bearer resource allocation of dedicated EPS bearer associated with first PDN connectivity
    //@siclog "Step 1" siclog@
    f_UT_RequestActivateDedicatedBearer (UT,
                                         hex2int(tsc_EpsDedicatedBearerId),
                                         hex2int(tsc_EpsDefaultBearerId),
                                         cds_EPS_QoS_Def_nonGBR_QCI,
                                         cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    
    //  The UE transmits a SERVICE REQUEST message.
    //@siclog "Step 2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    
    //  The SS establishes SRB2 and DRB associated with default EPS bearer context
    // (a first PDN obtained during the attach procedure).
    //@siclog "Step 2A" 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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                        omit)));
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(?,
                                                                                          tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 3");
    // store PTI received
    v_BEARER_RESOURCE_ALLOCATION_Req  := v_NasInd.Pdu.Msg.bEARER_RESOURCE_ALLOCATION_REQUEST;
    v_EpsTi := v_BEARER_RESOURCE_ALLOCATION_Req.procedureTransactionIdentifier;
    
    // The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message.
    // This message is included in a DLInformationTransfer message.
    //@siclog "Step 4" siclog@
    v_ModifyEPSBearerCxtReq := cs_508_ModifyEPSBearerCxtReq(tsc_EpsDefaultBearerId,
                                                            v_EpsTi,
                                                            cds_EPS_QoS_Def_nonGBR_QCI_tlv,
                                                            cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    //Send DLInformationTransfer as this only Modify EPS Bearer Request
    SRB.send(cas_SRB_NasPdu_REQ(eutra_CellA,
                                tsc_SRB2,
                                cs_TimingInfo_Now,
                                cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                               v_ModifyEPSBearerCxtReq)));

    //  Check:  Does the UE transmit a MODIFY EPS BEARER CONTEXT ACCEPT message as specified?
    //@siclog "Step 5" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ModifyEPSBearerCxtAccept(tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");
    
  } // function fl_TC_10_7_2_Body
  
  function f_TC_10_7_3_EUTRA() runs on EUTRA_PTC
  {
    //@desc UE requested bearer resource allocation not accepted by the network
    // @sic R5sxxxxxx sic@
    
    /* Test Purpose
       (1)
       with { UE has sent the BEARER RESOURCE ALLOCATION REQUEST message }
       ensure that {
       when { UE receives a BEARER RESOURCE ALLOCATION REJECT message with the procedure transaction identity (PTI) indicated in the BEARER RESOURCE ALLOCATION REQUEST message and a cause "Protocol error, unspecified" }
       then { UE enters state PROCEDURE TRANSACTION INACTIVE }
       }
    */
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_7_3_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_7_3_EUTRA
  
  function fl_TC_10_7_3_Body() runs on EUTRA_PTC
  {
    var  ProcedureTransactionIdentifier v_EpsTi := tsc_PTI_Unassigned;
    var BEARER_RESOURCE_ALLOCATION_REQUEST v_BEARER_RESOURCE_ALLOCATION_Req;
    var template (value) ESM_Cause v_EsmCause79, v_EsmCause111;
    var NAS_MSG_Indication_Type v_NasInd;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    var template (value) NAS_DL_Message_Type v_BearerResourceAllocReject;
    
    //  Cause the UE to request bearer resource allocation of dedicated
    //         EPS bearer associated with first PDN connectivity
    //@siclog "Step 1" siclog@
    f_UT_RequestActivateDedicatedBearer (UT,
                                         hex2int(tsc_EpsDedicatedBearerId),
                                         hex2int(tsc_EpsDefaultBearerId),
                                         cs_508_EPS_QoS_Dedicated_1,
                                         cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    
    //  The UE transmits a SERVICE REQUEST message.
    //@siclog "Step 2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                        omit)));
    
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                  cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    // The UE transmits a BEARER RESOURCE ALLOCATION REQUEST message.
    //@siclog "Step 3" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(?,
                                                                                          tsc_EpsDefaultBearerId))));
    // store PTI received
    v_BEARER_RESOURCE_ALLOCATION_Req  := v_NasInd.Pdu.Msg.bEARER_RESOURCE_ALLOCATION_REQUEST;
    v_EpsTi := v_BEARER_RESOURCE_ALLOCATION_Req.procedureTransactionIdentifier;
    
    // The SS transmits a BEARER RESOURCE ALLOCATION REJECT message.
    //@siclog "Step 4" siclog@
    v_EsmCause111 := cs_ESM_Cause_v ('01101111'B); // Protocol error unspecified
    v_BearerResourceAllocReject := cs_508_BearerResourceAllocReject(v_EpsTi,
                                                                    v_EsmCause111);
    SRB.send(cas_SRB1_RrcNasPdu_REQ(eutra_CellA,
                                    cs_TimingInfo_Now,
                                    cs_RRCConnectionReconfiguration_RadioResConfig(tsc_RRC_TI_Def,
                                                                                   cs_RadioResourceConfig_DRB_RECONFIG),
                                    cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                                   v_BearerResourceAllocReject)));
    
    //Receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA, cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def))); // @sic R5s100295 sic@
    
    //  The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST message.
    //@siclog "Step 5" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB2,
                                        tsc_EpsDedicatedBearerId,
                                        v_EpsTi,
                                        cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)),
                                        cs_508_EPS_QoS_Dedicated_1,
                                        cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    //  Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT REJECT message?
    //@siclog "Step 6" siclog@
    v_EsmCause79 := cs_ESM_Cause_v ('00101111'B); // PTI mismatch
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_ActDedicatedEPSBearerCxtReject(tsc_EpsDefaultBearerId,
                                                                                        v_EpsTi,
                                                                                        v_EsmCause79))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 6");
  } // function fl_TC_10_7_3_Body
  
  function f_TC_10_7_4_EUTRA() runs on EUTRA_PTC
  {
    //@desc UE requested bearer resource allocation / Expiry of timer T3480
    // @sic R5sxxxxxx sic@
    
    /* Test Purpose
       (1)
       with { UE has sent the BEARER RESOURCE ALLOCATION REQUEST message }
       ensure that {
       when { UE detects less than fifth expiry of timer T3480 }
       then { UE re-sends a BEARER RESOURCE ALLOCATION REQUEST message }
       }
       (2)
       with { UE has sent the BEARER RESOURCE ALLOCATION REQUEST message 5 times }
       ensure that {
       when { UE detects fifth expiry of timer T3480 }
       then { UE does not re-send a BEARER RESOURCE ALLOCATION REQUEST message }
       }
    */
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_7_4_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_7_4_EUTRA
  
  function fl_TC_10_7_4_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EpsTi := tsc_PTI_Unassigned;
    var BEARER_RESOURCE_ALLOCATION_REQUEST v_BEARER_RESOURCE_ALLOCATION_Req;
    var NAS_MSG_Indication_Type v_NasInd;
    var NasCount_Type v_NasCountUL;
    var EUTRA_SecurityParams_Type v_SecurityParams := f_EUTRA_Security_Get();
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_EUTRA_FDD_TDD_Info := f_EUTRA_CellInfo_GetFDD_TDD_Info (eutra_CellA); //Get FDD or TDD mode from Cell-configuration
    
    timer t_Timer3480 := f_EUTRA_SetTimerToleranceMax (eutra_CellA, 8.0);
    
    //  Cause the UE to request bearer resource allocation of dedicated
    //         EPS bearer associated with first PDN connectivity
    //@siclog "Step 1" siclog@
    f_UT_RequestActivateDedicatedBearer (UT,
                                         hex2int(tsc_EpsDedicatedBearerId),
                                         hex2int(tsc_EpsDefaultBearerId),
                                         cs_508_EPS_QoS_Dedicated_1,
                                         cs_508_Tft_Dedicated_1(tsc_EpsDedicatedBearerId));
    
    //  The UE transmits a SERVICE REQUEST message.
    //@siclog "Step 2" siclog@
    v_NasInd := f_EUTRA_RRC_ConnEst_DefWithNas(eutra_CellA,
                                               tsc_RRC_TI_Def,
                                               cr_EstablishmentCause_MoData,
                                               cr_NAS_Indication(tsc_SHT_IntegrityProtected,
                                                                 cr_508_SERVICE_REQUEST(f_EUTRA_SecurityKSIasme_Get())));
    
    // activate security in AS with parameters from AKA performed in preamble
    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);
    
    SRB.send(cas_SRB1_RrcPdu_REQ(eutra_CellA,
                                 cs_TimingInfo_Now,
                                 cs_RRCConnectionReconfiguration_Common(tsc_RRC_TI_Def,
                                                                        omit,
                                                                        omit,
                                                                        cs_508_RadioResourceConfigDedicated_Srb2( {cs_508_DRB_ToAddMod_DEFAULT_AM (tsc_DRB1)},
                                                                                                                  cs_508_MAC_MainConfig_Explicit_RBC_DrxL,
                                                                                                                  cs_508_PhysicalConfigDedicated_Default_RBC(v_EUTRA_FDD_TDD_Info.cqi_ReportConfig,
                                                                                                                                                             v_EUTRA_FDD_TDD_Info.soundingRS_UL_Config,
                                                                                                                                                             f_EUTRA_CellInfo_GetAntennaInfoDedicated (eutra_CellA))),
                                                                        omit)));
    
    // receive RRCConnectionReconfigurationComplete
    SRB.receive(car_SRB1_RrcPdu_IND(eutra_CellA,
                                    cr_508_RRCConnectionReconfigurationComplete(tsc_RRC_TI_Def)));
    
    // The UE transmits a BEARER RESOURCE ALLOCATION REQUEST message.
    //@siclog "Step 3" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(?,
                                                                                          tsc_EpsDefaultBearerId))));
    // store PTI received
    v_BEARER_RESOURCE_ALLOCATION_Req  := v_NasInd.Pdu.Msg.bEARER_RESOURCE_ALLOCATION_REQUEST;
    v_EpsTi := v_BEARER_RESOURCE_ALLOCATION_Req.procedureTransactionIdentifier;
    
    // Wait for 8 s to ensure that T3480 expires (1st expiry).
    //@siclog "Step 4" siclog@
    t_Timer3480.start; // timeout would be caught in the default
                       // stop not required as timer is restarted
    
    // Check: Does the UE re-transmit a BEARER RESOURCE ALLOCATION REQUEST message?
    //@siclog "Step 5" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(?,
                                                                                          tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 5");
    
    // Wait for 8 s to ensure that T3480 expires (2nd expiry).
    //@siclog "Step 6" siclog@
    t_Timer3480.start; // timeout would be caught in the default
                       // stop not required as timer is restarted
    
    // Check: Does the UE re-transmit a BEARER RESOURCE ALLOCATION REQUEST message?
    //@siclog "Step 7" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(v_EpsTi,
                                                                                          tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 7");
    
    // Wait for 8 s to ensure that T3480 expires (3rd expiry).
    //@siclog "Step 8" siclog@
    t_Timer3480.start; // timeout would be caught in the default
                       // stop not required as timer is restarted
    
    // Check: Does the UE re-transmit a BEARER RESOURCE ALLOCATION REQUEST message?
    //@siclog "Step 9" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(v_EpsTi,
                                                                                          tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 9");
    
    // Wait for 8 s to ensure that T3480 expires (4th expiry).
    //@siclog "Step 10" siclog@
    t_Timer3480.start; // timeout would be caught in the default
                       // stop not required as timer is restarted
    
    // Check: Does the UE re-transmit a BEARER RESOURCE ALLOCATION REQUEST message?
    //@siclog "Step 11" siclog@
    SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                        cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                            cr_508_BearerResourceAllocReq(v_EpsTi,
                                                                                          tsc_EpsDefaultBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 11");
    
    // Wait for 8 s to ensure that T3480 expires (5th expiry).
    //@siclog "Step 12" siclog@
    t_Timer3480.start; // timeout would be caught in the default
    
    // Check: Does the UE re-transmit a BEARER RESOURCE ALLOCATION REQUEST message?
    //@siclog "Step 13" siclog@
    alt {
      [] SRB.receive ( car_SRB2_NasPdu_IND ( eutra_CellA,
                                             cr_NAS_Indication ( tsc_SHT_IntegrityProtected_Ciphered,
                                                                 cr_508_BearerResourceAllocReq(v_EpsTi,
                                                                                               tsc_EpsDefaultBearerId))))
        {
          t_Timer3480.stop;
          f_EUTRA_SetVerdictFailOrInconc(__FILE__, __LINE__, "Step 13");
        }
      [] t_Timer3480.timeout
        {
        }
    }
    
  } // function fl_TC_10_7_4_Body

  /*
   * @desc      REFERENCE TS 36.523-1 clause 10.8.1
   * @status    APPROVED
   */
  function f_TC_10_8_1_EUTRA() runs on EUTRA_PTC
  {
    //@desc UE requested bearer resource modification accepted by the network / new EPS bearer context
    // @sic R5s100470 sic@
    
    // Purpose
    // -------
    //(1)
    //with { UE in PROCEDURE TRANSACTION INACTIVE state and in EMM-CONNECTED mode }
    //ensure that {
    //when { UE is requested to make an outgoing call for the specific QoS }
    //  then { UE sends a BEARER RESOURCE MODIFICATION REQUEST message }
    //          }
    //(2)
    //with { UE having sent the BEARER RESOURCE MODIFICATION REQUEST message }
    //ensure that {
    //when { UE receives an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST message with the procedure transaction identity (PTI) indicated in the BEARER RESOURCE MODIFICATION REQUEST message }
    //then { UE sends an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message }
    //         }
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 2, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_508_AM(eutra_CellA);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_8_1_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_8_1_EUTRA

  /*
   * @desc      test body of TC_10_8_1
   * @status    APPROVED
   */
  function fl_TC_10_8_1_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EpsPti := '01'O;
    var EPS_QualityOfService v_Qos;
    var SRB_COMMON_IND v_ReceivedAsp;
    //  Cause the UE to request bearer resource modification of
    //          dedicated EPS bearer associated with first PDN connectivity.
    //@siclog "Step 1" siclog@
    f_UT_RequestModifyDedicatedBearer (UT,
                                       hex2int(tsc_EpsDedicatedBearerId),
                                       hex2int(tsc_EpsDefaultBearerId),
                                       cs_508_EPS_QoS_Dedicated_1,
                                       cds_Tft_Dedicated_2_Modify (tsc_EpsDedicatedBearerId));
    //  Check: Does the UE transmit a BEARER RESOURCE MODIFICATION REQUEST message? (1,P)
    //@siclog "Step 2" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_BearerResourceModReq(?,
                                                                                  tsc_EpsDedicatedBearerId,
                                                                                  omit)))) -> value v_ReceivedAsp;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");
    // Store procedure transaction id to be used in SS responses.
    v_EpsPti := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.bEARER_RESOURCE_MODIFICATION_REQUEST.procedureTransactionIdentifier;
    v_Qos := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.bEARER_RESOURCE_MODIFICATION_REQUEST.requiredTrafficFlowQos;
    v_Qos.iei := omit;
    //  The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST message.
    //@siclog "Step 3" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB3,
                                        tsc_EpsDedicatedBearerId2,
                                        v_EpsPti,
                                        cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)),
                                        v_Qos,
                                        cds_Tft_Dedicated_2_Modify(tsc_EpsDedicatedBearerId2));
    
    //  Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT ACCEPT message? (2,P)
    //@siclog "Step 4" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(tsc_EpsDedicatedBearerId2))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    
  } // function fl_TC_10_8_1_Body
  
  function f_TC_10_8_2_EUTRA() runs on EUTRA_PTC
  {
    //@desc UE requested bearer resource modification accepted by the network / Existing EPS bearer context
    // @sic R5s100xxx sic@
    
    /* Test Purpose
       (1)
       with { UE in PROCEDURE TRANSACTION INACTIVE state and in EMM-CONNECTED mode }
       ensure that {
       when { UE is requested to modify of bearer resource corresponding to the dedicated bearer }
       then { UE sends a BEARER RESOURCE MODIFICATION REQUEST message }
       }
       (2)
       with { UE having sent the BEARER RESOURCE MODIFICATION REQUEST message }
       ensure that {
       when { UE receives a MODIFY EPS BEARER CONTEXT REQUEST message with the procedure transaction identity (PTI) indicated in the BEARER RESOURCE MODIFICATION REQUEST message }
       then { UE sends a MODIFY EPS BEARER CONTEXT ACCEPT message }
       }
    */
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_Def(eutra_CellA);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_8_2_Body();
    
    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_8_2_EUTRA
  
  function fl_TC_10_8_2_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EpsPti := '01'O;
    var template (value) NAS_DL_Message_Type v_ModifyEPSBearerCxtReq;
    var SRB_COMMON_IND v_ReceivedAsp;
    //  Cause the UE to request bearer resource modification of
    //  dedicated EPS bearer associated with first PDN connectivity.
    //@siclog "Step 1" siclog@
    f_UT_RequestModifyDedicatedBearer (UT,
                                       hex2int(tsc_EpsDedicatedBearerId),
                                       hex2int(tsc_EpsDefaultBearerId),
                                       cs_508_EPS_QoS_Dedicated_1,   // @sic R5-104168 sic@
                                       cds_Tft_Dedicated_2_Modify (tsc_EpsDedicatedBearerId));
  //  Check: Does the UE transmit a BEARER RESOURCE MODIFICATION REQUEST message? (1,P)
    //@siclog "Step 2" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_BearerResourceModReq(?,
                                                                                  tsc_EpsDedicatedBearerId,
                                                                                  omit)))) -> value v_ReceivedAsp;
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 2");
    // Store procedure transaction id to be used in SS responses.
    v_EpsPti :=  v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.bEARER_RESOURCE_MODIFICATION_REQUEST.procedureTransactionIdentifier;
    
    //  The SS transmits a MODIFY EPS BEARER CONTEXT REQUEST message.
    //@siclog "Step 3" siclog@
    v_ModifyEPSBearerCxtReq := cs_508_ModifyEPSBearerCxtReq(tsc_EpsDedicatedBearerId,
                                                            v_EpsPti,
                                                            cds_508_EPS_QoS_Dedicated_1_tlv,
                                                            cds_Tft_Dedicated_2_Modify(tsc_EpsDedicatedBearerId));  // cs_TftDef_1072 );  // omit should be used, TFTs are not required for default bearers
   
    //Send DLInformationTransfer as this only Modify EPS Bearer Request
    SRB.send(cas_SRB_NasPdu_REQ(eutra_CellA,
                                tsc_SRB2,
                                cs_TimingInfo_Now,
                                cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                               v_ModifyEPSBearerCxtReq)));
    //  Check: Does the UE transmit a MODIFY EPS BEARER CONTEXT ACCEPT message?
    //@siclog "Step 4" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_ActDedicatedEPSBearerCxtAccept(tsc_EpsDedicatedBearerId))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    
  } // function fl_TC_10_8_2_Body
  
  function f_TC_10_8_3_EUTRA() runs on EUTRA_PTC
  {
    //@desc UE requested bearer resource modification not accepted by the network
    // @sic R5sxxxxxx sic@
    
    /* Test Purpose
       (1)
       with { UE has sent the BEARER RESOURCE MODIFICATION REQUEST message }
       ensure that {
       when { UE receives a BEARER RESOURCE MODIFICATION REJECT message with the procedure transaction identity (PTI) indicated in the BEARER RESOURCE MODIFICATION REQUEST message and a cause "Protocol error, unspecified" }
       then { UE enters state PROCEDURE TRANSACTION INACTIVE }
       }
    */
    
    f_EUTRA_NAS_Init(LTE_AllCellsOnSamePLMN, LTEsinglecell);
    
    // Create cell and send out system information
    f_EUTRA_CellConfig_DRB_Common(eutra_CellA, 1, 0);
    
    f_EUTRA_Preamble(eutra_CellA, STATE2_IDLEUPDATE);
    f_EUTRA_RbEst_Def(eutra_CellA);
    
    f_EUTRA_TestBody_Set(true);
    
    fl_TC_10_8_3_Body();

    // Postamble
    f_EUTRA_TestBody_Set(false);
    f_EUTRA_Postamble(eutra_CellA, E2_CONNECTED);
  } // function f_TC_10_8_3_EUTRA
  
  function fl_TC_10_8_3_Body() runs on EUTRA_PTC
  {
    var ProcedureTransactionIdentifier v_EpsPti := '01'O;
    var template (value) NAS_DL_Message_Type v_BearerResourceAllocRej;
    var SRB_COMMON_IND v_ReceivedAsp;
    var EPS_QualityOfService v_Qos;
    var template (value) ESM_Cause v_EsmCause79, v_EsmCause111;

    //  Cause the UE to request bearer resource modification of
    //          dedicated EPS bearer associated with first PDN connectivity.
    //@siclog "Step 1" siclog@
    f_UT_RequestModifyDedicatedBearer (UT,
                                       hex2int(tsc_EpsDedicatedBearerId),
                                       hex2int(tsc_EpsDefaultBearerId),
                                       cs_508_EPS_QoS_Dedicated_1,
                                       cds_Tft_Dedicated_2_Modify (tsc_EpsDedicatedBearerId));    //  Check: Does the UE transmit a BEARER RESOURCE MODIFICATION REQUEST message? (1,P)
    //  Check: Does the UE transmit a BEARER RESOURCE MODIFICATION REQUEST message? (1,P)
    //@siclog "Step 2" siclog@
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_508_BearerResourceModReq(?,
                                                                                  tsc_EpsDefaultBearerId,
                                                                                  omit)))) -> value v_ReceivedAsp;
    // Store procedure transaction id to be used in SS responses.
    v_EpsPti :=  v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.bEARER_RESOURCE_MODIFICATION_REQUEST.procedureTransactionIdentifier;
    v_Qos := v_ReceivedAsp.Signalling.Nas[0].Pdu.Msg.bEARER_RESOURCE_MODIFICATION_REQUEST.requiredTrafficFlowQos;
    v_Qos.iei := omit;
    //  The SS transmits a BEARER RESOURCE MODIFICATION REJECT message.
    //@siclog "Step 3" siclog@
    v_EsmCause111 := cs_ESM_Cause_v ('01101111'B); // Protocol error unspecified
    v_BearerResourceAllocRej := cs_508_BearerResourceModificationReject(v_EpsPti,
                                                                        v_EsmCause111);
    //Send DLInformationTransfer as this only Modify EPS Bearer Request
    SRB.send(cas_SRB_NasPdu_REQ(eutra_CellA,
                                tsc_SRB2,
                                cs_TimingInfo_Now,
                                cs_NAS_Request(tsc_SHT_IntegrityProtected_Ciphered,
                                               v_BearerResourceAllocRej)));
    //  The SS transmits an ACTIVATE DEDICATED EPS BEARER CONTEXT REQUEST message.
    //@siclog "Step 4" siclog@
    f_EUTRA_TxDedicatedEpsBearerCtxtReq(eutra_CellA,
                                        tsc_DRB2,
                                        tsc_EpsDedicatedBearerId2,
                                        v_EpsPti,
                                        cs_LinkedId(hex2bit( tsc_EpsDefaultBearerId)),
                                        cds_EPS_QoS_Dedi_nonGBR_QCI,
                                        cs_508_Tft_Dedicated_2(tsc_EpsDedicatedBearerId2));
    //  Check: Does the UE transmit an ACTIVATE DEDICATED EPS BEARER CONTEXT REJECT message?
    //@siclog "Step 5" siclog@
    v_EsmCause79 := cs_ESM_Cause_v ('00101111'B); // PTI mismatch
    SRB.receive(car_SRB2_NasPdu_IND(eutra_CellA,
                                    cr_NAS_Indication(tsc_SHT_IntegrityProtected_Ciphered,
                                                      cr_ActDedicatedEPSBearerCxtReject(tsc_EpsDedicatedBearerId2,
                                                                                        v_EpsPti,
                                                                                        v_EsmCause79))));
    f_EUTRA_PreliminaryPass(__FILE__, __LINE__, "Step 4");
    
  } // function fl_TC_10_8_3_Body
  
  } // group TestcaseImplementations
} // module
