/******************************************************************************/
// @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-16 13:06:46 +0200 (Thu, 16 Sep 2010) $
// $Rev: 3929 $
/******************************************************************************/

module MultiLayer_Procedures_UTRAN {

  import from UTRAN_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from UTRAN_ASP_Definitions language "ASN.1:1997" all;
  import from UTRAN_TypeDefs all;
  import from UTRAN_Component all;
  import from UTRAN_CellInfo all;
  import from UTRAN_Templates all;
  import from UTRAN_CommonFunctions all;
  import from UTRAN_ASN1_Templates all;
  import from UTRANGERAN_CommonFunctions all;
  import from UTRAN_RAB_Functions all;
  import from UTRAN_RAB_Templates all;
  import from UTRAN_Parameters all;
  import from UTRAN_ConfigurationSteps all;

  import from NAS_24008Templates all;
  import from NAS_CommonTemplates all;
  import from NAS_AuxiliaryDefsAndFunctions all;
  import from NAS_24008TypeDefs all;
  import from NAS_CommonTypeDefs all;

  import from CommonIratDefs all;
  import from Parameters all;
  import from CommonDefs all;
  import from CommonIP all;
  import from UpperTesterFunctions all;
  
  import from UTRAN_RAB_TemplatesFDD all;//FFS - for template cs_UL_DPCH_Info_FDD

//----------------------------------------------------------------------
// Templates
//----------------------------------------------------------------------

  const SpreadingFactor tsc_Sf16 := sf16;
  const SF512_AndPilot  tsc_Sfd32 := tsc_DL_DPCH1_SFP_64k_PS;

  template U_RLC_AM_IND car_RLC_Test_Data_Ind ( UTRAN_CellId_Type  p_CellId,
                                                integer            p_RB_Id,
                                                bitstring          p_Data ) :=
  {
    testData := {
      cellId := p_CellId,
      rB_Id := p_RB_Id,
      data := {
         data := p_Data
        }
    }
  }

  template (value) U_RLC_AM_REQ cas_RLC_Test_Data_Req ( UTRAN_CellId_Type          p_CellId,
                                                        integer                    p_RB_Id,
                                                        bitstring                  p_Data ) :=
  {
    testData := {
      cellId := p_CellId,
      rB_Id := p_RB_Id,
      data := {
         data := p_Data
      }
    }
  }

  template RRCDataIndType cr_CallConfirmed_Common ( template TI p_TI,
                                                    template StreamId p_StrId ) :=
  {
    callConfirmed := cr_CallConf_Common (p_TI, p_StrId)
  };

  template (value) RRCDataReqType cs_SetupMTCall_Common( template (value) Bcap p_Bcap) :=
  {
    setupdl :=  cs_SetupMT_Common (p_Bcap)
  };
  
  template RRCDataIndType cr_SetupMOCall_Common(template Bcap p_Bcap,
                                                template LLC  p_LLC) :=
  {
    setupul :=  cr_SetupMO_Speech_Common(p_Bcap, p_LLC)
  };
  
  template RRCDataIndType cr_Alerting_Common (template TI p_TI) :=
  {
    alertingul := cr_Alert_Common (p_TI)
  };
  
  template RRCDataIndType cr_Connect (template TI p_TI) :=
  {
    connectul := cr_Connect_Common (p_TI)
  };
  
  template (value) RRCDataReqType cs_ConnectAck_Common (template (value) TI p_TI ) :=
  {
    connectAcknowledge := cs_ConnAck_Common(p_TI)
  }
  
  template (value) TFCS cs_TFCS_Cmpl0_To119_Tx (template (omit) PowerOffsetInformation p_PowerOffsetInformation):=
  {
    normalTFCI_Signalling := {
      complete := {
        ctfcSize := {
          ctfc8Bit := {
            {
              ctfc8 := 0,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 1,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 11,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 12,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 13,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 23,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 24,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 25,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 35,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 36,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 37,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 47,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 48,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 49,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 59,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 60,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 61,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 71,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 72,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 73,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 83,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 84,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 85,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 95,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 96,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 97,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 107,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 108,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 109,
              powerOffsetInformation := cs_PowerOffsetInfoComputed
            },
            {
              ctfc8 := 119,
              powerOffsetInformation := p_PowerOffsetInformation
            }
          }
        }
      }
    }
  };
  
  template (value) TFCS cs_TFCS_Cmpl0_To119_Rx :=
  {
    normalTFCI_Signalling := {
      complete := {
        ctfcSize := {
          ctfc8Bit := {
            {
              ctfc8 := 0,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 1,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 11,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 12,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 13,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 23,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 24,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 25,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 35,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 36,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 37,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 47,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 48,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 49,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 59,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 60,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 61,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 71,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 72,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 73,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 83,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 84,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 85,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 95,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 96,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 97,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 107,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 108,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 109,
              powerOffsetInformation := omit
            },
            {
              ctfc8 := 119,
              powerOffsetInformation := omit
            }
          }
        }
      }
    }
  };
  
  //FFS - template cs_PowerOffsetInfo64k_FDD in module UTRAN_RAB_TemplatesFDD shall be merged with this one
  template (value) PowerOffsetInformation cs_PowerOffsetInfoHigher64k_FDD :=
  {
    gainFactorInformation := {
      signalledGainFactors := {
        modeSpecificInfo := {
          fdd := {
            gainFactorBetaC := tsc_GainFactorBetaC_Higher64k
          }
        },
        gainFactorBetaD := tsc_GainFactorBetaD,
        referenceTFC_ID := 0
      }
    },
    powerOffsetPp_m := omit
  };
  
  template (value) UL_CommonTransChInfo_r4 cs_UL_CommTrChInfo_TM3_AM1_0To119_FDD :=
  {
    tfc_Subset := omit,
    prach_TFCS := omit,
    modeSpecificInfo := {
      fdd := {
        ul_TFCS := cs_TFCS_Cmpl0_To119_Tx ( cs_PowerOffsetInfoHigher64k_FDD )
      }
    },
    tfc_SubsetList := omit
  };
  
  //FFS - this template can be merged/parameterised with other similar templates
  template (value) DL_DCCH_Message cs_108_RB_SetUpPSandConvSpeech_FDD ( IntegrityCheckInfo p_Integrityinfo,
                                                                        RRC_TransactionIdentifier p_RRC_Ti,
                                                                        ActivationTime p_Activetime,
                                                                        bitstring p_RAB_Id,
                                                                        PrimaryScramblingCode p_PrimScramblingCode,
                                                                        UL_ScramblingCode p_UL_ScramblingCode ) :=
  {
    integrityCheckInfo := p_Integrityinfo,
    message_ := {
      radioBearerSetup := {
        later_than_r3 := {
          rrc_TransactionIdentifier := p_RRC_Ti,
          criticalExtensions := {
            criticalExtensions := {
              criticalExtensions := {
                criticalExtensions := {
                  criticalExtensions := {
                    r8 := {
                      radioBearerSetup_r8 := {//RadioBearerSetup-r8-IEs
                        integrityProtectionModeInfo := omit,
                        cipheringModeInfo           := omit,
                        sr_vcc_Info                 := omit,
                        activationTime              := p_Activetime,
                        new_U_RNTI                  := omit,
                        new_C_RNTI                  := omit,
                        new_DSCH_RNTI               := omit,
                        new_H_RNTI                  := omit,
                        newPrimary_E_RNTI           := omit,
                        newSecondary_E_RNTI         := omit,
                        rrc_StateIndicator          := cell_DCH,
                        utran_DRX_CycleLengthCoeff  := omit,
                        ura_Identity                := omit,
                        supportForChangeOfUE_Capability := omit,
                        cn_InformationInfo              := omit,
                        srb_InformationSetupList        := omit,
                        rab_InformationSetupList := {
                          cs_RAB_InfoSetupTM_12_2k ( useT314, p_RAB_Id)
                        },
                        rab_InformationReconfigList   := omit,
                        rb_InformationReconfigList    := omit,
                        rb_InformationAffectedList    := omit,
                        dl_CounterSynchronisationInfo := omit,
                        pdcp_ROHC_TargetMode          := omit,
                        ul_CommonTransChInfo          := cs_UL_CommTrChInfo_TM3_AM1_0To119_FDD,
                        ul_deletedTransChInfoList     := omit,
                        ul_AddReconfTransChInfoList   := cs_UL_AddReconfTransChInfoListTM_12_2k,
                        dl_CommonTransChInfo          := cs_DL_CommonTransChInfoDCH_FDD(cs_TFCS_Cmpl0_To119_Rx),
                        dl_DeletedTransChInfoList     := omit,
                        dl_AddReconfTransChInfoList   := cs_DL_AddReconfTransChInfoListTM_12_2k,
                        frequencyInfo                 := omit,
                        multi_frequencyInfo           := omit,
                        dtx_drx_TimingInfo            := omit,
                        dtx_drx_Info                  := omit,
                        hs_scch_LessInfo              := omit,
                        mimoParameters                := omit,
                        maxAllowedUL_TX_Power         := tsc_MaxAllowPwr,
                        ul_DPCH_Info                  := cs_UL_DPCH_Info_FDD ( tsc_Sf16,
                                                                               pl0_76,
                                                                               p_UL_ScramblingCode ),
                        ul_EDCH_Information         := omit,
                        dl_HSPDSCH_Information      := omit,
                        dl_CommonInformation        := cs_DL_CommonInformationRB_SetUp_FDD ( tsc_Sfd32, flexible ),//FFS - cs_DL_CommonInformationRB_SetUpSpeech can be merged with cs_DL_CommonInformationRB_SetUp_FDD
                        dl_InformationPerRL_List    := cs_DL_InformationPerRL_r8_FDD ( p_PrimScramblingCode,
                                                                                       tsc_DL_DPCH1_ChC_64k_PS,
                                                                                       tsc_DL_DPCH1_2ndScrC ),
                        dl_SecondaryCellInfoFDD      := omit,
                        controlChannelDRXInfo_TDD128 := omit,
                        sps_Information_TDD128       := omit,
                        mbms_PL_ServiceRestrictInfo  := omit
                      },
                      radioBearerSetup_r8_add_ext := omit,
                      v7d0NonCriticalExtensions := omit
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  
template (value) DL_DPCHInfo_r8 cs_DL_DPCH_64k_PS ( template (value) DL_CommonInformation_r8 p_DL_CommonInformation,
                                                    SecondaryScramblingCode p_SecondaryScramblingCode) :=
{
  dl_CommonInformation := p_DL_CommonInformation,
  dl_Dpch_InfoPerRL := {
    dl_DPCH_InfoPerRL := {
      fdd := {
        pCPICH_UsageForChannelEst := mayBeUsed,
        dpch_FrameOffset := (( (tsc_DefaultDPCH_OffsetValue*512 ) mod 38400)/256 ),
        // DPCH-FrameOffset = DefaultDPCH-OffsetValueFDD MOD 38400
        // Actual value DPCH-FrameOffset = IE value * 256
        // Actual value DefaultDPCH-OffsetValueFDD = IE value * 512 ,
        secondaryCPICH_Info := omit,
        dl_ChannelisationCodeList := {
          {
            secondaryScramblingCode := p_SecondaryScramblingCode,
            sf_AndCodeNumber := tsc_DL_DPCH1_ChC_64k_PS,
            scramblingCodeChange := omit
          }
        },
        tpc_CombinationIndex := 0,
        powerOffsetTPC_pdpdch := omit,
        closedLoopTimingAdjMode := omit
      }
    }
  },
  rl_Information := {
    powerOffsetOfTFCI_PO1 := tsc_DPCH_PowerOffsetTFCI,
    powerOffsetOfTPC_PO2 := tsc_DPCH_PowerOffsetTPC,
    powerOffsetOfPILOT_PO3 := tsc_DPCH_PowerOffsetPILOT,
    dl_TxPower := tsc_DL_TxPower_DPCH_64k,
    dl_TxPowerMax := 15,
    dl_TxPowerMin := -35,
    cfnTgtSfnFrameOffset := omit
  }
};

// =============================================================================
// ASN.1 ASP Constraint
// *** Comments:
// For FDD mode only, Used for PS + Speech config
// -----------------------------------------------------------------------------
  template (value) U_CPHY_CONFIG_REQ cs_5_DCH_0_To119_DL_Info_FDD(UTRAN_CellId_Type p_CellId,
                                                                  integer p_PhyChId,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS5,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS1,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS2,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS3,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS4,
                                                                  template (value) SS_ActivationTime p_SS_ActivationTime) :=
  {
    trchConfig_FDD := {
      cellId := p_CellId,
      routingInfo := {
        physicalChannelIdentity := p_PhyChId
      },
      ratType := fdd,
      trchConfigType := cs_TrChConfigTypeDCH_NoSHO,
      configMessage := {
        activationTime := p_SS_ActivationTime,
        ulconnectedTrCHList := omit,
        ulTFCS := omit,
        dlconnectedTrCHList := {
          {
            trchid := tsc_DL_DCH1,
            dl_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS1
          },
          {
            trchid := tsc_DL_DCH2,
            dl_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS2
          },
          {
            trchid := tsc_DL_DCH3,
            dl_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS3
          },
          {
            trchid := tsc_DL_DCH4,
            dl_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS4
          },
          {
            trchid := tsc_DL_DCH5,
            dl_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS5
          }
        },
        dlTFCS := cs_TFCS_Cmpl0_To119_Tx(cs_PowerOffsetInfoHigher64k_FDD),
        hsDSCHMacdFlows := omit,
        e_DCHMacdFlows := omit,
        ehs_DSCH_Flows := omit,
        ehs_DSCH_CommonFlows := omit,
        e_DCHMacd_CommonFlows := omit
      }
    }
  };
  
// =============================================================================
// ASN.1 Type Constraint
// *** Comments:
// transport format set for transport channel used in Interactive or Background /DL:.64kbps
// This corresponds to 6.10.2.4.1.25.2.1.1 of 34.108
// *** additional Notes:
// TTI = 20 ms;
// five transport formats: TransportBlocks = 0, TB size = 336 bits; TansportBlock = 1, Size =336 bits;  TransportBlocks = 2, TB size = 336 bits., TransportBlocks = 3, TB size = 336 bits,TransportBlocks = 4, TB size = 336 bits
// coding = turbo;
// CRCsize = 16;
// RateMatching = parameter(130-170)
// -----------------------------------------------------------------------------
  template (value) CommonOrDedicatedTFS cs_DCH_336_TFS_25_DL_20_TC :=
  {
    tti := {
      tti20 := {
        {
          tb_Size := 336,
          numberOfTbSizeList := {
            { zero := NULL },
            { one := NULL },
            { small := 2 },
            { small := 3 },
            { small := 4 }
          },
          logicalChannelList := {
            allSizes := NULL
          }
         }
      }
    },
    semistaticTF_Information := {
      channelCodingType := {
        turbo := NULL
      },
      rateMatchingAttribute := 150,
      crc_Size := crc16
    }
  };
  
  template (value) TrCHInfo cs_TrCHInfoDL_5_0To119 ( template (value) CommonOrDedicatedTFS p_DchTFS5,
                                                     template (value) CommonOrDedicatedTFS p_DchTFS1,
                                                     template (value) CommonOrDedicatedTFS p_DchTFS2,
                                                     template (value) CommonOrDedicatedTFS p_DchTFS3,
                                                     template (value) CommonOrDedicatedTFS p_DchTFS4) :=
  {
    ulconnectedTrCHList := omit,
    ulTFCS := omit,
    dlconnectedTrCHList := {
      {
        trchid := tsc_DL_DCH1,
        transportChannelInfo := p_DchTFS1
      },
      {
        trchid := tsc_DL_DCH2,
        transportChannelInfo := p_DchTFS2
      },
      {
        trchid := tsc_DL_DCH3,
        transportChannelInfo := p_DchTFS3
      },
      {
        trchid := tsc_DL_DCH4,
        transportChannelInfo := p_DchTFS4
      },
      {
        trchid := tsc_DL_DCH5,
        transportChannelInfo := p_DchTFS5
      }
    },
    dlTFCS := cs_TFCS_Cmpl0_To119_Tx(cs_PowerOffsetInfoHigher64k_FDD),
    hsDSCHMacdFlows := omit,
    ehs_DSCH_Flows        := omit,
    ehs_DSCH_CommonFlows  := omit
  };
  
  template (value) TrCH_LogCHMappingList1 cs_TrLogMappingDL_TM3_AM1 :=
  {
    ulconnectedTrCHList := omit,
    dlconnectedTrCHList := {
      {
        trchid := tsc_DL_DCH1,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DTCH1,
                logicalChannelType := dTCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 7
              }
            },
            rB_Identity := tsc_RB10,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_DL_DCH2,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DTCH2,
                logicalChannelType := dTCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 7
              }
            },
            rB_Identity := tsc_RB11,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_DL_DCH3,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DTCH3,
                logicalChannelType := dTCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 7
              }
            },
            rB_Identity := tsc_RB12,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_DL_DCH4,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DTCH4,
                logicalChannelType := dTCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 6
              }
            },
            rB_Identity := tsc_RB20,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_DL_DCH5,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DCCH1,
                logicalChannelType := dCCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 1
              }
            },
            rB_Identity := tsc_RB1,
            cn_DomainIdentity := omit
          },
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DCCH2,
                logicalChannelType := dCCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 2
              }
            },
            rB_Identity := tsc_RB2,
            cn_DomainIdentity := omit
          },
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DCCH3,
                logicalChannelType := dCCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 3
              }
            },
            rB_Identity := tsc_RB3,
            cn_DomainIdentity := omit
          },
          {
            logicalChannel_Mapping := {
              dl_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                dl_TransportChannelType := dch,
                logicalChannelIdentity := tsc_DL_DCCH4,
                logicalChannelType := dCCH,
                rlc_SizeList := {
                  configured := NULL
                },
                mac_LogicalChannelPriority := 4
              }
            },
            rB_Identity := tsc_RB4,
            cn_DomainIdentity := omit
          }
        }
      }
    },
    dlconnectedMACdFlows := omit,
    dlconnectedMAC_ehsFlows := omit,
    dlconnectedMAC_ehsCommonFlows := omit,
    dlconnectedMAC_ehsCommonFlowsDC := omit
  };
  
  template (value) U_CPHY_CONFIG_REQ cs_5_DCH_0_To119_UL_Info_FDD(UTRAN_CellId_Type p_CellId,
                                                                  integer p_PhyChId,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS5,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS1,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS2,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS3,
                                                                  template (value) CommonOrDedicatedTFS p_DchTFS4,
                                                                  template (value) SS_ActivationTime p_SS_ActivationTime) :=
  {
    trchConfig_FDD := {
      cellId := p_CellId,
      routingInfo := {
        physicalChannelIdentity := p_PhyChId
      },
      ratType := fdd,
      trchConfigType := cs_TrChConfigTypeDCH_NoSHO,
      configMessage := {
        activationTime := p_SS_ActivationTime,
        ulconnectedTrCHList := {
          {
            trchid := tsc_UL_DCH1,
            ul_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS1
          },
          {
            trchid := tsc_UL_DCH2,
            ul_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS2
          },
          {
            trchid := tsc_UL_DCH3,
            ul_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS3
          },
          {
            trchid := tsc_UL_DCH4,
            ul_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS4
          },
          {
            trchid := tsc_UL_DCH5,
            ul_TransportChannelType := dch,
            transportChannelInfo := p_DchTFS5
          }
        },
        ulTFCS := cs_TFCS_Cmpl0_To119_Rx,
        dlconnectedTrCHList := omit,
        dlTFCS := omit,
        hsDSCHMacdFlows := omit,
        e_DCHMacdFlows := omit,
        ehs_DSCH_Flows := omit,
        ehs_DSCH_CommonFlows := omit,
        e_DCHMacd_CommonFlows := omit
      }
    }
  };
  
// =============================================================================
// ASN.1 Type Constraint
// *** Comments:
// transport format set for transport channel used in Interactive or Background /UL:.64kbps
// This corresponds to 6.10.2.4.1.24.1.1.1 of 34.108
// *** additional Notes:
// TTI = 20 ms;
// five transport formats: TransportBlocks = 0, TB size = 336 bits; TansportBlock = 1, Size =336 bits;  TransportBlocks = 2, TB size = 336 bits., TransportBlocks = 3, TB size = 336 bits,TransportBlocks = 4, TB size = 336 bits
// coding = turbo;
// CRCsize = 16;
// RateMatching = parameter(130-170)
// -----------------------------------------------------------------------------
  template (value) CommonOrDedicatedTFS cs_DCH_336_TFS_24_UL_20_TC :=
  {
    tti := {
      tti20 := {
        {
          tb_Size := 336,
          numberOfTbSizeList := {
            { zero := NULL },
            { one := NULL },
            { small := 2 },
            { small := 3 },
            { small := 4 }
          },
          logicalChannelList := {
            allSizes := NULL
          }
        }
      }
    },
    semistaticTF_Information := {
      channelCodingType := {
        turbo := NULL
      },
      rateMatchingAttribute := 150,
      crc_Size := crc16
    }
  };
  
// =============================================================================
// ASN.1 Type Constraint
// *** Comments:
// With CTFC list : 0, 1, 11,12,13, 23, 24, 25, 35, 36, 37, 47,48,49,59,60,61,71, 72, 73, 83, 84, 85, 95, 96, 97, 107, 108, 109, 119
// -----------------------------------------------------------------------------
template (value) TrCHInfo cs_TrCHInfoUL_5_0To119( template (value) CommonOrDedicatedTFS p_DchTFS5,
                                                 template (value) CommonOrDedicatedTFS p_DchTFS1,
                                                 template (value) CommonOrDedicatedTFS p_DchTFS2,
                                                 template (value) CommonOrDedicatedTFS p_DchTFS3,
                                                 template (value) CommonOrDedicatedTFS p_DchTFS4) :=
  {
    ulconnectedTrCHList := {
      {
        trchid := tsc_UL_DCH1,
        transportChannelInfo := p_DchTFS1
      },
      {
        trchid := tsc_UL_DCH2,
        transportChannelInfo := p_DchTFS2
      },
      {
        trchid := tsc_UL_DCH3,
        transportChannelInfo := p_DchTFS3
      },
      {
        trchid := tsc_UL_DCH4,
        transportChannelInfo := p_DchTFS4
      },
      {
        trchid := tsc_UL_DCH5,
        transportChannelInfo := p_DchTFS5
      }
    },
    ulTFCS := cs_TFCS_Cmpl0_To119_Rx ,
    dlconnectedTrCHList := omit,
    dlTFCS := omit,
    hsDSCHMacdFlows := omit,
    ehs_DSCH_Flows        := omit,
    ehs_DSCH_CommonFlows  := omit
  };
  
// =============================================================================
// ASN.1 Type Constraint
// *** Comments:
// -----------------------------------------------------------------------------
  template (value) TrCH_LogCHMappingList1 cs_TrLogMappingUL_TM3_AM1 :=
  {
    ulconnectedTrCHList := {
      {
        trchid := tsc_UL_DCH1,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DTCH1,
                logicalChannelType := dTCH
              }
            },
            rB_Identity := tsc_RB10,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_UL_DCH2,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DTCH2,
                logicalChannelType := dTCH
              }
            },
            rB_Identity := tsc_RB11,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_UL_DCH3,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DTCH3,
                logicalChannelType := dTCH
              }
            },
            rB_Identity := tsc_RB12,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_UL_DCH4,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DTCH4,
                logicalChannelType := dTCH
              }
            },
            rB_Identity := tsc_RB20,
            cn_DomainIdentity := omit
          }
        }
      },
      {
        trchid := tsc_UL_DCH5,
        trCH_LogCHMappingList := {
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DCCH1,
                logicalChannelType := dCCH
              }
            },
            rB_Identity := tsc_RB1,
            cn_DomainIdentity := omit
          },
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DCCH2,
                logicalChannelType := dCCH
              }
            },
            rB_Identity := tsc_RB2,
            cn_DomainIdentity := omit
          },
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DCCH3,
                logicalChannelType := dCCH
              }
            },
            rB_Identity := tsc_RB3,
            cn_DomainIdentity := omit
          },
          {
            logicalChannel_Mapping := {
              ul_LogicalChannelMapping := {
                macHeaderManipulation := normalMacHeader,
                ul_TransportChannelType := dch,
                logicalChannelIdentity := tsc_UL_DCCH4,
                logicalChannelType := dCCH
              }
            },
            rB_Identity := tsc_RB4,
            cn_DomainIdentity := omit
          }
        }
      }
    },
    dlconnectedTrCHList := omit,
    dlconnectedMACdFlows := omit,
    dlconnectedMAC_ehsFlows := omit,
    dlconnectedMAC_ehsCommonFlows := omit,
    dlconnectedMAC_ehsCommonFlowsDC := omit
  };
  
  template RRCDataIndType cr_U_ServReq_MO_TMSI ( template (present) KeySeq p_KeySeq ) modifies cr_U_ServReqAny_Common :=
  {
    cmServiceRequest := cr_CM_ServReq_MO_TMSI (p_KeySeq)
  }

   template CMSERVICEREQUEST cr_CM_ServReq_MO_TMSI (template (present) KeySeq p_KeySeq) modifies cr_CM_ServReqAny_Common:=
  {
    cMServType      := '0001'B,//'Mobile originating call establishment or packet mode connection establishment'
    mobileId        := cr_MobileIdTMSI_lv (px_TMSI_Def)
  };

//----------------------------------------------------------------------
// Functions
//----------------------------------------------------------------------

  function fl_UTRAN_GMM_RAU_NoSecurityPerfomred(UTRAN_CellId_Type p_CellId) runs on UTRAN_PTC
  {
    var octetstring v_PLMN := f_U_Asn2Nas_PlmnId(f_UTRAN_CellInfo_GetPLMNIdentity(p_CellId));
    var octetstring v_LAC := f_UTRAN_CellInfo_GetLAC(p_CellId);
    var octetstring v_RAC := f_UTRAN_CellInfo_GetRAC(p_CellId);
    var B3_Type v_UpdateType := '000'B;

    var RRC_DATA_IND v_RRC_DataInd;

    U_Dc.receive(car_UplinkDirectTransfer(p_CellId,
                                          tsc_RB3,
                                          cr_U_RA_UpdReqAny (cr_GMM_UpdateType(?,?),
                                                             cr_RAI_Any (omit),
                                                             cr_PTMSI_SignatureAny ifpresent,
                                                             ? )))
    -> value v_RRC_DataInd;
    v_UpdateType := v_RRC_DataInd.msg.routingAreaUpdateRequest.updateType.updateValue;
    if (v_UpdateType != '000'B) {
      v_UpdateType := '001'B;
    }

    U_Dc.send (cs_PS_DataReq(p_CellId,
                             tsc_RB3,
                             cs_U_RA_UpdAcc3 (cs_GMM_UpdateResult (v_UpdateType),
                                              cs_RAI (omit,
                                                      cs_LAI(omit, v_PLMN, v_LAC),
                                                      v_RAC ),
                                              cs_PTMSI_Signature (px_PTMSI_SigDef),
                                              cs_MobileIdTMSIorPTMSI ('18'O, px_PTMSI_Def))));

    U_Dc.receive(car_UplinkDirectTransfer(p_CellId, tsc_RB3, cr_U_RAUpdComplete ));
  };

  /* @desc   Function used to initialise Authentication parameters
   * @param  p_CellId
  */
  function f_MM_AuthenticationInit ( ) runs on UTRAN_PTC
  {
    var UTRAN_SecurityInfo_Type v_UTRAN_SecurityInfo := f_UTRAN_Security_Get();
    var KeySeq v_CS_KeySeq;
    /* var B128_Type v_XDOut; */
    var B64_Type v_CDOut;
    /* var B64_Type v_XDOut_Half; */
    /* var B48_Type v_AK; */
    /* var B48_Type v_AUTN_1; */
    var B48_Type v_AuthSQN := '000000000000000000000000000000000000000000000000'B;
    /* var B64_Type v_MAC; */
    /* var B80_Type v_AUTN_2; */
    /* var Common_AuthenticationParams_Type v_Auth_Params; */

    //* @desc Increment Ciphering Key Sequence Number if Ciphering Key Sequence Number is not '111'B
    v_CS_KeySeq := v_UTRAN_SecurityInfo.authKeys.AuthCS.CKeySeq ;
  
    if(v_CS_KeySeq == '111'B)
    {
      v_CS_KeySeq := '000'B;
    }
    else
    {
      v_CS_KeySeq := int2bit((bit2int(v_CS_KeySeq) + 1) , 3);
    }
  
    //* @desc Calculate AUTN
    if( lengthof(px_AuthK) != 128)
    {
      f_UTRAN_SetVerdictFailOrInconc(__FILE__, __LINE__, "");
    }
    //FFS - Common Auth parameters not yet initialised
    //v_XDOut := v_Auth_Params.RandValue xor4b px_AuthK;
  
    if( lengthof(px_AuthAMF) != 64)
    {
      f_UTRAN_SetVerdictFailOrInconc(__FILE__, __LINE__, "");
    }
    //FFS - Common Auth parameters not yet initialised
    v_CDOut := v_AuthSQN & px_AuthAMF;
    //v_XDOut_Half := substr( v_XDOut, 0, 64);
    //v_AK := substr( v_XDOut, 24, 48);
    //v_AUTN_1 := v_AuthSQN xor4b v_AK;
    //v_MAC := v_XDOut_Half xor4b v_CDOut;
    //v_AUTN_2 := px_AuthAMF & v_MAC;
    //v_Auth_Params.AUTN   := v_AUTN_1 & v_AUTN_2;
  
    // v_IKey := 128 bits of v_XDOut, wrapped, starting from offset 16
    //v_Auth_Params.IK := substr( v_XDOut, 16, (128 - 16)) & substr( v_XDOut, 0, 16);
  
    // v_CKey := 128 bits of v_XDOut, wrapped, starting from offset 8
    //v_Auth_Params.CK   := substr( v_XDOut, 8, (128 - 8)) & substr( v_XDOut, 0, 8);
    //v_Auth_Params.XRES := v_XDOut;
  
    // ((CK1 XOR CK2) XOR (IK1 XOR IK2))
    //v_Auth_Params.KcGSM := (substr( v_Auth_Params.CK, 0, 64) xor4b substr( v_Auth_Params.CK, 64, 64)) xor4b (substr( v_Auth_Params.IK, 0, 64) xor4b substr( v_Auth_Params.IK, 64, 64));
  
    //* @desc Update Common Authentication Parameters and CS Key Sequence
    //v_UTRAN_SecurityInfo.authKeys.AuthPS := v_Auth_Params;
    //v_UTRAN_SecurityInfo.authKeys.AuthCS.CKeySeq := v_CS_KeySeq;
  
    f_UTRAN_Security_Set ( v_UTRAN_SecurityInfo );
  }

  /* @desc   Function used to perform MM Authentication in UTRAN
   * @param  p_CellId
  */
  function f_UTRAN_MM_Authentication ( UTRAN_CellId_Type p_CellId ) runs on UTRAN_PTC
  {
    var UTRAN_SecurityInfo_Type v_UTRAN_SecurityInfo:= f_UTRAN_Security_Get();
    var KeySeq v_CSKeySeq;
    var RRC_DATA_IND v_RRC_DataInd;
    var AuthRsp v_AuthRsp;
    var AuthRspExt v_AuthRspExt;
    var bitstring v_AuthRES;
    var Common_AuthenticationParams_Type v_Auth_Params;
    var B32_Type    v_AuthRES_High;

    v_UTRAN_SecurityInfo := f_UTRAN_Security_Get();
    v_Auth_Params := v_UTRAN_SecurityInfo.authKeys.AuthPS;
    v_CSKeySeq := v_UTRAN_SecurityInfo.authKeys.AuthCS.CKeySeq;

    f_MM_AuthenticationInit();
    
    U_Dc.send(cs_DataReq ( p_CellId,
                           tsc_RB3,
                           cs_U_AuthReq( v_CSKeySeq,
                                         v_Auth_Params.RandValue,
                                         cs_GSM_AUTN(v_Auth_Params.AUTN)) ) );

    alt {

      [] U_Dc.receive ( car_UplinkDirectTransfer ( p_CellId,
                                                   tsc_RB3,
                                                   cr_U_AuthRspAnyExt) )
      -> value v_RRC_DataInd
      {
        v_AuthRsp := v_RRC_DataInd.msg.authenticationResponse.authRsp;
        v_AuthRspExt := v_RRC_DataInd.msg.authenticationResponse.authRspExt;
   
        //*@descr First 32 bits of XRES correspond to AuthRsp and remaining bits correspond to AuthRspExt
        //* So instead of checking the AuthRsp and AuthRspExt separately,the 2 strings are concatenated and
        //* and compared against XRES.
   
        v_AuthRES_High := v_AuthRsp.rES;
        v_AuthRES := v_AuthRES_High & v_AuthRspExt.rES;
   
        //* @desc Bitwaise XOR of XRES and v_AuthRES should result in all zeroes
        //* which implies that the 2 bitstrings should match exactly.

        if (v_AuthRES != substr(v_Auth_Params.XRES, 0, lengthof(v_AuthRES))) {
          f_UTRAN_SetVerdictFailOrInconc(__FILE__, __LINE__, "");
        }
      }

    [] U_Dc.receive ( car_UplinkDirectTransfer ( p_CellId,
                                                 tsc_RB3,
                                                 cr_U_AuthRspAnyNoExt) )
    -> value v_RRC_DataInd
      {
        v_AuthRsp := v_RRC_DataInd.msg.authenticationResponse.authRsp;
        v_AuthRES_High := v_AuthRsp.rES;
   
        //* @desc Bitwaise XOR of XRES and v_AuthRES should result in all zeroes
        //* which implies that the 2 bitstrings should match exactly.

        if( v_AuthRES_High != substr(v_Auth_Params.XRES, 0, lengthof(v_AuthRES_High))) {
         f_UTRAN_SetVerdictFailOrInconc(__FILE__, __LINE__, "");
        }
      }
 
    [] U_Dc.receive ( car_UplinkDirectTransfer ( p_CellId,
                                                 tsc_RB3,
                                                 cr_U_AuthFailAny ) )
      {
       f_UTRAN_SetVerdictFailOrInconc(__FILE__, __LINE__, "");
      }
    }
  }

  /* @desc   Step 7-17 of 34.108 cl. 7.2.3.1
   *         From TTCN2 test step ts_CC_EnterU10_MT_Def
   * @param  p_CellId
   * @param  p_DoAuth            (default: true)   ...decides whether or not to do generate new keys
   * @param  p_PS_RB_Already_Est (default: false)  ...decides whether or not to configure or modify SS configuration.
   *                                                  p_PS_RB_Already_Est = TRUE is used in TC 13.1.4 where a PS RB has already been configured in SS and UE and then a CS Speech RB is set up/configured
   *                                                  p_PS_RB_Already_Est = FALSE is used in TC 13.1.3 where only a CS Speech RB is set up/configured
   * @status
  */
  function f_UTRAN_MT_SpeechCall_Steps7_17 (UTRAN_CellId_Type p_CellId,
                                            boolean           p_DoAuth := true,
                                            boolean           p_PS_RB_Already_Est := false) runs on UTRAN_PTC
  {
    var template (value) Bcap v_Bcap := cs_BcapSpeechMT;
    
    //@siclog "Step 7 - 8" siclog@
    //MM Authentication
    if (p_DoAuth) {
      f_UTRAN_MM_Authentication (p_CellId);
    }
    
    //@siclog "Step 9 - 10" siclog@
    //Security Mode procedure
    f_RRC_Security(p_CellId, p_DoAuth, cs_domain);
    
    //@siclog "Step 11" siclog@
    //Send Set Up
    U_Dc.send(cs_DataReq (p_CellId,
                          tsc_RB3,
                          cs_SetupMTCall_Common(v_Bcap)));
                           
    //@siclog "Step 12" siclog@
    //Receive Call Confirmed
    U_Dc.receive (car_UplinkDirectTransfer (p_CellId,
                                            tsc_RB3,
                                            cr_CallConfirmed_Common (?,
                                                                     cr_StreamIdPresent)));
    //@siclog "Step 13 - 14" siclog@
    //Radio Bearer Establishment
    if (p_PS_RB_Already_Est) {
      f_UTRAN_Setup_RAB_PS_and_ConvSpeech(p_CellId)
    }
    else {
      f_UTRAN_Setup_RAB_Speech (p_CellId);
    }

    alt {
    //@siclog "Step 15" siclog@
    [] U_Dc.receive (car_UplinkDirectTransfer (p_CellId,
                                               tsc_RB3,
                                               cr_Alerting_Common (?)))
       {
         f_UT_AnswerCSCall ( UT );

         //@siclog "Step 16" siclog@
         U_Dc.receive (car_UplinkDirectTransfer (p_CellId,
                                                 tsc_RB3,
                                                 cr_Connect (?)));
       }
    //@siclog "Step 16" siclog@
    [] U_Dc.receive (car_UplinkDirectTransfer (p_CellId,
                                               tsc_RB3,
                                               cr_Connect (?)))
       {}
    }
    
    //@siclog "Step 17" siclog@
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_ConnectAck_Common (cs_TI_MT)));

    //FFS - RLP activation needed?
  }
  
  /*
   * @desc      to configure physical channel DPCH1 and connect DCH1, DCH2, DCH3, DCH4 and DCH5 to the physical channel, then map DCCH1-4 on the DCH5 transport
   *            channel and map DTCH(subflow#1), DTCH(subflow#2), DTCH(subflow#3), DTCH(subflow#4) to the DCH1, DCH2, DCH3 and DCH4 and transport channel respectively.
   *            Used for conversational Speech/UL:12.2 kbps DL: 12.2 kbps/Interactive or background / UL: 64 DL: 64kbps / PS RAB + UL 3.4 DL: 3.4 kbps SRBs for DCCH.
   * @param     p_CellId
   * @param     p_ActTime
   * @param     p_DL_CommonInformation
   * @param     p_UL_DPCH_Info
   * @param     p_HS_DPCCHInfo
   * @status
   */
  function f_SS_5DCH_Modify_PS_and_ConvSpeech_FDD ( UTRAN_CellId_Type                        p_CellId,
                                                    ActivationTime                           p_ActTime,
                                                    template (value) DL_CommonInformation_r8 p_DL_CommonInformation,
                                                    template (omit)  UL_DPCH_Info_r7         p_UL_DPCH_Info ) runs on UTRAN_PTC {

    var template (value) SS_ActivationTime v_SS_ActivationTime := cas_ActivateCNF (p_ActTime);
    
    f_CPHY_RL_Modify (cas_DL_DPCH_ModifyInfo_FDD (p_CellId,
                                                  tsc_DL_DPCH1,
                                                  cs_DL_DPCH_64k_PS (p_DL_CommonInformation,
                                                                     tsc_DL_DPCH1_2ndScrC),
                                                  omit,
                                                  v_SS_ActivationTime));

    f_CPHY_TrCH_Config (cs_5_DCH_0_To119_DL_Info_FDD (p_CellId,
                                                      tsc_DL_DPCH1,
                                                      cs_DCH_148_TFS_DL_FDD,
                                                      cs_DCH_81_TFS_DL_FDD,
                                                      cs_DCH_103_TFS_FDD,
                                                      cs_DCH_60_TFS_FDD,
                                                      cs_DCH_336_TFS_25_DL_20_TC,
                                                      v_SS_ActivationTime));

    f_CMAC_Config ( cas_CMAC_ReconfigInfo_FDD ( p_CellId,
                                               tsc_DL_DPCH1,
                                               cs_UE_Info(omit, omit),
                                               cs_TrCHInfoDL_5_0To119(cs_DCH_148_TFS_DL_FDD,
                                                                      cs_DCH_81_TFS_DL_FDD,
                                                                      cs_DCH_103_TFS_FDD,
                                                                      cs_DCH_60_TFS_FDD,
                                                                      cs_DCH_336_TFS_25_DL_20_TC),
                                               cs_TrLogMappingDL_TM3_AM1,
                                               v_SS_ActivationTime));
                                               
    f_CPHY_RL_Modify ( cas_UL_DPCH_ModifyInfo_FDD ( p_CellId,
                                                    tsc_UL_DPCH1,
                                                    p_UL_DPCH_Info,
                                                    omit,
                                                    v_SS_ActivationTime ) );

    f_CPHY_TrCH_Config ( cs_5_DCH_0_To119_UL_Info_FDD (p_CellId,
                                                       tsc_UL_DPCH1,
                                                       cs_DCH_148_TFS_UL_FDD,
                                                       cs_DCH_81_TFS_FDD,
                                                       cs_DCH_103_TFS_FDD,
                                                       cs_DCH_60_TFS_FDD,
                                                       cs_DCH_336_TFS_24_UL_20_TC,
                                                       v_SS_ActivationTime));

    f_CMAC_Config ( cas_CMAC_ReconfigInfo_FDD ( p_CellId,
                                                tsc_UL_DPCH1,
                                                cs_UE_Info(omit, omit),
                                                cs_TrCHInfoUL_5_0To119(cs_DCH_148_TFS_UL_FDD,
                                                                       cs_DCH_81_TFS_FDD,
                                                                       cs_DCH_103_TFS_FDD,
                                                                       cs_DCH_60_TFS_FDD,
                                                                       cs_DCH_336_TFS_24_UL_20_TC),
                                                cs_TrLogMappingUL_TM3_AM1,
                                                v_SS_ActivationTime ) );
  };
  
  /* @desc    From TTCN2 ts_SendRB_SetUpInteractBackg_64k_ConvSpeech_PS_CS
  *  @param   p_CellId
  *  @status
  */
  function f_UTRAN_Setup_RAB_PS_and_ConvSpeech (UTRAN_CellId_Type p_CellId) runs on UTRAN_PTC
  {
  
    var U_RLC_AM_IND v_UTRAN_RLC_AM_IND;
    var B8_Type v_RAB_ID := tsc_RAB_DefCS;
    var UTRAN_FDD_TDD v_FDD_TDD_Mode := f_UTRAN_CellInfo_GetFDD_TDD (p_CellId);
    var UTRAN_CFN_Info_Type v_CfnInfo := f_CalculateActTime (p_CellId);
    var UTRAN_SecurityInfo_Type v_SecurityInfo := f_UTRAN_Security_Get ();
    
    
    if ( v_FDD_TDD_Mode == UTRAN_FDD ) {
      U_AM.send ( cas_RLC_Data_Req_Cnf ( p_CellId,
                                         tsc_RB2,
                                         tsc_Mui,
                                         cs_108_RB_SetUpPSandConvSpeech_FDD (v_SecurityInfo.dl_IntegrityCheckInfo,
                                                                             tsc_RRC_TI,
                                                                             v_CfnInfo.actTime,
                                                                             v_RAB_ID,
                                                                             f_UTRAN_CellInfo_GetPriScrmCode_FDD (p_CellId ),
                                                                             f_UTRAN_CellInfo_GetULScrmCode_FDD (p_CellId ))));

      //Modify SS for additional CS Speech RAB
      //FFS - need to write this . check ts_5DCH_ModifyConvSpeech_InteractBackg_64k_64k
      f_SS_5DCH_Modify_PS_and_ConvSpeech_FDD (p_CellId,
                                              v_CfnInfo.actTime,
                                              cs_DL_CommonInformationRB_SetUp_FDD (tsc_Sfd32, flexible),
                                              cs_UL_DPCH_Info_FDD (tsc_Sf16,
                                                                   pl0_76,
                                                                   f_UTRAN_CellInfo_GetULScrmCode_FDD (p_CellId)));
    }
    else {//FFS - TDD branch is still todo
/*
      U_AM.send ( cas_RLC_Data_Req_Cnf ( p_CellId,
                                         tsc_RB2,
                                         tsc_Mui,
                                         ? ) );

      //Configure SS with for CS Speech RAB
      f_SS_5DCH_Modify_PS_and_ConvSpeech_TDD ( p_CellId,
                                               v_CfnInfo.actTime,
                                               ?,
                                               ?,
                                               ?);
*/
    }

    f_SS_RB10_ToRB12_TM_Cfg (p_CellId);

    //Save cell configuration
    f_UTRAN_CellInfo_SetConfigType (p_CellId, cell_DCH_Speech);

    f_CMAC_SecurityMode_Config (v_SecurityInfo.recentSecureDomain,
                                v_SecurityInfo.start_CS,
                                v_SecurityInfo.authKeys.AuthCS.CKey,
                                omit,
                                omit);

    f_CMAC_UL_DL_CipherCfg (v_SecurityInfo.dL_CipherMode,
                            v_CfnInfo.actTime,
                            notInc);

    //Receive Radio Bearer Setup Complete message
    U_AM.receive ( car_RLC_Data_Ind (p_CellId,
                                     tsc_RB2,
                                     cr_108_RB_SetUpCmpl (tsc_RRC_TI))) -> value v_UTRAN_RLC_AM_IND;

    v_SecurityInfo.start_CS := v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.radioBearerSetupComplete.start_Value;

    //Store the security information
    f_UTRAN_Security_Set (v_SecurityInfo);
    //Download security keys to SS
    f_SS_DownloadSecurityKey (p_CellId, cs_domain);
  }
  
  /* @desc   Function for setting up a MO call on a UTRAN cell in which a PS RAB is already established.
  *          The UE shall be in state 6-10 or state 6-11 and this procedure represents
  *          the procedure defined in 34.108 cl. 7.4.2.9.2.2.
  *          From TTCN2 pr_GotoState6_14_PS_CS
  * @param   p_CellId
  * @status
  */
  function f_UTRAN_M0_SpeechCall_WithPsRabEst (UTRAN_CellId_Type p_CellId) runs on UTRAN_PTC
  {
    var UTRAN_SecurityInfo_Type v_SecurityInfo := f_UTRAN_Security_Get();
    var KeySeq v_KeySeq := v_SecurityInfo.authKeys.AuthCS.CKeySeq;
    var RRC_DATA_IND v_RRC_DataInd;
    
    //@siclog "Step 1" siclog@
    //Receive an INITIAL DIRECT TRANSFER message on Cell 5. This message includes a CM SERVICE REQUEST.
    U_Dc.receive (car_InitDirectTransfer (utran_Cell5,
                                          tsc_RB3,
                                          cr_U_ServReqAny_Common (v_KeySeq))) -> value v_RRC_DataInd;
                                          
    //@siclog "Step 2-3" siclog@
    //MM Authentication
    f_UTRAN_MM_Authentication (p_CellId);
    
    //@siclog "Step 4-5" siclog@
    //Security Mode procedure
    f_RRC_Security(p_CellId, true, cs_domain);
    
    //@siclog "Step 6" siclog@
    //Receive Set Up
    U_Dc.receive(car_UplinkDirectTransfer(p_CellId,
                                          tsc_RB3,
                                          cr_SetupMOCall_Common(cr_BcapSpeechMO, cr_LLC_Any)));
                           
    //@siclog "Step 7" siclog@
    //Transmit Call Proceeding message
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_U_CallProc (cs_TI_MT)));

    //@siclog "Step 8-9" siclog@
    //Radio Bearer Establishment
    f_UTRAN_Setup_RAB_PS_and_ConvSpeech (p_CellId);
    //FFS - Do i need to produce also f_UTRAN_Setup_RAB_PS_and_ConvUnknown_64k ?
    
    //@siclog "Step 10" siclog@
    //Transmit Alerting message
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_U_Alert (cs_TI_MT)));

    //@siclog "Step 11" siclog@
    //Transmit Connect message
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_U_Connect (cs_TI_MT)));

    //@siclog "Step 12" siclog@
    //Receive Connect Acknowledge message
    U_Dc.receive (car_UplinkDirectTransfer (p_CellId,
                                            tsc_RB3,
                                            cr_U_ConnAck (?)));

    //FFS - RLP activation needed? If so use finction ts_SS_ActivateRLP
  }
  
  /* @desc   Step 8-16 of 34.108 cl. 7.2.3.2
   * @param  p_CellId
   * @status
  */
  function f_UTRA_M0_SpeechCall_Steps8_16 ( UTRAN_CellId_Type p_CellId ) runs on UTRAN_PTC
  {
    var template (value) Bcap v_Bcap := cs_BcapSpeechMT;
    
    //@siclog "Step 8-9" siclog@
    //Security Mode procedure
    f_RRC_Security( p_CellId, false, cs_domain);
    
    //@siclog "Step 10" siclog@
    //Receive Set Up
    U_Dc.receive(car_UplinkDirectTransfer(p_CellId,
                                          tsc_RB3,
                                          cr_SetupMOCall_Common(cr_BcapSpeechMO, cr_LLC_Any)));
                           
    //@siclog "Step 11" siclog@
    //Send Call PROCEEDING
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_U_CallProc (cs_TI_MT)));
    
    //@siclog "Step 12-13" siclog@
    //Radio Bearer Establishment
    f_UTRAN_Setup_RAB_Speech (p_CellId);

    //@siclog "Step 14" siclog@
    //Send Alerting
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_U_Alert (cs_TI_MT)));
    
    //@siclog "Step 15" siclog@
    //Send Connect
    U_Dc.send (cs_DataReq (p_CellId,
                           tsc_RB3,
                           cs_U_Connect (cs_TI_MT)));
    
    //@siclog "Step 16" siclog@
    //Receive CONNECT ACKOWLEDGE
    U_Dc.receive (car_UplinkDirectTransfer (p_CellId,
                                            tsc_RB3,
                                            cr_U_ConnAck (?)));


    //FFS - RLP activation needed?
  }

  /*
   * @desc      REFERENCE TS 36.523-1 clause 13.1.2
   * @status
   */
  function f_TC_13_1_2_UTRAN() runs on UTRAN_PTC {
  
  /* Open issues/TBD/FFS
   * 1: How to achieve: "During the registration procedure, the UE is allocated the LAI of cell 5."?
  */
  
    var InitialUE_Identity v_InitialUE_Id;
    var integer v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5;
    var RLC_TR_DATA_IND v_RLC_TR_DATA_IND;
    var UTRAN_FDD_TDD v_FDD_TDD_Mode;
    var UTRAN_CellInfo_Type_FDD v_CellInfoFDD;
    var UTRAN_CellInfo_Type_TDD v_CellInfoTDD;
    var U_RNTI v_U_RNTI;
    var RRC_DATA_IND v_RRC_DataInd;
    var UTRAN_SecurityInfo_Type v_SecurityInfo := f_UTRAN_Security_Get();
    var KeySeq v_KeySeq := v_SecurityInfo.authKeys.AuthCS.CKeySeq;
    var KeySeq v_KeySeqPS, v_KeySeqCS;
    var octetstring v_PLMN;
    var octetstring v_LAC;
    var octetstring v_RAC;
    var boolean v_TriggerRxd := false;
    var template (present) EstablishmentCause v_EstCause := originatingConversationalCall;
    var B3_Type v_UpdateType := '000'B;
    v_T0_CPICH_Cell5 := -70;
    v_T0_PCCPCH_Cell5 := -72;       //TDD: To be clarified in prose
    
    //Initialise all cells
    f_UTRAN_Init (EUTRA_UTRAN);
    
    //cell 5 is in NMO 1. NMO1 is by default set in f_UTRAN_CellInfo_Init_FDD or f_UTRAN_CellInfo_Init_TDD
    
    //Get cell specific information
    v_LAC := f_UTRAN_CellInfo_GetLAC(utran_Cell5);
    v_RAC := f_UTRAN_CellInfo_GetRAC(utran_Cell5);
    v_PLMN := f_U_Asn2Nas_PlmnId(f_UTRAN_CellInfo_GetPLMNIdentity(utran_Cell5));
    v_U_RNTI := f_UTRAN_CellInfo_GetU_RNTI (utran_Cell5);
    v_FDD_TDD_Mode := f_UTRAN_CellInfo_GetFDD_TDD (utran_Cell5);
    if( v_FDD_TDD_Mode == UTRAN_FDD ) {
      v_CellInfoFDD := f_UTRAN_CellInfo_GetFDDSpecific (utran_Cell5);
    }
    else {//TDD
      v_CellInfoTDD := f_UTRAN_CellInfo_GetTDDSpecific (utran_Cell5);
    }
    
    //Send the cell info to the EUTRA component
    f_UTRAN_Send_IR_SysInfoToEUTRA (utran_Cell5);
    
    //Create and configure Cell 5
    //Cell started switched on with default power level, -60 and max attenuation
    f_SS_CreateCellDCH (utran_Cell5);
    
    //Since UE starts in EUTRA wait for EUTRA PTC to send the Auth Params
    f_UTRAN_InterRAT_InitialiseAuthParams();
    
    //Set cell power level according to T0
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( EUTRA );
    f_UTRAN_SetCellPower(utran_Cell5, v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5);
    
    f_UTRAN_TestBody_Set (true);
    
    //Wait for E-UTRA to complete Step 1 to Step 5
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    
    //@siclog "Step 9" siclog@
    //Receive an RRC CONNECTION REQUEST with an establishment cause indicating ' Originating Conversational Call '
    U_TM.receive ( car_RRC_ConnReq ( utran_Cell5,
                                     tsc_RB0,
                                     cdr_RRC_ConnReq_r8OrLater ( v_EstCause ) ) ) -> value v_RLC_TR_DATA_IND;

    //@siclog "Step 10" siclog@
    //Transmit RRC CONNECTION SETUP message.
    v_InitialUE_Id := v_RLC_TR_DATA_IND.tM_message.uL_CCCH_Message.message_.rrcConnectionRequest.initialUE_Identity;
    if ( v_FDD_TDD_Mode == UTRAN_FDD ) {
      U_UM.send (cas_RRC_ConnSetup (utran_Cell5,
                                    tsc_RB0,
                                    cs_108_RRC_ConnSetupDCH_r8_FDD (v_InitialUE_Id,
                                                                    tsc_RRC_TI,
                                                                    v_CellInfoFDD.priScrmCode,
                                                                    v_U_RNTI,
                                                                    v_CellInfoFDD.uL_ScramblingCode)));
    }
    else {//TDD
      U_UM.send (cas_RRC_ConnSetup (utran_Cell5,
                                    tsc_RB0,
                                    cs_108_RRC_ConnSetupDCH_r8_TDD (v_InitialUE_Id,
                                                                    tsc_RRC_TI,
                                                                    v_U_RNTI,
                                                                    v_CellInfoTDD.cellParametersID)))
    }
    
    //Set Cell configuration
    f_UTRAN_CellInfo_SetConfigType ( utran_Cell5, cell_DCH_StandAloneSRB );

    //@siclog "Step 11" siclog@
    //Receive RRC CONNECTION SETUP COMPLETE message
    f_UTRAN_RRC_ReceiveConnSetupCmpl (utran_Cell5);
    
    //@siclog "Step 12 & -" siclog@
    //Receive CM SERVICE REQUEST message and In parallel to step 12; Receive ROUTING AREA UPDATE REQUEST message?
    alt {
      []  U_Dc.receive (car_InitDirectTransfer (utran_Cell5,
                                                tsc_RB3,
                                                cr_U_ServReq_MO_TMSI (?))) -> value v_RRC_DataInd
      {
        f_SS_SecurityDownloadStart (cs_domain, v_RRC_DataInd.ttcn_start);
        U_Dc.receive(car_PS_InitDirectTransfer (utran_Cell5,
                                                tsc_RB3,
                                                cr_U_RA_UpdReqAny(cr_GMM_UpdateType(?,?),
                                                                  cr_RAI_Any (omit),
                                                                  cr_PTMSI_SignatureAny ifpresent,
                                                                  ?))) -> value v_RRC_DataInd;
        f_SS_SecurityDownloadStart(ps_domain, v_RRC_DataInd.ttcn_start);
        v_UpdateType := v_RRC_DataInd.msg.routingAreaUpdateRequest.updateType.updateValue;
      }
      [] U_Dc.receive(car_PS_InitDirectTransfer (utran_Cell5,
                                                 tsc_RB3,
                                                 cr_U_RA_UpdReqAny(cr_GMM_UpdateType(?,?),
                                                                   cr_RAI_Any (omit),
                                                                   cr_PTMSI_SignatureAny ifpresent,
                                                                   ?))) -> value v_RRC_DataInd
      {
        f_SS_SecurityDownloadStart(ps_domain, v_RRC_DataInd.ttcn_start);
        v_UpdateType := v_RRC_DataInd.msg.routingAreaUpdateRequest.updateType.updateValue;
        U_Dc.receive (car_InitDirectTransfer (utran_Cell5,
                                              tsc_RB3,
                                              cr_U_ServReq_MO_TMSI (?))) -> value v_RRC_DataInd;
        f_SS_SecurityDownloadStart (cs_domain, v_RRC_DataInd.ttcn_start);
      }
    }
    
    //@siclog "Step 13-14" siclog@
    //Transmit SECURITY MODE COMMAND message for the PS domain and receive SECURITY MODE COMPLETE message.
    f_RRC_Security(utran_Cell5, false, ps_domain);

    //@siclog "Step 15" siclog@
    //Transmit a ROUTING AREA UPDATE ACCEPT message not including P-TMSI
/*
    U_Dc.send (cs_PS_DataReq(utran_Cell5,
                             tsc_RB3,
                             cs_U_RA_UpdAcc3 (cs_GMM_UpdateResult (v_UpdateType),
                                              cs_RAI (omit,
                                                      cs_LAI(omit, v_PLMN, v_LAC),
                                                      v_RAC ),
                                              omit,//since this is optional elements the template cs_U_RA_UpdAcc3 & cs_RA_UpdAcc_Common must be updated to allow template (omit)
                                              omit)));//since this is optional elements the template cs_U_RA_UpdAcc3 & cs_RA_UpdAcc_Common must be updated to allow template (omit)
*/

    //@siclog "Step 16" siclog@
    //Perform step 8-16 of the generic test procedure in TS 34.108 subclause 7.2.3.2
    f_UTRA_M0_SpeechCall_Steps8_16 (utran_Cell5);
    
    f_UTRAN_TestBody_Set (false);
    
    //Notify EUTRA after completing test body
    f_SendIRATCoOrd (EUTRA, cms_IRAT_Trigger);
    
    f_UTRA_Postamble (utran_Cell5, U5_CSCALL);
  }
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 13.1.3
   * @status
   */

  function f_TC_13_1_3_UTRAN() runs on UTRAN_PTC {
  
    var integer v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5;
    var UTRAN_SecurityInfo_Type v_SecurityInfo;
    var AuthCSKeys_Type v_Auth_Params;
    var boolean v_TriggerRxd := false;
    var InitialUE_Identity v_InitialUE_Id;
    var template (present) EstablishmentCause v_EstCause := registration;//FFS - See open issues in EUTRA PTC
    var RLC_TR_DATA_IND v_RLC_TR_DATA_IND;
    var template (value) octetstring v_IpPacket_OctetString := crs_IPv4_AnyIcmpEchoReply_1 (px_IPv4_Address, px_IPv4_Address);
    var bitstring v_IpPacket_Bitstring := oct2bit (valueof(v_IpPacket_OctetString));
    v_T0_CPICH_Cell5 := -70;
    v_T0_PCCPCH_Cell5 := -72;       //TDD: To be clarified in prose
    
    //Initialise all cells
    f_UTRAN_Init (EUTRA_UTRAN);

    //Send the cell info to the EUTRA component
    f_UTRAN_Send_IR_SysInfoToEUTRA (utran_Cell5);
    
    //Create and configure Cell 5
    //Cell started switched on with default power level, -60 and max attenuation
    f_SS_CreateCellDCH (utran_Cell5);

    //Start sending System Information
    f_UTRAN_SendDefSysInfo (utran_Cell5);
    
    //Since UE starts in EUTRA wait for EUTRA PTC to send the Auth Params
    f_UTRAN_InterRAT_InitialiseAuthParams();
  
    //Set cell power level according to T0
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_UTRAN_SetCellPower(utran_Cell5, v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5);

    f_UTRAN_TestBody_Set ( false );
    
    //Wait for E-UTRA to complete Step 1 to Step 5
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    
    //@siclog "Step 6" siclog@
    //Receive RRC CONNECTION REQUEST
    U_TM.receive (car_RRC_ConnReq(utran_Cell5,
                                  tsc_RB0,
                                  cdr_RRC_ConnReq_r8OrLater (v_EstCause))) -> value v_RLC_TR_DATA_IND;

    v_InitialUE_Id := v_RLC_TR_DATA_IND.tM_message.uL_CCCH_Message.message_.rrcConnectionRequest.initialUE_Identity;
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.1.3 Step 6");
    
    //@siclog "Step 7 - 13" siclog@
    //Execute steps 2-8 of RAU procedure
    //FFS - See open issues in EUTRA PTC
    f_UTRAN_RRC_ConnEst_WithoutRRCConnectionReq (utran_Cell5, v_InitialUE_Id);
    f_UTRAN_GMM_RAU_MappedContext (utran_Cell5);

    v_SecurityInfo := f_UTRAN_Security_Get();
    
    //@siclog "Step 14" siclog@
    //Receive PAGING RESPONSE
    U_Dc.receive (car_InitDirectTransfer (utran_Cell5,
                                          tsc_RB3,
                                          cr_U_PagRsp_Common( v_SecurityInfo.authKeys.AuthCS.CKeySeq,
                                                              cs_MobileIdTMSI (omit, px_TMSI_Def))));
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.1.3 Step 14");
    
    //@siclog "Step 15 - 25" siclog@
    //Set up MT CS call according to 34.108 cl. 7.2.3.1 step 7-17
    f_UTRAN_MT_SpeechCall_Steps7_17 (utran_Cell5);
    
    //Release RRC Connection
    //FFS - Step not present in prose, see open issues in EUTRA PTC for parallel behaviour
    f_UTRAN_RRC_ConnRel (utran_Cell5, cell_Dch);

    //@siclog "Step 1-4 of Parallel behaviour" siclog@
    /* FFS - Instead of RAU procedure a Service Request procedure is performed
     * See open issues in EUTRA PTC for parallel behaviour */
    f_UTRAN_UE_PsRB_Est (utran_Cell5, cell_DCH_64kPS_RAB_SRB);
    
    //@siclog "Step 6" siclog@
    //Check: Does the UE loop back the IP packet on the RAB associated with the PDP context?
    U_AM.receive (car_RLC_Test_Data_Ind (utran_Cell5,
                                         tsc_RB20,
                                         v_IpPacket_Bitstring));
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.1.3 Parallel behaviout step 5");
    
    //Notify EUTRA after completing test body
    f_SendIRATCoOrd (EUTRA, cms_IRAT_Trigger);
    
    f_UTRAN_TestBody_Set (false);
    
    //Perform Switch/Power off and release UTRAN cell 5
    f_UTRA_Postamble (utran_Cell5, U2_CONNECTED);
  }
  
  /*
   * @desc      REFERENCE TS 36.523-1 clause 13.1.4
   * @status
   */
  function f_TC_13_1_4_UTRAN() runs on UTRAN_PTC {
  
    var UTRAN_SecurityInfo_Type v_SecurityInfo;
    var U_RLC_AM_IND v_UTRAN_RLC_AM_IND;
    var STARTList v_STARTList;
    var integer v_DomainCnt;
    var integer v_I:=0;
    var integer v_T0_CPICH_Cell5 := -70;
    var integer v_T0_PCCPCH_Cell5 := -72;
    var boolean v_TriggerRxd := false;
  
    //Initialise all cells
    f_UTRAN_Init (EUTRA_UTRAN);
    
    //Send UTRAN cell info to EUTRA PTC
    f_UTRAN_Send_IR_SysInfoToEUTRA (utran_Cell5);
    
    //Create and configure Cell 5
    //Cell started switched on with default power level, -60 and max attenuation
    f_SS_CreateCellDCH (utran_Cell5);

    //Start sending System Information
    f_UTRAN_SendDefSysInfo (utran_Cell5);
    
    //Configure a dedicated channel in the UTRAN FDD with configuration according to 34.108 cl. 6.10.2.4.1.26
    f_SS_Config_64kPS_RAB (utran_Cell5);
    
    //Since UE starts in EUTRA wait for EUTRA PTC to send the Auth Params
    f_UTRAN_InterRAT_InitialiseAuthParams();
    
    //Wait for preamble and then set appropiate cell power level
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( EUTRA );
    f_UTRAN_SetCellPower(utran_Cell5, v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5);
    
    f_UTRAN_TestBody_Set (true);
    
    v_SecurityInfo := f_UTRAN_Security_Get();

    //Wait for trigger
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    
    //@siclog "Step 7" siclog@
    //Receive HANDOVER TO UTRAN COMPLETE
    U_AM.receive (car_RLC_Data_Ind (utran_Cell5,
                                    tsc_RB2,
                                    cr_HandoverToUTRANComplete)) -> value v_UTRAN_RLC_AM_IND;

    if (ispresent (v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.handoverToUTRANComplete.startList)) {
      v_STARTList := v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.handoverToUTRANComplete.startList;
     //Get the domain associatioed start values and save them in the cell structure
      v_DomainCnt := sizeof(v_STARTList);
      if ((v_DomainCnt > 0) and (v_DomainCnt <= 2)) {
        for (v_I := 0; v_I < v_DomainCnt; v_I := v_I + 1) {
          if (v_STARTList[v_I].cn_DomainIdentity == cs_domain) {
            v_SecurityInfo.start_CS := v_STARTList[v_I].start_Value
          }
          else {
            v_SecurityInfo.start_PS := v_STARTList[v_I].start_Value
          }
        }
      }
      else { FatalError(__FILE__, __LINE__, "invalid configuration"); }
    }
    else {
      FatalError(__FILE__, __LINE__, "No startList provided in handoverToUTRANComplete message");
    }
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.1.4 Step 7");

    //Store the security information and download keys to SS
    f_UTRAN_Security_Set (v_SecurityInfo);
    f_SS_DownloadSecurityKey (utran_Cell5, cs_domain);
    f_SS_DownloadSecurityKey (utran_Cell5, ps_domain);
    v_SecurityInfo := f_UTRAN_Security_Get();
    
    //@siclog "Step 8" siclog@
    //Receive PAGING RESPONSE
    U_Dc.receive (car_InitDirectTransfer (utran_Cell5,
                                          tsc_RB3,
                                          cr_U_PagRsp_Common(v_SecurityInfo.authKeys.AuthCS.CKeySeq,
                                                             cs_MobileIdTMSI (omit, px_TMSI_Def))));
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.1.4 Step 8");
    
    //@siclog "Step 9-10" siclog@
    //Send SECURITY MODE COMMAND message and receive SECURITY MODE COMPLETE
    f_RRC_Security(utran_Cell5, false, ps_domain);
    
    //@siclog "Step 1-3 of Table 13.1.4.3.2-3: Parallel behaviour" siclog@
    //FFS - since the procedure to set up the CS call is controlled by TTCN perfomr RAU first
    fl_UTRAN_GMM_RAU_NoSecurityPerfomred(utran_Cell5);

    //@siclog "Step 11-17" siclog@
    //Perform steps 11 to 17 of the generic test procedure in TS 34.108 subclause 7.2.3.1
    f_UTRAN_MT_SpeechCall_Steps7_17(utran_Cell5, false, true);

    f_UTRAN_TestBody_Set(false);
    
    //Notify EUTRA after completing test body
    f_SendIRATCoOrd (EUTRA, cms_IRAT_Trigger);
    
    f_UTRA_Postamble (utran_Cell5, U5_CSCALL);
  }

  /*
   * @desc      REFERENCE TS 36.523-1 clause 13.1.5
   * @status
   */
  function f_TC_13_1_5_UTRAN() runs on UTRAN_PTC {

    var boolean v_TriggerRxd := false;
    var boolean v_NewKeyFlag := false;
    var U_RNTI v_U_RNTI;
    var C_RNTI v_C_RNTI;
    var UTRAN_SecurityInfo_Type v_SecurityInfo;
    var octetstring v_DomainSpecificNAS_Info;
    var U_RLC_AM_IND v_UTRAN_RLC_AM_IND;
    var STARTList v_STARTList;
    var integer v_DomainCnt;
    var DRX_CycleLengthStructure v_DRX_CycleLengthStructure;
    var PLMN_Identity v_PLMN_Identity;
    var octetstring v_LAC;
    var integer v_T0_CPICH_Cell5 := -65;
    var integer v_T0_PCCPCH_Cell5 := -67;
    var integer v_I:=0;
    var RRC_TransactionIdentifier v_RRC_TI := tsc_RRC_TI;
    var template (value) octetstring v_IpPacket_OctetString := crs_IPv4_AnyIcmpEchoReply_1 ( px_IPv4_Address, px_IPv4_Address );
    var bitstring v_IpPacket_Bitstring := oct2bit ( valueof(v_IpPacket_OctetString) );

    //Initialise all cells
    f_UTRAN_Init ( EUTRA_UTRAN );

    //Create and configure Cell 5
    //Cell started switched on with default power level, -60 and max attenuation
    f_SS_CreateCellDCH ( utran_Cell5 );

    //Start sending System Information
    f_UTRAN_SendDefSysInfo ( utran_Cell5 );

    //Send relevant UTRAN cell info to EUTRA PTC
    f_UTRAN_Send_IR_SysInfoToEUTRA ( utran_Cell5 );

    //Configure a dedicated channel in the UTRAN FDD with configuration according to 34.108 cl. 6.10.2.4.1.26
    f_SS_Config_64kPS_RAB ( utran_Cell5 );
    
    //Since UE starts in EUTRA wait for EUTRA PTC to send the Auth Params
    f_UTRAN_InterRAT_InitialiseAuthParams();

    //Wait for preamble and then set appropiate cell power level
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( EUTRA );
    f_UTRAN_SetCellPower(utran_Cell5, v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5);

    f_UTRAN_TestBody_Set( true );
    
    v_SecurityInfo := f_UTRAN_Security_Get ( );

    //Wait for trigger
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( EUTRA );

    //Step 6: Receive HANDOVER TO UTRAN COMPLETE message
    U_AM.receive (car_RLC_Data_Ind (utran_Cell5,
                                    tsc_RB2,
                                    cr_HandoverToUTRANComplete)) -> value v_UTRAN_RLC_AM_IND;

    if (ispresent (v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.handoverToUTRANComplete.startList)) {
      v_STARTList := v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.handoverToUTRANComplete.startList;
     //Get the domain associatioed start values and save them in the cell structure
      v_DomainCnt := sizeof(v_STARTList);
      if ((v_DomainCnt > 0) and (v_DomainCnt <= 2)) {
        for (v_I := 0; v_I < v_DomainCnt; v_I := v_I + 1) {
          if (v_STARTList[v_I].cn_DomainIdentity == cs_domain) {
            v_SecurityInfo.start_CS := v_STARTList[v_I].start_Value
          }
          else {
            v_SecurityInfo.start_PS := v_STARTList[v_I].start_Value
          }
        }
      }
      else { FatalError(__FILE__, __LINE__, "invalid configuration"); }
    }
    else {
      FatalError(__FILE__, __LINE__, "No startList provided in handoverToUTRANComplete message");
    }

    //Store the security information and download keys to SS
    f_UTRAN_Security_Set (v_SecurityInfo);
    f_SS_DownloadSecurityKey (utran_Cell5, cs_domain);
    f_SS_DownloadSecurityKey (utran_Cell5, ps_domain);
    
    //FFS - Possible RAU already here?
    /* According to 24.008 cl. 4.5.1.1      MM connection establishment initiated by the mobile station
    ...
    d)  When the MS is IMSI attached for CS services via EMM combined procedures, as described in 3GPP TS 24.301 [120], and the MS is camping on an E-UTRAN cell,
        the MM sublayer requests EMM to initiate a service request procedure for CS fallback. The MM connection establishment is delayed until the MS changes to
        a GERAN or UTRAN cell.

        If the MS enters a GERAN or UTRAN cell, then the MS shall initiate the MM connection establishment and send a CM SERVICE REQUEST message.
        If the MS determines that it is in a different location area than the stored location area, the MS shall first initiate a normal location
        updating procedure or a combined routing area update procedure, depending on Network Mode of Operation.
        The MM connection establishment is delayed until successful completion of the normal location updating or combined routing area update procedure.
    ...
    */

    //Step -: Perform CS Speech Radio Bearer establishment in UTRAN cell according to 34.108 cl. 7.4.2.9.2.2
    f_UTRAN_M0_SpeechCall_WithPsRabEst (utran_Cell5);

    //@siclog "Step 7 - 8" siclog@
    //Send SECURITY MODE COMMAND and receiev SECURITY MODE COMPLETE
    f_RRC_Security (utran_Cell5, v_NewKeyFlag, ps_domain);

    //@siclog "Step 9" siclog@
    //Transmits UTRAN MOBILITY INFORMATION message to notify CN information
    v_SecurityInfo := f_UTRAN_Security_Get ( );
    v_U_RNTI := f_UTRAN_CellInfo_GetU_RNTI ( utran_Cell5 );
    v_C_RNTI := f_UTRAN_CellInfo_GetC_RNTI( utran_Cell5 );
    v_DRX_CycleLengthStructure := f_UTRAN_CellInfo_GetDRX_CycleLength ( utran_Cell5 );
    v_DomainSpecificNAS_Info := f_UTRAN_CellInfo_GetRAC( utran_Cell5 ) & f_UTRAN_CellInfo_GetNMO( utran_Cell5 );
    v_PLMN_Identity := f_UTRAN_CellInfo_GetPLMNIdentity ( utran_Cell5 );
    v_LAC := f_UTRAN_CellInfo_GetLAC ( utran_Cell5 );
    
    U_AM.send (cas_RLC_Data_Req_NoCnf (utran_Cell5,
                                       tsc_RB2,
                                       cs_RRC_UtranMobilityInfo ( v_SecurityInfo.dl_IntegrityCheckInfo,//IntegrityCheckInfo
                                                                  v_RRC_TI,                            //RRC_TransactionIdentifier
                                                                  omit,                                //IntegrityProtectionModeInfo_r7
                                                                  omit,                                //CipheringModeInfo_r7
                                                                  v_U_RNTI,                            //U_RNTI
                                                                  v_C_RNTI,                            //C_RNTI
                                                                  omit,                                //H_RNTI
                                                                  cs_UEConnTimersConst,                //UE_ConnTimersAndConstants_r5
                                                                  cs_CNInfo( v_PLMN_Identity,          //CN_InformationInfoFull
                                                                             v_LAC,
                                                                             v_DRX_CycleLengthStructure,
                                                                             v_DomainSpecificNAS_Info),
                                                                  omit,                                //PLMN_Identity
                                                                  omit,                                //URA_Identity
                                                                  omit,                                //SupportChangeUECapab
                                                                  omit,                                //DL_CounterSynchronisationInfo_r5
                                                                  omit,                                //UtranMobilityInformation_r7_add_ext
                                                                  omit)));                             //UTRANMobilityInformation_v860ext2_Type

    //@siclog "Step 10" siclog@
    //Receieve UTRAN MOBILITY INFORMATION CONFIRM message
    U_AM.receive (car_RLC_Data_Ind (utran_Cell5,
                                    tsc_RB2,
                                    cr_108_UTRAN_MobilityInfoCnf (v_RRC_TI)));

    //@siclog "Step 11 - 13" siclog@
    //Perform RAU (no security activation since it has already been activated)
    fl_UTRAN_GMM_RAU_NoSecurityPerfomred (utran_Cell5);
    
    //@siclog "Step 14" siclog@
    //Send one IP packet to UE
    U_AM.send(cas_RLC_Test_Data_Req (utran_Cell5,
                                     tsc_RB20,
                                     v_IpPacket_Bitstring));

    //@siclog "Step 15" siclog@
    //Receive the looped back IP packet
    U_AM.receive(car_RLC_Test_Data_Ind (utran_Cell5,
                                        tsc_RB20,
                                        v_IpPacket_Bitstring));
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.1.3 Step 15");

    f_UTRAN_TestBody_Set(false);

   //Notify E-UTRA after configuring the E-UTRA cell
    f_SendIRATCoOrd (EUTRA, cms_IRAT_Trigger);

    //Switch/Power off UE and release cell
    f_UTRA_Postamble (utran_Cell5, U5_CSCALL);
  }

  /*
   * @desc      REFERENCE TS 36.523-1 clause 13.4.2.1
   * @status
   */
  function f_TC_13_4_2_1_UTRAN() runs on UTRAN_PTC
  {
  
    var integer v_T0_CPICH_Cell5, v_T1_CPICH_Cell5, v_T0_PCCPCH_Cell5, v_T1_PCCPCH_Cell5;
    var U_RLC_AM_IND v_UTRAN_RLC_AM_IND;
    var STARTList v_STARTList;
    var integer v_DomainCnt, v_I;
    var UTRAN_SecurityInfo_Type v_SecurityInfo;
    var template (value) octetstring v_IpPacket_OctetString := crs_IPv4_AnyIcmpEchoReply_1 ( px_IPv4_Address, px_IPv4_Address );
    var bitstring v_IpPacket_Bitstring := oct2bit ( valueof(v_IpPacket_OctetString) );
    var boolean v_TriggerRxd := false;
    v_T0_CPICH_Cell5 := -23;
    v_T1_CPICH_Cell5 := -12;
    v_T0_PCCPCH_Cell5 := -25;       // TDD: To be clarified in prose
    v_T1_PCCPCH_Cell5 := -14;       // TDD: To be clarified in prose
  
    //Initialise all cells
    f_UTRAN_Init (EUTRA_UTRAN);
    
    //Send the cell info to the EUTRA component
    f_UTRAN_Send_IR_SysInfoToEUTRA (utran_Cell5);
    
    //Create and configure Cell 5
    //Cell started switched on with default power level, -60 and max attenuation
    f_SS_CreateCellDCH (utran_Cell5);

    //Start sending System Information
    f_UTRAN_SendDefSysInfo (utran_Cell5);
    
    //Since UE starts in EUTRA wait for EUTRA PTC to send the Auth Params
    f_UTRAN_InterRAT_InitialiseAuthParams();
    
    //Set cell power levels according to T0
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_UTRAN_SetCellPower(utran_Cell5, v_T0_CPICH_Cell5, v_T0_PCCPCH_Cell5);

    //Start the test case and send relevant UTRAN cell info to EUTRA PTC
    f_UTRAN_Send_IR_SysInfoToEUTRA (utran_Cell5);
    f_UTRAN_TestBody_Set (true);
    
    //@siclog "Step 5" siclog@
    //Set Cell parameters according to T1
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger (EUTRA);
    f_UTRAN_SetCellPower(utran_Cell5, v_T1_CPICH_Cell5, v_T1_PCCPCH_Cell5);

    //Configure a dedicated channel in the UTRAN cell with configuration according to 34.108 cl. 6.10.2.4.1.26
    f_SS_Config_64kPS_RAB (utran_Cell5);
    
    //Get security from cell structure
    v_SecurityInfo := f_UTRAN_Security_Get ();
    
    //@siclog "Step 8" siclog@
    //Receive HANDOVER TO UTRAN COMPLETE message
    v_TriggerRxd := f_WaitForIRATCoOrd_Trigger ( EUTRA );
    U_AM.receive (car_RLC_Data_Ind (utran_Cell5,
                                    tsc_RB2,
                                    cr_HandoverToUTRANComplete)) -> value v_UTRAN_RLC_AM_IND;

    if (ispresent (v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.handoverToUTRANComplete.startList)) {
      v_STARTList := v_UTRAN_RLC_AM_IND.data.aM_message.uL_DCCH_Message.message_.handoverToUTRANComplete.startList;
     //Get the domain associatioed start values and save them in the cell structure
      v_DomainCnt := sizeof(v_STARTList);
      if ((v_DomainCnt > 0) and (v_DomainCnt <= 2)) {
        for (v_I := 0; v_I < v_DomainCnt; v_I := v_I + 1) {
          if (v_STARTList[v_I].cn_DomainIdentity == cs_domain) {
            v_SecurityInfo.start_CS := v_STARTList[v_I].start_Value
          }
          else {
            v_SecurityInfo.start_PS := v_STARTList[v_I].start_Value
          }
        }
      }
      else { FatalError(__FILE__, __LINE__, "invalid configuration"); }
    }
    else {
      FatalError(__FILE__, __LINE__, "No startList provided in handoverToUTRANComplete message");
    }
 
    //Store the security information and download keys to SS
    f_UTRAN_Security_Set (v_SecurityInfo);
    f_SS_DownloadSecurityKey (utran_Cell5, cs_domain);
    f_SS_DownloadSecurityKey (utran_Cell5, ps_domain);
    
    //@siclog "Step 9 - 15" siclog@
    //Perform step 4-10 of RAU procedure described in 36.508 cl. 6.4.2.8
    f_UTRAN_GMM_RAU_MappedContext (utran_Cell5);
    
    //@siclog "Step 16" siclog@
    //Send one IP packet to UE
    U_AM.send(cas_RLC_Test_Data_Req (utran_Cell5,
                                     tsc_RB20,
                                     v_IpPacket_Bitstring));

    //@siclog "Step 17" siclog@
    //Receive the looped back IP packet
    U_AM.receive(car_RLC_Test_Data_Ind (utran_Cell5,
                                        tsc_RB20,
                                        v_IpPacket_Bitstring));
    f_UTRAN_PreliminaryPass(__FILE__, __LINE__, "Test Case 13.4.2.1 Step 17");
    
    //Test case ends
    f_SendIRATCoOrd (EUTRA, cms_IRAT_Trigger);
    f_UTRAN_TestBody_Set (true);
    
    //Perform Switch/Power off and release cell 5
    f_UTRA_Postamble (utran_Cell5, U2_CONNECTED);
  }
}
